roseking commited on
Commit
ce0981c
·
verified ·
1 Parent(s): cfd6be6

Add lean source and binary files (part 51)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientCoverTilt.lean +602 -0
  2. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientLaw.lean +313 -0
  3. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientReindex.lean +69 -0
  4. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientResidueWidths.lean +553 -0
  5. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientSubspace.lean +584 -0
  6. lean/OAI/Combinatorics/Progressions/Lattices/AffineCommonReferenceBudget.lean +120 -0
  7. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredJetDensity.lean +213 -0
  8. lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredSiteValues.lean +99 -0
  9. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoordinates.lean +46 -0
  10. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoveredProjection.lean +84 -0
  11. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeMinorGoodMass.lean +622 -0
  12. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePlateauSite.lean +103 -0
  13. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePositiveComparison.lean +361 -0
  14. lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeUniformRemoval.lean +222 -0
  15. lean/OAI/Combinatorics/Progressions/Lattices/AffineIntervalNormalizedBounds.lean +42 -0
  16. lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelEndpointGeometry.lean +151 -0
  17. lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelResidueRetained.lean +324 -0
  18. lean/OAI/Combinatorics/Progressions/Lattices/AffineLayeredModeReduction.lean +53 -0
  19. lean/OAI/Combinatorics/Progressions/Lattices/AffineLiftInsertion.lean +94 -0
  20. lean/OAI/Combinatorics/Progressions/Lattices/AffineLowestLayer.lean +84 -0
  21. lean/OAI/Combinatorics/Progressions/Lattices/AffineMaskedInitialShell.lean +548 -0
  22. lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshRetention.lean +646 -0
  23. lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshScalarTail.lean +336 -0
  24. lean/OAI/Combinatorics/Progressions/Lattices/AffineModerateGeometricApproximation.lean +243 -0
  25. lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauModel.lean +492 -0
  26. lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauSite.lean +64 -0
  27. lean/OAI/Combinatorics/Progressions/Lattices/AffineNormalizedScales.lean +49 -0
  28. lean/OAI/Combinatorics/Progressions/Lattices/AffineObservedTransport.lean +80 -0
  29. lean/OAI/Combinatorics/Progressions/Lattices/AffineOneSiteNormalizedLaw.lean +521 -0
  30. lean/OAI/Combinatorics/Progressions/Lattices/AffinePrecisionBudget.lean +289 -0
  31. lean/OAI/Combinatorics/Progressions/Lattices/AffinePrimitiveLogBudget.lean +107 -0
  32. lean/OAI/Combinatorics/Progressions/Lattices/AffineProfileTranslationL1.lean +45 -0
  33. lean/OAI/Combinatorics/Progressions/Lattices/AffineRefinedCoefficients.lean +33 -0
  34. lean/OAI/Combinatorics/Progressions/Lattices/AffineResidualRecovery.lean +71 -0
  35. lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueAccuracy.lean +79 -0
  36. lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueCoordinateEquiv.lean +31 -0
  37. lean/OAI/Combinatorics/Progressions/Lattices/AffineSampleAlphabet.lean +635 -0
  38. lean/OAI/Combinatorics/Progressions/Lattices/AffineSiteCoverTilt.lean +84 -0
  39. lean/OAI/Combinatorics/Progressions/Lattices/AffineSliceC2Difference.lean +132 -0
  40. lean/OAI/Combinatorics/Progressions/Lattices/AffineSourceAccuracy.lean +59 -0
  41. lean/OAI/Combinatorics/Progressions/Lattices/AffineSquareErrorAccuracy.lean +42 -0
  42. lean/OAI/Combinatorics/Progressions/Lattices/AffineTopCoefficient.lean +97 -0
  43. lean/OAI/Combinatorics/Progressions/Lattices/AffineWindowGoodKernelBound.lean +316 -0
  44. lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorIntegerRestoration.lean +167 -0
  45. lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorWeightedAffineTopPullback.lean +528 -0
  46. lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResidueComparison.lean +436 -0
  47. lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResiduePointMass.lean +104 -0
  48. lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActualCRTRationalMarginal.lean +86 -0
  49. lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineAnalyticBudget.lean +325 -0
  50. lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineCanonicalBackendBudget.lean +409 -0
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientCoverTilt.lean ADDED
@@ -0,0 +1,602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
2
+ import OAI.Combinatorics.Progressions.Fourier.AnchoredCoefficientFourierNormalization
3
+ import OAI.Combinatorics.Progressions.Fourier.SiteFourierHaarMean
4
+ import OAI.Combinatorics.Progressions.Lattices.SmoothResidueWindowMass
5
+ import OAI.Combinatorics.Progressions.Probability.DensityIntegralBound
6
+ import OAI.Combinatorics.Progressions.Probability.ProbabilityIntegralApproximation
7
+
8
+ namespace OAI
9
+
10
+ section
11
+
12
+ namespace Erdos3
13
+
14
+ open Polynomial
15
+
16
+ theorem exists_integer_cover_threshold (A₀ : ℕ) :
17
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ P : ℝ, 0 ≤ P →
18
+ Real.exp ((P + A₀) ^ A₀) ≤ Real.exp ((P + A) ^ A) ∧
19
+ Real.exp P * Real.exp ((P + A₀) ^ A₀) ≤ Real.exp ((P + A) ^ A) := by
20
+ obtain ⟨A, hA, hpoly⟩ := exists_natPolynomial_eval_budget (X + (X + C A₀) ^ A₀ + 1)
21
+ refine ⟨A, hA, ?_⟩
22
+ intro P hP
23
+ have he : P + (P + A₀) ^ A₀ + 1 ≤ (P + A) ^ A := by
24
+ simpa [Polynomial.eval₂_pow] using hpoly P hP
25
+ constructor
26
+ · apply Real.exp_le_exp.mpr
27
+ linarith
28
+ · rw [← Real.exp_add]
29
+ apply Real.exp_le_exp.mpr
30
+ linarith
31
+
32
+ end Erdos3
33
+
34
+ end
35
+
36
+ section
37
+
38
+ namespace Erdos3.VectorPolynomial
39
+
40
+ theorem affineSampleCoefficientArray_smul {I K : Type*} [Fintype K] {m : ℕ}
41
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
42
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j)
43
+ (r : ℝ) (b : Option K → I → ℝ) :
44
+ affineSampleCoefficientArray U (fun j => r • p j)
45
+ (fun j => coefficients_smul_mem (U j) (p j) (hm j) r) b =
46
+ r • affineSampleCoefficientArray U p hm b := by
47
+ funext s
48
+ apply Subtype.ext
49
+ change (affineSampleCoefficientArray U (fun j => r • p j) _ b s).val =
50
+ r • (affineSampleCoefficientArray U p hm b s).val
51
+ rw [affineSampleCoefficientArray_val, affineSampleCoefficientArray_val]
52
+ simp only [map_smul, Finsupp.smul_apply]
53
+
54
+ noncomputable def affineCoefficientCoverSample {I K : Type*} [Fintype K] {m : ℕ}
55
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
56
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j)
57
+ (q : ℕ) (b : Option K → I → ℝ) : CoefficientTorus (K := K) U :=
58
+ QuotientAddGroup.mk' (coefficientIntegerLattice U) ((q : ℝ)⁻¹ • affineSampleCoefficientArray U p hm b)
59
+
60
+ theorem affineCoefficientCoverSample_eq_scaled {I K : Type*} [Fintype K] {m : ℕ}
61
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
62
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j)
63
+ (q : ℕ) (b : Option K → I → ℝ) :
64
+ affineCoefficientCoverSample U p hm q b =
65
+ affineSampleCoefficientTorus U (fun j => (q : ℝ)⁻¹ • p j)
66
+ (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹) b := by
67
+ rw [affineSampleCoefficientTorus, affineSampleCoefficientArray_smul]
68
+ rfl
69
+
70
+ theorem affineCoefficientCoverSample_projection {I K : Type*} [Fintype K] {m : ℕ}
71
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
72
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j)
73
+ (q : ℕ) (hq : 0 < q) (b : Option K → I → ℝ) :
74
+ quotientIntegerCover (coefficientIntegerLattice U) q (affineCoefficientCoverSample U p hm q b) =
75
+ affineSampleCoefficientTorus U p hm b := by
76
+ have hq0 : (q : ℝ) ≠ 0 := by exact_mod_cast hq.ne'
77
+ rw [affineCoefficientCoverSample, quotientIntegerCover_mk,
78
+ smul_smul, mul_inv_cancel₀ hq0, one_smul]
79
+ rfl
80
+
81
+ end Erdos3.VectorPolynomial
82
+
83
+ end
84
+
85
+ section
86
+
87
+ namespace Erdos3.VectorPolynomial
88
+
89
+ open MeasureTheory
90
+ open scoped BigOperators Classical
91
+
92
+ theorem exists_affine_coefficient_haar_comparison (m : ℕ) :
93
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
94
+ [Fintype I] [DecidableEq I] [Fintype K]
95
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
96
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
97
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
98
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
99
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
100
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
101
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
102
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
103
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
104
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
105
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
106
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
107
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
108
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
109
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
110
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
111
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
112
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
113
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
114
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
115
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
116
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
117
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z),
118
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
119
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
120
+ coefficientTorusFourierSum U frequency c
121
+ (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) -
122
+ (∫ x, coefficientTorusFourierSum U frequency c x ∂μ)‖ ≤ ε := by
123
+ obtain ⟨A, hA, hnormalization⟩ := exists_affine_coefficient_fourier_normalization m
124
+ refine ⟨A, hA, ?_⟩
125
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
126
+ 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
127
+ obtain ⟨hZ, hnorm⟩ := hnormalization hP hn hd U hC hCP frequency hbound c hB hBP hcoefficients
128
+ p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth
129
+ refine ⟨hZ, ?_⟩
130
+ rw [coefficientTorusFourierSum_integral]
131
+ simpa only [coefficientTorusFourierSum, coefficientTorusCharacter_sample U _ p hp hm] using hnorm
132
+
133
+ end Erdos3.VectorPolynomial
134
+
135
+ end
136
+
137
+ section
138
+
139
+ namespace Erdos3.VectorPolynomial
140
+
141
+ open MeasureTheory
142
+ open scoped BigOperators Classical
143
+
144
+ theorem exists_affine_coefficient_haar_approximation (m : ℕ) :
145
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
146
+ [Fintype I] [DecidableEq I] [Fintype K]
147
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
148
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
149
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
150
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
151
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
152
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
153
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
154
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
155
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
156
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
157
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
158
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
159
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
160
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
161
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
162
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
163
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
164
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
165
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
166
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
167
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
168
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
169
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
170
+ (f : CoefficientTorus (K := K) U → ℂ) (_hf : Integrable f μ)
171
+ {η : ℝ} (_hη : 0 ≤ η)
172
+ (_happrox : ∀ x, ‖f x - coefficientTorusFourierSum U frequency c x‖ ≤ η),
173
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
174
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
175
+ f (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) -
176
+ (∫ x, f x ∂μ)‖ ≤ 2 * η + ε := by
177
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_comparison m
178
+ refine ⟨A, hA, ?_⟩
179
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
180
+ 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
181
+ obtain ⟨hZ, hcomp⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients
182
+ p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth
183
+ refine ⟨hZ, ?_⟩
184
+ let g := coefficientTorusFourierSum U frequency c
185
+ let sample (z : Option K × I → ℤ) := affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))
186
+ let E (a : CoefficientTorus (K := K) U → ℂ) :=
187
+ ∑' z, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * a (sample z)
188
+ have hfirst := selectedResidueSmoothPMF_approximation stride G V hV hZ
189
+ (fun _ => 1) (fun z => f (sample z)) (fun z => g (sample z)) hη
190
+ (fun _ _ => by simp) (fun z _ => happrox (sample z))
191
+ simp only [one_mul] at hfirst
192
+ have hlast := probability_integral_approximation μ g f
193
+ (coefficientTorusFourierSum_integrable U frequency c μ) hf
194
+ (fun x => by simpa only [norm_sub_rev] using happrox x)
195
+ have htri := norm_sub_le_norm_sub_add_norm_sub (E f) (E g) (∫ x, f x ∂μ)
196
+ have htri' := norm_sub_le_norm_sub_add_norm_sub (E g) (∫ x, g x ∂μ) (∫ x, f x ∂μ)
197
+ change ‖E f - E g‖ ≤ η at hfirst
198
+ change ‖E g - ∫ x, g x ∂μ‖ ≤ ε at hcomp
199
+ change ‖E f - ∫ x, f x ∂μ‖ ≤ 2 * η + ε
200
+ linarith
201
+
202
+ end Erdos3.VectorPolynomial
203
+
204
+ end
205
+
206
+ section
207
+
208
+ namespace Erdos3.VectorPolynomial
209
+
210
+ open MeasureTheory
211
+ open scoped BigOperators Classical
212
+
213
+ theorem exists_affine_coefficient_cover_haar_approximation (m : ℕ) :
214
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
215
+ [Fintype I] [DecidableEq I] [Fintype K]
216
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
217
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
218
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
219
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
220
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
221
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
222
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
223
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
224
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
225
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
226
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
227
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
228
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
229
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
230
+ (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P)
231
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
232
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
233
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
234
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
235
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
236
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
237
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
238
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
239
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
240
+ (f : CoefficientTorus (K := K) U → ℂ) (_hf : Integrable f μ)
241
+ {η : ℝ} (_hη : 0 ≤ η)
242
+ (_happrox : ∀ x, ‖f x - coefficientTorusFourierSum U frequency c x‖ ≤ η),
243
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
244
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
245
+ f (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) -
246
+ (∫ x, f x ∂μ)‖ ≤ 2 * η + ε := by
247
+ obtain ⟨A₀, _, hcomparison⟩ := exists_affine_coefficient_haar_approximation m
248
+ obtain ⟨A, hA, hbudget⟩ := exists_integer_cover_threshold A₀
249
+ refine ⟨A, hA, ?_⟩
250
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
251
+ 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
252
+ have hb := hbudget P hP
253
+ have hR0 : 0 ≤ R := (Real.exp_pos _).le.trans hR
254
+ have hq0 : (0 : ℝ) < q := by exact_mod_cast hq
255
+ have hscaledR : Real.exp ((P + A₀) ^ A₀) ≤ R / q := by
256
+ apply (le_div_iff₀ hq0).mpr
257
+ calc
258
+ _ ≤ Real.exp P * Real.exp ((P + A₀) ^ A₀) := by
259
+ simpa only [mul_comm] using mul_le_mul_of_nonneg_right hqP (Real.exp_pos ((P + A₀) ^ A₀)).le
260
+ _ ≤ Real.exp ((P + A) ^ A) := hb.2
261
+ _ ≤ R := hR
262
+ obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients
263
+ (fun j => (q : ℝ)⁻¹ • p j) (fun j => (hp j).smul (q : ℝ)⁻¹)
264
+ (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹)
265
+ stride hs hS hSP hρ hε hρP hεP hstride H (fun k => hb.1.trans (hsize k))
266
+ (fun j => (hrank j).div_nat hR0 q hq) hscaledR G hG V hV hwidth f hf hη happrox
267
+ refine ⟨hZ, ?_⟩
268
+ simpa only [affineCoefficientCoverSample_eq_scaled] using he
269
+
270
+ end Erdos3.VectorPolynomial
271
+
272
+ end
273
+
274
+ section
275
+
276
+ namespace Erdos3.VectorPolynomial
277
+
278
+ open MeasureTheory
279
+ open scoped BigOperators Classical
280
+
281
+ theorem exists_affine_coefficient_density_mass (m : ℕ) :
282
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
283
+ [Fintype I] [DecidableEq I] [Fintype K]
284
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
285
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
286
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
287
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
288
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
289
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
290
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
291
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
292
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
293
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
294
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
295
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
296
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
297
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
298
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
299
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
300
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
301
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
302
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
303
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
304
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
305
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
306
+ (V : Option K × I → ℝ) (_hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
307
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ)
308
+ (_hDmass : (∫ x, D x ∂μ) = 1)
309
+ {η : ℝ} (_hη : 0 ≤ η)
310
+ (_happrox : ∀ x, ‖(D x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η),
311
+ ∃ _hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
312
+ |selectedResidueDensityMass stride G V
313
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤
314
+ 2 * η + ε := by
315
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_approximation m
316
+ refine ⟨A, hA, ?_⟩
317
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
318
+ 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
319
+ obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients
320
+ p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth
321
+ (fun x => (D x : ℂ)) hD.ofReal hη happrox
322
+ refine ⟨hZ, ?_⟩
323
+ rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he
324
+ rw [← selectedResidueDensityMass_complex stride G V hV hZ
325
+ (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))),
326
+ ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he
327
+ exact he
328
+
329
+ end Erdos3.VectorPolynomial
330
+
331
+ end
332
+
333
+ section
334
+
335
+ namespace Erdos3.VectorPolynomial
336
+
337
+ open MeasureTheory
338
+ open scoped BigOperators Classical
339
+
340
+ theorem exists_affine_coefficient_cover_tilted_family_comparison (m : ℕ) :
341
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
342
+ [Fintype I] [DecidableEq I] [Fintype K]
343
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] (F : Bool → Type*) [∀ b, Fintype (F b)]
344
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
345
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
346
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
347
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
348
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
349
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
350
+ (frequency : ∀ b, F b → ∀ j, (K →₀ ℕ) → J j → ℤ)
351
+ (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C)
352
+ (c : ∀ b, F b → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
353
+ (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B)
354
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
355
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
356
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
357
+ (cover : ℕ) (_hcover : 0 < cover) (_hcoverP : (cover : ℝ) ≤ Real.exp P)
358
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
359
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
360
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
361
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
362
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
363
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
364
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
365
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
366
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
367
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ)
368
+ (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x)
369
+ (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ)
370
+ (_hfbound : ∀ x, ‖f x‖ ≤ 1)
371
+ {η : ℝ} (_hη : 0 ≤ η)
372
+ (_happrox : ∀ b x,
373
+ ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η)
374
+ (_hsmall : 2 * η + ε ≤ 1 / 2),
375
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
376
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
377
+ (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))),
378
+ |selectedResidueDensityMass stride G V
379
+ (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧
380
+ (1 / 2 ≤ selectedResidueDensityMass stride G V
381
+ (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ))))) ∧
382
+ (selectedResidueDensityMass stride G V
383
+ (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧
384
+ ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ
385
+ (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ))))
386
+ (fun _z => _hD0 _) hDpos z).toReal : ℂ) *
387
+ f (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) -
388
+ (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by
389
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_cover_haar_approximation m
390
+ refine ⟨A, hA, ?_⟩
391
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
392
+ 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
393
+ D hD hDmass hD0 f hf hfbound η hη happrox hsmall
394
+ let sample (z : Option K × I → ℤ) := affineCoefficientCoverSample U p hm cover (fun k j => (z (k, j) : ℝ))
395
+ obtain ⟨hZ, he0⟩ := hcomparison hP hn hd U μ hC hCP (frequency false) (hbound false)
396
+ (c false) hB hBP (hcoefficients false) p hp hm cover hcover hcoverP stride hs hS hSP hρ hε hρP hεP hstride
397
+ H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ)) hD.ofReal hη
398
+ (fun x => by simpa using happrox false x)
399
+ have hmass : |selectedResidueDensityMass stride G V (fun z => D (sample z)) - 1| ≤ 2 * η + ε := by
400
+ rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he0
401
+ rw [← selectedResidueDensityMass_complex stride G V hV hZ (fun z => D (sample z)),
402
+ ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he0
403
+ exact he0
404
+ have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V (fun z => D (sample z)) := by
405
+ have := (abs_le.mp hmass).1
406
+ linarith
407
+ have hupper : selectedResidueDensityMass stride G V (fun z => D (sample z)) ≤ 3 / 2 := by
408
+ have := (abs_le.mp hmass).2
409
+ linarith
410
+ have hDpos : 0 < selectedResidueDensityMass stride G V (fun z => D (sample z)) := by linarith
411
+ refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩
412
+ obtain ⟨hZ', he1⟩ := hcomparison hP hn hd U μ hC hCP (frequency true) (hbound true)
413
+ (c true) hB hBP (hcoefficients true) p hp hm cover hcover hcoverP stride hs hS hSP hρ hε hρP hεP hstride
414
+ H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ) * f x)
415
+ (density_mul_integrable μ D hD f hf hfbound) hη
416
+ (fun x => by simpa using happrox true x)
417
+ have he := selectedResidueDensityPMF_error stride G V hV hZ
418
+ (fun z => D (sample z)) (fun z => hD0 _) hDpos (fun z => f (sample z))
419
+ hlower he1 hmass (norm_density_integral_le_one μ D hD hD0 hDmass f hfbound)
420
+ convert he using 1; ring
421
+
422
+ end Erdos3.VectorPolynomial
423
+
424
+ end
425
+
426
+ section
427
+
428
+ namespace Erdos3.VectorPolynomial
429
+
430
+ open MeasureTheory
431
+ open scoped BigOperators Classical
432
+
433
+ theorem exists_affine_coefficient_tilted_comparison (m : ℕ) :
434
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
435
+ [Fintype I] [DecidableEq I] [Fintype K]
436
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
437
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
438
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
439
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
440
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
441
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
442
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
443
+ (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ)
444
+ (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C)
445
+ (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
446
+ (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B)
447
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
448
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
449
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
450
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
451
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
452
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
453
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
454
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
455
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
456
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
457
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
458
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
459
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ)
460
+ (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x)
461
+ (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ)
462
+ (_hfbound : ∀ x, ‖f x‖ ≤ 1)
463
+ {η : ℝ} (_hη : 0 ≤ η)
464
+ (_happrox : ∀ b x,
465
+ ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η)
466
+ (_hsmall : 2 * η + ε ≤ 1 / 2),
467
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
468
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
469
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))),
470
+ |selectedResidueDensityMass stride G V
471
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧
472
+ (1 / 2 ≤ selectedResidueDensityMass stride G V
473
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))) ∧
474
+ (selectedResidueDensityMass stride G V
475
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧
476
+ ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ
477
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))
478
+ (fun _z => _hD0 _) hDpos z).toReal : ℂ) *
479
+ f (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) -
480
+ (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by
481
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_approximation m
482
+ refine ⟨A, hA, ?_⟩
483
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
484
+ 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
485
+ D hD hDmass hD0 f hf hfbound η hη happrox hsmall
486
+ let sample (z : Option K × I → ℤ) := affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))
487
+ obtain ⟨hZ, he0⟩ := hcomparison hP hn hd U μ hC hCP (frequency false) (hbound false)
488
+ (c false) hB hBP (hcoefficients false) p hp hm stride hs hS hSP hρ hε hρP hεP hstride
489
+ H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ)) hD.ofReal hη
490
+ (fun x => by simpa using happrox false x)
491
+ have hmass : |selectedResidueDensityMass stride G V (fun z => D (sample z)) - 1| ≤ 2 * η + ε := by
492
+ rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he0
493
+ rw [← selectedResidueDensityMass_complex stride G V hV hZ (fun z => D (sample z)),
494
+ ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he0
495
+ exact he0
496
+ have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V (fun z => D (sample z)) := by
497
+ have := (abs_le.mp hmass).1
498
+ linarith
499
+ have hupper : selectedResidueDensityMass stride G V (fun z => D (sample z)) ≤ 3 / 2 := by
500
+ have := (abs_le.mp hmass).2
501
+ linarith
502
+ have hDpos : 0 < selectedResidueDensityMass stride G V (fun z => D (sample z)) := by linarith
503
+ refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩
504
+ obtain ⟨hZ', he1⟩ := hcomparison hP hn hd U μ hC hCP (frequency true) (hbound true)
505
+ (c true) hB hBP (hcoefficients true) p hp hm stride hs hS hSP hρ hε hρP hεP hstride
506
+ H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ) * f x)
507
+ (density_mul_integrable μ D hD f hf hfbound) hη
508
+ (fun x => by simpa using happrox true x)
509
+ have he := selectedResidueDensityPMF_error stride G V hV hZ
510
+ (fun z => D (sample z)) (fun z => hD0 _) hDpos (fun z => f (sample z))
511
+ hlower he1 hmass (norm_density_integral_le_one μ D hD hD0 hDmass f hfbound)
512
+ convert he using 1; ring
513
+
514
+ end Erdos3.VectorPolynomial
515
+
516
+ end
517
+
518
+ section
519
+
520
+ namespace Erdos3.VectorPolynomial
521
+
522
+ open MeasureTheory
523
+ open scoped BigOperators Classical
524
+
525
+ theorem exists_affine_coefficient_cover_tilted_comparison (m : ℕ) :
526
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
527
+ [Fintype I] [DecidableEq I] [Fintype K]
528
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
529
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
530
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
531
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
532
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
533
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
534
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
535
+ (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ)
536
+ (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C)
537
+ (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
538
+ (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B)
539
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
540
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
541
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
542
+ (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P)
543
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
544
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
545
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
546
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
547
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
548
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
549
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
550
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
551
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
552
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ)
553
+ (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x)
554
+ (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ)
555
+ (_hfbound : ∀ x, ‖f x‖ ≤ 1)
556
+ {η : ℝ} (_hη : 0 ≤ η)
557
+ (_happrox : ∀ b x,
558
+ ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η)
559
+ (_hsmall : 2 * η + ε ≤ 1 / 2),
560
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
561
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
562
+ (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))),
563
+ |selectedResidueDensityMass stride G V
564
+ (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧
565
+ (1 / 2 ≤ selectedResidueDensityMass stride G V
566
+ (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ))))) ∧
567
+ (selectedResidueDensityMass stride G V
568
+ (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧
569
+ ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ
570
+ (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ))))
571
+ (fun _z => _hD0 _) hDpos z).toReal : ℂ) *
572
+ f (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) -
573
+ (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by
574
+ obtain ⟨A₀, _, hcomparison⟩ := exists_affine_coefficient_tilted_comparison m
575
+ obtain ⟨A, hA, hbudget⟩ := exists_integer_cover_threshold A₀
576
+ refine ⟨A, hA, ?_⟩
577
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients
578
+ 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
579
+ D hD hDmass hD0 f hf hfbound η hη happrox hsmall
580
+ have hb := hbudget P hP
581
+ have hR0 : 0 ≤ R := (Real.exp_pos _).le.trans hR
582
+ have hq0 : (0 : ℝ) < q := by exact_mod_cast hq
583
+ have hscaledR : Real.exp ((P + A₀) ^ A₀) ≤ R / q := by
584
+ apply (le_div_iff₀ hq0).mpr
585
+ calc
586
+ _ ≤ Real.exp P * Real.exp ((P + A₀) ^ A₀) := by
587
+ simpa only [mul_comm] using mul_le_mul_of_nonneg_right hqP (Real.exp_pos ((P + A₀) ^ A₀)).le
588
+ _ ≤ Real.exp ((P + A) ^ A) := hb.2
589
+ _ ≤ R := hR
590
+ have he := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients
591
+ (fun j => (q : ℝ)⁻¹ • p j) (fun j => (hp j).smul (q : ℝ)⁻¹)
592
+ (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹)
593
+ stride hs hS hSP hρ hε hρP hεP hstride H (fun k => hb.1.trans (hsize k))
594
+ (fun j => (hrank j).div_nat hR0 q hq) hscaledR G hG V hV hwidth
595
+ D hD hDmass hD0 f hf hfbound hη happrox hsmall
596
+ simpa only [affineCoefficientCoverSample_eq_scaled] using he
597
+
598
+ end Erdos3.VectorPolynomial
599
+
600
+ end
601
+
602
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientLaw.lean ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Group.Integral
2
+ import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
3
+ import OAI.Combinatorics.Progressions.Probability.SelectedDensityNormalization
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open MeasureTheory
12
+ open scoped ContDiff
13
+
14
+ noncomputable def affineProbabilityProfile (c w x : ℝ) : ℝ :=
15
+ w⁻¹ * smoothProbabilityProfile ((x - c) / w)
16
+
17
+ theorem affineProbabilityProfile_nonneg (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) :
18
+ 0 ≤ affineProbabilityProfile c w x :=
19
+ mul_nonneg (inv_nonneg.mpr hw.le) (smoothProbabilityProfile_range _).1
20
+
21
+ theorem affineProbabilityProfile_le (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) :
22
+ affineProbabilityProfile c w x ≤ w⁻¹ := by
23
+ exact (mul_le_mul_of_nonneg_left (smoothProbabilityProfile_range _).2
24
+ (inv_nonneg.mpr hw.le)).trans_eq (mul_one _)
25
+
26
+ theorem affineProbabilityProfile_contDiff (c w : ℝ) :
27
+ ContDiff ℝ ∞ (affineProbabilityProfile c w) := by
28
+ change ContDiff ℝ ∞ (fun x => w⁻¹ * smoothProbabilityProfile ((x-c)/w))
29
+ exact contDiff_const.mul
30
+ (smoothProbabilityProfile_contDiff.comp ((contDiff_id.sub contDiff_const).div_const w))
31
+
32
+ theorem affineProbabilityProfile_zero (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ)
33
+ (hx : w < |x - c|) : affineProbabilityProfile c w x = 0 := by
34
+ have hnorm : 1 < |(x-c)/w| := by
35
+ rw [abs_div, abs_of_pos hw]
36
+ exact (one_lt_div hw).mpr hx
37
+ rw [affineProbabilityProfile, smoothProbabilityProfile_zero_outside _ hnorm, mul_zero]
38
+
39
+ theorem affineProbabilityProfile_zero_outside (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ)
40
+ (hx : |c| + w < |x|) : affineProbabilityProfile c w x = 0 := by
41
+ apply affineProbabilityProfile_zero c hw x
42
+ have ht : |x| ≤ |x-c| + |c| := by
43
+ simpa only [sub_add_cancel] using abs_add_le (x-c) c
44
+ linarith
45
+
46
+ theorem affineProbabilityProfile_compact (c : ℝ) {w : ℝ} (hw : 0 < w) :
47
+ HasCompactSupport (affineProbabilityProfile c w) := by
48
+ apply HasCompactSupport.of_support_subset_isCompact (isCompact_closedBall (0 : ℝ) (|c|+w))
49
+ intro x hx
50
+ rw [Metric.mem_closedBall, dist_zero_right, Real.norm_eq_abs]
51
+ exact le_of_not_gt (fun h => hx (affineProbabilityProfile_zero_outside c hw x h))
52
+
53
+ theorem affineProbabilityProfile_integrable (c : ℝ) {w : ℝ} (hw : 0 < w) :
54
+ Integrable (affineProbabilityProfile c w) :=
55
+ (affineProbabilityProfile_contDiff c w).continuous.integrable_of_hasCompactSupport
56
+ (affineProbabilityProfile_compact c hw)
57
+
58
+ theorem affineProbabilityProfile_integral (c : ℝ) {w : ℝ} (hw : 0 < w) :
59
+ (∫ x, affineProbabilityProfile c w x) = 1 := by
60
+ change (∫ x, w⁻¹ * smoothProbabilityProfile ((x-c)/w)) = 1
61
+ rw [integral_const_mul,
62
+ integral_sub_right_eq_self (fun x => smoothProbabilityProfile (x/w)) c,
63
+ Measure.integral_comp_div, smoothProbabilityProfile_integral, smul_eq_mul,
64
+ mul_one, abs_of_pos hw, inv_mul_cancel₀ hw.ne']
65
+
66
+ end Erdos3
67
+
68
+ end
69
+
70
+ section
71
+
72
+ namespace Erdos3
73
+
74
+ open MeasureTheory
75
+ open scoped BigOperators ContDiff
76
+
77
+ noncomputable def affineProductProfile {I : Type*} [Fintype I] (c w x : I → ℝ) : ℝ :=
78
+ ∏ i, affineProbabilityProfile (c i) (w i) (x i)
79
+
80
+ noncomputable def profileWidthFactor {I : Type*} [Fintype I] (w : I → ℝ) : ℝ :=
81
+ ∏ i, (w i)⁻¹
82
+
83
+ theorem affineProductProfile_eq {I : Type*} [Fintype I] (c w x : I → ℝ) :
84
+ affineProductProfile c w x = profileWidthFactor w *
85
+ smoothProductProfile I (fun i => (x i - c i) / w i) := by
86
+ simp only [affineProductProfile, affineProbabilityProfile, Finset.prod_mul_distrib,
87
+ profileWidthFactor, smoothProductProfile]
88
+
89
+ theorem profileWidthFactor_pos {I : Type*} [Fintype I] (w : I → ℝ) (hw : ∀ i, 0 < w i) :
90
+ 0 < profileWidthFactor w := Finset.prod_pos (fun i _ => inv_pos.mpr (hw i))
91
+
92
+ theorem affineProductProfile_nonneg {I : Type*} [Fintype I] (c w : I → ℝ)
93
+ (hw : ∀ i, 0 < w i) (x : I → ℝ) : 0 ≤ affineProductProfile c w x :=
94
+ Finset.prod_nonneg (fun i _ => affineProbabilityProfile_nonneg (c i) (hw i) (x i))
95
+
96
+ theorem affineProductProfile_norm_le {I : Type*} [Fintype I] (c w : I → ℝ)
97
+ (hw : ∀ i, 0 < w i) (x : I → ℝ) : ‖affineProductProfile c w x‖ ≤ profileWidthFactor w := by
98
+ rw [Real.norm_eq_abs, abs_of_nonneg (affineProductProfile_nonneg c w hw x)]
99
+ exact Finset.prod_le_prod₀ (fun i _ => affineProbabilityProfile_nonneg (c i) (hw i) (x i))
100
+ (fun i _ => affineProbabilityProfile_le (c i) (hw i) (x i))
101
+
102
+ theorem affineProductProfile_contDiff {I : Type*} [Fintype I] (c w : I → ℝ) :
103
+ ContDiff ℝ ∞ (affineProductProfile c w) := by
104
+ unfold affineProductProfile
105
+ apply contDiff_prod
106
+ intro i _
107
+ exact (affineProbabilityProfile_contDiff (c i) (w i)).comp
108
+ (ContinuousLinearMap.proj i : (I → ℝ) →L[ℝ] ℝ).contDiff
109
+
110
+ theorem affineProductProfile_compact {I : Type*} [Fintype I] (c w : I → ℝ)
111
+ (hw : ∀ i, 0 < w i) : HasCompactSupport (affineProductProfile c w) :=
112
+ tensorCutoffWeight_compact (fun i => affineProbabilityProfile (c i) (w i))
113
+ (fun i => affineProbabilityProfile_compact (c i) (hw i))
114
+
115
+ theorem affineProductProfile_integrable {I : Type*} [Fintype I] (c w : I → ℝ)
116
+ (hw : ∀ i, 0 < w i) : Integrable (affineProductProfile c w) :=
117
+ (affineProductProfile_contDiff c w).continuous.integrable_of_hasCompactSupport
118
+ (affineProductProfile_compact c w hw)
119
+
120
+ theorem affineProductProfile_integral {I : Type*} [Fintype I] (c w : I → ℝ)
121
+ (hw : ∀ i, 0 < w i) : (∫ x, affineProductProfile c w x) = 1 := by
122
+ change (∫ x, tensorCutoffWeight (fun i => affineProbabilityProfile (c i) (w i)) x) = 1
123
+ rw [tensorCutoffWeight_integral]
124
+ simp only [affineProbabilityProfile_integral _ (hw _), Finset.prod_const_one]
125
+
126
+ theorem affineProductProfile_zero_outside {I : Type*} [Fintype I] (c w : I → ℝ)
127
+ (hw : ∀ i, 0 < w i) {R : ℝ} (hR : 0 ≤ R) (hcw : ∀ i, |c i| + w i ≤ R) :
128
+ ∀ x, R < ‖x‖ → affineProductProfile c w x = 0 := by
129
+ classical
130
+ intro x hx
131
+ by_contra hne
132
+ apply (not_le_of_gt hx)
133
+ apply (pi_norm_le_iff_of_nonneg hR).mpr
134
+ intro i
135
+ rw [Real.norm_eq_abs]
136
+ by_contra! hi
137
+ exact hne (Finset.prod_eq_zero (Finset.mem_univ i)
138
+ (affineProbabilityProfile_zero_outside (c i) (hw i) (x i) ((hcw i).trans_lt hi)))
139
+
140
+ end Erdos3
141
+
142
+ end
143
+
144
+ section
145
+
146
+ namespace Erdos3
147
+
148
+ open MeasureTheory
149
+
150
+ theorem affineProbabilityProfile_integral_test (c : ℝ) {w : ℝ} (hw : 0 < w) (φ : ℝ → ℝ) :
151
+ (∫ x, affineProbabilityProfile c w x * φ x) =
152
+ ∫ y, smoothProbabilityProfile y * φ (c + w*y) := by
153
+ let g := fun y => smoothProbabilityProfile y * φ (c+w*y)
154
+ have he (x : ℝ) : affineProbabilityProfile c w x * φ x = w⁻¹ * g ((x-c)/w) := by
155
+ have hx : c + w*((x-c)/w) = x := by field_simp [hw.ne']; ring
156
+ simp only [affineProbabilityProfile, g, hx]
157
+ ring
158
+ simp_rw [he]
159
+ rw [integral_const_mul, integral_sub_right_eq_self (fun x => g (x/w)) c,
160
+ Measure.integral_comp_div, smul_eq_mul, abs_of_pos hw, ← mul_assoc,
161
+ inv_mul_cancel₀ hw.ne', one_mul]
162
+
163
+ theorem affineProbabilityProfile_law (c : ℝ) {w : ℝ} (hw : 0 < w) :
164
+ (realDensityMeasure volume smoothProbabilityProfile).map (fun y => c + w*y) =
165
+ realDensityMeasure volume (affineProbabilityProfile c w) := by
166
+ have hψ : Integrable smoothProbabilityProfile :=
167
+ smoothProbabilityProfile_contDiff.continuous.integrable_of_hasCompactSupport smoothProbabilityProfile_compact
168
+ let : IsFiniteMeasure (realDensityMeasure volume smoothProbabilityProfile) :=
169
+ realDensityMeasure_finite _ _ hψ (fun y => (smoothProbabilityProfile_range y).1)
170
+ let : IsFiniteMeasure (realDensityMeasure volume (affineProbabilityProfile c w)) :=
171
+ realDensityMeasure_finite _ _ (affineProbabilityProfile_integrable c hw) (affineProbabilityProfile_nonneg c hw)
172
+ have hmap : Measurable (fun y : ℝ => c+w*y) := by fun_prop
173
+ apply finiteMeasure_eq_of_integrals
174
+ intro φ hφ
175
+ rw [integral_map hmap.aemeasurable hφ.aestronglyMeasurable,
176
+ realDensityMeasure_integral volume smoothProbabilityProfile
177
+ smoothProbabilityProfile_contDiff.continuous.measurable (fun y => (smoothProbabilityProfile_range y).1),
178
+ realDensityMeasure_integral volume (affineProbabilityProfile c w)
179
+ (affineProbabilityProfile_contDiff c w).continuous.measurable (affineProbabilityProfile_nonneg c hw)]
180
+ exact (affineProbabilityProfile_integral_test c hw φ).symm
181
+
182
+ theorem affineProductProfile_law {I : Type*} [Fintype I]
183
+ (c w : I → ℝ) (hw : ∀ i, 0 < w i) :
184
+ (realDensityMeasure volume (smoothProductProfile I)).map (fun y i => c i + w i * y i) =
185
+ realDensityMeasure volume (affineProductProfile c w) := by
186
+ have hψ : Integrable smoothProbabilityProfile :=
187
+ smoothProbabilityProfile_contDiff.continuous.integrable_of_hasCompactSupport smoothProbabilityProfile_compact
188
+ let : IsFiniteMeasure (realDensityMeasure volume smoothProbabilityProfile) :=
189
+ realDensityMeasure_finite _ _ hψ (fun y => (smoothProbabilityProfile_range y).1)
190
+ have hsrc := realDensityMeasure_pi (fun _ : I => (volume : Measure ℝ))
191
+ (fun _ => smoothProbabilityProfile) (fun _ => hψ) (fun _ y => (smoothProbabilityProfile_range y).1)
192
+ have hdst := realDensityMeasure_pi (fun _ : I => (volume : Measure ℝ))
193
+ (fun i => affineProbabilityProfile (c i) (w i))
194
+ (fun i => affineProbabilityProfile_integrable (c i) (hw i))
195
+ (fun i => affineProbabilityProfile_nonneg (c i) (hw i))
196
+ change (Measure.pi (fun _ : I => realDensityMeasure volume smoothProbabilityProfile)) =
197
+ realDensityMeasure volume (smoothProductProfile I) at hsrc
198
+ change (Measure.pi (fun i : I => realDensityMeasure volume (affineProbabilityProfile (c i) (w i)))) =
199
+ realDensityMeasure volume (affineProductProfile c w) at hdst
200
+ rw [← hsrc, Measure.pi_map_pi (fun i =>
201
+ (show Measurable (fun y : ℝ => c i + w i * y) by fun_prop).aemeasurable)]
202
+ simp_rw [affineProbabilityProfile_law _ (hw _)]
203
+ exact hdst
204
+
205
+ end Erdos3
206
+
207
+ end
208
+
209
+ section
210
+
211
+ namespace Erdos3
212
+
213
+ open MeasureTheory
214
+
215
+ theorem affineProbabilityProfile_support (c : ℝ) {w : ℝ} (hw : 0 < w) {x : ℝ}
216
+ (hx : affineProbabilityProfile c w x ≠ 0) : |x - c| < 3 * w / 4 := by
217
+ by_contra! h
218
+ have hz : smoothProbabilityProfile ((x-c)/w) = 0 := by
219
+ apply smoothProbabilityProfile_zero
220
+ rw [abs_div, abs_of_pos hw]
221
+ apply (le_div_iff₀ hw).mpr
222
+ linarith
223
+ exact hx (by simp only [affineProbabilityProfile, hz, mul_zero])
224
+
225
+ theorem realDensityMeasure_ae_of_support {X : Type*} [MeasurableSpace X]
226
+ (μ : Measure X) (f : X → ℝ) (hf : Measurable f) (P : X → Prop)
227
+ (hP : ∀ x, f x ≠ 0 → P x) : ∀ᵐ x ∂realDensityMeasure μ f, P x := by
228
+ apply (ae_withDensity_iff hf.ennreal_ofReal).mpr
229
+ exact Filter.Eventually.of_forall (fun x hx => hP x (fun hz => hx (by simp [hz])))
230
+
231
+ noncomputable def affineCoefficientMeasure (c w : ℝ) : Measure ℝ :=
232
+ realDensityMeasure volume (affineProbabilityProfile c w)
233
+
234
+ theorem affineCoefficientMeasure_probability (c : ℝ) {w : ℝ} (hw : 0 < w) :
235
+ IsProbabilityMeasure (affineCoefficientMeasure c w) :=
236
+ realDensityMeasure_probability volume _ (affineProbabilityProfile_integrable c hw)
237
+ (affineProbabilityProfile_nonneg c hw) (affineProbabilityProfile_integral c hw)
238
+
239
+ theorem affineCoefficientMeasure_support (c : ℝ) {w : ℝ} (hw : 0 < w) :
240
+ ∀ᵐ x ∂affineCoefficientMeasure c w, |x - c| < 3 * w / 4 :=
241
+ realDensityMeasure_ae_of_support volume _ (affineProbabilityProfile_contDiff c w).continuous.measurable
242
+ _ (fun _ hx => affineProbabilityProfile_support c hw hx)
243
+
244
+ theorem affineCoefficientMeasure_law (c : ℝ) {w : ℝ} (hw : 0 < w) :
245
+ (realDensityMeasure volume smoothProbabilityProfile).map (fun y => c + w*y) =
246
+ affineCoefficientMeasure c w :=
247
+ affineProbabilityProfile_law c hw
248
+
249
+ end Erdos3
250
+
251
+ end
252
+
253
+ section
254
+
255
+ namespace Erdos3
256
+
257
+ open MeasureTheory
258
+ open scoped Matrix
259
+
260
+ theorem affineProductProfile_integral_test {J : Type*} [Fintype J]
261
+ (c w : J → ℝ) (hw : ∀ j, 0 < w j) (φ : (J → ℝ) → ℝ) (hφ : Measurable φ) :
262
+ (∫ x, affineProductProfile c w x * φ x) =
263
+ ∫ r, smoothProductProfile J r * φ (fun j => c j + w j * r j) := by
264
+ have hmap : Measurable (fun r : J → ℝ => fun j => c j + w j * r j) := by fun_prop
265
+ rw [← realDensityMeasure_integral volume (affineProductProfile c w)
266
+ (affineProductProfile_contDiff c w).continuous.measurable (affineProductProfile_nonneg c w hw),
267
+ ← affineProductProfile_law c w hw, integral_map hmap.aemeasurable hφ.aestronglyMeasurable,
268
+ realDensityMeasure_integral volume (smoothProductProfile J)
269
+ (smoothProductProfile_contDiff J).continuous.measurable (fun r => (smoothProductProfile_range J r).1)]
270
+
271
+ theorem affineProductProfile_retained_integral {Ω J : Type*} [MeasurableSpace Ω] [Fintype J]
272
+ (μ : Measure Ω) (c w : Ω → J → ℝ) (hw : ∀ ω j, 0 < w ω j)
273
+ (φ : Ω → (J → ℝ) → ℝ) (hφ : ∀ ω, Measurable (φ ω)) :
274
+ (∫ ω, (∫ x, affineProductProfile (c ω) (w ω) x * φ ω x) ∂μ) =
275
+ ∫ ω, (∫ r, smoothProductProfile J r * φ ω (fun j => c ω j + w ω j * r j)) ∂μ := by
276
+ apply integral_congr_ae
277
+ exact Filter.Eventually.of_forall (fun ω => affineProductProfile_integral_test (c ω) (w ω) (hw ω) (φ ω) (hφ ω))
278
+
279
+ theorem affineCoefficientDensity_unit_source {I J : Type*}
280
+ [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
281
+ (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0)
282
+ (S : J → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i)
283
+ (c w : J → ℝ) (hw : ∀ j, 0 < w j) :
284
+ (realDensityMeasure volume (smoothProductProfile J)).map
285
+ (fun r => normalizedIntegerColumns A S P *ᵥ (fun j => c j + w j * r j)) =
286
+ realDensityMeasure volume
287
+ (selectedCoefficientDensity A s hA S P hS hP (affineProductProfile c w)) := by
288
+ have hF : Measurable (fun x => normalizedIntegerColumns A S P *ᵥ x) :=
289
+ (matrixSupCLM (normalizedIntegerColumns A S P)).continuous.measurable
290
+ have hmap : Measurable (fun r : J → ℝ => fun j => c j + w j * r j) := by fun_prop
291
+ change ((realDensityMeasure volume (smoothProductProfile J)).map
292
+ ((fun x => normalizedIntegerColumns A S P *ᵥ x) ∘
293
+ (fun r j => c j + w j * r j))) = _
294
+ rw [← Measure.map_map hF hmap, affineProductProfile_law c w hw]
295
+ exact selectedCoefficientDensity_law A s hA S P hS hP _
296
+ (affineProductProfile_integrable c w hw) (affineProductProfile_nonneg c w hw)
297
+
298
+ theorem affineProductProfile_measurable_comp {Ω J : Type*} [MeasurableSpace Ω] [Fintype J]
299
+ (c w x : Ω → J → ℝ) (hc : Measurable c) (hw : Measurable w) (hx : Measurable x) :
300
+ Measurable (fun ω => affineProductProfile (c ω) (w ω) (x ω)) := by
301
+ unfold affineProductProfile affineProbabilityProfile
302
+ apply Finset.measurable_prod
303
+ intro j _
304
+ exact ((measurable_pi_apply j).comp hw).inv.mul
305
+ (smoothProbabilityProfile_contDiff.continuous.measurable.comp
306
+ ((((measurable_pi_apply j).comp hx).sub ((measurable_pi_apply j).comp hc)).div
307
+ ((measurable_pi_apply j).comp hw)))
308
+
309
+ end Erdos3
310
+
311
+ end
312
+
313
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientReindex.lean ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Probability.CoefficientJetDensityFactors
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped BigOperators Matrix
10
+
11
+ variable {I J O : Type*} [Fintype I] [Fintype J]
12
+
13
+ theorem affineProductProfile_reindex (e : I ≃ J) (c w x : J → ℝ) :
14
+ affineProductProfile (c ∘ e) (w ∘ e) (x ∘ e) = affineProductProfile c w x :=
15
+ Equiv.prod_comp e (fun j => affineProbabilityProfile (c j) (w j) (x j))
16
+
17
+ theorem affineCoefficientWeight_reindex (e : I ≃ J) (c w S : J → ℝ) (z : J → ℤ) :
18
+ coefficientWeight (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) (z ∘ e) =
19
+ coefficientWeight (affineProductProfile c w) S z :=
20
+ affineProductProfile_reindex e c w (fun j => (z j : ℝ)/S j)
21
+
22
+ theorem affineCoefficientWeightSum_reindex (e : I ≃ J) (c w S : J → ℝ) :
23
+ coefficientWeightSum (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) =
24
+ coefficientWeightSum (affineProductProfile c w) S := by
25
+ let E : (J → ℤ) ≃ (I → ℤ) := Equiv.arrowCongr e.symm (Equiv.refl ℤ)
26
+ calc
27
+ _ = ∑' z : J → ℤ,
28
+ coefficientWeight (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) (z ∘ e) :=
29
+ (E.tsum_eq _).symm
30
+ _ = _ := tsum_congr (fun z => affineCoefficientWeight_reindex e c w S z)
31
+
32
+ theorem coefficientPMF_affine_reindex (e : I ≃ J) (c w S : J → ℝ)
33
+ (hw : ∀ j, 0 < w j) (hS : ∀ j, 0 < S j) {R : ℝ} (hR : 0 ≤ R)
34
+ (hcw : ∀ j, |c j|+w j ≤ R) (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) :
35
+ (coefficientPMF (affineProductProfile (c ∘ e) (w ∘ e))
36
+ (affineProductProfile_nonneg _ _ (fun i => hw (e i))) (S ∘ e) (fun i => hS (e i))
37
+ (affineProductProfile_zero_outside _ _ (fun i => hw (e i)) hR (fun i => hcw (e i)))
38
+ (by rw [affineCoefficientWeightSum_reindex]; exact hZ)).map (fun z => z ∘ e.symm) =
39
+ coefficientPMF (affineProductProfile c w) (affineProductProfile_nonneg c w hw) S hS
40
+ (affineProductProfile_zero_outside c w hw hR hcw) hZ := by
41
+ let E : (I → ℤ) ≃ (J → ℤ) := Equiv.arrowCongr e (Equiv.refl ℤ)
42
+ change (coefficientPMF _ _ _ _ _ _).map E = _
43
+ ext z
44
+ rw [pmf_map_equiv_apply]
45
+ apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp
46
+ change ((coefficientPMF _ _ _ _ _ _) (z ∘ e)).toReal = _
47
+ rw [coefficientPMF_apply, coefficientPMF_apply,
48
+ affineCoefficientWeight_reindex, affineCoefficientWeightSum_reindex]
49
+
50
+ theorem coefficientImagePMF_affine_reindex (A : Matrix O J ℤ) (e : I ≃ J) (c w S : J → ℝ)
51
+ (hw : ∀ j, 0 < w j) (hS : ∀ j, 0 < S j) {R : ℝ} (hR : 0 ≤ R)
52
+ (hcw : ∀ j, |c j|+w j ≤ R) (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) :
53
+ coefficientImagePMF (A.submatrix id e) (affineProductProfile (c ∘ e) (w ∘ e))
54
+ (affineProductProfile_nonneg _ _ (fun i => hw (e i))) (S ∘ e) (fun i => hS (e i))
55
+ (affineProductProfile_zero_outside _ _ (fun i => hw (e i)) hR (fun i => hcw (e i)))
56
+ (by rw [affineCoefficientWeightSum_reindex]; exact hZ) =
57
+ coefficientImagePMF A (affineProductProfile c w) (affineProductProfile_nonneg c w hw) S hS
58
+ (affineProductProfile_zero_outside c w hw hR hcw) hZ := by
59
+ unfold coefficientImagePMF
60
+ rw [← coefficientPMF_affine_reindex e c w S hw hS hR hcw hZ, PMF.map_comp]
61
+ congr 1
62
+ funext z
63
+ exact Matrix.submatrix_mulVec_equiv A z id e
64
+
65
+ end Erdos3
66
+
67
+ end
68
+
69
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientResidueWidths.lean ADDED
@@ -0,0 +1,553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.LayerRemovalBudgets
2
+ import OAI.Combinatorics.Progressions.Estimates.ModeShiftLengths
3
+ import OAI.Combinatorics.Progressions.Fourier.AffineFrequencyLift
4
+ import OAI.Combinatorics.Progressions.Fourier.LayeredFourierCharacter
5
+ import OAI.Combinatorics.Progressions.Polynomial.MonomialCoordinateRows
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3.VectorPolynomial
12
+
13
+ open scoped BigOperators Classical
14
+
15
+ theorem integerContractedRow_monomial {K J : Type*}
16
+ (frequency : (K →₀ ℕ) → J → ℤ) (d : K →₀ ℕ) (j : J) :
17
+ integerContractedRow frequency (MvPolynomial.monomial d 1) j = frequency d j := by
18
+ simp [integerContractedRow]
19
+
20
+ theorem exists_unit_integer_mode_rows {K J : Type*} [Fintype K] [Fintype J]
21
+ (W : Submodule ℝ (J → ℝ)) (frequency : (K →₀ ℕ) → J → ℤ) {h : ℕ} {C : ℝ}
22
+ (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C)
23
+ (hnonzero : ∃ p, Homogeneous h p ∧
24
+ coefficientFunctional (fun d j => (frequency d j : ℝ)) (map W.subtype p) ≠ 0) :
25
+ ∃ rows : Fin h → K → ℤ,
26
+ (∀ i k, |(rows i k : ℝ)| ≤ 1) ∧
27
+ (∀ j, |(integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ C) ∧
28
+ ∃ w : W, (∑ j, (integerContractedRow frequency
29
+ (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by
30
+ obtain ⟨d, hd, w, hw⟩ := exists_restricted_coefficient_nonzero W frequency hnonzero
31
+ obtain ⟨rows, hrows, hprod⟩ := exists_monomial_coordinate_rows d hd
32
+ refine ⟨rows, hrows, ?_, ?_⟩
33
+ · simpa only [hprod, integerContractedRow_monomial] using hbound d hd
34
+ · exact ⟨w, by simpa only [hprod, integerContractedRow_monomial] using hw⟩
35
+
36
+ end Erdos3.VectorPolynomial
37
+
38
+ end
39
+
40
+ section
41
+
42
+ namespace Erdos3.VectorPolynomial
43
+
44
+ open scoped BigOperators
45
+
46
+ theorem layeredModeTestedPhase_empty_zero {I K : Type*} [Fintype K] {m : ℕ}
47
+ {W : Fin m → Type*} [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)]
48
+ (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ)
49
+ (p : ∀ j, VectorPolynomial I ℝ (W j)) (b : K → I → ℝ) :
50
+ layeredModeTestedPhase L p 0 (Empty.elim : Empty → K → ℤ) Empty.elim b =
51
+ layeredCoefficientCharacter L p b := by
52
+ simp [layeredModeTestedPhase, layeredCoefficientCharacter]
53
+
54
+ theorem exists_affine_coefficient_local_removal {I K : Type*}
55
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
56
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
57
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
58
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ}
59
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
60
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
61
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
62
+ (map (U i).subtype P) ≠ 0)
63
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
64
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
65
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
66
+ (N stride : I → ℕ) (hs : ∀ k, 0 < stride k)
67
+ {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k)
68
+ (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A)
69
+ (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ)))
70
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
71
+ (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R)
72
+ (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I,
73
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R)
74
+ (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) *
75
+ (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R)
76
+ {β : ℝ} (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) :
77
+ ∃ i : Fin m, ∃ rows : Fin (i.val + 1) → Option K → ℤ,
78
+ (∀ a k, |(rows a k : ℝ)| ≤ 1) ∧
79
+ ∀ base : Option K → I → ℝ,
80
+ ‖𝔼 x : Fin (i.val + 1) → ∀ j, Fin (N j),
81
+ layeredCoefficientCharacter
82
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
83
+ p (rowShiftedTuple base rows
84
+ (fun (y : ∀ j, Fin (N j)) j => (stride j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ β := by
85
+ classical
86
+ let L := fun j => coefficientFunctional (fun d a => (frequency j d a : ℝ))
87
+ let site : Empty → K → ℝ := Empty.elim
88
+ have hf (i : Fin m) := homogeneous_empty_factorization_iff
89
+ ((affineModeLift (L i)).comp (map (U i).subtype)) (i.val + 1)
90
+ (fun s (k : Option K) => k.elim 1 (site s))
91
+ have hbad' : ∃ i, ¬∃ M : (Empty → U i) →ₗ[ℝ] ℝ,
92
+ ∀ P, Homogeneous (i.val + 1) P → affineModeLift (L i) (map (U i).subtype P) =
93
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) P) := by
94
+ obtain ⟨i, P, hP, hn⟩ := hbad
95
+ exact ⟨i, fun h => hn ((hf i).mp h P hP)⟩
96
+ obtain ⟨i, hi, hfactor⟩ := exists_highest_affine_subspace_nonfactor U site L hbad'
97
+ have hn := mt (hf i).mpr hi
98
+ simp only [not_forall, LinearMap.comp_apply] at hn
99
+ obtain ⟨P, hP, hnP⟩ := hn
100
+ obtain ⟨rows, hrows, hcontract, hnonzero⟩ := exists_unit_integer_mode_rows (U i)
101
+ (affineLiftFrequency (frequency i)) (affineLiftFrequency_bound _ (hbound i))
102
+ (by exact ⟨P, hP, by simpa only [L, affineModeLift_integerFrequency] using hnP⟩)
103
+ have hsite : (fun (s : Empty) (k : Option K) => (((Empty.elim s : Option K → ℤ) k : ℤ) : ℝ)) =
104
+ (fun s (k : Option K) => k.elim 1 (site s)) := Subsingleton.elim _ _
105
+ obtain ⟨Q', hQ', test', ht, he⟩ := exists_subspace_layered_mode_reduction i U
106
+ (fun j => affineModeLift (L j)) p hm hp (Empty.elim : Empty → Option K → ℤ)
107
+ (by rw [hsite]; exact hfactor) 0 (by simp) Empty.elim (fun s => s.elim)
108
+ have he' (b : Option K → I → ℝ) :
109
+ layeredCoefficientCharacter (fun j => affineModeLift (L j)) p b =
110
+ coefficientModeTestedPhase
111
+ (coefficientFunctional (fun d a => ((affineLiftFrequency (frequency i) d a : ℤ) : ℝ)))
112
+ (p i) Q' Empty.elim test' b := by
113
+ simpa only [layeredModeTestedPhase_empty_zero, L, affineModeLift_integerFrequency] using he b
114
+ refine ⟨i, rows, hrows, ?_⟩
115
+ intro base
116
+ change ‖𝔼 x : Fin (i.val + 1) → ∀ j, Fin (N j),
117
+ layeredCoefficientCharacter (fun j => affineModeLift (L j)) p
118
+ (rowShiftedTuple base rows
119
+ (fun (y : ∀ j, Fin (N j)) j => (stride j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ β
120
+ simp_rw [he']
121
+ exact inhomogeneous_coefficient_mode_local_removal (affineLiftFrequency (frequency i)) rows
122
+ (p i) (hp i) (U i) N stride hs hζ (hN i) H hH hA hscale (hrank i)
123
+ hcontract (hrowBudget i) hnonzero (hdenom i) (hcoeff i)
124
+ Empty.elim (fun s => s.elim) Q' hQ' test' ht hβ (hpower i) base
125
+
126
+ end Erdos3.VectorPolynomial
127
+
128
+ end
129
+
130
+ section
131
+
132
+ namespace Erdos3.VectorPolynomial
133
+
134
+ open scoped BigOperators NNReal
135
+
136
+ theorem affine_coefficient_mode_residue_removal_lipschitz_amplitude {I K : Type*}
137
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
138
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
139
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
140
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ}
141
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
142
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
143
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
144
+ (map (U i).subtype P) ≠ 0)
145
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
146
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
147
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
148
+ (N stride : I → ℕ) (hs : ∀ k, 0 < stride k)
149
+ {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k)
150
+ (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A)
151
+ (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ)))
152
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
153
+ (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R)
154
+ (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I,
155
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R)
156
+ (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) *
157
+ (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R)
158
+ (residue : Option K × I → ℤ)
159
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
160
+ (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride)
161
+ (residueProfileWidth stride V))
162
+ (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z)
163
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ)
164
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
165
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
166
+ {r β : ℝ} (hr : 0 ≤ r)
167
+ (hmove : ∀ i : Fin m, ∀ z,
168
+ ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z)
169
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1)))
170
+ (F : (Option K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1)
171
+ {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) :
172
+ ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) *
173
+ (F (fun t => (residueLatticeArray residue stride z t : ℝ) / V t) *
174
+ layeredCoefficientCharacter
175
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
176
+ p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ)))‖ ≤
177
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
178
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + (Lip : ℝ) * r + β := by
179
+ obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal
180
+ U frequency hbound hbad p hp hm N stride hs hζ hN
181
+ H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower
182
+ have hNp k : 0 < N k := by
183
+ exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k)
184
+ exact residue_smooth_row_shift_transfer_lipschitz_amplitude N stride hNp hs rows residue V hV hZ hV1
185
+ hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i)
186
+ _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal F hF hLip
187
+
188
+ end Erdos3.VectorPolynomial
189
+
190
+ end
191
+
192
+ section
193
+
194
+ namespace Erdos3.VectorPolynomial
195
+
196
+ open scoped BigOperators
197
+
198
+ theorem affine_coefficient_mode_residue_removal {I K : Type*}
199
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
200
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
201
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
202
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ}
203
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
204
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
205
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
206
+ (map (U i).subtype P) ≠ 0)
207
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
208
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
209
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
210
+ (N stride : I → ℕ) (hs : ∀ k, 0 < stride k)
211
+ {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k)
212
+ (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A)
213
+ (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ)))
214
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
215
+ (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R)
216
+ (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I,
217
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R)
218
+ (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) *
219
+ (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R)
220
+ (residue : Option K × I → ℤ)
221
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
222
+ (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride)
223
+ (residueProfileWidth stride V))
224
+ (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z)
225
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ)
226
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
227
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
228
+ {r β : ℝ} (hr : 0 ≤ r)
229
+ (hmove : ∀ i : Fin m, ∀ z,
230
+ ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z)
231
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) :
232
+ ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) *
233
+ layeredCoefficientCharacter
234
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
235
+ p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤
236
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
237
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by
238
+ obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal
239
+ U frequency hbound hbad p hp hm N stride hs hζ hN
240
+ H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower
241
+ have hNp k : 0 < N k := by
242
+ exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k)
243
+ exact residue_smooth_row_shift_transfer N stride hNp hs rows residue V hV hZ hV1
244
+ hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i)
245
+ _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal
246
+
247
+ end Erdos3.VectorPolynomial
248
+
249
+ end
250
+
251
+ section
252
+
253
+ namespace Erdos3.VectorPolynomial
254
+
255
+ open scoped BigOperators
256
+
257
+ theorem anchored_affine_coefficient_mode_residue_removal {I K : Type*}
258
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
259
+ (origin : Option K → I → ℝ)
260
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
261
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
262
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ}
263
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
264
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
265
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
266
+ (map (U i).subtype P) ≠ 0)
267
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
268
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
269
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
270
+ (N stride : I → ℕ) (hs : ∀ k, 0 < stride k)
271
+ {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k)
272
+ (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A)
273
+ (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ)))
274
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
275
+ (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R)
276
+ (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I,
277
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R)
278
+ (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) *
279
+ (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R)
280
+ (residue : Option K × I → ℤ)
281
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
282
+ (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride)
283
+ (residueProfileWidth stride V))
284
+ (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z)
285
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ)
286
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
287
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
288
+ {r β : ℝ} (hr : 0 ≤ r)
289
+ (hmove : ∀ i : Fin m, ∀ z,
290
+ ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z)
291
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) :
292
+ ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) *
293
+ layeredCoefficientCharacter
294
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
295
+ p (origin + fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤
296
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
297
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by
298
+ obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal
299
+ U frequency hbound hbad p hp hm N stride hs hζ hN
300
+ H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower
301
+ have hNp k : 0 < N k := by
302
+ exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k)
303
+ exact anchored_residue_smooth_row_shift_transfer origin N stride hNp hs rows residue V hV hZ hV1
304
+ hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i)
305
+ _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal
306
+
307
+ end Erdos3.VectorPolynomial
308
+
309
+ end
310
+
311
+ section
312
+
313
+ namespace Erdos3.VectorPolynomial
314
+
315
+ open scoped BigOperators
316
+
317
+ def affineCoefficientModeTrivial {K : Type*} {m : ℕ}
318
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
319
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
320
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : Prop :=
321
+ ∀ j, ∀ P, Homogeneous (j.val + 1) P →
322
+ affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))
323
+ (map (U j).subtype P) = 0
324
+
325
+ theorem not_affineCoefficientModeTrivial_iff {K : Type*} {m : ℕ}
326
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
327
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
328
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) :
329
+ ¬affineCoefficientModeTrivial U frequency ↔
330
+ ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
331
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
332
+ (map (U i).subtype P) ≠ 0 := by
333
+ simp only [affineCoefficientModeTrivial, not_forall, exists_prop]
334
+
335
+ theorem affineModeLift_zero_of_homogeneous {K W : Type*}
336
+ [AddCommGroup W] [Module ℝ W]
337
+ (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) {h : ℕ}
338
+ (hz : ∀ P, Homogeneous h P → affineModeLift L P = 0)
339
+ (P : VectorPolynomial (Option K) ℝ W) (hP : DegreeLE (1 : Option K → ℕ) h P) :
340
+ affineModeLift L P = 0 := by
341
+ have hf := (affineModeLift_factorization_iff h (Empty.elim : Empty → K → ℝ)
342
+ L (0 : (Empty → W) →ₗ[ℝ] ℝ)).mp (by simpa only [LinearMap.zero_apply] using hz)
343
+ exact hf P hP
344
+
345
+ theorem layeredCoefficientCharacter_eq_one_of_trivial {I K : Type*} [Fintype K] {m : ℕ}
346
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
347
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
348
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
349
+ (hz : affineCoefficientModeTrivial U frequency)
350
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
351
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
352
+ (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) :
353
+ layeredCoefficientCharacter
354
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) p b = 1 := by
355
+ have hzero (j : Fin m) :
356
+ affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))
357
+ (substitute (fun u => rowPolynomial (fun k => b k u)) (p j)) = 0 := by
358
+ let p' := restrictCoefficients (U j) (p j) (hm j)
359
+ have hp' := degreeLE_restrictCoefficients (U j) (p j) (hm j) (hp j)
360
+ have he := affineModeLift_zero_of_homogeneous
361
+ ((coefficientFunctional (fun d a => (frequency j d a : ℝ))).comp (map (U j).subtype))
362
+ (by simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hz j)
363
+ (substitute (fun u => rowPolynomial (fun k => b k u)) p')
364
+ (degreeLE_substitute_affine _ (fun u => (rowPolynomial_homogeneous (fun k => b k u)).totalDegree_le) p' hp')
365
+ simpa only [affineModeLift_comp_map, LinearMap.comp_apply, map_substitute,
366
+ p', map_restrictCoefficients] using he
367
+ simp only [layeredCoefficientCharacter, hzero, Finset.sum_const_zero,
368
+ AddCircle.coe_zero, CircleFourier.character_zero]
369
+
370
+ end Erdos3.VectorPolynomial
371
+
372
+ end
373
+
374
+ section
375
+
376
+ namespace Erdos3.VectorPolynomial
377
+
378
+ open scoped BigOperators NNReal
379
+
380
+ theorem affine_coefficient_residue_removal_of_widths_lipschitz_amplitude {I K : Type*}
381
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
382
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
383
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
384
+ {C : ℝ} (hC : 0 ≤ C)
385
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
386
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
387
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
388
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
389
+ (map (U i).subtype P) ≠ 0)
390
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
391
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
392
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
393
+ (stride : I → ℕ) (hs : ∀ k, 0 < stride k)
394
+ {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S)
395
+ (hstride : ∀ k, (stride k : ℝ) ≤ S)
396
+ (H : I → ℝ) (hH : ∀ k, 0 < H k)
397
+ (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k)
398
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
399
+ (hR : layerRemovalRankBudget m (Fintype.card I) C 1
400
+ (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R)
401
+ (residue : Option K × I → ℤ)
402
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
403
+ (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride)
404
+ (residueProfileWidth stride V))
405
+ (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z)
406
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ)
407
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
408
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
409
+ {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r)
410
+ (hwidth : ∀ z, ρ * H z.2 ≤ V z)
411
+ (hmove : (m : ℝ) * 1 ≤ r * ρ * T)
412
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1)))
413
+ (F : (Option K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1)
414
+ {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) :
415
+ ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) *
416
+ (F (fun t => (residueLatticeArray residue stride z t : ℝ) / V t) *
417
+ layeredCoefficientCharacter
418
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
419
+ p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ)))‖ ≤
420
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
421
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + (Lip : ℝ) * r + β := by
422
+ classical
423
+ let B := finiteLayerBiasBudget m ζ
424
+ let D : ℝ := 1
425
+ have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ
426
+ have hD : 0 ≤ D := zero_le_one
427
+ have hA : 0 ≤ 2 * T := by positivity
428
+ have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B :=
429
+ multiaffineBiasBudget_le_finite i hζ
430
+ obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth
431
+ have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD
432
+ (zero_le_one.trans hB) hA hS
433
+ apply affine_coefficient_mode_residue_removal_lipschitz_amplitude U frequency hbound hbad
434
+ p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank
435
+ (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
436
+ · intro i
437
+ have hi := tensorDenominatorBound_le (H := Fin (i.val + 1))
438
+ (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ))
439
+ (fun k => Nat.cast_nonneg _) hstride
440
+ have hi' : (∏ j : Fin (i.val + 1) → I,
441
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤
442
+ (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by
443
+ simpa only [Fintype.card_fin] using hi
444
+ apply hi'.trans
445
+ apply le_trans _ ((hbud i).2.1.trans hR)
446
+ exact pow_le_pow_left₀
447
+ (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _))
448
+ (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _
449
+ · intro i
450
+ apply le_trans _ ((hbud i).2.2.trans hR)
451
+ exact mul_le_mul_of_nonneg_left
452
+ (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _))
453
+ (pow_nonneg (Nat.cast_nonneg _) _)
454
+ · intro i z
455
+ have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt
456
+ have hs' : (m : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z := by
457
+ simpa only [mul_one] using hshift z
458
+ exact (mul_le_mul_of_nonneg_right hi
459
+ (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))).trans hs'
460
+
461
+ end Erdos3.VectorPolynomial
462
+
463
+ end
464
+
465
+ section
466
+
467
+ namespace Erdos3.VectorPolynomial
468
+
469
+ open scoped BigOperators NNReal
470
+
471
+ theorem affine_coefficient_residue_removal_of_widths {I K : Type*}
472
+ [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ}
473
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
474
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
475
+ {C : ℝ} (hC : 0 ≤ C)
476
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
477
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
478
+ (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧
479
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ)))
480
+ (map (U i).subtype P) ≠ 0)
481
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
482
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
483
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
484
+ (stride : I → ℕ) (hs : ∀ k, 0 < stride k)
485
+ {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S)
486
+ (hstride : ∀ k, (stride k : ℝ) ≤ S)
487
+ (H : I → ℝ) (hH : ∀ k, 0 < H k)
488
+ (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k)
489
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
490
+ (hR : layerRemovalRankBudget m (Fintype.card I) C 1
491
+ (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R)
492
+ (residue : Option K × I → ℤ)
493
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
494
+ (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride)
495
+ (residueProfileWidth stride V))
496
+ (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z)
497
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ)
498
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
499
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
500
+ {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r)
501
+ (hwidth : ∀ z, ρ * H z.2 ≤ V z)
502
+ (hmove : (m : ℝ) * 1 ≤ r * ρ * T)
503
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) :
504
+ ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) *
505
+ layeredCoefficientCharacter
506
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
507
+ p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤
508
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
509
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by
510
+ classical
511
+ let B := finiteLayerBiasBudget m ζ
512
+ let D : ℝ := 1
513
+ have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ
514
+ have hD : 0 ≤ D := zero_le_one
515
+ have hA : 0 ≤ 2 * T := by positivity
516
+ have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B :=
517
+ multiaffineBiasBudget_le_finite i hζ
518
+ obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth
519
+ have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD
520
+ (zero_le_one.trans hB) hA hS
521
+ apply affine_coefficient_mode_residue_removal U frequency hbound hbad
522
+ p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank
523
+ (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
524
+ · intro i
525
+ have hi := tensorDenominatorBound_le (H := Fin (i.val + 1))
526
+ (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ))
527
+ (fun k => Nat.cast_nonneg _) hstride
528
+ have hi' : (∏ j : Fin (i.val + 1) → I,
529
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤
530
+ (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by
531
+ simpa only [Fintype.card_fin] using hi
532
+ apply hi'.trans
533
+ apply le_trans _ ((hbud i).2.1.trans hR)
534
+ exact pow_le_pow_left₀
535
+ (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _))
536
+ (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _
537
+ · intro i
538
+ apply le_trans _ ((hbud i).2.2.trans hR)
539
+ exact mul_le_mul_of_nonneg_left
540
+ (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _))
541
+ (pow_nonneg (Nat.cast_nonneg _) _)
542
+ · intro i z
543
+ have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt
544
+ have hs' : (m : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z := by
545
+ simpa only [mul_one] using hshift z
546
+ exact (mul_le_mul_of_nonneg_right hi
547
+ (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))).trans hs'
548
+
549
+ end Erdos3.VectorPolynomial
550
+
551
+ end
552
+
553
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientSubspace.lean ADDED
@@ -0,0 +1,584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.BoundedAmbientModeWitness
2
+ import OAI.Combinatorics.Progressions.Estimates.OrderedLayerSplit
3
+ import OAI.Combinatorics.Progressions.Polynomial.PolynomialSiteAbsorption
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3.VectorPolynomial
10
+
11
+ open scoped BigOperators TensorProduct Classical
12
+
13
+ noncomputable def integerContractedRow {σ J : Type*}
14
+ (frequency : (σ →₀ ℕ) → J → ℤ) (P : MvPolynomial σ ℤ) : J → ℤ :=
15
+ fun j => ∑ d ∈ P.support, P.coeff d * frequency d j
16
+
17
+ theorem integerContractedRow_cast {σ J : Type*}
18
+ (Λ : VectorPolynomial σ ℝ (J → ℝ) →ₗ[ℝ] ℝ)
19
+ (frequency : (σ →₀ ℕ) → J → ℤ) {h : ℕ}
20
+ (hfrequency : ∀ d : σ →₀ ℕ, d.degree = h → ∀ j,
21
+ Λ (MvPolynomial.monomial d 1 ⊗ₜ[ℝ] Pi.single j 1) = (frequency d j : ℝ))
22
+ {P : MvPolynomial σ ℤ} (hP : P.IsHomogeneous h) (j : J) :
23
+ (integerContractedRow frequency P j : ℝ) = contractedRow Λ (MvPolynomial.map (Int.castRingHom ℝ) P) j := by
24
+ change _ = ((TensorProduct.curry Λ).flip (Pi.single j 1)) (MvPolynomial.map (Int.castRingHom ℝ) P)
25
+ rw [polynomialFunctional_map_expansion]
26
+ simp only [integerContractedRow, Int.cast_sum, Int.cast_mul, Int.coe_castRingHom]
27
+ apply Finset.sum_congr rfl
28
+ intro d hd
29
+ have hdeg : d.degree = h := by
30
+ simpa only [Finsupp.degree_eq_weight_one, Pi.one_def] using hP (MvPolynomial.mem_support_iff.mp hd)
31
+ change _ = ((P.coeff d : ℤ) : ℝ) * Λ (MvPolynomial.monomial d 1 ⊗ₜ[ℝ] Pi.single j 1)
32
+ rw [hfrequency d hdeg j]
33
+
34
+ theorem integerContractedRow_coefficientFunctional {σ J : Type*} [Fintype J]
35
+ (frequency : (σ →₀ ℕ) → J → ℤ) {P : MvPolynomial σ ℤ} {h : ℕ}
36
+ (hP : P.IsHomogeneous h) (j : J) :
37
+ (integerContractedRow frequency P j : ℝ) = contractedRow
38
+ (coefficientFunctional (fun d j => (frequency d j : ℝ)))
39
+ (MvPolynomial.map (Int.castRingHom ℝ) P) j :=
40
+ integerContractedRow_cast _ frequency (fun d _ j => coefficientFunctional_unit _ d j) hP j
41
+
42
+ end Erdos3.VectorPolynomial
43
+
44
+ end
45
+
46
+ section
47
+
48
+ namespace Erdos3.BooleanCubeKernel
49
+
50
+ open scoped BigOperators Classical
51
+
52
+ theorem integer_cube_root_bound {K : Type*} {q : ℕ}
53
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {L : ℝ}
54
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) :
55
+ ∀ k, |(root k : ℝ)| ≤ L := by
56
+ intro k
57
+ simpa only [affineSite, Finset.sum_empty, add_zero] using hsite ∅ k
58
+
59
+ theorem integer_cube_difference_bound {K : Type*} {q : ℕ}
60
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {L : ℝ}
61
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) :
62
+ ∀ i k, |(difference i k : ℝ)| ≤ 2 * L := by
63
+ intro i k
64
+ have he : (difference i k : ℝ) =
65
+ ((affineSite root difference {i} (some k) : ℤ) : ℝ) - (root k : ℝ) := by
66
+ simp [affineSite]
67
+ rw [he]
68
+ have ht := hsite {i} k
69
+ have hr := integer_cube_root_bound root difference hsite k
70
+ exact (abs_sub _ _).trans (by linarith)
71
+
72
+ end Erdos3.BooleanCubeKernel
73
+
74
+ end
75
+
76
+ section
77
+
78
+ namespace Erdos3.BooleanCubeKernel
79
+
80
+ theorem integerCubeWitnessBound_le_polynomial (q : ℕ) {H D : ℝ}
81
+ (hH : 0 ≤ H) (hD : 0 ≤ D) :
82
+ integerCubeWitnessBound q H D ≤
83
+ (q.factorial : ℝ) * (2 + (q : ℝ) * (q + 1)) * (1 + H + D) ^ (q + 2) := by
84
+ let M := 1 + H + D
85
+ have hM : 1 ≤ M := by dsimp [M]; linarith
86
+ have hDq : D ^ q ≤ M ^ q := pow_le_pow_left₀ hD (by dsimp [M]; linarith) q
87
+ have hDm : D ^ (q - 1) ≤ M ^ q :=
88
+ (pow_le_pow_left₀ hD (by dsimp [M]; linarith) (q - 1)).trans
89
+ (pow_le_pow_right₀ hM (Nat.sub_le _ _))
90
+ have hHM : 1 + H ≤ M := by dsimp [M]; linarith
91
+ have hA : (q.factorial : ℝ) * D ^ q ≤ (q.factorial : ℝ) * M ^ q :=
92
+ mul_le_mul_of_nonneg_left hDq (Nat.cast_nonneg _)
93
+ have hB : (q : ℝ) * ((q.factorial : ℝ) * D ^ (q - 1) * (1 + H)) ≤
94
+ (q : ℝ) * (q.factorial : ℝ) * M ^ (q + 1) := by
95
+ calc
96
+ _ ≤ (q : ℝ) * ((q.factorial : ℝ) * M ^ q * M) := by gcongr
97
+ _ = _ := by rw [pow_succ]; ring
98
+ have hfactor : (q : ℝ) * D + 1 ≤ ((q : ℝ) + 1) * M := by
99
+ have hd : D ≤ M := by dsimp [M]; linarith
100
+ nlinarith [show (0 : ℝ) ≤ (q : ℝ) from Nat.cast_nonneg q]
101
+ have hbase : 2 + H ≤ 2 * M := by dsimp [M]; linarith
102
+ have hpow : M ^ (q + 1) ≤ M ^ (q + 2) := pow_le_pow_right₀ hM (by omega)
103
+ unfold integerCubeWitnessBound integerFormMassBound
104
+ calc
105
+ _ ≤ (q.factorial : ℝ) * M ^ q * (2 * M) +
106
+ (((q : ℝ) + 1) * M) * ((q : ℝ) * (q.factorial : ℝ) * M ^ (q + 1)) := by
107
+ exact add_le_add (mul_le_mul hA hbase (by positivity) (by positivity))
108
+ (mul_le_mul hfactor hB (by positivity) (by positivity))
109
+ _ = 2 * (q.factorial : ℝ) * M ^ (q + 1) +
110
+ ((q : ℝ) * (q + 1) * (q.factorial : ℝ)) * M ^ (q + 2) := by
111
+ simp only [pow_succ]
112
+ ring
113
+ _ ≤ 2 * (q.factorial : ℝ) * M ^ (q + 2) +
114
+ ((q : ℝ) * (q + 1) * (q.factorial : ℝ)) * M ^ (q + 2) := by gcongr
115
+ _ = _ := by dsimp [M]; ring
116
+
117
+ end Erdos3.BooleanCubeKernel
118
+
119
+ end
120
+
121
+ section
122
+
123
+ namespace Erdos3.BooleanCubeKernel
124
+
125
+ open MvPolynomial
126
+ open scoped BigOperators TensorProduct Classical
127
+
128
+ theorem exists_bounded_integer_mode_witness {K J : Type*} [Fintype K] [Fintype J] {q : ℕ}
129
+ (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
130
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
131
+ {H D C : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hC : 0 ≤ C)
132
+ (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D)
133
+ (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ)
134
+ (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C)
135
+ (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ,
136
+ ∀ p, VectorPolynomial.Homogeneous h p →
137
+ VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ))
138
+ (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation
139
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) :
140
+ ∃ P : Fin h → MvPolynomial (Option K) ℤ,
141
+ (∀ i, (P i).IsHomogeneous 1 ∧
142
+ realPolynomialMass (map (Int.castRingHom ℝ) (P i)) ≤ integerCubeWitnessBound q H D) ∧
143
+ (∀ s : Finset (Fin q), ∃ i, eval (affineSite root difference s) (P i) = 0) ∧
144
+ (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, P i) j : ℝ)| ≤
145
+ C * integerCubeWitnessBound q H D ^ h) ∧
146
+ ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency (∏ i, P i) j : ℝ) * w.val j) ≠ 0 := by
147
+ obtain ⟨P, hP, hz, hb, w, hw⟩ := exists_bounded_ambient_mode_witness W root difference hlin
148
+ hH hD hC hroot hdiff (VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ)))
149
+ h (VectorPolynomial.coefficientFunctional_rowBound _ hbound) hnonfactor
150
+ have hp : (∏ i, P i).IsHomogeneous h := by
151
+ simpa using IsHomogeneous.prod Finset.univ P (fun _ => 1) (fun i _ => (hP i).1)
152
+ have hcast (j : J) := VectorPolynomial.integerContractedRow_coefficientFunctional frequency hp j
153
+ refine ⟨P, hP, hz, ?_, w, ?_⟩
154
+ · intro j
155
+ rw [hcast j]
156
+ exact hb j
157
+ · simp_rw [hcast]
158
+ exact hw
159
+
160
+ end Erdos3.BooleanCubeKernel
161
+
162
+ end
163
+
164
+ section
165
+
166
+ namespace Erdos3
167
+
168
+ open MvPolynomial
169
+ open scoped BigOperators TensorProduct Classical
170
+
171
+ theorem rowPolynomial_homogeneous {σ R : Type*} [Fintype σ] [CommRing R] (a : σ → R) :
172
+ (rowPolynomial a).IsHomogeneous 1 :=
173
+ IsHomogeneous.sum Finset.univ _ 1 (fun i _ => isHomogeneous_C_mul_X (a i) i)
174
+
175
+ theorem VectorPolynomial.integerContractedRow_apply {σ J : Type*} [Fintype J]
176
+ (frequency : (σ →₀ ℕ) → J → ℤ) {P : MvPolynomial σ ℤ} {h : ℕ}
177
+ (hP : P.IsHomogeneous h) (w : J → ℝ) :
178
+ (∑ j, (integerContractedRow frequency P j : ℝ) * w j) =
179
+ coefficientFunctional (fun d j => (frequency d j : ℝ))
180
+ ((MvPolynomial.map (Int.castRingHom ℝ) P) ⊗ₜ[ℝ] w) := by
181
+ simp_rw [integerContractedRow_coefficientFunctional frequency hP]
182
+ exact contractedRow_apply _ _ w
183
+
184
+ namespace BooleanCubeKernel
185
+
186
+ theorem exists_bounded_integer_mode_rows {K J : Type*} [Fintype K] [Fintype J] {q : ℕ}
187
+ (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
188
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
189
+ {H D C : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hC : 0 ≤ C)
190
+ (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D)
191
+ (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ)
192
+ (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C)
193
+ (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ,
194
+ ∀ p, VectorPolynomial.Homogeneous h p →
195
+ VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ))
196
+ (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation
197
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) :
198
+ ∃ rows : Fin h → Option K → ℤ,
199
+ (∀ i k, |(rows i k : ℝ)| ≤ integerCubeWitnessBound q H D) ∧
200
+ (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧
201
+ (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤
202
+ C * integerCubeWitnessBound q H D ^ h) ∧
203
+ ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency
204
+ (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by
205
+ obtain ⟨P, hP, hz, hb, hw⟩ := exists_bounded_integer_mode_witness W root difference hlin
206
+ hH hD hC hroot hdiff frequency h hbound hnonfactor
207
+ let rows := fun i => polynomialLinearRow (P i)
208
+ have hp (i : Fin h) : rowPolynomial (rows i) = P i :=
209
+ (homogeneous_eq_rowPolynomial _ (hP i).1).symm
210
+ have hprod : (∏ i, rowPolynomial (rows i)) = ∏ i, P i := by simp_rw [hp]
211
+ refine ⟨rows, ?_, ?_, ?_, ?_⟩
212
+ · intro i k
213
+ exact (integer_coefficient_le_mass (P i) (Finsupp.single k 1)).trans (hP i).2
214
+ · intro s
215
+ obtain ⟨i, hi⟩ := hz s
216
+ refine ⟨i, ?_⟩
217
+ change (∑ k, polynomialLinearRow (P i) k * affineSite root difference s k) = 0
218
+ rw [← homogeneous_eval_eq_row _ (hP i).1]
219
+ exact hi
220
+ · rw [hprod]
221
+ exact hb
222
+ · rw [hprod]
223
+ exact hw
224
+
225
+ end BooleanCubeKernel
226
+ end Erdos3
227
+
228
+ end
229
+
230
+ section
231
+
232
+ namespace Erdos3.VectorPolynomial
233
+
234
+ open scoped BigOperators
235
+
236
+ noncomputable def affineParameterSubstitution {I K : Type*} [Fintype K]
237
+ (b : Option K → I → ℝ) (j : I) : MvPolynomial K ℝ :=
238
+ MvPolynomial.C (b none j) + rowPolynomial (fun k => b (some k) j)
239
+
240
+ theorem dehomogenize_rowPolynomial {K : Type*} [Fintype K] (a : Option K → ℝ) :
241
+ MvPolynomial.aeval dehomogenizingSubstitution (rowPolynomial a) =
242
+ MvPolynomial.C (a none) + rowPolynomial (fun k => a (some k)) := by
243
+ simp [rowPolynomial, dehomogenizingSubstitution, Fintype.sum_option]
244
+
245
+ theorem affineParameterSubstitution_degree {I K : Type*} [Fintype K]
246
+ (b : Option K → I → ℝ) (j : I) : (affineParameterSubstitution b j).totalDegree ≤ 1 := by
247
+ apply (MvPolynomial.totalDegree_add _ _).trans
248
+ exact max_le (by simp) (rowPolynomial_homogeneous (fun k => b (some k) j)).totalDegree_le
249
+
250
+ theorem affineParameterSubstitution_eval {I K : Type*} [Fintype K]
251
+ (b : Option K → I → ℝ) (t : K → ℝ) (j : I) :
252
+ MvPolynomial.aeval t (affineParameterSubstitution b j) =
253
+ b none j + ∑ k, b (some k) j * t k := by
254
+ change MvPolynomial.eval t (affineParameterSubstitution b j) = _
255
+ rw [affineParameterSubstitution, map_add, MvPolynomial.eval_C, rowPolynomial_eval]
256
+
257
+ noncomputable def affineModeLift {K W : Type*} [AddCommGroup W] [Module ℝ W]
258
+ (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) : VectorPolynomial (Option K) ℝ W →ₗ[ℝ] ℝ :=
259
+ Λ.comp (substitute dehomogenizingSubstitution)
260
+
261
+ theorem affineModeLift_substitute {I K W : Type*} [Fintype K]
262
+ [AddCommGroup W] [Module ℝ W]
263
+ (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W)
264
+ (b : Option K → I → ℝ) :
265
+ affineModeLift Λ (substitute (fun j => rowPolynomial (fun k => b k j)) p) =
266
+ Λ (substitute (affineParameterSubstitution b) p) := by
267
+ rw [affineModeLift, LinearMap.comp_apply, substitute_comp]
268
+ simp only [dehomogenize_rowPolynomial]
269
+ rfl
270
+
271
+ theorem coefficientModePolynomial_affine_eval {I K W : Type*} [Fintype K]
272
+ [AddCommGroup W] [Module ℝ W]
273
+ (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W)
274
+ (b : Option K → I → ℝ) :
275
+ MvPolynomial.eval (fun z => b z.1 z.2) (coefficientModePolynomial (affineModeLift Λ) p) =
276
+ Λ (substitute (affineParameterSubstitution b) p) := by
277
+ rw [coefficientModePolynomial_eval, affineModeLift_substitute]
278
+
279
+ theorem coefficientModePolynomial_degreeLE {I K W : Type*} [Fintype K]
280
+ [AddCommGroup W] [Module ℝ W]
281
+ (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W)
282
+ {h : ℕ} (hp : DegreeLE (1 : I → ℕ) h p) :
283
+ (coefficientModePolynomial L p).totalDegree ≤ h := by
284
+ unfold coefficientModePolynomial
285
+ apply MvPolynomial.totalDegree_finsetSum_le
286
+ intro d hd
287
+ apply (mapPolynomialCoefficients_degree _ _).trans
288
+ apply parameterPolynomialPullback_degree
289
+ have hb : d.sum (fun _ n => n) ≤ h := by
290
+ simpa only [Finsupp.weight_apply, Pi.one_def, smul_eq_mul, mul_one] using
291
+ (degreeLE_iff (1 : I → ℕ) h p).mp hp d hd
292
+ exact (MvPolynomial.totalDegree_monomial_le d 1).trans hb
293
+
294
+ end Erdos3.VectorPolynomial
295
+
296
+ end
297
+
298
+ section
299
+
300
+ namespace Erdos3.VectorPolynomial
301
+
302
+ open CircleFourier
303
+ open scoped BigOperators
304
+
305
+ theorem rowPolynomial_integer_site {I K : Type*} [Fintype K]
306
+ (site : K → ℤ) (b : K → I → ℝ) :
307
+ (fun i => MvPolynomial.aeval (fun k => (site k : ℝ)) (rowPolynomial (fun k => b k i))) =
308
+ integerSiteValue site b := by
309
+ funext i
310
+ change MvPolynomial.eval (fun k => (site k : ℝ)) (rowPolynomial (fun k => b k i)) = _
311
+ rw [rowPolynomial_eval]
312
+ change (∑ k, b k i * (site k : ℝ)) = (∑ k, site k • b k) i
313
+ rw [Finset.sum_apply]
314
+ apply Finset.sum_congr rfl
315
+ intro k _
316
+ change b k i * (site k : ℝ) = site k • b k i
317
+ rw [zsmul_eq_mul, mul_comm]
318
+
319
+ theorem exists_absorbed_integer_site_tests {A I K S : Type*} {W : A → Type*}
320
+ [Fintype A] [Fintype K] [Fintype S] [DecidableEq S]
321
+ [∀ a, AddCommGroup (W a)] [∀ a, Module ℝ (W a)]
322
+ (h : A → ℕ) (site : S → K → ℤ)
323
+ (L : ∀ a, VectorPolynomial K ℝ (W a) →ₗ[ℝ] ℝ)
324
+ (hfactor : ∀ a, ∃ M : (S → W a) →ₗ[ℝ] ℝ,
325
+ ∀ q, DegreeLE (1 : K → ℕ) (h a) q →
326
+ L a q = M (siteEvaluation (fun s k => (site s k : ℝ)) q))
327
+ (p : ∀ a, VectorPolynomial I ℝ (W a)) (hp : ∀ a, DegreeLE (1 : I → ℕ) (h a) (p a))
328
+ (low : (K → I → ℝ) → ℝ)
329
+ (test : S ��� (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) :
330
+ ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b,
331
+ character ((low b + ∑ a, L a (substitute (fun i => rowPolynomial (fun k => b k i)) (p a)) : ℝ) :
332
+ CircleFourier.Circle) * (∏ s, test s (integerSiteValue (site s) b)) =
333
+ character (low b : CircleFourier.Circle) * (∏ s, test' s (integerSiteValue (site s) b)) := by
334
+ have hf (a : A) : ∃ M : (S → W a) →ₗ[ℝ] ℝ,
335
+ ∀ q, Homogeneous (h a) q → L a (substitute dehomogenizingSubstitution q) =
336
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q) := by
337
+ obtain ⟨M, hM⟩ := hfactor a
338
+ exact ⟨M, (homogeneous_site_factorization_iff (h a)
339
+ (fun s k => (site s k : ℝ)) (L a) M).mpr hM⟩
340
+ obtain ⟨test', ht, he⟩ := exists_absorbed_polynomial_site_tests h
341
+ (fun s k => (site s k : ℝ)) L hf p hp
342
+ (fun (b : K → I → ℝ) i => rowPolynomial (fun k => b k i))
343
+ (fun b i => (rowPolynomial_homogeneous (fun k => b k i)).totalDegree_le) low test htest
344
+ refine ⟨test', ht, ?_⟩
345
+ intro b
346
+ simpa only [rowPolynomial_integer_site] using he b
347
+
348
+ end Erdos3.VectorPolynomial
349
+
350
+ end
351
+
352
+ section
353
+
354
+ namespace Erdos3.BooleanCubeKernel
355
+
356
+ open MvPolynomial
357
+ open scoped BigOperators TensorProduct Classical
358
+
359
+ def cubeModePolynomialBudget (q : ℕ) (L : ℝ) : ℝ :=
360
+ (q.factorial : ℝ) * (2 + (q : ℝ) * (q + 1)) * (1 + 3 * L) ^ (q + 2)
361
+
362
+ theorem integerCubeWitnessBound_le_vertex_budget (q : ℕ) {L : ℝ} (hL : 0 ≤ L) :
363
+ integerCubeWitnessBound q L (2 * L) ≤ cubeModePolynomialBudget q L := by
364
+ have he : 1 + L + 2 * L = 1 + 3 * L := by ring
365
+ simpa only [cubeModePolynomialBudget, he] using
366
+ integerCubeWitnessBound_le_polynomial q hL (show 0 ≤ 2 * L by positivity)
367
+
368
+ theorem exists_vertex_bounded_integer_mode {K J : Type*} [Fintype K] [Fintype J] {q : ℕ}
369
+ (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
370
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
371
+ {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C)
372
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
373
+ (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ)
374
+ (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C)
375
+ (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ,
376
+ ∀ p, VectorPolynomial.Homogeneous h p →
377
+ VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ))
378
+ (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation
379
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) :
380
+ ∃ rows : Fin h → Option K → ℤ,
381
+ (∀ i k, |(rows i k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧
382
+ (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧
383
+ (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤
384
+ C * cubeModePolynomialBudget q L ^ h) ∧
385
+ ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency
386
+ (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by
387
+ obtain ⟨rows, hr, hz, hb, hw⟩ := exists_bounded_integer_mode_rows W root difference hlin
388
+ hL (show 0 ≤ 2 * L by positivity) hC
389
+ (integer_cube_root_bound root difference hsite)
390
+ (integer_cube_difference_bound root difference hsite) frequency h hbound hnonfactor
391
+ have hbudget := integerCubeWitnessBound_le_vertex_budget q hL
392
+ refine ⟨rows, (fun i k => (hr i k).trans hbudget), hz, ?_, hw⟩
393
+ intro j
394
+ exact (hb j).trans (mul_le_mul_of_nonneg_left
395
+ (pow_le_pow_left₀ (integerCubeWitnessBound_nonneg q hL (by positivity)) hbudget h) hC)
396
+
397
+ end Erdos3.BooleanCubeKernel
398
+
399
+ end
400
+
401
+ section
402
+
403
+ namespace Erdos3.VectorPolynomial
404
+
405
+ theorem degreeLE_dehomogenize {K W : Type*} [AddCommGroup W] [Module ℝ W]
406
+ {h : ℕ} {p : VectorPolynomial (Option K) ℝ W}
407
+ (hp : DegreeLE (1 : Option K → ℕ) h p) :
408
+ DegreeLE (1 : K → ℕ) h (substitute dehomogenizingSubstitution p) := by
409
+ apply degreeLE_substitute_affine _ _ p hp
410
+ intro k
411
+ cases k <;> simp [dehomogenizingSubstitution]
412
+
413
+ theorem affineModeLift_factorization_iff {K S W : Type*} [AddCommGroup W] [Module ℝ W]
414
+ (h : ℕ) (site : S → K → ℝ) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ)
415
+ (M : (S → W) →ₗ[ℝ] ℝ) :
416
+ (∀ q, Homogeneous h q → affineModeLift L q =
417
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ↔
418
+ (∀ q, DegreeLE (1 : Option K → ℕ) h q → affineModeLift L q =
419
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) := by
420
+ constructor
421
+ · intro hf q hq
422
+ have ho := (homogeneous_site_factorization_iff h site L M).mp hf
423
+ change L (substitute dehomogenizingSubstitution q) = _
424
+ rw [← siteEvaluation_dehomogenize]
425
+ exact ho _ (degreeLE_dehomogenize hq)
426
+ · intro hf q hq
427
+ exact hf q (homogeneous_degreeLE hq)
428
+
429
+ theorem affineModeLift_exists_factorization_iff {K S W : Type*}
430
+ [AddCommGroup W] [Module ℝ W]
431
+ (h : ℕ) (site : S → K → ℝ) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) :
432
+ (∃ M : (S → W) →ₗ[ℝ] ℝ, ∀ q, Homogeneous h q → affineModeLift L q =
433
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ↔
434
+ (∃ M : (S → W) →ₗ[ℝ] ℝ, ∀ q, DegreeLE (1 : Option K → ℕ) h q → affineModeLift L q =
435
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) :=
436
+ exists_congr (fun M => affineModeLift_factorization_iff h site L M)
437
+
438
+ theorem exists_highest_affine_nonfactor {K S : Type*} {m : ℕ} {W : Fin m → Type*}
439
+ [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)]
440
+ (site : S → K → ℝ) (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ)
441
+ (hbad : ∃ i, ¬∃ M : (S → W i) →ₗ[ℝ] ℝ,
442
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q =
443
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) :
444
+ ∃ i, (¬∃ M : (S → W i) →ₗ[ℝ] ℝ,
445
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q =
446
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ∧
447
+ ∀ j, i < j → ∃ M : (S → W j) →ₗ[ℝ] ℝ,
448
+ ∀ q, DegreeLE (1 : Option K → ℕ) (j.val + 1) q → affineModeLift (L j) q =
449
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q) := by
450
+ obtain ⟨i, hi, hh⟩ := exists_highest_exceptional_layer _ hbad
451
+ refine ⟨i, hi, ?_⟩
452
+ intro j hj
453
+ exact (affineModeLift_exists_factorization_iff (j.val + 1) site (L j)).mp (hh j hj)
454
+
455
+ end Erdos3.VectorPolynomial
456
+
457
+ end
458
+
459
+ section
460
+
461
+ namespace Erdos3.VectorPolynomial
462
+
463
+ open CircleFourier
464
+ open scoped BigOperators
465
+
466
+ theorem exists_absorbed_affine_site_tests {A I K S : Type*} {W : A → Type*}
467
+ [Fintype A] [Fintype K] [Fintype S] [DecidableEq S]
468
+ [∀ a, AddCommGroup (W a)] [∀ a, Module ℝ (W a)]
469
+ (h : A → ℕ) (site : S → K → ℝ)
470
+ (Λ : ∀ a, VectorPolynomial K ℝ (W a) →ₗ[ℝ] ℝ)
471
+ (hfactor : ∀ a, ∃ M : (S → W a) →ₗ[ℝ] ℝ,
472
+ ∀ q, Homogeneous (h a) q → affineModeLift (Λ a) q =
473
+ M (siteEvaluation (fun s (i : Option K) => i.elim 1 (site s)) q))
474
+ (p : ∀ a, VectorPolynomial I ℝ (W a)) (hp : ∀ a, DegreeLE (1 : I → ℕ) (h a) (p a))
475
+ (low : (Option K → I → ℝ) → ℝ)
476
+ (test : S → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) :
477
+ ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b,
478
+ character ((low b + ∑ a, MvPolynomial.eval (fun z => b z.1 z.2)
479
+ (coefficientModePolynomial (affineModeLift (Λ a)) (p a)) : ℝ) : CircleFourier.Circle) *
480
+ (∏ s, test s (fun i => b none i + ∑ k, b (some k) i * site s k)) =
481
+ character (low b : CircleFourier.Circle) *
482
+ (∏ s, test' s (fun i => b none i + ∑ k, b (some k) i * site s k)) := by
483
+ obtain ⟨test', htest', he⟩ := exists_absorbed_polynomial_site_tests h site Λ hfactor p hp
484
+ affineParameterSubstitution affineParameterSubstitution_degree low test htest
485
+ refine ⟨test', htest', ?_⟩
486
+ intro b
487
+ simpa only [coefficientModePolynomial_affine_eval, affineParameterSubstitution_eval] using he b
488
+
489
+ end Erdos3.VectorPolynomial
490
+
491
+ end
492
+
493
+ section
494
+
495
+ namespace Erdos3
496
+
497
+ open CircleFourier MvPolynomial
498
+ open scoped BigOperators Classical
499
+
500
+ def FiniteSitePhaseRemoval {h : ℕ} {S K X V : Type*}
501
+ [Fintype S] [Fintype K] [Fintype X] [AddCommGroup V]
502
+ (site : S → K → ℤ) (rows : Fin h → K → ℤ) : Prop :=
503
+ ∀ (base : K → V) (shift : X → V) (phase : (K → V) → ℝ) (test : S → V → ℂ),
504
+ (∀ s v, ‖test s v‖ ≤ 1) →
505
+ ‖𝔼 x, character (phase (rowShiftedTuple base rows shift x) : CircleFourier.Circle) *
506
+ ∏ s, test s (integerSiteValue (site s) (rowShiftedTuple base rows shift x))‖ ^ (2 ^ h) ≤
507
+ ‖𝔼 u, 𝔼 v, character ((additiveBoxDifference h
508
+ (fun x (_ : Unit) => phase (rowShiftedTuple base rows shift x)) u v () : ℝ) : CircleFourier.Circle)‖
509
+
510
+ theorem finiteSitePhaseRemoval_of_annihilates {h : ℕ} {S K X V : Type*}
511
+ [Fintype S] [Fintype K] [Fintype X] [Nonempty X] [AddCommGroup V]
512
+ (hh : 0 < h) (site : S → K → ℤ) (rows : Fin h → K → ℤ)
513
+ (hzero : ∀ s, ∃ i, (∑ k, rows i k * site s k) = 0) :
514
+ FiniteSitePhaseRemoval (X := X) (V := V) site rows := by
515
+ intro base shift phase test htest
516
+ exact row_shifted_site_phase_cauchySchwarz hh site base rows shift hzero phase test htest
517
+
518
+ namespace BooleanCubeKernel
519
+
520
+ theorem exists_vertex_mode_with_phase_removal {K J X V : Type*}
521
+ [Fintype K] [Fintype J] [Fintype X] [Nonempty X] [AddCommGroup V] {q h : ℕ}
522
+ (hh : 0 < h) (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
523
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
524
+ {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C)
525
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
526
+ (frequency : ((Option K) →₀ ℕ) → J → ℤ)
527
+ (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C)
528
+ (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ,
529
+ ∀ p, VectorPolynomial.Homogeneous h p →
530
+ VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ))
531
+ (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation
532
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) :
533
+ ∃ rows : Fin h → Option K → ℤ,
534
+ (∀ i k, |(rows i k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧
535
+ (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧
536
+ (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤
537
+ C * cubeModePolynomialBudget q L ^ h) ∧
538
+ (∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency
539
+ (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0) ∧
540
+ FiniteSitePhaseRemoval (X := X) (V := V) (fun s => affineSite root difference s) rows := by
541
+ obtain ⟨rows, hr, hz, hb, hw⟩ := exists_vertex_bounded_integer_mode W root difference hlin
542
+ hL hC hsite frequency h hbound hnonfactor
543
+ exact ⟨rows, hr, hz, hb, hw, finiteSitePhaseRemoval_of_annihilates hh _ rows hz⟩
544
+
545
+ end BooleanCubeKernel
546
+ end Erdos3
547
+
548
+ end
549
+
550
+ section
551
+
552
+ namespace Erdos3.VectorPolynomial
553
+
554
+ theorem affineModeLift_comp_map {K V W : Type*}
555
+ [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W]
556
+ (f : V →ₗ[ℝ] W) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) :
557
+ affineModeLift (L.comp (map f)) = (affineModeLift L).comp (map f) := by
558
+ apply LinearMap.ext
559
+ intro q
560
+ simp only [affineModeLift, LinearMap.comp_apply, map_substitute]
561
+
562
+ theorem exists_highest_affine_subspace_nonfactor {K S : Type*} {m : ℕ}
563
+ {V : Fin m → Type*} [∀ j, AddCommGroup (V j)] [∀ j, Module ℝ (V j)]
564
+ (U : ∀ j, Submodule ℝ (V j)) (site : S → K → ℝ)
565
+ (L : ∀ j, VectorPolynomial K ℝ (V j) →ₗ[ℝ] ℝ)
566
+ (hbad : ∃ i, ¬∃ M : (S → U i) →ₗ[ℝ] ℝ,
567
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) (map (U i).subtype q) =
568
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) :
569
+ ∃ i, (¬∃ M : (S → U i) →ₗ[ℝ] ℝ,
570
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) (map (U i).subtype q) =
571
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ∧
572
+ ∀ j, i < j → ∃ M : (S → U j) →ₗ[ℝ] ℝ,
573
+ ∀ q, DegreeLE (1 : Option K → ℕ) (j.val + 1) q →
574
+ affineModeLift (L j) (map (U j).subtype q) =
575
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q) := by
576
+ have hh := exists_highest_affine_nonfactor site (fun j => (L j).comp (map (U j).subtype))
577
+ (by simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hbad)
578
+ simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hh
579
+
580
+ end Erdos3.VectorPolynomial
581
+
582
+ end
583
+
584
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCommonReferenceBudget.lean ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.AffineSidePolynomialBudget
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem affineAdaptiveDegreeBudget_le_power {P : ℝ} (hP : 0 ≤ P) :
10
+ affineAdaptiveDegreeBudget P ≤ 1024 * (P + 3) ^ 3 := by
11
+ apply le_of_sub_nonneg
12
+ simp only [affineAdaptiveDegreeBudget, affineLocalDegreeBudget, affineOuterDegreeInputBudget,
13
+ affineLocalDegreeInputBudget, affineShellLogBudget, affineCountLogBudget, affinePrimitiveLogBudget]
14
+ ring_nf
15
+ positivity
16
+
17
+ theorem affineSidePolynomialBudget_le_power {P : ℝ} (hP : 0 ≤ P) :
18
+ affineSidePolynomialBudget P ≤ 65536 * (P + 3) ^ 4 := by
19
+ apply le_of_sub_nonneg
20
+ simp only [affineSidePolynomialBudget, affineOrderPolynomialBudget, affineAccuracyPolynomialBudget,
21
+ affineAdaptiveDegreeBudget, affineLocalDegreeBudget, affineOuterDegreeInputBudget,
22
+ affineLocalDegreeInputBudget, affineShellLogBudget, affineCountLogBudget, affinePrimitiveLogBudget]
23
+ ring_nf
24
+ positivity
25
+
26
+ theorem adaptiveAffineCutoff_le_power (A sourceDim siteDim : ℕ)
27
+ {epsilon L T C totalShell modLog P : ℝ}
28
+ (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P)
29
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog)
30
+ (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P) (hmod : modLog ≤ P)
31
+ (hA : (A : ℝ) ≤ P) (hsource : (sourceDim : ℝ) ≤ P) (hsite : (siteDim : ℝ) ≤ P)
32
+ (hinverse : epsilon⁻¹ ≤ Real.exp P) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp P) :
33
+ (adaptiveAffineCutoff A sourceDim siteDim epsilon L T C totalShell modLog : ℝ) ≤
34
+ 1024 * (P + 3) ^ 3 :=
35
+ (adaptiveAffineCutoff_le_polynomialBudget A sourceDim siteDim hepsilon hepsilon1 hP hL hT hC hmod0
36
+ hLP hTP hCP hmod hA hsource hsite hinverse htotal htotalInv).trans (affineAdaptiveDegreeBudget_le_power hP)
37
+
38
+ theorem adaptiveAffineSideLog_le_power (A sourceDim siteDim : ℕ)
39
+ {epsilon L T C totalShell modLog dimLog P : ℝ}
40
+ (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P)
41
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog)
42
+ (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P) (hmod : modLog ≤ P) (hdim : dimLog ≤ P)
43
+ (hA : (A : ℝ) ≤ P) (hsource : (sourceDim : ℝ) ≤ P) (hsite : (siteDim : ℝ) ≤ P)
44
+ (hinverse : epsilon⁻¹ ≤ Real.exp P) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp P) :
45
+ adaptiveAffineSideLog A sourceDim siteDim epsilon L T C totalShell modLog dimLog ≤
46
+ 65536 * (P + 3) ^ 4 :=
47
+ (adaptiveAffineSideLog_le_polynomialBudget A sourceDim siteDim hepsilon hepsilon1 hP hL hT hC hmod0
48
+ hLP hTP hCP hmod hdim hA hsource hsite hinverse htotal htotalInv).trans (affineSidePolynomialBudget_le_power hP)
49
+
50
+ end Erdos3
51
+
52
+ end
53
+
54
+ section
55
+
56
+ namespace Erdos3
57
+
58
+ noncomputable def affineCommonReferenceBudget (E : ℕ) (epsilon U : ℝ) : ℝ :=
59
+ 2 * (affineReferenceInput epsilon U + 2) ^ E
60
+
61
+ theorem affineCommonReferenceBudget_bounds {E : ℕ} (hE : 2 ≤ E) (epsilon : ℝ) {U : ℝ} (hU : 0 ≤ U) :
62
+ 0 ≤ affineCommonReferenceBudget E epsilon U ∧
63
+ U ≤ affineCommonReferenceBudget E epsilon U ∧
64
+ (⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊ : ℝ) ≤ affineCommonReferenceBudget E epsilon U := by
65
+ have hb := affineReferenceInput_bounds epsilon hU
66
+ have hbase : 0 ≤ affineReferenceInput epsilon U + 2 := by linarith [hb.1]
67
+ have hpow : affineReferenceInput epsilon U + 2 ≤ (affineReferenceInput epsilon U + 2) ^ E := by
68
+ simpa only [pow_one] using pow_le_pow_right₀ (by linarith : 1 ≤ affineReferenceInput epsilon U + 2)
69
+ (show 1 ≤ E by omega)
70
+ have hc := Nat.ceil_lt_add_one (by positivity : 0 ≤ (affineReferenceInput epsilon U + 2) ^ E)
71
+ unfold affineCommonReferenceBudget
72
+ exact ⟨by positivity, by linarith [hb.2.1], by linarith [hb.1]⟩
73
+
74
+ theorem adaptiveAffineCutoff_reference_bounds {E sourceDim siteDim : ℕ}
75
+ {epsilon L T C totalShell modLog U : ℝ}
76
+ (hE : 2 ≤ E) (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hU : 0 ≤ U)
77
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog)
78
+ (hLU : L ≤ U) (hTU : T ≤ U) (hCU : C ≤ U) (hmod : modLog ≤ U)
79
+ (hsource : (sourceDim : ℝ) ≤ U) (hsite : (siteDim : ℝ) ≤ U)
80
+ (hinverse : epsilon⁻¹ ≤ Real.exp U) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp U) :
81
+ let A := ⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊
82
+ let b := adaptiveAffineCutoff A sourceDim siteDim epsilon L T C totalShell modLog
83
+ 2 * U ≤ (b : ℝ) ∧ (b : ℝ) ≤ 1024 * (affineCommonReferenceBudget E epsilon U + 3) ^ 3 := by
84
+ intro A b
85
+ have hp := affineReferenceInput_bounds epsilon hU
86
+ have hc := affineCommonReferenceBudget_bounds hE epsilon hU
87
+ have he : Real.exp U ≤ Real.exp (affineCommonReferenceBudget E epsilon U) := Real.exp_le_exp.mpr hc.2.1
88
+ constructor
89
+ · have hA : A ≤ b := by
90
+ have h := (adaptiveAffineCutoff_bounds A sourceDim siteDim epsilon L T C totalShell modLog).1
91
+ dsimp only [b]
92
+ omega
93
+ have hAr : (A : ℝ) ≤ b := by exact_mod_cast hA
94
+ have hbase := ceil_power_dominates_twice hp.1 hE
95
+ change 2 * affineReferenceInput epsilon U ≤ (A : ℝ) at hbase
96
+ linarith [hp.2.1]
97
+ · exact adaptiveAffineCutoff_le_power A sourceDim siteDim hepsilon hepsilon1 hc.1 hL hT hC hmod0
98
+ (hLU.trans hc.2.1) (hTU.trans hc.2.1) (hCU.trans hc.2.1) (hmod.trans hc.2.1)
99
+ hc.2.2 (hsource.trans hc.2.1) (hsite.trans hc.2.1) (hinverse.trans he) htotal (htotalInv.trans he)
100
+
101
+ theorem adaptiveAffineSideLog_reference_bound {E sourceDim siteDim : ℕ}
102
+ {epsilon L T C totalShell modLog dimLog U : ℝ}
103
+ (hE : 2 ≤ E) (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hU : 0 ≤ U)
104
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog)
105
+ (hLU : L ≤ U) (hTU : T ≤ U) (hCU : C ≤ U) (hmod : modLog ≤ U) (hdim : dimLog ≤ U)
106
+ (hsource : (sourceDim : ℝ) ≤ U) (hsite : (siteDim : ℝ) ≤ U)
107
+ (hinverse : epsilon⁻¹ ≤ Real.exp U) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp U) :
108
+ adaptiveAffineSideLog ⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊ sourceDim siteDim
109
+ epsilon L T C totalShell modLog dimLog ≤ 65536 * (affineCommonReferenceBudget E epsilon U + 3) ^ 4 := by
110
+ have hc := affineCommonReferenceBudget_bounds hE epsilon hU
111
+ have he : Real.exp U ≤ Real.exp (affineCommonReferenceBudget E epsilon U) := Real.exp_le_exp.mpr hc.2.1
112
+ exact adaptiveAffineSideLog_le_power _ sourceDim siteDim hepsilon hepsilon1 hc.1 hL hT hC hmod0
113
+ (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)
114
+ hc.2.2 (hsource.trans hc.2.1) (hsite.trans hc.2.1) (hinverse.trans he) htotal (htotalInv.trans he)
115
+
116
+ end Erdos3
117
+
118
+ end
119
+
120
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredJetDensity.lean ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Probability.CanonicalCoverLaw
2
+ import OAI.Combinatorics.Progressions.Probability.EuclideanJetDensity
3
+ import OAI.Combinatorics.Progressions.Probability.LowJetDensity
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3.BooleanCubeKernel
10
+
11
+ open MeasureTheory VectorPolynomial
12
+ open scoped BigOperators Classical
13
+
14
+ theorem exists_affine_covered_density (m q : ℕ) :
15
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K]
16
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P →
17
+ (Fintype.card K : ℝ) ≤ P →
18
+ (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) →
19
+ ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧
20
+ ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
21
+ [CompactSpace (CoefficientTorus (K := K) U)]
22
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
23
+ [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)]
24
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
25
+ (D : CoefficientTorus (K := K) U → ℝ), Continuous D →
26
+ ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 →
27
+ let E := coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k))
28
+ let π := Set.rangeFactorization E
29
+ let C := quotientIntegerCover (coefficientIntegerLattice U) d
30
+ ∃ g : Set.range E → ℝ, Continuous g ∧ (∀ y, g y ∈ Set.Icc (0 : ℝ) B) ∧
31
+ Integrable g (μ.map π) ∧ (∫ y, g y ∂μ.map π) = 1 ∧
32
+ (realDensityMeasure μ (fun x => D (C x))).map π = realDensityMeasure (μ.map π) g ∧
33
+ ∀ {I F : Type*} [Fintype F]
34
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) {η : ℝ},
35
+ (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) →
36
+ ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)),
37
+ (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) →
38
+ ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ),
39
+ ‖affineCubeFourierProjection U root difference frequency p c b -
40
+ (g (π (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by
41
+ obtain ⟨A, hA, hbudget⟩ := exists_geometric_positive_cover_budget m q
42
+ refine ⟨A, hA, ?_⟩
43
+ intro K _ root difference P hP hK hsite
44
+ let site := fun s k => affineSite root difference s (some k)
45
+ obtain ⟨d, T, hd, hT, hbound⟩ := exists_common_integer_site_residual
46
+ (fun j : Fin m => boundedSiteMatrix (j.val + 1) site) (fun _ => exponentialSiteHeight m P)
47
+ (fun _ => exponentialSiteHeight_pos m P)
48
+ (fun j => boundedSiteMatrix_height_of_exp m (Nat.succ_le_of_lt j.isLt) site hsite)
49
+ have hperiod := hbound (geometricSiteBudget_nonneg m q hP)
50
+ (fun j => boundedCoefficientExponent_card_le_geometricSiteBudget m q
51
+ (Nat.succ_le_of_lt j.isLt) hP hK)
52
+ (cubeSites_card_le_geometricSiteBudget m q hP)
53
+ (fun _ => (exponentialSiteHeight_le m hP).trans
54
+ (Real.exp_le_exp.mpr (degree_mul_le_geometricSiteBudget m q hP)))
55
+ refine ⟨d, hd, ?_, ?_⟩
56
+ · exact hperiod.trans (Real.exp_le_exp.mpr (by simpa only [Fintype.card_fin] using hbudget P hP))
57
+ intro J _ U _ _ _ _ _ μ _ _ D hD B hcap hmass E π C
58
+ let R := coefficientSiteResidual U site (fun _ => d) T
59
+ let hR := coefficientSiteResidual_preserves_lattice U site (fun _ => d) T
60
+ obtain ⟨g, hgc, hgb, hgi, hgmass, hg, hlaw⟩ :=
61
+ exists_covered_coefficient_density U site d hd T (fun j x => hT j x) μ D hD hcap hmass
62
+ refine ⟨g, hgc, hgb, hgi, hgmass, hlaw, ?_⟩
63
+ intro I F _ frequency c η happrox p hp hm b
64
+ have hfactor (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) :
65
+ (coefficientArrayFunctional U frequency).comp R = 0 ↔
66
+ affineCubeModeFactors U root difference frequency := by
67
+ change (coefficientArrayFunctional U frequency).comp
68
+ (coefficientSiteResidual U site (fun _ => d) T) = 0 ↔ _
69
+ rw [coefficientSiteResidual_zero_iff U site (fun _ => d) T (fun _ => hd) (fun j x => hT j x),
70
+ affineCubeModeFactors_iff_bounded]
71
+ have hb (x) : ‖D x‖ ≤ B := by rw [Real.norm_of_nonneg (hcap x).1]; exact (hcap x).2
72
+ have he := coefficientTorusFourierProjection_approx_residualAverage U R hR root difference hfactor
73
+ frequency c μ D happrox (affineSampleCoefficientTorus U p hm b)
74
+ (coefficientResidual_section_integrable U R hR μ D hD hb _)
75
+ have hvalue := hg (affineCoefficientCoverSample U p hm d b)
76
+ rw [affineCoefficientCoverSample_projection U p hm d hd b] at hvalue
77
+ rw [hvalue]
78
+ simpa only [coefficientTorusCharacter_sample U _ p hp hm b, affineCubeFourierProjection] using he
79
+
80
+ end Erdos3.BooleanCubeKernel
81
+
82
+ end
83
+
84
+ section
85
+
86
+ namespace Erdos3.BooleanCubeKernel
87
+
88
+ open MeasureTheory VectorPolynomial
89
+ open scoped Classical
90
+
91
+ theorem exists_affine_covered_euclidean_density (m q : ℕ) :
92
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K]
93
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P →
94
+ (Fintype.card K : ℝ) ≤ P →
95
+ (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) →
96
+ ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧
97
+ ∀ (a : ℤ), a ≠ 0 →
98
+ integerScalarLattice (Fin q) a ≤ (Matrix.of difference).mulVecLin.range →
99
+ ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
100
+ [CompactSpace (CoefficientTorus (K := K) U)]
101
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
102
+ [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)]
103
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
104
+ (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸
105
+ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup))
106
+ [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)]
107
+ (D : CoefficientTorus (K := K) U → ℝ), Continuous D →
108
+ ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 →
109
+ let F := euclideanCoefficientJetMap U root (Matrix.of difference)
110
+ (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q)))
111
+ let C := quotientIntegerCover (coefficientIntegerLattice U) d
112
+ let ξ := Measure.pi (fun j => Measure.pi (fun _ : BoundedBooleanJet (Fin q) (j.val + 1) => ν j))
113
+ ∃ f : EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ,
114
+ Continuous f ∧ (∀ z, f z ∈ Set.Icc (0 : ℝ) B) ∧ Integrable f ξ ∧
115
+ (∫ z, f z ∂ξ) = 1 ∧
116
+ (realDensityMeasure μ (fun x => D (C x))).map F = realDensityMeasure ξ f ∧
117
+ ∀ {I G : Type*} [Fintype G]
118
+ (frequency : G → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : G → ℂ) {η : ℝ},
119
+ (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) →
120
+ ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)),
121
+ (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) →
122
+ ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ),
123
+ ‖affineCubeFourierProjection U root difference frequency p c b -
124
+ (f (F (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by
125
+ obtain ⟨A, hA, hcover⟩ := exists_affine_covered_density m q
126
+ refine ⟨A, hA, ?_⟩
127
+ intro K _ root difference P hP hK hsite
128
+ obtain ⟨d, hd, hdb, hcover⟩ := hcover root difference hP hK hsite
129
+ refine ⟨d, hd, hdb, ?_⟩
130
+ intro a ha hperiod J _ U _ _ _ _ _ μ _ _ ν _ _ D hD B hcap hmass F C ξ
131
+ obtain ⟨g, hgc, hgb, _, hgmass, hglaw, hgapprox⟩ := hcover U μ D hD hcap hmass
132
+ obtain ⟨hfc, hfb, hfi, hfmass, hvalue, hflaw⟩ := siteImage_density_euclideanJet U root
133
+ (Matrix.of difference) a ha hperiod μ ν (realDensityMeasure μ (fun x => D (C x)))
134
+ g hgc hgb hgmass hglaw
135
+ refine ⟨_, hfc, hfb, hfi, hfmass, hflaw, ?_⟩
136
+ intro I G _ frequency c η happrox p hp hm b
137
+ have he := hvalue (Set.rangeFactorization
138
+ (coefficientSiteTorusMap U (integerAffineCube root (Matrix.of difference)))
139
+ (affineCoefficientCoverSample U p hm d b))
140
+ change (g ((euclideanSiteImageHomeomorph U root (Matrix.of difference) a ha hperiod).symm
141
+ (F (affineCoefficientCoverSample U p hm d b)))) = _ at he
142
+ rw [he]
143
+ exact hgapprox frequency c happrox p hp hm b
144
+
145
+ end Erdos3.BooleanCubeKernel
146
+
147
+ end
148
+
149
+ section
150
+
151
+ namespace Erdos3.BooleanCubeKernel
152
+
153
+ open MeasureTheory VectorPolynomial
154
+ open scoped Classical
155
+
156
+ theorem exists_affine_covered_jet_density (m q : ℕ) :
157
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K]
158
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P →
159
+ (Fintype.card K : ℝ) ≤ P →
160
+ (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) →
161
+ ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧
162
+ ∀ (a : ℤ), a ≠ 0 →
163
+ integerScalarLattice (Fin q) a ≤ (Matrix.of difference).mulVecLin.range →
164
+ ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
165
+ [CompactSpace (CoefficientTorus (K := K) U)]
166
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
167
+ [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)]
168
+ [∀ j, MeasurableSpace (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j))]
169
+ [∀ j, BorelSpace (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j))]
170
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
171
+ (ν : ∀ j, Measure (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j)))
172
+ [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)]
173
+ (D : CoefficientTorus (K := K) U → ℝ), Continuous D →
174
+ ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 →
175
+ let F := coefficientBooleanJetTorusMap U root (Matrix.of difference)
176
+ (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q)))
177
+ let C := quotientIntegerCover (coefficientIntegerLattice U) d
178
+ ∃ f : LowBooleanJetTorus (Fin q) U → ℝ, Continuous f ∧
179
+ (∀ z, f z ∈ Set.Icc (0 : ℝ) B) ∧ Integrable f (Measure.pi ν) ∧
180
+ (∫ z, f z ∂Measure.pi ν) = 1 ∧
181
+ (realDensityMeasure μ (fun x => D (C x))).map F = realDensityMeasure (Measure.pi ν) f ∧
182
+ ∀ {I G : Type*} [Fintype G]
183
+ (frequency : G → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : G → ℂ) {η : ℝ},
184
+ (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) →
185
+ ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)),
186
+ (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) →
187
+ ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ),
188
+ ‖affineCubeFourierProjection U root difference frequency p c b -
189
+ (f (F (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by
190
+ obtain ⟨A, hA, hcover⟩ := exists_affine_covered_density m q
191
+ refine ⟨A, hA, ?_⟩
192
+ intro K _ root difference P hP hK hsite
193
+ obtain ⟨d, hd, hdb, hcover⟩ := hcover root difference hP hK hsite
194
+ refine ⟨d, hd, hdb, ?_⟩
195
+ intro a ha hperiod J _ U _ _ _ _ _ _ _ μ _ _ ν _ _ D hD B hcap hmass F C
196
+ obtain ⟨g, hgc, hgb, _, hgmass, hglaw, hgapprox⟩ := hcover U μ D hD hcap hmass
197
+ obtain ⟨f, hfc, hfb, hfi, hfmass, hvalue, hflaw⟩ := siteImage_density_lowJet U root
198
+ (Matrix.of difference) a ha hperiod μ ν (realDensityMeasure μ (fun x => D (C x)))
199
+ g hgc hgb hgmass hglaw
200
+ refine ⟨f, hfc, hfb, hfi, hfmass, hflaw, ?_⟩
201
+ intro I G _ frequency c η happrox p hp hm b
202
+ have he := hvalue (Set.rangeFactorization
203
+ (coefficientSiteTorusMap U (integerAffineCube root (Matrix.of difference)))
204
+ (affineCoefficientCoverSample U p hm d b))
205
+ change f (F (affineCoefficientCoverSample U p hm d b)) = _ at he
206
+ rw [he]
207
+ exact hgapprox frequency c happrox p hp hm b
208
+
209
+ end Erdos3.BooleanCubeKernel
210
+
211
+ end
212
+
213
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredSiteValues.lean ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.GeometricRetainedCommonCover
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.BooleanCubeKernel
8
+
9
+ open VectorPolynomial
10
+ open scoped BigOperators
11
+
12
+ noncomputable def affineCoveredSiteSample {I K : Type*} [Fintype K] {m q : ℕ}
13
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
14
+ (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ)
15
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
16
+ (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) :
17
+ ∀ j, SubspaceArrayTorus (Finset (Fin q)) (U j) := fun j =>
18
+ QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j))
19
+ ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation
20
+ (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ))
21
+ (substitute (affineParameterSubstitution x) (restrictCoefficients (U j) (p j) (hm j))))
22
+
23
+ theorem layeredCoefficientCharacter_of_site_factorization
24
+ {I K : Type*} [Fintype K] {m q : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)]
25
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
26
+ (D : ℕ) (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
27
+ (b : ∀ j, Matrix (Finset (Fin q)) (J j) ℤ)
28
+ (hchar : ∀ (j : Fin m) (v : VectorPolynomial K ℝ (U j)),
29
+ DegreeLE (1 : K → ℕ) (j.val + 1) v →
30
+ CircleFourier.character
31
+ (coefficientFunctional (fun d a => (frequency j d a : ℝ))
32
+ (map (U j).subtype v) : CircleFourier.Circle) =
33
+ subspaceArrayCharacter (U j) (b j)
34
+ (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j))
35
+ ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation
36
+ (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) v)))
37
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
38
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
39
+ (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) :
40
+ layeredCoefficientCharacter
41
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) p x =
42
+ ∏ j, subspaceArrayCharacter (U j) (b j)
43
+ (affineCoveredSiteSample U root difference D p hm x j) := by
44
+ unfold layeredCoefficientCharacter
45
+ rw [character_real_sum]
46
+ apply Finset.prod_congr rfl
47
+ intro j _
48
+ rw [affineModeLift_substitute]
49
+ have he := hchar j
50
+ (substitute (affineParameterSubstitution x) (restrictCoefficients (U j) (p j) (hm j)))
51
+ (degreeLE_substitute_affine _ (affineParameterSubstitution_degree x) _
52
+ (degreeLE_restrictCoefficients (U j) (p j) (hm j) (hp j)))
53
+ simpa only [map_substitute, map_restrictCoefficients, affineCoveredSiteSample] using he
54
+
55
+ end Erdos3.BooleanCubeKernel
56
+
57
+ end
58
+
59
+ section
60
+
61
+ namespace Erdos3.BooleanCubeKernel
62
+
63
+ open VectorPolynomial
64
+ open scoped BigOperators
65
+
66
+ theorem affine_site_substitution_eval {I K W : Type*} [Fintype K]
67
+ [AddCommGroup W] [Module ℝ W] {q : ℕ}
68
+ (root : K → ℤ) (difference : Fin q → K → ℤ)
69
+ (p : VectorPolynomial I ℝ W) (x : Option K → I → ℝ) :
70
+ VectorPolynomial.siteEvaluation
71
+ (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ))
72
+ (substitute (affineParameterSubstitution x) p) =
73
+ fun s => eval (integerSiteValue (affineSite root difference s) x) p := by
74
+ funext s
75
+ change eval _ (substitute _ p) = _
76
+ rw [eval_substitute]
77
+ apply congrArg (fun t : I → ℝ => eval t p)
78
+ funext i
79
+ rw [affineParameterSubstitution_eval]
80
+ simp [integerSiteValue, Fintype.sum_option, affineSite, Finset.sum_apply,
81
+ zsmul_eq_mul, mul_comm]
82
+
83
+ theorem affineCoveredSiteSample_eq_values {I K : Type*} [Fintype K] {m q : ℕ}
84
+ {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ))
85
+ (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ)
86
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
87
+ (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) (j : Fin m) :
88
+ affineCoveredSiteSample U root difference D p hm x j =
89
+ QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j))
90
+ ((D : ℝ)⁻¹ • fun s => eval (integerSiteValue (affineSite root difference s) x)
91
+ (restrictCoefficients (U j) (p j) (hm j))) := by
92
+ unfold affineCoveredSiteSample
93
+ rw [affine_site_substitution_eval]
94
+
95
+ end Erdos3.BooleanCubeKernel
96
+
97
+ end
98
+
99
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoordinates.lean ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.CoefficientSliceEmbedding
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ def affineCubeCoordinates {I : Type*} (u : Option I → ℝ) (v : Option I → ℕ)
10
+ (x : Option I → ℝ) : Option I → ℝ := fun i => u i + (v i : ℝ) * x i
11
+
12
+ def affineIntegerCubeCoordinates {I : Type*} (u : Option I → ℤ) (v : Option I → ℕ)
13
+ (x : Option I → ℤ) : Option I → ℤ := fun i => u i + (v i : ℤ) * x i
14
+
15
+ theorem affineIntegerCubeCoordinates_cast {I : Type*} (u : Option I → ℤ) (v : Option I → ℕ)
16
+ (x : Option I → ℤ) :
17
+ (fun i => (affineIntegerCubeCoordinates u v x i : ℝ)) =
18
+ affineCubeCoordinates (fun i => (u i : ℝ)) v (fun i => (x i : ℝ)) := by
19
+ funext i
20
+ simp only [affineIntegerCubeCoordinates, affineCubeCoordinates, Int.cast_add, Int.cast_mul, Int.cast_natCast]
21
+
22
+ theorem ScalarCubeLocalizationData.affine_point_scale {I : Type*} [Fintype I] [DecidableEq I]
23
+ (d : ScalarCubeLocalizationData I) (u : Option I → ℝ) (v : Option I → ℕ)
24
+ (z : IntegerScalarCubeBox I d.length) :
25
+ affineCubeCoordinates u v (fun i => (d.length : ℝ) * d.point z i) =
26
+ affineCubeCoordinates u v (fun i => (z i : ℝ)) := by
27
+ congr 1
28
+ funext i
29
+ exact d.point_scale z i
30
+
31
+ theorem ScalarCubeLocalizationData.affine_cell_scale {I : Type*} [Fintype I] [DecidableEq I]
32
+ (d : ScalarCubeLocalizationData I) (u : Option I → ℝ) (v : Option I → ℕ)
33
+ (k : Option I → Fin d.cellCount) (t : Option I → Fin d.cellLength) :
34
+ affineCubeCoordinates u v (fun i => (d.length : ℝ) * d.cell k t i) =
35
+ fun i => (u i + (v i : ℝ) * d.integerOffset k i) +
36
+ ((v i * d.modulus i : ℕ) : ℝ) * (t i).val := by
37
+ rw [d.cell_scale]
38
+ funext i
39
+ simp only [affineCubeCoordinates, Nat.cast_mul]
40
+ ring
41
+
42
+ end Erdos3
43
+
44
+ end
45
+
46
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoveredProjection.lean ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.SectionRetainedFourier
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.BooleanCubeKernel
8
+
9
+ open VectorPolynomial Polynomial
10
+ open scoped BigOperators
11
+
12
+ theorem exists_affine_cube_covered_projection (m q : ℕ) :
13
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
14
+ [Fintype I] [DecidableEq I] [Fintype K]
15
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
16
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
17
+ (_hK : (Fintype.card K : ℝ) ≤ P) (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
18
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
19
+ (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
20
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
21
+ (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
22
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
23
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
24
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
25
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
26
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
27
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
28
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
29
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
30
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
31
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
32
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
33
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
34
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
35
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
36
+ (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0)
37
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1)
38
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
39
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z),
40
+ ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧
41
+ ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ,
42
+ (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧
43
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
44
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
45
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
46
+ affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ)))) -
47
+ (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
48
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
49
+ retainedSiteFourierSum U root difference frequency b c
50
+ (affineCoveredSiteSample U root difference D p hm (fun k j => (z (k, j) : ℝ)))))‖ ≤ ε := by
51
+ obtain ⟨A₀, _, hprojection⟩ := exists_affine_cube_fourier_projection m q
52
+ obtain ⟨A₁, _, hcover⟩ := exists_geometric_site_fourier_projection m q
53
+ obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget
54
+ ((X + Polynomial.C A₀) ^ A₀ + (X + Polynomial.C A₁) ^ A₁)
55
+ refine ⟨A, hA, ?_⟩
56
+ intro I K _ _ _ J _ F _ P hP hn hK hd U root difference hlin L C hL hC hLP hCP
57
+ hsite frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP
58
+ hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth
59
+ have hsum : (P + A₀) ^ A₀ + (P + A₁) ^ A₁ ≤ (P + A) ^ A := by
60
+ simpa [Polynomial.eval₂_pow] using hbudget P hP
61
+ have hb₀ : (P + A₀) ^ A₀ ≤ (P + A) ^ A := by
62
+ linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₁)) A₁]
63
+ have hb₁ : (P + A₁) ^ A₁ ≤ (P + A) ^ A := by
64
+ linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₀)) A₀]
65
+ obtain ⟨D, hD, hDP, hrows⟩ := hcover root difference hP hK (fun s k => (hsite s k).trans hLP)
66
+ obtain ⟨b, hb, heq⟩ := hrows U frequency (fun a j d hd t => (hbound a j d hd t).trans hCP)
67
+ obtain ⟨hZ, hproj⟩ := hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite
68
+ frequency hbound c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP
69
+ hstride H (fun k => (Real.exp_le_exp.mpr hb₀).trans (hsize k)) hrank
70
+ ((Real.exp_le_exp.mpr hb₀).trans hR) Q hQ test htest G hG V hV hwidth
71
+ refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hb₁), b,
72
+ fun a j s t => (hb a j s t).trans (Real.exp_le_exp.mpr hb₁), hZ, ?_⟩
73
+ have hfun : affineCubeFourierProjection U root difference frequency p c =
74
+ fun x => retainedSiteFourierSum U root difference frequency b c
75
+ (affineCoveredSiteSample U root difference D p hm x) :=
76
+ funext (fun x => heq p hp hm c x)
77
+ rw [hfun] at hproj
78
+ exact hproj
79
+
80
+ end Erdos3.BooleanCubeKernel
81
+
82
+ end
83
+
84
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeMinorGoodMass.lean ADDED
@@ -0,0 +1,622 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
2
+ import OAI.Combinatorics.Progressions.Estimates.CanonicalCubeMinorThreshold
3
+ import OAI.Combinatorics.Progressions.Probability.JointBooleanCutoffLaw
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open MeasureTheory
12
+
13
+ variable {I : Type*} [Fintype I]
14
+
15
+ theorem affine_preimage_volume_real (L : (I → ℝ) ≃L[ℝ] (I → ℝ))
16
+ (b : I → ℝ) (s : Set (I → ℝ)) :
17
+ volume.real ((fun x => b + L x) ⁻¹' s) = inverseJacobian L * volume.real s := by
18
+ change (volume (L ⁻¹' ((fun x => b + x) ⁻¹' s))).toReal = _
19
+ rw [Measure.addHaar_preimage_continuousLinearEquiv volume L, measure_preimage_add,
20
+ ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _)]
21
+ rfl
22
+
23
+ theorem affine_sublevel_volume_real (L : (I → ℝ) ≃L[ℝ] (I → ℝ))
24
+ (b : I → ℝ) (Ω : Set (I → ℝ)) (g : (I → ℝ) → ℝ) (u : ℝ) :
25
+ volume.real (Ω ∩ {x | |g (b + L x)| ≤ u}) = inverseJacobian L *
26
+ volume.real (((fun x => b + L x) '' Ω) ∩ {x | |g x| ≤ u}) := by
27
+ have he : Ω ∩ {x | |g (b + L x)| ≤ u} =
28
+ (fun x => b + L x) ⁻¹' (((fun x => b + L x) '' Ω) ∩ {x | |g x| ≤ u}) := by
29
+ ext x
30
+ constructor
31
+ · rintro ⟨hx, hg⟩
32
+ exact ⟨⟨x, hx, rfl⟩, hg⟩
33
+ · rintro ⟨⟨y, hy, he⟩, hg⟩
34
+ have hyx : y = x := L.injective (add_left_cancel he)
35
+ exact ⟨hyx ▸ hy, hg⟩
36
+ rw [he, affine_preimage_volume_real]
37
+
38
+ theorem exists_affine_boolean_minor_sublevel_bound {O α : Type*}
39
+ [Fintype O] [Fintype α] [DecidableEq O] [DecidableEq α]
40
+ (c : O → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets)
41
+ (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h)
42
+ {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N)
43
+ {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c o|) :
44
+ ∃ r : O → Option α, ∀ (d : ℕ), 0 < d → Fintype.card O * (h - 1) ≤ d →
45
+ ∀ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ)
46
+ (Ω : Set (Fin N → ℝ)) (R u : ℝ), 1 ≤ R →
47
+ (∀ x ∈ Ω, ∀ j, |(b + L x) j| ≤ R) → 0 < u →
48
+ volume.real (Ω ∩ {x | |((booleanSelectedMinor c sets id (⟨0, hh⟩ : Fin h) r).map
49
+ (MvPolynomial.eval ((b + L x) ∘ e))).det| ≤ u}) ≤
50
+ inverseJacobian L * (R ^ N * multivariateSublevelConstant N d *
51
+ (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by
52
+ obtain ⟨r, hr⟩ := exists_boolean_minor_sublevel_bound c sets hsets h hh hcard e hN hc₀ hc
53
+ refine ⟨r, ?_⟩
54
+ intro d hd hdeg L b Ω R u hR hΩ hu
55
+ rw [affine_sublevel_volume_real L b Ω
56
+ (fun x => ((booleanSelectedMinor c sets id (⟨0, hh⟩ : Fin h) r).map
57
+ (MvPolynomial.eval (x ∘ e))).det) u]
58
+ apply mul_le_mul_of_nonneg_left _ (inverseJacobian_pos L).le
59
+ apply hr d hd hdeg _ R u hR _ hu
60
+ rintro y ⟨x, hx, rfl⟩ j
61
+ exact hΩ x hx j
62
+
63
+ end Erdos3
64
+
65
+ end
66
+
67
+ section
68
+
69
+ namespace Erdos3
70
+
71
+ open MeasureTheory
72
+
73
+ noncomputable def reindexedAffineSource {I : Type*} {N : ℕ} (e : I ≃ Fin N)
74
+ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) (a : I → ℝ) : I → ℝ :=
75
+ (b + L (a ∘ e.symm)) ∘ e
76
+
77
+ theorem reindexedAffineSource_continuous {I : Type*} [Fintype I] {N : ℕ}
78
+ (e : I ≃ Fin N) (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) :
79
+ Continuous (reindexedAffineSource e L b) := by
80
+ unfold reindexedAffineSource
81
+ fun_prop
82
+
83
+ theorem reindexedAffineSource_apply {I : Type*} {N : ℕ} (e : I ≃ Fin N)
84
+ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b x : Fin N → ℝ) :
85
+ reindexedAffineSource e L b (x ∘ e) = (b + L x) ∘ e := by
86
+ have he : (x ∘ e) ∘ e.symm = x := by funext j; simp
87
+ simp only [reindexedAffineSource, he]
88
+
89
+ theorem exists_affine_cube_minor_probability_bound {O α : Type*}
90
+ [Fintype O] [Fintype α] [DecidableEq O] [DecidableEq α]
91
+ (c : O → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets)
92
+ (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h)
93
+ {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N)
94
+ {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c o|) :
95
+ ∃ r : O → Option α, ∀ d : ℕ, 0 < d → Fintype.card O * (h - 1) ≤ d →
96
+ ∀ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) (R u : ℝ),
97
+ 1 ≤ R → (∀ x ∈ reindexedBlockCubeDomain e, ∀ j, |(b + L x) j| ≤ R) → 0 < u →
98
+ (blockCubeMeasure O (Fin h) α).real
99
+ {a | |booleanMinorDeterminant c sets id (⟨0, hh⟩ : Fin h) r
100
+ (reindexedAffineSource e L b a)| ≤ u} ≤
101
+ scalarCubeDomainDensity α ^ Fintype.card (O × Fin h) * inverseJacobian L *
102
+ (R ^ N * multivariateSublevelConstant N d *
103
+ (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by
104
+ obtain ⟨r, hr⟩ := exists_affine_boolean_minor_sublevel_bound c sets hsets h hh hcard e hN hc₀ hc
105
+ refine ⟨r, ?_⟩
106
+ intro d hd hdeg L b R u hR hbox hu
107
+ have hsm : MeasurableSet {a | |booleanMinorDeterminant c sets id (⟨0, hh⟩ : Fin h) r
108
+ (reindexedAffineSource e L b a)| ≤ u} :=
109
+ measurableSet_le (((booleanMinorDeterminant_contDiff c sets id (⟨0, hh⟩ : Fin h) r).continuous.comp
110
+ (reindexedAffineSource_continuous e L b)).measurable.abs) measurable_const
111
+ rw [blockCubeMeasure_real_reindex e _ hsm]
112
+ simp only [Set.mem_ofPred_eq, reindexedAffineSource_apply]
113
+ have hvol := hr d hd hdeg L b (reindexedBlockCubeDomain e) R u hR hbox hu
114
+ exact (mul_le_mul_of_nonneg_left hvol
115
+ (pow_nonneg (scalarCubeDomainDensity_pos α).le (Fintype.card (O × Fin h)))).trans_eq
116
+ (mul_assoc _ _ _).symm
117
+
118
+ theorem booleanMinorDeterminant_affine_sublevel_marginal {B O F α : Type*}
119
+ [Fintype B] [Fintype O] [Fintype F] [Fintype α]
120
+ [DecidableEq B] [DecidableEq O] [DecidableEq F] [DecidableEq α]
121
+ (c : B → ℝ) (sets : O → Finset α) (block : O → B) (hblock : Function.Injective block)
122
+ (v : F) (r : O → Option α)
123
+ (T : (BlockParameter B F α → ℝ) → (BlockParameter B F α → ℝ))
124
+ (T₀ : (BlockParameter O F α → ℝ) → (BlockParameter O F α → ℝ))
125
+ (hT₀ : Measurable T₀)
126
+ (hrestrict : ∀ a, restrictBlockParameters block (T a) = T₀ (restrictBlockParameters block a)) (u : ℝ) :
127
+ (blockCubeMeasure B F α).real {a | |booleanMinorDeterminant c sets block v r (T a)| ≤ u} =
128
+ (blockCubeMeasure O F α).real {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} := by
129
+ have hs : MeasurableSet {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} :=
130
+ measurableSet_le (((booleanMinorDeterminant_contDiff (c ∘ block) sets id v r).continuous.measurable.comp
131
+ hT₀).abs) measurable_const
132
+ have hm := (restrictBlockParameters_cube_measurePreserving (F := F) (α := α) block hblock).measureReal_preimage
133
+ hs.nullMeasurableSet
134
+ have he : {a | |booleanMinorDeterminant c sets block v r (T a)| ≤ u} =
135
+ restrictBlockParameters block ⁻¹'
136
+ {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} := by
137
+ ext a
138
+ change |booleanMinorDeterminant c sets block v r (T a)| ≤ u ↔ _
139
+ rw [booleanMinorDeterminant_restrict c sets block v r (T a), hrestrict]
140
+ rfl
141
+ rw [he]
142
+ exact hm
143
+
144
+ end Erdos3
145
+
146
+ end
147
+
148
+ section
149
+
150
+ namespace Erdos3
151
+
152
+ open MeasureTheory
153
+ open scoped BigOperators
154
+
155
+ theorem inverseJacobian_coordinateScale_le {I : Type*} [Fintype I]
156
+ (a : I → ℝ) (ha : ∀ i, a i ≠ 0) {δ : ℝ} (hδ : 0 < δ)
157
+ (hwidth : ∀ i, δ ≤ |a i|) :
158
+ inverseJacobian (coordinateScaleEquiv a ha).toContinuousLinearEquiv ≤ δ⁻¹ ^ Fintype.card I := by
159
+ rw [inverseJacobian_eq]
160
+ change |LinearMap.det (coordinateScaleEquiv a ha).toLinearMap|⁻¹ ≤ _
161
+ rw [diagonalDensityTransport_det, Finset.abs_prod, ← Finset.prod_inv_distrib]
162
+ calc
163
+ _ ≤ ∏ _i : I, δ⁻¹ := by
164
+ apply Finset.prod_le_prod₀
165
+ · intro i _
166
+ exact inv_nonneg.mpr (abs_nonneg _)
167
+ · intro i _
168
+ simpa only [one_div] using one_div_le_one_div_of_le hδ (hwidth i)
169
+ _ = _ := by simp
170
+
171
+ theorem exists_allocated_affine_cube_minor_probability_bound {B O α : Type*}
172
+ [Fintype B] [Fintype O] [Fintype α]
173
+ [DecidableEq B] [DecidableEq O] [DecidableEq α]
174
+ (c : B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets)
175
+ (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h)
176
+ (block : O → B) (hblock : Function.Injective block)
177
+ {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N)
178
+ {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c (block o)|) :
179
+ ∃ r : O → Option α, ∀ d : ℕ, 0 < d → Fintype.card O * (h - 1) ≤ d →
180
+ ∀ (center width : BlockParameter B (Fin h) α → ℝ) (δ u : ℝ), 0 < δ →
181
+ (∀ z : BlockParameter O (Fin h) α, δ ≤ |restrictBlockParameters block width z|) →
182
+ (∀ z : BlockParameter O (Fin h) α,
183
+ |restrictBlockParameters block center z| + |restrictBlockParameters block width z| ≤ 1) →
184
+ 0 < u →
185
+ (blockCubeMeasure B (Fin h) α).real
186
+ {a | |booleanMinorDeterminant c sets block (⟨0, hh⟩ : Fin h) r
187
+ (fun z => center z + width z * a z)| ≤ u} ≤
188
+ scalarCubeDomainDensity α ^ Fintype.card (O × Fin h) * δ⁻¹ ^ N *
189
+ (multivariateSublevelConstant N d *
190
+ (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by
191
+ obtain ⟨r, hr⟩ := exists_affine_cube_minor_probability_bound
192
+ (c ∘ block) sets hsets h hh hcard e hN hc₀ hc
193
+ refine ⟨r, ?_⟩
194
+ intro d hd hdeg center width δ u hδ hwidth hbox hu
195
+ let w : Fin N → ℝ := restrictBlockParameters block width ∘ e.symm
196
+ let b : Fin N → ℝ := restrictBlockParameters block center ∘ e.symm
197
+ have hw (i) : δ ≤ |w i| := hwidth (e.symm i)
198
+ have hwne (i) : w i ≠ 0 := abs_pos.mp (hδ.trans_le (hw i))
199
+ let L := (coordinateScaleEquiv w hwne).toContinuousLinearEquiv
200
+ let T := fun a : BlockParameter B (Fin h) α → ℝ => fun z => center z + width z * a z
201
+ let T₀ := reindexedAffineSource e L b
202
+ have hrestrict (a) : restrictBlockParameters block (T a) = T₀ (restrictBlockParameters block a) := by
203
+ funext z
204
+ change center (block z.1, z.2) + width (block z.1, z.2) * a (block z.1, z.2) =
205
+ b (e z) + w (e z) * restrictBlockParameters block a (e.symm (e z))
206
+ simp only [w, b, Function.comp_apply, e.symm_apply_apply, restrictBlockParameters]
207
+ rw [booleanMinorDeterminant_affine_sublevel_marginal c sets block hblock (⟨0, hh⟩ : Fin h) r
208
+ T T₀ (reindexedAffineSource_continuous e L b).measurable hrestrict u]
209
+ have hbox' (x) (hx : x ∈ reindexedBlockCubeDomain e) (i) : |(b + L x) i| ≤ (1 : ℝ) := by
210
+ change |b i + w i * x i| ≤ 1
211
+ calc
212
+ _ ≤ |b i| + |w i * x i| := abs_add_le _ _
213
+ _ = |b i| + |w i| * |x i| := by rw [abs_mul]
214
+ _ ≤ |b i| + |w i| := add_le_add le_rfl
215
+ (mul_le_of_le_one_right (abs_nonneg _) (reindexedBlockCubeDomain_box e hx i))
216
+ _ ≤ 1 := hbox (e.symm i)
217
+ have hp := hr d hd hdeg L b 1 u le_rfl hbox' hu
218
+ simp only [one_pow, one_mul] at hp
219
+ apply hp.trans
220
+ have hJ : inverseJacobian L ≤ δ⁻¹ ^ N := by
221
+ simpa only [Fintype.card_fin] using inverseJacobian_coordinateScale_le w hwne hδ hw
222
+ have hconst : 0 ≤ multivariateSublevelConstant N d := (multivariateSublevelConstant_pos hN d).le
223
+ exact mul_le_mul_of_nonneg_right
224
+ (mul_le_mul_of_nonneg_left hJ (pow_nonneg (scalarCubeDomainDensity_pos α).le _))
225
+ (mul_nonneg hconst (Real.rpow_nonneg (by positivity) _))
226
+
227
+ end Erdos3
228
+
229
+ end
230
+
231
+ section
232
+
233
+ namespace Erdos3
234
+
235
+ open MeasureTheory
236
+ open scoped BigOperators
237
+
238
+ noncomputable def affineCubeMinorThreshold (J O α : Type*) [Fintype J] [Fintype O] [Fintype α]
239
+ [DecidableEq α] (h N d : ℕ) (c₀ δ η : ℝ) : ℝ :=
240
+ polynomialSublevelThreshold (N * d) (Fintype.card J)
241
+ (cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N)
242
+ (cubeMinorProbabilityScale O N d c₀) η
243
+
244
+ theorem affineCubeMinorThreshold_pos (J O α : Type*) [Fintype J] [Fintype O] [Fintype α]
245
+ [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ)
246
+ {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hη : 0 < η) :
247
+ 0 < affineCubeMinorThreshold J O α h N d c₀ δ η :=
248
+ polynomialSublevelThreshold_pos _ _
249
+ (mul_nonneg (cubeMinorProbabilityConstant_pos O α h hN d).le (pow_nonneg (inv_nonneg.mpr hδ.le) _))
250
+ (cubeMinorProbabilityScale_pos O N d hc₀).le hη
251
+
252
+ theorem affineCubeMinorThreshold_log_inv (J O α : Type*) [Fintype J] [Fintype O] [Fintype α]
253
+ [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ)
254
+ {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hη : 0 < η) :
255
+ Real.log (affineCubeMinorThreshold J O α h N d c₀ δ η)⁻¹ =
256
+ Real.log 2 + Real.log (1 + cubeMinorProbabilityScale O N d c₀) +
257
+ (N * d : ℕ) * Real.log (1 + 2 * (cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N) *
258
+ (Fintype.card J + 1 : ℝ) / η) :=
259
+ polynomialSublevelThreshold_log_inv _ _
260
+ (mul_nonneg (cubeMinorProbabilityConstant_pos O α h hN d).le (pow_nonneg (inv_nonneg.mpr hδ.le) _))
261
+ (cubeMinorProbabilityScale_pos O N d hc₀).le hη
262
+
263
+ theorem exists_affine_cube_minor_thresholds {B O J α : Type*}
264
+ [Fintype B] [Fintype O] [Fintype J] [Fintype α]
265
+ [DecidableEq B] [DecidableEq O] [DecidableEq α]
266
+ (c : J → B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets)
267
+ (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h)
268
+ (block : J → O → B) (hblock : ∀ j, Function.Injective (block j))
269
+ {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N)
270
+ (d : ℕ) (hd : 0 < d) (hdeg : Fintype.card O * (h - 1) ≤ d)
271
+ {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ j o, c₀ ≤ |c j (block j o)|) :
272
+ ∃ sel : J → O → Option α, ∀ δ η : ℝ, 0 < δ → 0 < η →
273
+ ∀ center width : BlockParameter B (Fin h) α → ℝ,
274
+ (∀ j z, δ ≤ |restrictBlockParameters (block j) width z|) →
275
+ (∀ j z, |restrictBlockParameters (block j) center z| +
276
+ |restrictBlockParameters (block j) width z| ≤ 1) →
277
+ (∑ j, (blockCubeMeasure B (Fin h) α).real
278
+ {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| <
279
+ 2 * affineCubeMinorThreshold J O α h N d c₀ δ η}) ≤ η / 2 := by
280
+ choose sel hsel using (fun j => exists_allocated_affine_cube_minor_probability_bound
281
+ (c j) sets hsets h hh hcard (block j) (hblock j) e hN hc₀ (hc j))
282
+ refine ⟨sel, ?_⟩
283
+ intro δ η hδ hη center width hwidth hbox
284
+ let K := cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N
285
+ let scale := cubeMinorProbabilityScale O N d c₀
286
+ let κ := affineCubeMinorThreshold J O α h N d c₀ δ η
287
+ have hK : 0 < K := mul_pos (cubeMinorProbabilityConstant_pos O α h hN d) (pow_pos (inv_pos.mpr hδ) _)
288
+ have hscale : 0 < scale := cubeMinorProbabilityScale_pos O N d hc₀
289
+ have hκ : 0 < κ := affineCubeMinorThreshold_pos J O α h hN d hc₀ hδ hη
290
+ have hp (j : J) : (blockCubeMeasure B (Fin h) α).real
291
+ {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| < 2 * κ} ≤
292
+ K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) := by
293
+ have hm : (blockCubeMeasure B (Fin h) α).real
294
+ {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| < 2 * κ} ≤
295
+ (blockCubeMeasure B (Fin h) α).real
296
+ {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| ≤ 2 * κ} := by
297
+ apply measureReal_mono
298
+ · intro a ha
299
+ change |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| ≤ 2 * κ
300
+ exact le_of_lt ha
301
+ · exact measure_ne_top _ _
302
+ apply hm.trans
303
+ have hb := hsel j d hd hdeg center width δ (2 * κ) hδ (hwidth j) (hbox j) (by positivity)
304
+ simpa only [K, scale, cubeMinorProbabilityConstant, cubeMinorProbabilityScale,
305
+ div_eq_mul_inv, mul_assoc, mul_left_comm, mul_comm] using hb
306
+ calc
307
+ _ ≤ ∑ _j : J, K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) :=
308
+ Finset.sum_le_sum (fun j _ => hp j)
309
+ _ = (Fintype.card J : ℝ) * K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) := by
310
+ rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
311
+ ring
312
+ _ ≤ η / 2 := polynomialSublevelThreshold_total_bound (Nat.mul_pos hN hd) hK.le hscale.le hη
313
+
314
+ end Erdos3
315
+
316
+ end
317
+
318
+ section
319
+
320
+ namespace Erdos3
321
+
322
+ lemma log_one_add_inverse_width_pow {A δ : ℝ} (hA : 0 ≤ A) (hδ : 0 < δ) (hδone : δ ≤ 1)
323
+ (N : ℕ) :
324
+ Real.log (1 + A * δ⁻¹ ^ N) ≤ Real.log (1 + A) + (N : ℝ) * Real.log δ⁻¹ := by
325
+ have hi : 1 ≤ δ⁻¹ := (one_le_inv₀ hδ).mpr hδone
326
+ have hp : 1 ≤ δ⁻¹ ^ N := one_le_pow₀ hi
327
+ have hmul : 1 + A * δ⁻¹ ^ N ≤ (1 + A) * δ⁻¹ ^ N := by nlinarith
328
+ have hlog := Real.log_le_log (show 0 < 1 + A * δ⁻¹ ^ N by positivity) hmul
329
+ rw [Real.log_mul (by positivity : (1 + A : ℝ) ≠ 0) (by positivity : δ⁻¹ ^ N ≠ 0),
330
+ Real.log_pow] at hlog
331
+ exact hlog
332
+
333
+ theorem affineCubeMinorThreshold_log_inv_slice_bound (J O α : Type*) [Fintype J] [Fintype O]
334
+ [Fintype α] [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ)
335
+ {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) :
336
+ Real.log (affineCubeMinorThreshold J O α h N d c₀ δ η)⁻¹ ≤
337
+ Real.log 2 + Real.log (1 + cubeMinorProbabilityScale O N d c₀) +
338
+ (N * d : ℕ) * (Real.log (1 + 2 * cubeMinorProbabilityConstant O α h N d *
339
+ (Fintype.card J + 1 : ℝ) / η) + (N : ℝ) * Real.log δ⁻¹) := by
340
+ rw [affineCubeMinorThreshold_log_inv J O α h hN d hc₀ hδ hη]
341
+ apply add_le_add le_rfl
342
+ apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg (N * d))
343
+ have hA : 0 ≤ 2 * cubeMinorProbabilityConstant O α h N d * (Fintype.card J + 1 : ℝ) / η :=
344
+ div_nonneg (mul_nonneg (mul_nonneg (by norm_num) (cubeMinorProbabilityConstant_pos O α h hN d).le)
345
+ (by positivity)) hη.le
346
+ have hb := log_one_add_inverse_width_pow hA hδ hδone N
347
+ convert hb using 1
348
+ congr 1
349
+ ring
350
+
351
+ end Erdos3
352
+
353
+ end
354
+
355
+ section
356
+
357
+ namespace Erdos3
358
+
359
+ open MeasureTheory
360
+ open scoped ContDiff BigOperators
361
+
362
+ variable {B O J α : Type*} [Fintype B] [Fintype O] [Fintype J] [Fintype α]
363
+ [DecidableEq B] [DecidableEq O] [DecidableEq α] {h : ℕ}
364
+
365
+ noncomputable def affineBooleanCubeDeterminant
366
+ (c : B → ℝ) (sets : O → Finset α) (block : O → B)
367
+ (v : Fin h) (sel : O → Option α)
368
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
369
+ (b : BlockParameter B (Fin h) α → ℝ) (x : (B × Fin h) → Option α → ℝ) : ℝ :=
370
+ booleanMinorDeterminant c sets block v sel (b + L (blockCubeFlatten B (Fin h) α x))
371
+
372
+ theorem affineBooleanCubeDeterminant_contDiff
373
+ (c : B → ℝ) (sets : O → Finset α) (block : O → B)
374
+ (v : Fin h) (sel : O → Option α)
375
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
376
+ (b : BlockParameter B (Fin h) α → ℝ) :
377
+ ContDiff ℝ ∞ (affineBooleanCubeDeterminant c sets block v sel L b) :=
378
+ (booleanMinorDeterminant_contDiff c sets block v sel).comp
379
+ (contDiff_const.add (L.contDiff.comp (blockCubeFlatten B (Fin h) α).contDiff))
380
+
381
+ noncomputable def affineBooleanCubeGoodWeight
382
+ (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B)
383
+ (v : Fin h) (sel : J → O → Option α)
384
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
385
+ (b : BlockParameter B (Fin h) α → ℝ)
386
+ (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ) :
387
+ (BlockParameter B (Fin h) α → ℝ) → ℝ :=
388
+ blockCubeWeight (scalarCubeGoodWeight α ψ r κ
389
+ (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b))
390
+
391
+ noncomputable def affineBooleanCubeCutoff
392
+ (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B)
393
+ (v : Fin h) (sel : J → O → Option α)
394
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
395
+ (b : BlockParameter B (Fin h) α → ℝ)
396
+ (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ)
397
+ (a : BlockParameter B (Fin h) α → ℝ) : ℝ :=
398
+ goodDomainCutoff ψ κ
399
+ (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b)
400
+ (scalarCubeProductCutoff α r) ((blockCubeFlatten B (Fin h) α).symm a)
401
+
402
+ variable (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B)
403
+ (v : Fin h) (sel : J → O → Option α)
404
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
405
+ (b : BlockParameter B (Fin h) α → ℝ)
406
+ (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ)
407
+
408
+ theorem affineBooleanCubeCutoff_contDiff (hψ : ContDiff ℝ ∞ ψ) :
409
+ ContDiff ℝ ∞ (affineBooleanCubeCutoff c sets block v sel L b ψ r κ) :=
410
+ (goodDomainCutoff_smooth ψ hψ κ _
411
+ (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b) _
412
+ (scalarCubeProductCutoff_smooth r)).comp (blockCubeFlatten B (Fin h) α).symm.contDiff
413
+
414
+ theorem affineBooleanCubeCutoff_range (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
415
+ (x : BlockParameter B (Fin h) α → ℝ) :
416
+ affineBooleanCubeCutoff c sets block v sel L b ψ r κ x ∈ Set.Icc (0 : ℝ) 1 :=
417
+ goodDomainCutoff_range ψ hrange κ _ _ (scalarCubeProductCutoff_range r) _
418
+
419
+ theorem affineBooleanCubeGoodWeight_spec
420
+ (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
421
+ (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) :
422
+ let w := affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ
423
+ ContDiff ℝ 1 w ∧ HasCompactSupport w ∧ (∀ a, 0 ≤ w a) ∧ (∫ a, |w a|) ≤ 1 ∧
424
+ ∀ a ∈ tsupport w, (∀ z, |a z| ≤ 1) ∧
425
+ ∀ j, κ j ≤ |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| := by
426
+ let d := fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b
427
+ have hs := scalarCubeGoodWeight_spec ψ hψ hrange hzero r hr κ hκ d
428
+ (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b)
429
+ refine ⟨blockCubeWeight_contDiff _ hs.1, blockCubeWeight_compact _ hs.2.1,
430
+ fun a => hs.2.2.2.1 _, ?_, ?_⟩
431
+ · change (∫ a, |blockCubeWeight (scalarCubeGoodWeight α ψ r κ d) a|) ≤ 1
432
+ rw [blockCubeWeight_abs_integral]
433
+ exact hs.2.2.2.2
434
+ · intro a ha
435
+ refine ⟨blockCubeWeight_box _ (fun x hx => (hs.2.2.1 hx).1) ha, ?_⟩
436
+ change a ∈ tsupport (blockCubeWeight (scalarCubeGoodWeight α ψ r κ d)) at ha
437
+ rw [blockCubeWeight_tsupport] at ha
438
+ intro j
439
+ simpa only [d, affineBooleanCubeDeterminant, ContinuousLinearEquiv.apply_symm_apply] using
440
+ (hs.2.2.1 ha).2 j
441
+
442
+ theorem affineBooleanCubeGoodWeight_integral_test (hr : ∀ i, 0 < r i)
443
+ (f : (BlockParameter B (Fin h) α → ℝ) → ℝ) :
444
+ (∫ a, affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ a * f a) =
445
+ ∫ a, affineBooleanCubeCutoff c sets block v sel L b ψ r κ a * f a
446
+ ∂blockCubeMeasure B (Fin h) α := by
447
+ unfold affineBooleanCubeGoodWeight
448
+ rw [blockCubeWeight_integral_test, blockCubeMeasure_integral]
449
+ simp only [affineBooleanCubeCutoff, ContinuousLinearEquiv.symm_apply_apply]
450
+ exact scalarCubeGoodWeight_integral_test ψ r hr κ _ _
451
+
452
+ theorem affineBooleanCubeGoodWeight_measure
453
+ (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
454
+ (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) :
455
+ realDensityMeasure volume (affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ) =
456
+ realDensityMeasure (blockCubeMeasure B (Fin h) α)
457
+ (affineBooleanCubeCutoff c sets block v sel L b ψ r κ) := by
458
+ let w := affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ
459
+ let χ := affineBooleanCubeCutoff c sets block v sel L b ψ r κ
460
+ have hw := affineBooleanCubeGoodWeight_spec c sets block v sel L b ψ r κ hψ hrange hzero hr hκ
461
+ have hm : Measurable χ :=
462
+ (affineBooleanCubeCutoff_contDiff c sets block v sel L b ψ r κ hψ).continuous.measurable
463
+ have h01 := affineBooleanCubeCutoff_range c sets block v sel L b ψ r κ hrange
464
+ let : IsFiniteMeasure (realDensityMeasure volume w) :=
465
+ realDensityMeasure_finite volume w (hw.1.continuous.integrable_of_hasCompactSupport hw.2.1) hw.2.2.1
466
+ let : IsFiniteMeasure (realDensityMeasure (blockCubeMeasure B (Fin h) α) χ) :=
467
+ realDensityMeasure_finite _ χ (cutoff_integrable _ χ hm h01) (fun a => (h01 a).1)
468
+ apply finiteMeasure_eq_of_integrals
469
+ intro f _
470
+ rw [realDensityMeasure_integral volume w hw.1.continuous.measurable hw.2.2.1,
471
+ realDensityMeasure_integral _ χ hm (fun a => (h01 a).1)]
472
+ exact affineBooleanCubeGoodWeight_integral_test c sets block v sel L b ψ r κ hr f
473
+
474
+ theorem affineBooleanCubeGoodWeight_mass_lower
475
+ (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
476
+ (hone : ∀ t, 2 ≤ |t| → ψ t = 1) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) :
477
+ 1 - scalarCubeBoundaryConstant α * ∑ i, r i -
478
+ ∑ j, (blockCubeMeasure B (Fin h) α).real
479
+ {a | |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| < 2 * κ j} ≤
480
+ ∫ a, affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ a := by
481
+ unfold affineBooleanCubeGoodWeight
482
+ rw [blockCubeWeight_integral]
483
+ have hs := scalarCubeGoodWeight_mass_lower ψ hψ hrange hone r hr κ hκ
484
+ (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b)
485
+ (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b)
486
+ have he (j : J) :
487
+ (scalarCubeProductMeasure (B × Fin h) α).real
488
+ {x | |affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b x| < 2 * κ j} =
489
+ (blockCubeMeasure B (Fin h) α).real
490
+ {a | |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| < 2 * κ j} := by
491
+ symm
492
+ exact blockCubeMeasure_real_apply _ (measurableSet_lt
493
+ (((booleanMinorDeterminant_contDiff (c j) sets (block j) v (sel j)).comp
494
+ (contDiff_const.add L.contDiff)).continuous.measurable.abs) measurable_const)
495
+ simp_rw [he] at hs
496
+ exact hs
497
+
498
+ end Erdos3
499
+
500
+ end
501
+
502
+ section
503
+
504
+ namespace Erdos3
505
+
506
+ open MeasureTheory
507
+ open scoped ContDiff BigOperators NNReal
508
+
509
+ variable {B O J α : Type*} [Fintype B] [Fintype O] [Fintype J] [Fintype α]
510
+ [DecidableEq B] [DecidableEq O] [DecidableEq α] {h : ℕ}
511
+
512
+ theorem affineBooleanCubeDeterminant_fderiv_norm_le
513
+ (c : B → ℝ) (sets : O → Finset α) (block : O → B)
514
+ (v : Fin h) (sel : O → Option α) (hcard : ∀ o, (sets o).card ≤ h)
515
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
516
+ (b : BlockParameter B (Fin h) α → ℝ) (hL : ‖L‖ ≤ 1)
517
+ {C : ℝ} (hC : 0 ≤ C) (hc : ∀ o, |c (block o)| ≤ C)
518
+ (x : (B × Fin h) → Option α → ℝ)
519
+ (hx : ∀ z, |(b + L (blockCubeFlatten B (Fin h) α x)) z| ≤ 1) :
520
+ ‖fderiv ℝ (affineBooleanCubeDeterminant c sets block v sel L b) x‖ ≤
521
+ productMinorDeterminantDerivativeBound (Fintype.card (BlockParameter B (Fin h) α))
522
+ (Fintype.card O) (Fintype.card α) h C 1 := by
523
+ let e := (blockCubeFlatten B (Fin h) α).toContinuousLinearMap
524
+ have hLe : ‖L.comp e‖ ≤ 1 := by
525
+ apply (ContinuousLinearMap.opNorm_comp_le L e).trans
526
+ exact (mul_le_mul hL (blockCubeFlatten_norm_le_one B (Fin h) α)
527
+ (norm_nonneg _) zero_le_one).trans_eq (one_mul 1)
528
+ have hF := (booleanMinorDeterminant_contDiff c sets block v sel).differentiable (by norm_num)
529
+ have hd := affineSlice_fderiv (booleanMinorDeterminant c sets block v sel) b (L.comp e) x
530
+ (hF (b + (L.comp e) x))
531
+ change fderiv ℝ (affineBooleanCubeDeterminant c sets block v sel L b) x = _ at hd
532
+ rw [hd]
533
+ exact ((ContinuousLinearMap.opNorm_comp_le _ _).trans
534
+ (mul_le_of_le_one_right (norm_nonneg _) hLe)).trans
535
+ (booleanMinorDeterminant_fderiv_norm_le c sets block v sel hcard _ hC le_rfl hc hx)
536
+
537
+ theorem affineBooleanCubeGoodWeight_derivative_budget
538
+ (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B)
539
+ (v : Fin h) (sel : J → O → Option α) (hcard : ∀ o, (sets o).card ≤ h)
540
+ (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ))
541
+ (b : BlockParameter B (Fin h) α → ℝ) (hL : ‖L‖ ≤ 1)
542
+ (hbox : ∀ x ∈ scalarCubeProductDomain (B × Fin h) α,
543
+ ∀ z, |(b + L (blockCubeFlatten B (Fin h) α x)) z| ≤ 1)
544
+ (C : J → ℝ) (hC : ∀ j, 0 ≤ C j) (hc : ∀ j o, |c j (block j o)| ≤ C j)
545
+ (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
546
+ (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition)
547
+ (r : B × Fin h → ℝ) (hr : ∀ i, 0 < r i) (κ : J → ℝ) (hκ : ∀ j, 0 < κ j) :
548
+ (∑ z : BlockParameter B (Fin h) α, ∫ a,
549
+ |fderiv ℝ (affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ) a (Pi.single z 1)|) ≤
550
+ (∑ i, ((2 * 2 ^ Fintype.card α : ℕ) : ℝ) * ((Fintype.card α : ℝ) + 1) ^ 2 * T / r i) +
551
+ (Fintype.card (B × Fin h) : ℝ) * ((Fintype.card α : ℝ) + 1) *
552
+ (∑ j, (A : ℝ) / κ j * productMinorDeterminantDerivativeBound
553
+ (Fintype.card (BlockParameter B (Fin h) α)) (Fintype.card O) (Fintype.card α) h (C j) 1) := by
554
+ let d := fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b
555
+ have hd := fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b
556
+ have hw : ContDiff ℝ 1 (scalarCubeGoodWeight α ψ r κ d) :=
557
+ (scalarCubeProductWeight_spec (α := α) r hr).1.mul
558
+ ((sublevelCutoffProduct_smooth ψ hψ κ d hd).of_le (by norm_num))
559
+ unfold affineBooleanCubeGoodWeight
560
+ rw [blockCubeWeight_derivative_sum _ hw]
561
+ let D : J → ℝ≥0 := fun j => ⟨productMinorDeterminantDerivativeBound
562
+ (Fintype.card (BlockParameter B (Fin h) α)) (Fintype.card O) (Fintype.card α) h (C j) 1,
563
+ productMinorDeterminantDerivativeBound_nonneg _ _ _ _ (hC j) zero_le_one⟩
564
+ exact scalarCubeGoodWeight_derivative_budget ψ hψ hrange A T hLip hTransition r hr κ hκ d hd D
565
+ (fun j x hx => affineBooleanCubeDeterminant_fderiv_norm_le (c j) sets (block j) v (sel j)
566
+ hcard L b hL (hC j) (hc j) x (hbox x hx))
567
+
568
+ end Erdos3
569
+
570
+ end
571
+
572
+ section
573
+
574
+ namespace Erdos3
575
+
576
+ open MeasureTheory
577
+ open scoped BigOperators ContDiff
578
+
579
+ theorem exists_affine_cube_good_mass {B O J α : Type*}
580
+ [Fintype B] [Fintype O] [Fintype J] [Fintype α]
581
+ [DecidableEq B] [DecidableEq O] [DecidableEq α]
582
+ (c : J → B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets)
583
+ (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h)
584
+ (block : J → O → B) (hblock : ∀ j, Function.Injective (block j))
585
+ {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N)
586
+ (d : ℕ) (hd : 0 < d) (hdeg : Fintype.card O * (h - 1) ≤ d)
587
+ {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ j o, c₀ ≤ |c j (block j o)|)
588
+ (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1)
589
+ (hone : ∀ t, 2 ≤ |t| → ψ t = 1) :
590
+ ∃ sel : J → O → Option α, ∀ δ η : ℝ, 0 < δ → 0 < η →
591
+ ∀ (center width : BlockParameter B (Fin h) α → ℝ) (hw : ∀ z, width z ≠ 0),
592
+ (∀ j z, δ ≤ |restrictBlockParameters (block j) width z|) →
593
+ (∀ j z, |restrictBlockParameters (block j) center z| +
594
+ |restrictBlockParameters (block j) width z| ≤ 1) →
595
+ 1 - η ≤ ∫ a, affineBooleanCubeGoodWeight c sets block (⟨0, hh⟩ : Fin h) sel
596
+ (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap center ψ
597
+ (fun _ => scalarCubeProductBoundaryRadius (B × Fin h) α (η / 2))
598
+ (fun _ => affineCubeMinorThreshold J O α h N d c₀ δ η) a := by
599
+ obtain ⟨sel, hs⟩ := exists_affine_cube_minor_thresholds c sets hsets h hh hcard
600
+ block hblock e hN d hd hdeg hc₀ hc
601
+ refine ⟨sel, ?_⟩
602
+ intro δ η hδ hη center width hw hwidth hbox
603
+ let κ := affineCubeMinorThreshold J O α h N d c₀ δ η
604
+ have hκ : 0 < κ := affineCubeMinorThreshold_pos J O α h hN d hc₀ hδ hη
605
+ have hr := scalarCubeProductBoundaryRadius_pos (B × Fin h) α (half_pos hη)
606
+ have hm := affineBooleanCubeGoodWeight_mass_lower c sets block (⟨0, hh⟩ : Fin h) sel
607
+ (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap center ψ
608
+ (fun _ => scalarCubeProductBoundaryRadius (B × Fin h) α (η / 2)) (fun _ => κ)
609
+ hψ hrange hone (fun _ => hr) (fun _ => hκ)
610
+ have hp := hs δ η hδ hη center width hwidth hbox
611
+ have he (a : BlockParameter B (Fin h) α → ℝ) :
612
+ center + (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap a =
613
+ fun z => center z + width z * a z := rfl
614
+ simp only [he] at hm
615
+ have hb := scalarCubeProductBoundaryRadius_loss (B × Fin h) α (half_pos hη)
616
+ linarith only [hm, hp, hb]
617
+
618
+ end Erdos3
619
+
620
+ end
621
+
622
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePlateauSite.lean ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.WeightedPlateauSiteApproximation
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+ open scoped BigOperators Classical NNReal
11
+
12
+ variable {B α T : Type*} [Fintype B] [DecidableEq B] [Fintype α] [DecidableEq α]
13
+ variable {n K M : ℕ} [NeZero M]
14
+ variable (s : B → Fin (n + 1) → NormalizedScalarCubeSource α)
15
+ variable (u : B → Fin (n + 1) → Option α → ℤ) (v : B → Fin (n + 1) → Option α → ℕ)
16
+
17
+ noncomputable def affineCubePlateauCoefficient (K M : ℕ) (rows : Finset (Finset α))
18
+ (k : rows → Fin M) : ℂ :=
19
+ ((K : ℂ) / M) ^ rows.card * ∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k
20
+
21
+ omit [NeZero M] [DecidableEq B] in
22
+ theorem affineCubePlateauCoefficient_sum_le (rows : Finset (Finset α))
23
+ (F : Finset (rows → Fin M)) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ}
24
+ (hcap : (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k‖) ≤ C) :
25
+ (∑ k : F, ‖affineCubePlateauCoefficient s u v K M rows k‖) ≤ C := by
26
+ rw [← Finset.sum_subtype F (fun _ => Iff.rfl)
27
+ (fun k => ‖affineCubePlateauCoefficient s u v K M rows k‖)]
28
+ simp only [affineCubePlateauCoefficient, norm_mul, norm_pow, norm_div,
29
+ Complex.norm_natCast, ← Finset.mul_sum]
30
+ have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap
31
+ apply (mul_le_mul_of_nonneg_left
32
+ ((Finset.sum_le_univ_sum_of_nonneg (fun _ => norm_nonneg _)).trans hcap) (by positivity)).trans
33
+ exact mul_le_of_le_one_left hC hscale
34
+
35
+ variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T]
36
+
37
+ theorem affineCubePlateauMixture_model
38
+ (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset α))
39
+ (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
40
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
41
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K)
42
+ (shift : T → rows → ℤ) (z : rows → ℤ) :
43
+ (∫ zeta, affineCubePlateauApproximation s u v K H rows (shift zeta) z F ∂p.toMeasure) =
44
+ finiteResidueModeModel (fun k : F => D k) (fun k => a k)
45
+ (fun k => affineCubePlateauCoefficient s u v K M rows k)
46
+ (fun k => plateauModeMixture p H (D k) K (a k) (ω k) shift)
47
+ (fun k => integerGridResidue (D k) z) (fun t => (z t : ℝ) / K) := by
48
+ rw [affineCubePlateauMixture_expansion s u v p hK H rows shift z F D a ω hfreq]
49
+ let term (k : rows → Fin M) := affineCubePlateauCoefficient s u v K M rows k *
50
+ (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) *
51
+ plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K))
52
+ calc
53
+ _ = ∑ k ∈ F, term k := by
54
+ simp only [term, affineCubePlateauCoefficient, Finset.mul_sum, mul_assoc]
55
+ _ = ∑ k : F, term k := Finset.sum_subtype F (fun _ => Iff.rfl) term
56
+ _ = _ := rfl
57
+
58
+ theorem exists_affineCube_plateau_site_approximation
59
+ (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset α))
60
+ (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
61
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
62
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K)
63
+ (shift : T → rows → ℤ) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ}
64
+ (hcap : (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k‖) ≤ C)
65
+ (W : ℝ≥0) (hW : ∀ k ∈ F, ∀ t, |ω k t| ≤ W)
66
+ {R δ P : ℝ} (hR : 0 < R) (hδ : 0 < δ) (hP : 0 ≤ P)
67
+ (hRP : R ≤ Real.exp P) (hδP : (δ / (C + 1))⁻¹ ≤ Real.exp P)
68
+ (hLP : ((CircleFourier.characterLipConstant * (rows.card * W) + 4) *
69
+ (2 : ℝ≥0) ^ Fintype.card α : ℝ≥0) ≤ Real.exp P) :
70
+ ∃ N : F → ℕ, (∀ k, (N k : ℝ) ≤ Real.exp (4 * P + 8)) ∧
71
+ (Fintype.card (PlateauSiteIndex α F N) : ℝ) ≤
72
+ F.card * Real.exp (Fintype.card (Finset α) * (4 * P + 8)) ∧
73
+ ∃ (β : PlateauSiteIndex α F N → ℂ)
74
+ (f : (k : PlateauSiteIndex α F N) → Finset α → ZMod (D k.1) → ℝ → ℂ),
75
+ (∑ k, ‖β k‖) ≤ C * Real.exp (Fintype.card (Finset α) * (4 * P + 8) + P) ∧
76
+ (∀ k u r x, ‖f k u r x‖ ≤ 1) ∧
77
+ (∀ k u r, LipschitzWith ⟨Real.exp (1 + 6 * P + 12), Real.exp_nonneg _⟩ (f k u r)) ∧
78
+ ∀ y : Finset α → ℤ, (∀ u, |(y u : ℝ) / K| ≤ R) →
79
+ ‖(∫ zeta, affineCubePlateauApproximation s u v K H rows (shift zeta)
80
+ (fun t => booleanCoefficient y t) F ∂p.toMeasure) -
81
+ ∑ k, β k * ∏ u, f k u (y u : ZMod (D k.1)) ((y u : ℝ) / K)‖ ≤ δ := by
82
+ have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap
83
+ have htol : 0 < δ / (C + 1) := div_pos hδ (by positivity)
84
+ obtain ⟨N, hN, hcard, β, f, hβ, hf, hLf, he⟩ :=
85
+ exists_integer_plateau_sum_site_approximation p H K rows (fun k : F => D k)
86
+ (fun k => a k) (fun k => ω k) shift
87
+ (fun k => affineCubePlateauCoefficient s u v K M rows k)
88
+ (affineCubePlateauCoefficient_sum_le s u v rows F hscale hcap)
89
+ W (fun k => hW k k.property) hR htol hP hRP hδP hLP
90
+ refine ⟨N, hN, ?_, β, f, hβ, hf, hLf, ?_⟩
91
+ · simpa only [Fintype.card_coe] using hcard
92
+ · intro y hy
93
+ rw [affineCubePlateauMixture_model s u v p hK H rows F D a ω hfreq shift]
94
+ apply (he y hy).trans
95
+ rw [← mul_div_assoc]
96
+ apply (div_le_iff₀ (by positivity : 0 < C + 1)).mpr
97
+ nlinarith only [hC, hδ]
98
+
99
+ end Erdos3
100
+
101
+ end
102
+
103
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePositiveComparison.lean ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.SectionRetainedFourier
2
+ import OAI.Combinatorics.Progressions.Fourier.SiteFourierHaarMean
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3.BooleanCubeKernel
9
+
10
+ open VectorPolynomial
11
+ open scoped BigOperators
12
+
13
+ theorem exists_affine_cube_approximated_projection (m q : ℕ) :
14
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
15
+ [Fintype I] [DecidableEq I] [Fintype K]
16
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
17
+ {F : Type*} [Fintype F]
18
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
19
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
20
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
21
+ (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
22
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
23
+ (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
24
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
25
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
26
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
27
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
28
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
29
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
30
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
31
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
32
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
33
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
34
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
35
+ (H : I → ℝ)
36
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
37
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
38
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
39
+ (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0)
40
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1)
41
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
42
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
43
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
44
+ (f g : (Option K × I → ℤ) → ℂ) {η : ℝ} (_hη : 0 ≤ η)
45
+ (_hf : ∀ z ∈ rectangularWeightIndices 0 V 1,
46
+ ‖f z - affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ))‖ ≤ η)
47
+ (_hg : ∀ z ∈ rectangularWeightIndices 0 V 1,
48
+ ‖affineCubeFourierProjection U root difference frequency p c (fun k j => (z (k, j) : ℝ)) - g z‖ ≤ η),
49
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
50
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
51
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * f z)) -
52
+ (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
53
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * g z))‖ ≤ 2 * η + ε := by
54
+ obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_fourier_projection m q
55
+ refine ⟨A, hA, ?_⟩
56
+ intro I K _ _ _ J _ F _ P hP hn hd U root difference hlin L C hL hC hLP hCP
57
+ hsite frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP
58
+ hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth f g η hη hf hg
59
+ obtain ⟨hZ, hproj⟩ := hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite
60
+ frequency hbound c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP
61
+ hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth
62
+ refine ⟨hZ, ?_⟩
63
+ exact selectedResidueSmoothPMF_projection_approximation stride G V hV hZ
64
+ (fun z => layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)))
65
+ f (fun z => affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ)))
66
+ (fun z => affineCubeFourierProjection U root difference frequency p c (fun k j => (z (k, j) : ℝ)))
67
+ g hη (fun z _ => layeredSiteWeight_norm_le Q _ test htest _) hf hg hproj
68
+
69
+ end Erdos3.BooleanCubeKernel
70
+
71
+ end
72
+
73
+ section
74
+
75
+ namespace Erdos3.BooleanCubeKernel
76
+
77
+ open VectorPolynomial
78
+ open scoped Classical
79
+
80
+ theorem affineCubeModeFactors_iff_bounded {K : Type*} [Fintype K] {m q : ℕ}
81
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
82
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
83
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) :
84
+ affineCubeModeFactors U root difference frequency ↔
85
+ ∀ j, ∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ,
86
+ ∀ p : VectorPolynomial K ℝ (U j), DegreeLE (1 : K → ℕ) (j.val + 1) p →
87
+ coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) =
88
+ M (VectorPolynomial.siteEvaluation (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p) := by
89
+ constructor
90
+ · exact affineCubeModeFactors_bounded U root difference frequency
91
+ · intro h j
92
+ obtain ⟨M, hM⟩ := h j
93
+ refine ⟨M, ?_⟩
94
+ let L := (coefficientFunctional (fun d a => (frequency j d a : ℝ))).comp (map (U j).subtype)
95
+ have hh := (homogeneous_site_factorization_iff (j.val + 1)
96
+ (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) L M).mpr hM
97
+ change ∀ p, Homogeneous (j.val + 1) p → affineModeLift L p = _ at hh
98
+ have he : (fun s (k : Option K) => k.elim (1 : ℝ)
99
+ (fun k => ((affineSite root difference s (some k) : ℤ) : ℝ))) =
100
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) := by
101
+ funext s k
102
+ cases k <;> simp [affineSite, Int.cast_sum]
103
+ simpa only [L, affineModeLift_comp_map, LinearMap.comp_apply, he] using hh
104
+
105
+ theorem exists_affine_cube_residual {K : Type*} [Fintype K] (m q : ℕ)
106
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {H : ℕ} (hH : 1 ≤ H)
107
+ (hsite : ∀ (s : Finset (Fin q)) k, (affineSite root difference s (some k)).natAbs ≤ H) :
108
+ ∃ (d : Fin m → ℕ)
109
+ (T : ∀ j : Fin m, Matrix (BoundedCoefficientExponent K (j.val + 1)) (Finset (Fin q)) ℤ),
110
+ (∀ j, 0 < d j) ∧
111
+ ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)),
112
+ let R := coefficientSiteResidual U (fun s k => affineSite root difference s (some k)) d T
113
+ (∀ x ∈ coefficientIntegerLattice U, R x ∈ coefficientIntegerLattice U) ∧
114
+ ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ,
115
+ (coefficientArrayFunctional U frequency).comp R = 0 ↔
116
+ affineCubeModeFactors U root difference frequency := by
117
+ let site := fun s k => affineSite root difference s (some k)
118
+ have hex (j : Fin m) := exists_integer_site_residual (boundedSiteMatrix (j.val + 1) site)
119
+ (Nat.one_le_pow _ _ hH) (boundedSiteMatrix_height (j.val + 1) site hH hsite)
120
+ choose d T hd hT _hbound using hex
121
+ refine ⟨d, T, hd, ?_⟩
122
+ intro J _ U
123
+ refine ⟨coefficientSiteResidual_preserves_lattice U site d T, ?_⟩
124
+ intro frequency
125
+ rw [coefficientSiteResidual_zero_iff U site d T hd (fun j x => hT j x),
126
+ affineCubeModeFactors_iff_bounded]
127
+
128
+ end Erdos3.BooleanCubeKernel
129
+
130
+ end
131
+
132
+ section
133
+
134
+ namespace Erdos3.BooleanCubeKernel
135
+
136
+ open MeasureTheory VectorPolynomial
137
+ open scoped BigOperators Classical
138
+
139
+ variable {K : Type*} [Fintype K] {m q : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)]
140
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
141
+ (R : CoefficientArray (K := K) U →ₗ[ℝ] CoefficientArray (K := K) U)
142
+ (hR : ∀ x ∈ coefficientIntegerLattice U, R x ∈ coefficientIntegerLattice U)
143
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
144
+
145
+ theorem coefficientResidual_section_integrable
146
+ {W : Type*} [NormedAddCommGroup W] [NormedSpace ℝ W]
147
+ (μ : Measure (CoefficientTorus (K := K) U)) [IsFiniteMeasure μ]
148
+ (f : CoefficientTorus (K := K) U → W) (hf : Continuous f)
149
+ {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) (x : CoefficientTorus (K := K) U) :
150
+ Integrable (fun y => f (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ := by
151
+ have hc := linearQuotientEndomorphism_continuous (coefficientIntegerLattice U) R hR
152
+ R.continuous_of_finiteDimensional
153
+ exact Integrable.of_bound (hf.comp (continuous_const.add hc)).aestronglyMeasurable B
154
+ (ae_of_all μ (fun _ => hB _))
155
+
156
+ theorem coefficientResidualAverage_continuous
157
+ {W : Type*} [NormedAddCommGroup W] [NormedSpace ℝ W]
158
+ (μ : Measure (CoefficientTorus (K := K) U)) [IsFiniteMeasure μ]
159
+ (f : CoefficientTorus (K := K) U → W) (hf : Continuous f)
160
+ {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) :
161
+ Continuous (linearQuotientAverage (coefficientIntegerLattice U) R hR μ f) := by
162
+ apply continuous_of_dominated
163
+ (fun x => (coefficientResidual_section_integrable U R hR μ f hf hB x).aestronglyMeasurable)
164
+ (fun _ => ae_of_all μ (fun _ => hB _)) (integrable_const B)
165
+ exact ae_of_all μ (fun _ => hf.comp (continuous_id.add continuous_const))
166
+
167
+ theorem coefficientTorusFourierSum_residualAverage {F : Type*} [Fintype F]
168
+ (root : K → ℤ) (difference : Fin q → K → ℤ)
169
+ (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ,
170
+ (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency)
171
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ)
172
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
173
+ (x : CoefficientTorus (K := K) U) :
174
+ linearQuotientAverage (coefficientIntegerLattice U) R hR μ (coefficientTorusFourierSum U frequency c) x =
175
+ ∑ a, if affineCubeModeFactors U root difference (frequency a) then
176
+ c a * coefficientTorusCharacter U (frequency a) x else 0 := by
177
+ have hi (a : F) := coefficientResidual_section_integrable U R hR μ
178
+ (coefficientTorusCharacter U (frequency a))
179
+ (quotientLinearCharacter_continuous _ _ _ (coefficientArrayFunctional U (frequency a)).continuous_of_finiteDimensional)
180
+ (fun x => (quotientLinearCharacter_norm _ _ _ x).le) x
181
+ change (∫ y, ∑ a, c a * coefficientTorusCharacter U (frequency a)
182
+ (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y) ∂μ) = _
183
+ rw [integral_finsetSum _ (fun a _ => (hi a).const_mul (c a))]
184
+ simp only [integral_const_mul]
185
+ change (∑ a, c a * linearQuotientAverage (coefficientIntegerLattice U) R hR μ
186
+ (quotientLinearCharacter (coefficientIntegerLattice U) (coefficientArrayFunctional U (frequency a))
187
+ (coefficientArrayFunctional_integral U (frequency a))) x) = _
188
+ simp only [linearQuotientAverage_character, hfactor, mul_ite, mul_zero]
189
+ rfl
190
+
191
+ theorem affineCubeFourierProjection_eq_residualAverage {I F : Type*} [Fintype F]
192
+ (root : K → ℤ) (difference : Fin q → K → ℤ)
193
+ (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ,
194
+ (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency)
195
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ)
196
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
197
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
198
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
199
+ (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) :
200
+ affineCubeFourierProjection U root difference frequency p c b =
201
+ linearQuotientAverage (coefficientIntegerLattice U) R hR μ (coefficientTorusFourierSum U frequency c)
202
+ (affineSampleCoefficientTorus U p hm b) := by
203
+ rw [coefficientTorusFourierSum_residualAverage U R hR root difference hfactor]
204
+ simp only [coefficientTorusCharacter_sample U _ p hp hm b, affineCubeFourierProjection]
205
+
206
+ theorem coefficientTorusFourierProjection_approx_residualAverage {F : Type*} [Fintype F]
207
+ (root : K → ℤ) (difference : Fin q → K → ℤ)
208
+ (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ,
209
+ (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency)
210
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ)
211
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
212
+ (D : CoefficientTorus (K := K) U → ℝ) {η : ℝ}
213
+ (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η)
214
+ (x : CoefficientTorus (K := K) U)
215
+ (hD : Integrable (fun y => D (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ) :
216
+ ‖(∑ a, if affineCubeModeFactors U root difference (frequency a) then
217
+ c a * coefficientTorusCharacter U (frequency a) x else 0) -
218
+ ((linearQuotientAverage (coefficientIntegerLattice U) R hR μ D x : ℝ) : ℂ)‖ ≤ η := by
219
+ rw [← coefficientTorusFourierSum_residualAverage U R hR root difference hfactor frequency c μ x]
220
+ have hi : Integrable (fun y => coefficientTorusFourierSum U frequency c
221
+ (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ := by
222
+ apply integrable_finsetSum
223
+ intro a _
224
+ apply Integrable.const_mul
225
+ exact coefficientResidual_section_integrable U R hR μ (coefficientTorusCharacter U (frequency a))
226
+ (quotientLinearCharacter_continuous _ _ _ (coefficientArrayFunctional U (frequency a)).continuous_of_finiteDimensional)
227
+ (fun x => (quotientLinearCharacter_norm _ _ _ x).le) x
228
+ have he := linearQuotientAverage_approx (coefficientIntegerLattice U) R hR μ
229
+ (coefficientTorusFourierSum U frequency c) (fun x => (D x : ℂ)) happrox x hi hD.ofReal
230
+ simpa only [linearQuotientAverage, integral_complex_ofReal] using he
231
+
232
+ end Erdos3.BooleanCubeKernel
233
+
234
+ end
235
+
236
+ section
237
+
238
+ namespace Erdos3.BooleanCubeKernel
239
+
240
+ open MeasureTheory VectorPolynomial
241
+ open scoped BigOperators Classical
242
+
243
+ theorem exists_affine_cube_positive_density {K : Type*} [Fintype K] {m q : ℕ}
244
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
245
+ (root : K → ℤ) (difference : Fin q → K → ℤ) {H : ℕ} (hH : 1 ≤ H)
246
+ (hsite : ∀ (s : Finset (Fin q)) k, (affineSite root difference s (some k)).natAbs ≤ H)
247
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
248
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
249
+ (D : CoefficientTorus (K := K) U → ℝ) (hD : Continuous D) {B : ℝ}
250
+ (hcap : ∀ x, D x ∈ Set.Icc (0 : ℝ) B) (hmass : (∫ x, D x ∂μ) = 1) :
251
+ ∃ g : CoefficientTorus (K := K) U → ℝ,
252
+ Continuous g ∧ (∀ x, g x ∈ Set.Icc (0 : ℝ) B) ∧ Integrable g μ ∧ (∫ x, g x ∂μ) = 1 ∧
253
+ ∀ {F : Type*} [Fintype F] (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ)
254
+ {η : ℝ}, (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) →
255
+ ∀ x, ‖(∑ a, if affineCubeModeFactors U root difference (frequency a) then
256
+ c a * coefficientTorusCharacter U (frequency a) x else 0) - (g x : ℂ)‖ ≤ η := by
257
+ obtain ⟨d, T, _, hR⟩ := exists_affine_cube_residual m q root difference hH hsite
258
+ obtain ⟨hlattice, hfactor⟩ := hR U
259
+ let R := coefficientSiteResidual U (fun s k => affineSite root difference s (some k)) d T
260
+ let g := linearQuotientAverage (coefficientIntegerLattice U) R hlattice μ D
261
+ have hRm := (linearQuotientEndomorphism_continuous (coefficientIntegerLattice U) R hlattice
262
+ R.continuous_of_finiteDimensional).measurable
263
+ have hb (x) : ‖D x‖ ≤ B := by rw [Real.norm_of_nonneg (hcap x).1]; exact (hcap x).2
264
+ have hi : Integrable D μ := Integrable.of_bound hD.aestronglyMeasurable B (ae_of_all μ hb)
265
+ have hp := linearQuotientAverage_probability (coefficientIntegerLattice U) R hlattice μ hRm D
266
+ hD.measurable hi (fun x => (hcap x).1) hmass
267
+ refine ⟨g, ?_, ?_, hp.2.1, hp.2.2, ?_⟩
268
+ · exact coefficientResidualAverage_continuous U R hlattice μ D hD hb
269
+ · intro x
270
+ refine ⟨hp.1 x, ?_⟩
271
+ have h := linearQuotientAverage_bound (coefficientIntegerLattice U) R hlattice μ D hb x
272
+ rwa [Real.norm_of_nonneg (hp.1 x)] at h
273
+ · intro F _ frequency c η happrox x
274
+ exact coefficientTorusFourierProjection_approx_residualAverage U R hlattice root difference hfactor
275
+ frequency c μ D happrox x (coefficientResidual_section_integrable U R hlattice μ D hD hb x)
276
+
277
+ end Erdos3.BooleanCubeKernel
278
+
279
+ end
280
+
281
+ section
282
+
283
+ namespace Erdos3.BooleanCubeKernel
284
+
285
+ open MeasureTheory VectorPolynomial
286
+ open scoped BigOperators Classical
287
+
288
+ theorem exists_affine_cube_positive_comparison (m q : ℕ) :
289
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
290
+ [Fintype I] [DecidableEq I] [Fintype K]
291
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
292
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
293
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
294
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
295
+ (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
296
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
297
+ (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
298
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
299
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
300
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
301
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
302
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
303
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
304
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
305
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
306
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
307
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
308
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
309
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
310
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
311
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
312
+ (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0)
313
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1)
314
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
315
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
316
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
317
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
318
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Continuous D) {B₀ η : ℝ}
319
+ (_hcap : ∀ x, D x ∈ Set.Icc (0 : ℝ) B₀) (_hmass : (∫ x, D x ∂μ) = 1) (_hη : 0 ≤ η)
320
+ (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η),
321
+ ∃ g : CoefficientTorus (K := K) U → ℝ,
322
+ Continuous g ∧ (∀ x, g x ∈ Set.Icc (0 : ℝ) B₀) ∧ Integrable g μ ∧ (∫ x, g x ∂μ) = 1 ∧
323
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
324
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
325
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
326
+ (D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ))) -
327
+ (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
328
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
329
+ (g (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ)))‖ ≤ 2 * η + ε := by
330
+ obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_approximated_projection m q
331
+ refine ⟨A, hA, ?_⟩
332
+ intro I K _ _ _ J _ F _ P hP hn hd U root difference hlin L C hL hC hLP hCP hsite
333
+ frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP
334
+ hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth _ _ μ _ _ D hD B₀ η hcap hmass hη happrox
335
+ let H₀ := max 1 (Finset.univ.sup (fun sk : Finset (Fin q) × K =>
336
+ (affineSite root difference sk.1 (some sk.2)).natAbs))
337
+ have hH₀ : 1 ≤ H₀ := le_max_left _ _
338
+ have hsite₀ (s : Finset (Fin q)) (k : K) : (affineSite root difference s (some k)).natAbs ≤ H₀ :=
339
+ (Finset.le_sup (f := fun sk : Finset (Fin q) × K =>
340
+ (affineSite root difference sk.1 (some sk.2)).natAbs) (Finset.mem_univ (s, k))).trans (le_max_right _ _)
341
+ obtain ⟨g, hgm, hgc, hgi, hgmass, hg⟩ :=
342
+ exists_affine_cube_positive_density U root difference hH₀ hsite₀ μ D hD hcap hmass
343
+ refine ⟨g, hgm, hgc, hgi, hgmass, ?_⟩
344
+ apply hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite frequency hbound c
345
+ hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR
346
+ Q hQ test htest G hG V hV hwidth
347
+ (fun z => (D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ))
348
+ (fun z => (g (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ)) hη
349
+ · intro z _
350
+ have h := happrox (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))
351
+ simpa only [coefficientTorusFourierSum, coefficientTorusCharacter_sample U _ p hp hm,
352
+ affineCubeFourierSum, norm_sub_rev] using h
353
+ · intro z _
354
+ have h := hg frequency c happrox (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))
355
+ simpa only [coefficientTorusCharacter_sample U _ p hp hm, affineCubeFourierProjection] using h
356
+
357
+ end Erdos3.BooleanCubeKernel
358
+
359
+ end
360
+
361
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeUniformRemoval.lean ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.CubeModeUniformBudget
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.BooleanCubeKernel
8
+
9
+ open VectorPolynomial
10
+ open scoped BigOperators NNReal
11
+
12
+ theorem affine_cube_removal_of_widths {I K : Type*}
13
+ [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ}
14
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
15
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
16
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
17
+ {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C)
18
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
19
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
20
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
21
+ (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ,
22
+ ∀ P, Homogeneous (i.val + 1) P →
23
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) =
24
+ M (VectorPolynomial.siteEvaluation
25
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P))
26
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
27
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
28
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
29
+ (stride : I → ℕ) (hs : ∀ k, 0 < stride k)
30
+ {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S)
31
+ (hstride : ∀ k, (stride k : ℝ) ≤ S)
32
+ (H : I → ℝ) (hH : ∀ k, 0 < H k)
33
+ (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k)
34
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
35
+ (hR : layerRemovalRankBudget m (Fintype.card I) C (cubeModePolynomialBudget q L)
36
+ (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R)
37
+ (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0)
38
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1)
39
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (hV1 : ∀ z, 1 ≤ V z)
40
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / V z ≤ δ)
41
+ (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) *
42
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
43
+ {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r)
44
+ (hwidth : ∀ z, ρ * H z.2 ≤ V z)
45
+ (hmove : (m : ℝ) * cubeModePolynomialBudget q L ≤ r * ρ * T)
46
+ (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) :
47
+ ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) *
48
+ layeredModeTestedPhase
49
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
50
+ p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤
51
+ 4 * (3 : ℝ) ^ Fintype.card (Option K × I) *
52
+ ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by
53
+ classical
54
+ let B := finiteLayerBiasBudget m ζ
55
+ let D := cubeModePolynomialBudget q L
56
+ have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ
57
+ have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le
58
+ have hA : 0 ≤ 2 * T := by positivity
59
+ have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B :=
60
+ multiaffineBiasBudget_le_finite i hζ
61
+ obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth
62
+ have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD
63
+ (zero_le_one.trans hB) hA hS
64
+ apply affine_cube_mode_smooth_removal U root difference hlin hL hC hsite frequency hbound hbad
65
+ p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank
66
+ (fun i => (hbud i).1.trans hR) _ _ Q hQ test htest V hV hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower
67
+ · intro i
68
+ have hi := tensorDenominatorBound_le (H := Fin (i.val + 1))
69
+ (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ))
70
+ (fun k => Nat.cast_nonneg _) hstride
71
+ have hi' : (∏ j : Fin (i.val + 1) → I,
72
+ (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤
73
+ (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by
74
+ simpa only [Fintype.card_fin] using hi
75
+ apply hi'.trans
76
+ apply le_trans _ ((hbud i).2.1.trans hR)
77
+ exact pow_le_pow_left₀
78
+ (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _))
79
+ (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _
80
+ · intro i
81
+ apply le_trans _ ((hbud i).2.2.trans hR)
82
+ exact mul_le_mul_of_nonneg_left
83
+ (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _))
84
+ (pow_nonneg (Nat.cast_nonneg _) _)
85
+ · intro i z
86
+ have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt
87
+ apply le_trans _ (hshift z)
88
+ exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hi hD)
89
+ (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))
90
+
91
+ end Erdos3.BooleanCubeKernel
92
+
93
+ end
94
+
95
+ section
96
+
97
+ namespace Erdos3.BooleanCubeKernel
98
+
99
+ open VectorPolynomial
100
+ open scoped BigOperators
101
+
102
+ theorem affine_cube_removal_at_error {I K : Type*}
103
+ [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ}
104
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
105
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
106
+ (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
107
+ {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C)
108
+ (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
109
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
110
+ (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
111
+ (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ,
112
+ ∀ P, Homogeneous (i.val + 1) P →
113
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) =
114
+ M (VectorPolynomial.siteEvaluation
115
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P))
116
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
117
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
118
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
119
+ (stride : I → ℕ) (hs : ∀ k, 0 < stride k)
120
+ {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε)
121
+ (hstride : ∀ k, (stride k : ℝ) ≤ S)
122
+ (H : I → ℝ)
123
+ (hsize : ∀ k, modeRemovalSideThreshold m (Fintype.card (Option K × I))
124
+ (cubeModePolynomialBudget q L) S ρ ε ≤ H k)
125
+ (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
126
+ (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I))
127
+ C (cubeModePolynomialBudget q L) S ρ ε ≤ R)
128
+ (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0)
129
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1)
130
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
131
+ (hwidth : ∀ z, ρ * H z.2 ≤ V z) :
132
+ ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) *
133
+ layeredModeTestedPhase
134
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
135
+ p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by
136
+ classical
137
+ let d := Fintype.card (Option K × I)
138
+ let D := cubeModePolynomialBudget q L
139
+ let T := modeRemovalShrink m d D ρ ε
140
+ let B := finiteLayerBiasBudget m (modeRemovalBias m ε)
141
+ have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le
142
+ have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε)
143
+ have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε)
144
+ have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε
145
+ have hH k : 0 < H k := hside.1.trans_le (hsize k)
146
+ have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by
147
+ calc
148
+ _ ≤ S * T * (B + 1) := by gcongr; exact hstride k
149
+ _ ≤ H k := hside.2.1.trans (hsize k)
150
+ have hv z : 1 ≤ V z ∧ 1 / V z ≤ modeRemovalMesh d := by
151
+ apply modeRemovalMesh_of_width d (hV z)
152
+ exact (hside.2.2.trans (mul_le_mul_of_nonneg_left (hsize z.2) hρ.le)).trans (hwidth z)
153
+ have hout := affine_cube_removal_of_widths U root difference hlin hL hC hsite frequency hbound hbad
154
+ p hp hm stride hs (modeRemovalBias_pos m hε) hT hS hstride H hH hsize' hrank hR
155
+ Q hQ test htest V hV (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d)
156
+ (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε).le hwidth
157
+ (modeRemovalShrink_move m d hρ hε) (modeRemovalBeta_pos hε).le (fun i => modeRemovalBias_le i hε)
158
+ exact hout.trans (modeRemovalError_bound d hε)
159
+
160
+ end Erdos3.BooleanCubeKernel
161
+
162
+ end
163
+
164
+ section
165
+
166
+ namespace Erdos3.BooleanCubeKernel
167
+
168
+ open VectorPolynomial
169
+ open scoped BigOperators
170
+
171
+ theorem exists_affine_cube_uniform_removal (m q : ℕ) :
172
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
173
+ [Fintype I] [DecidableEq I] [Fintype K]
174
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
175
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
176
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
177
+ (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ)
178
+ (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ)))
179
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
180
+ (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
181
+ (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ)
182
+ (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C)
183
+ (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ,
184
+ ∀ P, Homogeneous (i.val + 1) P →
185
+ affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) =
186
+ M (VectorPolynomial.siteEvaluation
187
+ (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P))
188
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
189
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
190
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
191
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
192
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
193
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
194
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
195
+ (H : I → ℝ)
196
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
197
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
198
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
199
+ (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0)
200
+ (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1)
201
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
202
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z),
203
+ ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) *
204
+ layeredModeTestedPhase
205
+ (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))))
206
+ p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by
207
+ obtain ⟨A, hA, hbudget⟩ := exists_cube_mode_threshold_exp_budget m q
208
+ refine ⟨A, hA, ?_⟩
209
+ intro I K _ _ _ J _ P hP hn hd U root difference hlin L C hL hC hLP hCP
210
+ hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP
211
+ hstride H hsize hrank hR Q hQ test htest V hV hwidth
212
+ obtain ⟨hside, hrankBudget⟩ := hbudget (Fintype.card I) (Fintype.card (Option K × I))
213
+ P C L S ρ ε hP hn hd hC hCP hL hLP hS hSP hρ hρP hε hεP
214
+ exact affine_cube_removal_at_error U root difference hlin hL hC hsite frequency hbound hbad
215
+ p hp hm stride hs hS hρ hε hstride H (fun k => hside.trans (hsize k)) hrank
216
+ (hrankBudget.trans hR) Q hQ test htest V hV hwidth
217
+
218
+ end Erdos3.BooleanCubeKernel
219
+
220
+ end
221
+
222
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineIntervalNormalizedBounds.lean ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.Order.Field.Basic
2
+ import Mathlib.Tactic
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ theorem affineInterval_normalized_bounds
11
+ {L H step : ℕ} {start : ℤ}
12
+ (hL : 0 < L) (hH : 2 ≤ H) (hstep : 0 < step)
13
+ (hinside : ∀ t : Fin H, 0 ≤ start + step * (t.val : ℤ) ∧
14
+ start + step * (t.val : ℤ) < L) :
15
+ 0 ≤ (start : ℝ) / L ∧
16
+ 0 < (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L ∧
17
+ (start : ℝ) / L + (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L < 1 ∧
18
+ (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L ≤ 1 := by
19
+ have hHpos : 0 < H := by omega
20
+ have hlast : H - 1 < H := Nat.sub_lt hHpos (by norm_num)
21
+ have hstartZ : 0 ≤ start := by
22
+ simpa only [Nat.cast_zero, mul_zero, add_zero] using (hinside ⟨0, hHpos⟩).1
23
+ have hendZ := (hinside ⟨H - 1, hlast⟩).2
24
+ have hstart : (0 : ℝ) ≤ start := by exact_mod_cast hstartZ
25
+ have hend : (start : ℝ) + (step : ℝ) * ((H - 1 : ℕ) : ℝ) < L := by
26
+ exact_mod_cast hendZ
27
+ have hLreal : (0 : ℝ) < L := by exact_mod_cast hL
28
+ have hstepreal : (0 : ℝ) < step := by exact_mod_cast hstep
29
+ have hHreal : (0 : ℝ) < ((H - 1 : ℕ) : ℝ) := by
30
+ exact_mod_cast (show 0 < H - 1 by omega)
31
+ have hlower := div_nonneg hstart hLreal.le
32
+ have hwidth := div_pos (mul_pos hstepreal hHreal) hLreal
33
+ have hsum : (start : ℝ) / L + (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L < 1 := by
34
+ rw [← add_div]
35
+ exact (div_lt_one hLreal).mpr hend
36
+ exact ⟨hlower, hwidth, hsum, by linarith⟩
37
+
38
+ end Erdos3
39
+
40
+ end
41
+
42
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelEndpointGeometry.lean ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.DenseProgressionInnerFamily
2
+ import OAI.Combinatorics.Progressions.Estimates.JointCoefficientRetainedTest
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open MeasureTheory
11
+ open scoped NNReal BigOperators
12
+
13
+ variable {J I : Type*} [Fintype J] [Fintype I]
14
+
15
+ def affineCubeTuple (lower width : J → ℝ) (x : J → Option I → ℝ) : J → Option I → ℝ :=
16
+ fun j i => (if i = none then lower j else 0) + width j * x j i
17
+
18
+ theorem affineCubeTuple_lipschitz (lower width : J → ℝ) (K : ℝ≥0)
19
+ (hw : ∀ j, |width j| ≤ K) : LipschitzWith K (affineCubeTuple (I := I) lower width) := by
20
+ apply LipschitzWith.of_dist_le_mul
21
+ intro x y
22
+ apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr
23
+ intro j
24
+ apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr
25
+ intro i
26
+ simp only [affineCubeTuple, dist_add_left, Real.dist_eq, ← mul_sub, abs_mul]
27
+ simpa only [Real.dist_eq] using mul_le_mul (hw j)
28
+ ((dist_le_pi_dist (x j) (y j) i).trans (dist_le_pi_dist x y j))
29
+ dist_nonneg K.coe_nonneg
30
+
31
+ theorem affineCubeTuple_width_dist (lower w v : J → ℝ) {ε : ℝ} (hε : 0 ≤ ε)
32
+ (hw : ∀ j, |w j - v j| ≤ ε) (x : J → Option I → ℝ) (hx : ‖x‖ ≤ 1) :
33
+ dist (affineCubeTuple lower w x) (affineCubeTuple lower v x) ≤ ε := by
34
+ apply (dist_pi_le_iff hε).mpr
35
+ intro j
36
+ apply (dist_pi_le_iff hε).mpr
37
+ intro i
38
+ have hxj : |x j i| ≤ 1 := by
39
+ exact (norm_le_pi_norm (x j) i).trans ((norm_le_pi_norm x j).trans hx)
40
+ simp only [affineCubeTuple, dist_add_left, Real.dist_eq, ← sub_mul, abs_mul]
41
+ exact (mul_le_mul (hw j) hxj (abs_nonneg _) hε).trans_eq (mul_one _)
42
+
43
+ theorem affineCubeTuple_integral_width_error [DecidableEq I]
44
+ (lower w v : J → ℝ) {ε : ℝ} (hε : 0 ≤ ε) (hw : ∀ j, |w j - v j| ≤ ε)
45
+ (φ : (J → Option I → ℝ) → ℝ) {K : ℝ≥0} {A : ℝ}
46
+ (hφ : LipschitzWith K φ) (_hA : 0 ≤ A) (hb : ∀ x, ‖φ x‖ ≤ A) :
47
+ |(∫ x, φ (affineCubeTuple lower w x) ∂scalarCubeProductMeasure J I) -
48
+ ∫ x, φ (affineCubeTuple lower v x) ∂scalarCubeProductMeasure J I| ≤ K * ε := by
49
+ have hm (v : J → ℝ) : Measurable (affineCubeTuple (I := I) lower v) := by
50
+ unfold affineCubeTuple
51
+ fun_prop
52
+ have hi (v : J → ℝ) : Integrable (fun x => φ (affineCubeTuple lower v x)) (scalarCubeProductMeasure J I) :=
53
+ Integrable.mono' (integrable_const A) (hφ.continuous.measurable.comp (hm v)).aestronglyMeasurable
54
+ (Filter.Eventually.of_forall (fun x => hb _))
55
+ rw [← integral_sub (hi w) (hi v)]
56
+ have he : ∀ᵐ x ∂scalarCubeProductMeasure J I,
57
+ ‖φ (affineCubeTuple lower w x) - φ (affineCubeTuple lower v x)‖ ≤ K * ε := by
58
+ filter_upwards [scalarCubeProductMeasure_ae_closedBall J I] with x hx
59
+ rw [Metric.mem_closedBall, dist_zero_right] at hx
60
+ rw [← dist_eq_norm]
61
+ exact (hφ.dist_le_mul _ _).trans
62
+ (mul_le_mul_of_nonneg_left (affineCubeTuple_width_dist lower w v hε hw x hx) K.coe_nonneg)
63
+ have ht := norm_integral_le_of_norm_le (integrable_const ((K : ℝ) * ε) (μ := scalarCubeProductMeasure J I)) he
64
+ simpa only [Real.norm_eq_abs, integral_const, probReal_univ, one_smul] using ht
65
+
66
+ theorem affineCubeTuple_residue_riemann [DecidableEq J] [DecidableEq I]
67
+ (H M : J → ℕ) (hH : ∀ j, 0 < H j) (modulus : J → Option I → ℕ)
68
+ (residue : ∀ j i, ZMod (modulus j i))
69
+ (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j)
70
+ (hsize : ∀ j, (Fintype.card I + 1) * M j ≤ H j)
71
+ (hsmall : ∀ j, scalarCubeGridBoundaryConstant I * ((M j : ℝ) / H j) < volume.real (scalarCubeDomain I))
72
+ (lower w v : J → ℝ) (W : ℝ≥0) (hw : ∀ j, |w j| ≤ W)
73
+ {ε : ℝ} (hε : 0 ≤ ε) (hwidth : ∀ j, |w j - v j| ≤ ε)
74
+ (φ : (J → Option I → ℝ) → ℝ) {K : ℝ≥0} {A : ℝ}
75
+ (hφ : LipschitzWith K φ) (hA : 0 ≤ A) (hb : ∀ x, ‖φ x‖ ≤ A) :
76
+ |(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (H j) (M j) (hH j)
77
+ (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean
78
+ (fun z => φ (affineCubeTuple lower w (fun j i => (z j i : ℝ) / H j))) -
79
+ ∫ x, φ (affineCubeTuple lower v x) ∂scalarCubeProductMeasure J I| ≤
80
+ (2 * A * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K * W) *
81
+ ∑ j, (M j : ℝ) / H j + K * ε := by
82
+ have htest := hφ.comp (affineCubeTuple_lipschitz lower w W hw)
83
+ have he := scalarCubeResidueWeights_pi_riemann H M hH modulus residue hm hmM hsize hsmall
84
+ (φ ∘ affineCubeTuple lower w) htest hA (fun x => hb _)
85
+ have hi := affineCubeTuple_integral_width_error lower w v hε hwidth φ hφ hA hb
86
+ exact (abs_sub_le _ _ _).trans (add_le_add he hi)
87
+
88
+ end Erdos3
89
+
90
+ end
91
+
92
+ section
93
+
94
+ namespace Erdos3
95
+ open scoped BigOperators NNReal Classical
96
+ variable {G : Type*} [Fintype G]
97
+
98
+ noncomputable def affineKernelContinuousPoint (lower : G → ℝ) (step S : ℝ) (H : G → ℕ)
99
+ (x : G → Option Empty → ℝ) : G → ℝ :=
100
+ fun g => (lower g + step * ((H g - 1 : ℕ) : ℝ) * x g none) / S
101
+
102
+ noncomputable def affineKernelDiscretePoint (lower : G → ℝ) (step S : ℝ) {H : G → ℕ}
103
+ (z : ∀ g, IntegerScalarCubeBox Empty (H g)) : G → ℝ :=
104
+ fun g => (lower g + step * (z g none : ℝ)) / S
105
+
106
+ theorem affineKernelContinuousPoint_lipschitz (lower : G → ℝ) (step S : ℝ) (H : G → ℕ)
107
+ (hS : 0 < S) (hstep : 0 ≤ step)
108
+ (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S) :
109
+ LipschitzWith 1 (affineKernelContinuousPoint lower step S H) := by
110
+ apply LipschitzWith.of_dist_le_mul
111
+ intro x y
112
+ simp only [NNReal.coe_one, one_mul]
113
+ apply (dist_pi_le_iff dist_nonneg).mpr
114
+ intro g
115
+ have hw0 : 0 ≤ step * ((H g - 1 : ℕ) : ℝ) := mul_nonneg hstep (Nat.cast_nonneg _)
116
+ have hw : step * ((H g - 1 : ℕ) : ℝ) / S ≤ 1 := (div_le_one hS).mpr (hspan g)
117
+ have hx : |x g none - y g none| ≤ dist x y :=
118
+ (dist_le_pi_dist (x g) (y g) none).trans (dist_le_pi_dist x y g)
119
+ change |(lower g + step * ((H g - 1 : ℕ) : ℝ) * x g none) / S -
120
+ (lower g + step * ((H g - 1 : ℕ) : ℝ) * y g none) / S| ≤ _
121
+ rw [← sub_div, add_sub_add_left_eq_sub, ← mul_sub, abs_div, abs_mul,
122
+ abs_of_nonneg hw0, abs_of_pos hS]
123
+ calc
124
+ _ = (step * ((H g - 1 : ℕ) : ℝ) / S) * |x g none - y g none| := by ring
125
+ _ ≤ 1 * dist x y := mul_le_mul hw hx (abs_nonneg _) zero_le_one
126
+ _ = _ := one_mul _
127
+
128
+ theorem affineKernelEndpoint_dist_le (lower : G → ℝ) (step S : ℝ) (H : G → ℕ)
129
+ (hH : ∀ g, 0 < H g) (hS : 0 < S) (hstep : 0 ≤ step)
130
+ (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S)
131
+ (z : ∀ g, IntegerScalarCubeBox Empty (H g))
132
+ (hz : (FiniteProbabilityWeights.pi
133
+ (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight z ≠ 0) :
134
+ dist (affineKernelDiscretePoint lower step S z)
135
+ (affineKernelContinuousPoint lower step S H (fun g i => (z g i : ℝ) / H g)) ≤
136
+ ∑ g, (1 : ℝ) / H g := by
137
+ have hsum : 0 ≤ ∑ g, (1 : ℝ) / H g := Finset.sum_nonneg (fun g _ => by positivity)
138
+ apply (dist_pi_le_iff hsum).mpr
139
+ intro g
140
+ have hz' := integerScalarCubePi_root_real_bounds H hH z hz g
141
+ have he := affineKernelEndpoint_error_nat (lower g) (hH g) hS hz'.1 hz'.2 hstep (hspan g)
142
+ change |(lower g + step * (z g none : ℝ)) / S -
143
+ (lower g + step * ((H g - 1 : ℕ) : ℝ) * ((z g none : ℝ) / H g)) / S| ≤ _
144
+ exact he.trans (Finset.single_le_sum (f := fun j => (1 : ℝ) / H j)
145
+ (fun j _ => by positivity) (Finset.mem_univ g))
146
+
147
+ end Erdos3
148
+
149
+ end
150
+
151
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelResidueRetained.lean ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Integral.Prod
2
+ import OAI.Combinatorics.Progressions.Lattices.OriginalKernelResidueRetained
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+ open MeasureTheory
10
+ open scoped BigOperators Classical NNReal
11
+
12
+ theorem originalKernel_residue_slow_quadrature_varying
13
+ {G : Type*} [Fintype G] [DecidableEq G]
14
+ (L : G → ℕ) (q : ℕ) [NeZero q]
15
+ (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g)
16
+ (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L g) <
17
+ volume.real (scalarCubeDomain Empty))
18
+ (F : (G → ZMod q) → (G → Option Empty → ℝ) → ℂ)
19
+ {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r))
20
+ (hbound : ∀ r x, ‖F r x‖ ≤ 1) :
21
+ ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean
22
+ (fun z => F (fun g => ((z g none : ℤ) : ZMod q))
23
+ (fun g i => (z g i : ℝ) / L g)) -
24
+ 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤
25
+ (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty /
26
+ volume.real (scalarCubeDomain Empty) + K)) *
27
+ (∑ g, (q : ℝ) / L g) := by
28
+ let test := fun (r : G → ZMod q) (z : ∀ g, IntegerScalarCubeBox Empty (L g)) =>
29
+ F r (fun g i => (z g i : ℝ) / L g)
30
+ let law := fun (r : G → ZMod q) => FiniteProbabilityWeights.pi
31
+ (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g)
32
+ (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL g))
33
+ let e : ℝ := 2 * (2 * scalarCubeGridBoundaryConstant Empty /
34
+ volume.real (scalarCubeDomain Empty) + K) * (∑ g, (q : ℝ) / L g)
35
+ have hcond (r : G → ZMod q) :
36
+ ‖(law r).complexMean (test r) - ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by
37
+ simpa only [law, test, e, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using
38
+ scalarCubeResidueWeights_pi_complex_riemann L (fun _ => q) hL
39
+ (fun (_ : G) (_ : Option Empty) => q) (fun g _ => r g) (fun _ _ => hq)
40
+ (fun _ _ => le_rfl) (fun g => by simpa using hqL g)
41
+ hsmall (F r) (hF r) zero_le_one (hbound r)
42
+ have hmix := integerScalarCubeWeights_empty_pi_uniform_residue_error_varying L q hL hq hqL
43
+ test (fun r z => hbound r _)
44
+ have havg : ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) -
45
+ 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by
46
+ rw [← Finset.expect_sub_distrib]
47
+ apply (RCLike.norm_expect_le (K := ℂ)).trans
48
+ exact (Finset.expect_le_expect (fun r _ => hcond r)).trans_eq (by simp)
49
+ calc
50
+ _ ≤ ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean
51
+ (fun z => test (fun g => ((z g none : ℤ) : ZMod q)) z) -
52
+ 𝔼 r : G → ZMod q, (law r).complexMean (test r)‖ +
53
+ ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) -
54
+ 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ :=
55
+ norm_sub_le_norm_sub_add_norm_sub _ _ _
56
+ _ ≤ (∑ g, (q : ℝ) / L g) + e := add_le_add hmix havg
57
+ _ = _ := by dsimp only [e]; ring
58
+
59
+ end Erdos3
60
+
61
+ end
62
+
63
+ section
64
+
65
+ namespace Erdos3
66
+
67
+ open MeasureTheory
68
+ open scoped BigOperators Classical NNReal
69
+
70
+ variable {G R : Type*} [Fintype G] [DecidableEq G]
71
+
72
+ theorem affineKernel_residue_slow_quadrature
73
+ (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g)
74
+ (hq : 0 < q) (hqH : ∀ g, q ≤ H g)
75
+ (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) <
76
+ volume.real (scalarCubeDomain Empty))
77
+ (lower : G → ℝ) (step S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step)
78
+ (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S)
79
+ (residueMap : (G → ZMod q) → R) (F : R → (G → ℝ) → ℂ)
80
+ {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r))
81
+ (hbound : ∀ r x, ‖F r x‖ ≤ 1) :
82
+ ‖(FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean
83
+ (fun z => F (residueMap (fun g => ((z g none : ℤ) : ZMod q)))
84
+ (fun g => (lower g + step * (z g none : ℝ)) / S)) -
85
+ 𝔼 r : G → ZMod q, ∫ x,
86
+ F (residueMap r) (affineKernelContinuousPoint lower step S H x)
87
+ ∂scalarCubeProductMeasure G Empty‖ ≤
88
+ (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty /
89
+ volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by
90
+ let p := FiniteProbabilityWeights.pi
91
+ (fun g => integerScalarCubeWeights Empty (H g) (hH g))
92
+ let test := fun r x => F (residueMap r) (affineKernelContinuousPoint lower step S H x)
93
+ have htest (r : G → ZMod q) : LipschitzWith K (test r) := by
94
+ simpa only [test, Function.comp_def, mul_one] using (hF (residueMap r)).comp
95
+ (affineKernelContinuousPoint_lipschitz lower step S H hS hstep hspan)
96
+ have hquad := originalKernel_residue_slow_quadrature_varying H q hH hq hqH
97
+ hsmall test htest (fun r x => hbound _ _)
98
+ have hsum : (∑ g, (1 : ℝ) / H g) ≤ ∑ g, (q : ℝ) / H g := by
99
+ apply Finset.sum_le_sum
100
+ intro g _
101
+ exact div_le_div_of_nonneg_right (by exact_mod_cast hq) (by positivity)
102
+ have hpoint :
103
+ ‖p.complexMean (fun z => F (residueMap (fun g => ((z g none : ℤ) : ZMod q)))
104
+ (fun g => (lower g + step * (z g none : ℝ)) / S)) -
105
+ p.complexMean (fun z => test (fun g => ((z g none : ℤ) : ZMod q))
106
+ (fun g i => (z g i : ℝ) / H g))‖ ≤ (K : ℝ) * ∑ g, (q : ℝ) / H g := by
107
+ apply (p.norm_complexMean_sub_le _ _ (fun _ => (K : ℝ) * ∑ g, (q : ℝ) / H g) ?_).trans_eq
108
+ (p.mean_const _)
109
+ intro z hz
110
+ rw [← dist_eq_norm]
111
+ exact ((hF _).dist_le_mul _ _).trans (mul_le_mul_of_nonneg_left
112
+ ((affineKernelEndpoint_dist_le lower step S H hH hS hstep hspan z hz).trans hsum)
113
+ K.coe_nonneg)
114
+ exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans
115
+ ((add_le_add hpoint hquad).trans_eq (by ring))
116
+
117
+ theorem affineKernel_integer_residue_slow_quadrature
118
+ (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g)
119
+ (hq : 0 < q) (hqH : ∀ g, q ≤ H g)
120
+ (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) <
121
+ volume.real (scalarCubeDomain Empty))
122
+ (start : G → ℤ) (step : ℤ) (S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step)
123
+ (hspan : ∀ g, (step : ℝ) * ((H g - 1 : ℕ) : ℝ) ≤ S)
124
+ (F : (G → ZMod q) → (G → ℝ) → ℂ)
125
+ {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r))
126
+ (hbound : ∀ r x, ‖F r x‖ ≤ 1) :
127
+ ‖(FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean
128
+ (fun z => F (fun g => ((start g + step * (z g none : ℤ) : ℤ) : ZMod q))
129
+ (fun g => ((start g + step * (z g none : ℤ) : ℤ) : ℝ) / S)) -
130
+ 𝔼 r : G → ZMod q, ∫ x,
131
+ F (fun g => (start g : ZMod q) + (step : ZMod q) * r g)
132
+ (fun g => ((start g : ℝ) + (step : ℝ) * ((H g - 1 : ℕ) : ℝ) * x g none) / S)
133
+ ∂scalarCubeProductMeasure G Empty‖ ≤
134
+ (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty /
135
+ volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by
136
+ have h := affineKernel_residue_slow_quadrature H q hH hq hqH hsmall
137
+ (fun g => (start g : ℝ)) (step : ℝ) S hS (by exact_mod_cast hstep) hspan
138
+ (fun r g => (start g : ZMod q) + (step : ZMod q) * r g) F hF hbound
139
+ simp only [Int.cast_add, Int.cast_mul] at ⊢
140
+ convert h using 1
141
+ rfl
142
+
143
+ omit [Fintype G] [DecidableEq G] in
144
+
145
+ theorem affineKernel_span_of_contained
146
+ (H : G → ℕ) (hH : ∀ g, 0 < H g) (start : G → ℤ)
147
+ (step S : ℕ) (hstep : 0 < step)
148
+ (hcontained : ∀ g, integerProgressionSupport (start g) (step : ℤ) (H g) ⊆
149
+ Finset.Ico (0 : ℤ) (S : ℤ)) :
150
+ ∀ g, (step : ℝ) * ((H g - 1 : ℕ) : ℝ) ≤ S := by
151
+ intro g
152
+ have hfirst := hcontained g
153
+ (integerProgressionSupport_point (start g) step (H g) hstep 0 (hH g))
154
+ have hlast := hcontained g
155
+ (integerProgressionSupport_point (start g) step (H g) hstep (H g - 1) (by
156
+ have := hH g
157
+ omega))
158
+ have hc : (0 : ℤ) ≤ start g := by simpa using (Finset.mem_Ico.mp hfirst).1
159
+ have he : start g + (step : ℤ) * ((H g - 1 : ℕ) : ℤ) < S :=
160
+ (Finset.mem_Ico.mp hlast).2
161
+ have hs : (step : ℤ) * ((H g - 1 : ℕ) : ℤ) ≤ S := by omega
162
+ exact_mod_cast hs
163
+
164
+ end Erdos3
165
+
166
+ end
167
+
168
+ section
169
+
170
+ namespace Erdos3
171
+
172
+ open MeasureTheory
173
+ open scoped BigOperators Classical NNReal
174
+
175
+ theorem originalKernel_residue_slow_retained_quadrature_varying
176
+ {G Z : Type*} [Fintype G] [DecidableEq G] [MeasurableSpace Z]
177
+ (μ : Measure Z) [IsProbabilityMeasure μ]
178
+ (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q)
179
+ (hqL : ∀ g, q ≤ L g)
180
+ (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L g) <
181
+ volume.real (scalarCubeDomain Empty))
182
+ (F : Z → (G → ZMod q) → (G → Option Empty → ℝ) → ℂ)
183
+ (hMeas : ∀ r, Measurable (fun zx : Z × (G → Option Empty → ℝ) => F zx.1 r zx.2))
184
+ {K : ℝ≥0} (hLip : ∀ z r, LipschitzWith K (F z r))
185
+ (hbound : ∀ z r x, ‖F z r x‖ ≤ 1) :
186
+ ‖(∫ z, (FiniteProbabilityWeights.pi
187
+ (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean
188
+ (fun y => F z (fun g => ((y g none : ℤ) : ZMod q))
189
+ (fun g i => (y g i : ℝ) / L g)) ∂μ) -
190
+ ∫ z, 𝔼 r : G → ZMod q,
191
+ ∫ x, F z r x ∂scalarCubeProductMeasure G Empty ∂μ‖ ≤
192
+ (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty /
193
+ volume.real (scalarCubeDomain Empty) + K)) *
194
+ (∑ g, (q : ℝ) / L g) := by
195
+ let p := FiniteProbabilityWeights.pi
196
+ (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))
197
+ let a (z : Z) := p.complexMean
198
+ (fun y => F z (fun g => ((y g none : ℤ) : ZMod q))
199
+ (fun g i => (y g i : ℝ) / L g))
200
+ let b (z : Z) := 𝔼 r : G → ZMod q,
201
+ ∫ x, F z r x ∂scalarCubeProductMeasure G Empty
202
+ have haMeas : Measurable a := by
203
+ unfold a FiniteProbabilityWeights.complexMean
204
+ apply Finset.measurable_sum
205
+ intro y _
206
+ exact measurable_const.mul ((hMeas _).comp (measurable_id.prodMk measurable_const))
207
+ have haBound (z : Z) : ‖a z‖ ≤ 1 := by
208
+ apply (p.norm_complexMean_le_mean_norm _).trans
209
+ exact (p.mean_mono (fun y => hbound z _ _)).trans_eq (p.mean_const 1)
210
+ have haInt : Integrable a μ :=
211
+ (integrable_const (1 : ℝ)).mono' haMeas.aestronglyMeasurable (ae_of_all μ haBound)
212
+ have hiMeas (r : G → ZMod q) :
213
+ StronglyMeasurable (fun z => ∫ x, F z r x ∂scalarCubeProductMeasure G Empty) :=
214
+ (hMeas r).stronglyMeasurable.integral_prod_right'
215
+ have hiBound (z : Z) (r : G → ZMod q) :
216
+ ‖∫ x, F z r x ∂scalarCubeProductMeasure G Empty‖ ≤ 1 := by
217
+ simpa only [probReal_univ, mul_one] using
218
+ norm_integral_le_of_norm_le_const
219
+ (ae_of_all (scalarCubeProductMeasure G Empty) (hbound z r))
220
+ have hbMeas : Measurable b := by
221
+ unfold b
222
+ simp only [Fintype.expect_eq_sum_div_card]
223
+ apply Measurable.div_const
224
+ exact Finset.measurable_sum _ (fun r _ => (hiMeas r).measurable)
225
+ have hbBound (z : Z) : ‖b z‖ ≤ 1 := by
226
+ apply (RCLike.norm_expect_le (K := ℂ)).trans
227
+ exact (Finset.expect_le_expect (fun r _ => hiBound z r)).trans_eq (by simp)
228
+ have hbInt : Integrable b μ :=
229
+ (integrable_const (1 : ℝ)).mono' hbMeas.aestronglyMeasurable (ae_of_all μ hbBound)
230
+ change ‖(∫ z, a z ∂μ) - ∫ z, b z ∂μ‖ ≤ _
231
+ rw [← integral_sub haInt hbInt]
232
+ have he := ae_of_all μ (fun z =>
233
+ originalKernel_residue_slow_quadrature_varying L q hL hq hqL hsmall
234
+ (F z) (hLip z) (hbound z))
235
+ simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he
236
+
237
+ end Erdos3
238
+
239
+ end
240
+
241
+ section
242
+
243
+ namespace Erdos3
244
+
245
+ open MeasureTheory
246
+ open scoped BigOperators Classical NNReal
247
+
248
+ theorem affineKernel_residue_slow_retained_quadrature
249
+ {G R Z : Type*} [Fintype G] [DecidableEq G] [MeasurableSpace Z]
250
+ (μ : Measure Z) [IsProbabilityMeasure μ]
251
+ (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g)
252
+ (hq : 0 < q) (hqH : ∀ g, q ≤ H g)
253
+ (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) <
254
+ volume.real (scalarCubeDomain Empty))
255
+ (lower : G → ℝ) (step S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step)
256
+ (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S)
257
+ (residueMap : (G → ZMod q) → R) (F : Z → R → (G → ℝ) → ℂ)
258
+ (hMeas : ∀ r, Measurable (fun zx : Z × (G → ℝ) => F zx.1 r zx.2))
259
+ {K : ℝ≥0} (hLip : ∀ z r, LipschitzWith K (F z r))
260
+ (hbound : ∀ z r x, ‖F z r x‖ ≤ 1) :
261
+ ‖(∫ z, (FiniteProbabilityWeights.pi
262
+ (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean
263
+ (fun y => F z (residueMap (fun g => ((y g none : ℤ) : ZMod q)))
264
+ (fun g => (lower g + step * (y g none : ℝ)) / S)) ∂μ) -
265
+ ∫ z, 𝔼 r : G → ZMod q, ∫ x,
266
+ F z (residueMap r) (affineKernelContinuousPoint lower step S H x)
267
+ ∂scalarCubeProductMeasure G Empty ∂μ‖ ≤
268
+ (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty /
269
+ volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by
270
+ let p := FiniteProbabilityWeights.pi
271
+ (fun g => integerScalarCubeWeights Empty (H g) (hH g))
272
+ let a (z : Z) := p.complexMean
273
+ (fun y => F z (residueMap (fun g => ((y g none : ℤ) : ZMod q)))
274
+ (fun g => (lower g + step * (y g none : ℝ)) / S))
275
+ let b (z : Z) := 𝔼 r : G → ZMod q,
276
+ ∫ x, F z (residueMap r) (affineKernelContinuousPoint lower step S H x)
277
+ ∂scalarCubeProductMeasure G Empty
278
+ have haMeas : Measurable a := by
279
+ unfold a FiniteProbabilityWeights.complexMean
280
+ apply Finset.measurable_sum
281
+ intro y _
282
+ exact measurable_const.mul ((hMeas _).comp (measurable_id.prodMk measurable_const))
283
+ have haBound (z : Z) : ‖a z‖ ≤ 1 := by
284
+ apply (p.norm_complexMean_le_mean_norm _).trans
285
+ exact (p.mean_mono (fun y => hbound z _ _)).trans_eq (p.mean_const 1)
286
+ have haInt : Integrable a μ :=
287
+ (integrable_const (1 : ℝ)).mono' haMeas.aestronglyMeasurable (ae_of_all μ haBound)
288
+ have hAffine : Measurable (affineKernelContinuousPoint lower step S H) :=
289
+ (affineKernelContinuousPoint_lipschitz lower step S H hS hstep hspan).continuous.measurable
290
+ have hiMeas (r : G → ZMod q) :
291
+ StronglyMeasurable (fun z => ∫ x,
292
+ F z (residueMap r) (affineKernelContinuousPoint lower step S H x)
293
+ ∂scalarCubeProductMeasure G Empty) := by
294
+ have hm : Measurable (fun zx : Z × (G → Option Empty → ℝ) =>
295
+ F zx.1 (residueMap r) (affineKernelContinuousPoint lower step S H zx.2)) :=
296
+ (hMeas _).comp (measurable_fst.prodMk (hAffine.comp measurable_snd))
297
+ exact hm.stronglyMeasurable.integral_prod_right'
298
+ have hiBound (z : Z) (r : G → ZMod q) :
299
+ ‖∫ x, F z (residueMap r) (affineKernelContinuousPoint lower step S H x)
300
+ ∂scalarCubeProductMeasure G Empty‖ ≤ 1 := by
301
+ simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const
302
+ (ae_of_all (scalarCubeProductMeasure G Empty) (fun x => hbound z _ _))
303
+ have hbMeas : Measurable b := by
304
+ unfold b
305
+ simp only [Fintype.expect_eq_sum_div_card]
306
+ apply Measurable.div_const
307
+ exact Finset.measurable_sum _ (fun r _ => (hiMeas r).measurable)
308
+ have hbBound (z : Z) : ‖b z‖ ≤ 1 := by
309
+ apply (RCLike.norm_expect_le (K := ℂ)).trans
310
+ exact (Finset.expect_le_expect (fun r _ => hiBound z r)).trans_eq (by simp)
311
+ have hbInt : Integrable b μ :=
312
+ (integrable_const (1 : ℝ)).mono' hbMeas.aestronglyMeasurable (ae_of_all μ hbBound)
313
+ change ‖(∫ z, a z ∂μ) - ∫ z, b z ∂μ‖ ≤ _
314
+ rw [← integral_sub haInt hbInt]
315
+ have he := ae_of_all μ (fun z =>
316
+ affineKernel_residue_slow_quadrature H q hH hq hqH hsmall lower step S hS hstep hspan
317
+ residueMap (F z) (hLip z) (hbound z))
318
+ simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he
319
+
320
+ end Erdos3
321
+
322
+ end
323
+
324
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineLayeredModeReduction.lean ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.SubspaceLayeredModeSmoothRemoval
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.VectorPolynomial
8
+
9
+ noncomputable def liftedIntegerSite {K : Type*} (site : K → ℤ) : Option K → ℤ :=
10
+ fun k => k.elim 1 site
11
+
12
+ theorem liftedIntegerSite_cast {K : Type*} (site : K → ℤ) :
13
+ (fun k => (liftedIntegerSite site k : ℝ)) =
14
+ (fun k : Option K => k.elim 1 (fun k => (site k : ℝ))) := by
15
+ funext k
16
+ cases k <;> simp [liftedIntegerSite]
17
+
18
+ theorem exists_affine_layered_mode_reduction {I K S : Type*}
19
+ [Fintype K] [Fintype S] [DecidableEq S] {m : ℕ}
20
+ {W : Fin m → Type*} [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)]
21
+ (site : S → K → ℤ) (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ)
22
+ (p : ∀ j, VectorPolynomial I ℝ (W j))
23
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
24
+ (hbad : ∃ i, ¬∃ M : (S → W i) →ₗ[ℝ] ℝ,
25
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q =
26
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q))
27
+ (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0)
28
+ (test : S → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) :
29
+ ∃ i, (¬∃ M : (S → W i) →ₗ[ℝ] ℝ,
30
+ ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q =
31
+ M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q)) ∧
32
+ ∃ Q' : MvPolynomial (Option K × I) ℝ, Q'.totalDegree < i.val + 1 ∧
33
+ ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b,
34
+ layeredModeTestedPhase (fun j => affineModeLift (L j)) p Q
35
+ (fun s => liftedIntegerSite (site s)) test b =
36
+ coefficientModeTestedPhase (affineModeLift (L i)) (p i) Q'
37
+ (fun s => liftedIntegerSite (site s)) test' b := by
38
+ obtain ⟨i, hi, hh⟩ := exists_highest_affine_nonfactor (fun s k => (site s k : ℝ)) L hbad
39
+ refine ⟨i, hi, ?_⟩
40
+ apply exists_layered_mode_reduction i (fun j => affineModeLift (L j)) p hp
41
+ (fun s => liftedIntegerSite (site s)) _ Q (hQ.trans_lt (Nat.zero_lt_succ _)) test htest
42
+ have hs : (fun s k => (liftedIntegerSite (site s) k : ℝ)) =
43
+ (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) := by
44
+ funext s k
45
+ exact congrFun (liftedIntegerSite_cast (site s)) k
46
+ rw [hs]
47
+ exact hh
48
+
49
+ end Erdos3.VectorPolynomial
50
+
51
+ end
52
+
53
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineLiftInsertion.lean ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialPatchComposition
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MvPolynomial
10
+
11
+ variable {σ ρ : Type*} {D E s : ℕ}
12
+
13
+ noncomputable def affineLiftSubstitution (c : ρ → ℝ) (M : ρ → Fin D → ℝ) :
14
+ σ ⊕ ρ → MvPolynomial (σ ⊕ Fin D) ℝ :=
15
+ Sum.elim (fun a => X (Sum.inl a))
16
+ (fun a => C (c a) + ∑ j, M a j • X (Sum.inr j))
17
+
18
+ theorem affineLiftSubstitution_degree {p : ρ → ℕ} {w : Fin D → ℕ}
19
+ (c : ρ → ℝ) (M : ρ → Fin D → ℝ)
20
+ (hM : ∀ a j, M a j ≠ 0 → w j ≤ p a) (a : σ ⊕ ρ) :
21
+ affineLiftSubstitution c M a ∈ weightedSupportLE (Sum.elim (fun _ : σ => 1) w)
22
+ (Sum.elim (fun _ : σ => 1) p a) := by
23
+ classical
24
+ cases a with
25
+ | inl a => exact weightedSupportLE_X _ (Sum.inl a)
26
+ | inr a =>
27
+ apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _)
28
+ apply (weightedSupportLE _ _).sum_mem
29
+ intro j _
30
+ by_cases hj : M a j = 0
31
+ · simp only [hj, zero_smul]
32
+ exact (weightedSupportLE _ _).zero_mem
33
+ · exact weightedSupportLE_mono (hM a j hj)
34
+ ((weightedSupportLE _ _).smul_mem (M a j)
35
+ (weightedSupportLE_X (Sum.elim (fun _ : σ => 1) w) (Sum.inr j)))
36
+
37
+ theorem affineLiftSubstitution_eval (c : ρ → ℝ) (M : ρ → Fin D → ℝ)
38
+ (t : σ → ℝ) (x : Fin D → ℝ) (a : σ ⊕ ρ) :
39
+ aeval (Sum.elim t x) (affineLiftSubstitution c M a) =
40
+ Sum.elim t (fun a => c a + ∑ j, M a j * x j) a := by
41
+ cases a <;> simp [affineLiftSubstitution]
42
+
43
+ namespace PolynomialPatch
44
+
45
+ noncomputable def insertAffineLifts {p : ρ → ℕ} (A : PolynomialPatch σ s D)
46
+ (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E)
47
+ (c : ρ → ℝ) (M : ρ → Fin D → ℝ)
48
+ (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a) : PolynomialPatch σ s (D + E) :=
49
+ A.insertLifts (B.reparam (affineLiftSubstitution c M) (affineLiftSubstitution_degree c M hM))
50
+
51
+ @[simp] theorem insertAffineLifts_lip {p : ρ → ℕ} (A : PolynomialPatch σ s D)
52
+ (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E)
53
+ (c : ρ → ℝ) (M : ρ → Fin D → ℝ)
54
+ (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a) :
55
+ (A.insertAffineLifts B c M hM).kernel.lip = A.kernel.lip + B.kernel.lip := rfl
56
+
57
+ theorem insertAffineLifts_value_at_lift {p : ρ → ℕ} (A : PolynomialPatch σ s D)
58
+ (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E)
59
+ (c : ρ → ℝ) (M : ρ → Fin D → ℝ)
60
+ (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a)
61
+ (t : σ → ℝ) (b : Fin D → ℤ)
62
+ (hb : ∀ i, |(A.form.slots t).residual b i| ≤ 1 / 3) :
63
+ (A.insertAffineLifts B c M hM).value t =
64
+ A.kernel.value ((A.form.slots t).residual b) *
65
+ B.value (Sum.elim t (fun a => c a + ∑ j, M a j * (b j : ℝ))) := by
66
+ unfold insertAffineLifts
67
+ rw [insertLifts_value_at_lift _ _ t b hb, WeightedParameterPatch.reparam_value]
68
+ simp only [affineLiftSubstitution_eval]
69
+
70
+ theorem exists_affine_lift_insertion {p : ρ → ℕ} (w : Fin D → ℕ)
71
+ (hw : ∀ i, 1 ≤ w i) (hws : ∀ i, w i ≤ s) (hmono : Monotone w)
72
+ (P : Fin D → MvPolynomial σ ℝ)
73
+ (hP : ∀ i, P i ∈ weightedSupportLE (fun _ : σ => 1) (w i)) (Φ : PatchKernel D)
74
+ (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E)
75
+ (c : ρ → ℝ) (M : ρ → Fin D → ℝ) (hM : ∀ a j, M a j ≠ 0 → w j ≤ p a) :
76
+ ∃ Q : PolynomialPatch σ s (D + E), Q.kernel.lip = Φ.lip + B.kernel.lip ∧
77
+ ∀ (t : σ → ℝ) (b : Fin D → ℤ),
78
+ (∀ i, |(b i : ℝ) - aeval t (P i)| ≤ 1 / 3) →
79
+ Q.value t = Φ.value (fun i => (b i : ℝ) - aeval t (P i)) *
80
+ B.value (Sum.elim t (fun a => c a + ∑ j, M a j * (b j : ℝ))) := by
81
+ let A := ofCoordinates w hw hws hmono P hP Φ
82
+ refine ⟨A.insertAffineLifts B c M hM, rfl, ?_⟩
83
+ intro t b hb
84
+ have hres : (A.form.slots t).residual b = fun i => (b i : ℝ) - aeval t (P i) :=
85
+ ofCoordinates_residual w hw hws hmono P hP Φ t b
86
+ rw [insertAffineLifts_value_at_lift A B c M hM t b (by simpa only [hres] using hb), hres]
87
+ rfl
88
+
89
+ end PolynomialPatch
90
+ end Erdos3
91
+
92
+ end
93
+
94
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineLowestLayer.lean ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.DependentPatchValue
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ namespace TriangularSlots
10
+
11
+ variable {D : ℕ}
12
+
13
+ noncomputable def affineBlock (M : Matrix (Fin D) (Fin D) ℝ)
14
+ (hM : ∀ i j, i ≤ j → M i j = 0) (P : Fin D → ℝ) : TriangularSlots D where
15
+ center x := P + M.mulVec (x - P)
16
+ lower i x y hxy := by
17
+ simp only [Pi.add_apply, Matrix.mulVec, dotProduct]
18
+ congr 1
19
+ apply Finset.sum_congr rfl
20
+ intro j _
21
+ by_cases hji : j < i
22
+ · simp only [Pi.sub_apply, hxy j hji]
23
+ · simp [hM i j (le_of_not_gt hji)]
24
+
25
+ theorem affineBlock_residual (M : Matrix (Fin D) (Fin D) ℝ)
26
+ (hM : ∀ i j, i ≤ j → M i j = 0) (P : Fin D → ℝ) (b : Fin D → ℤ) :
27
+ (affineBlock M hM P).residual b = (1 - M).mulVec ((fun i => (b i : ℝ)) - P) := by
28
+ rw [Matrix.sub_mulVec, Matrix.one_mulVec]
29
+ ext i
30
+ simp only [residual, affineBlock, Pi.sub_apply, Pi.add_apply]
31
+ ring
32
+
33
+ end TriangularSlots
34
+
35
+ def shiftedIntegerBlock {T : Type*} {D : ℕ} (I : T → Fin D → ℤ)
36
+ (t₀ : T) (b₀ : Fin D → ℤ) (t : T) : Fin D → ℤ := b₀ + I t - I t₀
37
+
38
+ @[simp] theorem shiftedIntegerBlock_at_base {T : Type*} {D : ℕ}
39
+ (I : T → Fin D → ℤ) (t₀ : T) (b₀ : Fin D → ℤ) :
40
+ shiftedIntegerBlock I t₀ b₀ t₀ = b₀ := by simp [shiftedIntegerBlock]
41
+
42
+ theorem affine_residual_shift_identity {T : Type*} {D : ℕ}
43
+ (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0)
44
+ (P : T → Fin D → ℝ) (I : T → Fin D → ℤ) (t₀ t : T) (b₀ : Fin D → ℤ) :
45
+ (TriangularSlots.affineBlock M hM (P t)).residual (shiftedIntegerBlock I t₀ b₀ t) -
46
+ (TriangularSlots.affineBlock M hM (P t₀)).residual b₀ =
47
+ -(1 - M).mulVec ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ))) := by
48
+ rw [TriangularSlots.affineBlock_residual, TriangularSlots.affineBlock_residual,
49
+ ← Matrix.mulVec_sub, ← Matrix.mulVec_neg]
50
+ congr 1
51
+ ext i
52
+ simp only [shiftedIntegerBlock, Pi.add_apply, Pi.sub_apply, Pi.neg_apply, Int.cast_sub, Int.cast_add]
53
+ ring
54
+
55
+ theorem affine_residual_shift_dist {T : Type*} {D : ℕ}
56
+ (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0)
57
+ (P : T → Fin D → ℝ) (I : T → Fin D → ℤ) (t₀ t : T) (b₀ : Fin D → ℤ) :
58
+ dist ((TriangularSlots.affineBlock M hM (P t)).residual (shiftedIntegerBlock I t₀ b₀ t))
59
+ ((TriangularSlots.affineBlock M hM (P t₀)).residual b₀) =
60
+ ‖(1 - M).mulVec ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ)))‖ := by
61
+ rw [dist_eq_norm, affine_residual_shift_identity, norm_neg]
62
+
63
+ theorem freeze_affine_lowest_layer {T : Type*} {D E : ℕ}
64
+ (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0)
65
+ (P : T → Fin D → ℝ) (I : T → Fin D → ℤ)
66
+ (B : T → (Fin D → ℝ) → TriangularSlots E) (Φ : PatchKernel (D + E))
67
+ (t₀ : T) (b₀ : Fin D → ℤ) {ε : ℝ}
68
+ (hbase : ∀ i, |(TriangularSlots.affineBlock M hM (P t₀)).residual b₀ i| ≤ 1 / 4)
69
+ (hε : ε < 1 / 12)
70
+ (hosc : ∀ t, ‖(1 - M).mulVec
71
+ ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ)))‖ ≤ ε) :
72
+ ∀ t, dist (((TriangularSlots.affineBlock M hM (P t)).append (B t)).patchValue Φ)
73
+ ((B t (fun i => (shiftedIntegerBlock I t₀ b₀ t i : ℝ))).patchValue
74
+ (Φ.freeze ((TriangularSlots.affineBlock M hM (P t₀)).residual b₀))) ≤ Φ.lip * ε := by
75
+ intro t
76
+ apply TriangularSlots.patchValue_freeze_prefix _ _ Φ _ _ hbase hε
77
+ rw [affine_residual_shift_dist]
78
+ exact hosc t
79
+
80
+ end Erdos3
81
+
82
+ end
83
+
84
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineMaskedInitialShell.lean ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.InitialConditioningBudget
2
+ import OAI.Combinatorics.Progressions.Geometry.OutsideProductTransport
3
+ import OAI.Combinatorics.Progressions.Lattices.ResidueCellNormLengths
4
+ import OAI.Combinatorics.Progressions.Lattices.RetainedPhysicalCRT
5
+
6
+ namespace OAI
7
+
8
+ section
9
+
10
+ namespace Erdos3
11
+
12
+ open scoped BigOperators Classical
13
+
14
+ variable {ι σ : Type*} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ]
15
+ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ)
16
+ (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a))
17
+ (q : ι → ℕ) [∀ i, NeZero (q i)]
18
+ (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
19
+ (K : Finset ι) (base : ∀ i, σ → ZMod (q i))
20
+ (u : ResiduePrimeCoordinateCell lo N M a q K base)
21
+
22
+ include hpair u
23
+
24
+ theorem residuePrimeCoordinateDensity_fixed (f : (σ → ℤ) → ℝ)
25
+ (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) :
26
+ residuePrimeCoordinateDensity lo N M a hne q f x =
27
+ residuePrimeCoordinateMassRatio lo N M a q K base *
28
+ residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by
29
+ have hcover : K ∪ (Finset.univ : Finset {i // i ∉ K}).image Subtype.val = Finset.univ := by
30
+ ext i
31
+ by_cases hi : i ∈ K
32
+ · simp [hi]
33
+ · simp only [Finset.mem_union, hi, false_or, Finset.mem_image, Finset.mem_univ, iff_true]
34
+ exact ⟨⟨i, hi⟩, trivial, rfl⟩
35
+ have h := residuePrimeCoordinateDensity_conditional_outside lo N M a hne q hpair K base u f
36
+ (Finset.univ : Finset {i // i ∉ K}) x hx
37
+ rw [hcover, productConditionalMean_univ, productConditionalMean_univ] at h
38
+ rw [residueCellOutsideDensity_lcm lo N M a q hpair K base u f]
39
+ exact h
40
+
41
+ theorem residuePrimeCoordinateDensity_section (f : (σ → ℤ) → ℝ) (x : ∀ i, σ → ZMod (q i)) :
42
+ productSectionAverage (primeCoordinateReference (σ := σ) q) K K base
43
+ (residuePrimeCoordinateDensity lo N M a hne q f) x =
44
+ residuePrimeCoordinateMassRatio lo N M a q K base *
45
+ residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by
46
+ have hx : ∀ i ∈ K, productCoordinateMix K base x i = base i := by
47
+ intro i hi
48
+ simp only [productCoordinateMix, hi, ite_true]
49
+ have hout : (fun i : {i // i ∉ K} => productCoordinateMix K base x i.val) = (fun i : {i // i ∉ K} => x i.val) := by
50
+ funext i
51
+ simp only [productCoordinateMix, i.property, ite_false]
52
+ rw [productSectionAverage_eq_conditionalMean _ K K (Finset.Subset.refl K)]
53
+ simp only [Finset.union_compl, productConditionalMean_univ]
54
+ rw [residuePrimeCoordinateDensity_fixed lo N M a hne q hpair K base u f _ hx, hout]
55
+
56
+ omit hne hpair in
57
+ theorem residuePrimeCoordinateMassRatio_pos : 0 < residuePrimeCoordinateMassRatio lo N M a q K base := by
58
+ let : Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) := ⟨u⟩
59
+ let : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := ⟨u.val⟩
60
+ have hp : 0 < ∏ i ∈ K, q i := Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i)))
61
+ rw [residuePrimeCoordinateMassRatio_eq_count]
62
+ positivity
63
+
64
+ theorem residuePrimeCoordinateDensity_normalized_section (f : (σ → ℤ) → ℝ)
65
+ (x : ∀ i, σ → ZMod (q i)) :
66
+ (residuePrimeCoordinateMassRatio lo N M a q K base)⁻¹ *
67
+ productSectionAverage (primeCoordinateReference (σ := σ) q) K K base
68
+ (residuePrimeCoordinateDensity lo N M a hne q f) x =
69
+ residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by
70
+ rw [residuePrimeCoordinateDensity_section lo N M a hne q hpair K base u f x,
71
+ ← mul_assoc, inv_mul_cancel₀ (residuePrimeCoordinateMassRatio_pos lo N M a q K base u).ne', one_mul]
72
+
73
+ end Erdos3
74
+
75
+ end
76
+
77
+ section
78
+
79
+ namespace Erdos3
80
+
81
+ open scoped BigOperators Classical
82
+
83
+ theorem residuePrimeCoordinateMassRatio_le_prime_product {ι σ : Type*}
84
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ]
85
+ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)]
86
+ (K : Finset ι) (base : ∀ i, σ → ZMod (q i))
87
+ (u : ResiduePrimeCoordinateCell lo N M a q K base) :
88
+ residuePrimeCoordinateMassRatio lo N M a q K base ≤ ((∏ i ∈ K, q i : ℕ) : ℝ) ^ Fintype.card σ := by
89
+ let : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := ⟨u.val⟩
90
+ have hB : (0 : ℝ) < Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := by
91
+ exact_mod_cast Fintype.card_pos
92
+ have hcard : (Fintype.card (ResiduePrimeCoordinateCell lo N M a q K base) : ℝ) ≤
93
+ Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) :=
94
+ Nat.cast_le.mpr (Fintype.card_subtype_le _)
95
+ have hratio : (Fintype.card (ResiduePrimeCoordinateCell lo N M a q K base) : ℝ) /
96
+ Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) ≤ 1 := by
97
+ apply (div_le_iff₀ hB).mpr
98
+ simpa only [one_mul] using hcard
99
+ rw [residuePrimeCoordinateMassRatio_eq_count, mul_div_assoc]
100
+ exact mul_le_of_le_one_right (by positivity) hratio
101
+
102
+ theorem residuePrimeCoordinateMassRatio_le_exp {ι σ : Type*}
103
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ]
104
+ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)]
105
+ (K : Finset ι) (base : ∀ i, σ → ZMod (q i))
106
+ (u : ResiduePrimeCoordinateCell lo N M a q K base) (modLog : ℝ)
107
+ (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) :
108
+ residuePrimeCoordinateMassRatio lo N M a q K base ≤
109
+ Real.exp ((K.card : ℝ) * Fintype.card σ * modLog) := by
110
+ have hprod := primeCoordinateProduct_le_exp q K modLog hmoduli
111
+ calc
112
+ _ ≤ ((∏ i ∈ K, q i : ℕ) : ℝ) ^ Fintype.card σ :=
113
+ residuePrimeCoordinateMassRatio_le_prime_product lo N M a q K base u
114
+ _ ≤ (Real.exp (modLog * K.card)) ^ Fintype.card σ :=
115
+ pow_le_pow_left₀ (Nat.cast_nonneg _) hprod _
116
+ _ = _ := by
117
+ rw [← Real.exp_nat_mul]
118
+ congr 1
119
+ ring
120
+
121
+ end Erdos3
122
+
123
+ end
124
+
125
+ section
126
+
127
+ namespace Erdos3
128
+
129
+ open scoped BigOperators Classical
130
+
131
+ theorem residuePrimeCoordinateDensity_section_norm {ι σ : Type*}
132
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ]
133
+ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ)
134
+ (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a))
135
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
136
+ (K : Finset ι) (base : ∀ i, σ → ZMod (q i))
137
+ (u : ResiduePrimeCoordinateCell lo N M a q K base) (f : (σ → ℤ) → ℝ) (B : ℕ) :
138
+ Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) q) (lowDegreeCoordinateSets ι B)
139
+ (productSectionAverage (primeCoordinateReference (σ := σ) q) K K base
140
+ (residuePrimeCoordinateDensity lo N M a hne q f))) =
141
+ residuePrimeCoordinateMassRatio lo N M a q K base *
142
+ Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val))
143
+ (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity lo N M a q K base u f)) := by
144
+ have hs := funext (residuePrimeCoordinateDensity_section lo N M a hne q hpair K base u f)
145
+ rw [hs, sqrt_productANOVAEnergy_smul,
146
+ productANOVAEnergy_outside (primeCoordinateReference (σ := σ) q) K base B,
147
+ abs_of_nonneg (residuePrimeCoordinateMassRatio_pos lo N M a q K base u).le]
148
+ rfl
149
+
150
+ end Erdos3
151
+
152
+ end
153
+
154
+ section
155
+
156
+ namespace Erdos3
157
+
158
+ open scoped BigOperators Classical
159
+
160
+ theorem residueSectionPairing_core {ι σ τ : Type*}
161
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ]
162
+ (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ)
163
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
164
+ (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ)
165
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
166
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
167
+ (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i))
168
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
169
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
170
+ (c : ∀ i, FiniteProbabilityCoupling (primeCoordinateReference (σ := σ) q i) (primeCoordinateReference (σ := τ) q i))
171
+ (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) :
172
+ productTruncatedPairing c (conditioningCoreSupports K B)
173
+ (productSectionAverage (primeCoordinateReference (σ := σ) q) K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w))
174
+ (productSectionAverage (primeCoordinateReference (σ := τ) q) K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f)) =
175
+ residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
176
+ productTruncatedPairing (fun i : {i // i ∉ K} => c i.val)
177
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
178
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
179
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f) := by
180
+ have hx := funext (residuePrimeCoordinateDensity_section loX NX MX aX hneX q hpair K baseX uX w)
181
+ have hy := funext (residuePrimeCoordinateDensity_section loY NY MY aY hneY q hpair K baseY uY f)
182
+ rw [hx, hy, productTruncatedPairing_smul, productTruncatedPairing_outside_core c K baseX baseY B]
183
+
184
+ end Erdos3
185
+
186
+ end
187
+
188
+ section
189
+
190
+ namespace Erdos3
191
+
192
+ open scoped BigOperators Classical
193
+
194
+ theorem residue_initial_conditioning_shell {ι σ τ : Type*}
195
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ]
196
+ (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ)
197
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
198
+ (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ)
199
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
200
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
201
+ (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i))
202
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
203
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
204
+ (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ → ZMod (q i)))
205
+ (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i)
206
+ (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 →
207
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤
208
+ C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2))
209
+ (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ),
210
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) =
211
+ (primeCoordinateReference (σ := τ) q i).mean f)
212
+ (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) (hKB : K.card ≤ B)
213
+ {κ sourceNorm siteNorm : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2)
214
+ (hsourceNorm : Real.sqrt (productANOVAEnergy
215
+ (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val))
216
+ (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity loX NX MX aX q K baseX uX w)) ≤ sourceNorm)
217
+ (hsiteNorm : Real.sqrt (productANOVAEnergy
218
+ (primeCoordinateReference (σ := τ) (fun i : {i // i ∉ K} => q i.val))
219
+ (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity loY NY MY aY q K baseY uY f)) ≤ siteNorm) :
220
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i)
221
+ (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i)
222
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
223
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
224
+ productCouplingAtomMass c K baseX baseY *
225
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
226
+ productTruncatedPairing (fun i : {i // i ∉ K} => c i.val)
227
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
228
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
229
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤
230
+ (2 : ℝ) ^ K.card * (κ ^ (B - K.card) *
231
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * sourceNorm) *
232
+ (residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * siteNorm)) := by
233
+ let μ := primeCoordinateReference (σ := σ) q
234
+ let ν := primeCoordinateReference (σ := τ) q
235
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (kernel i) (hmean i)
236
+ have hx : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι B)
237
+ (productSectionAverage μ K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w))) ≤
238
+ residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * sourceNorm := by
239
+ rw [residuePrimeCoordinateDensity_section_norm loX NX MX aX hneX q hpair K baseX uX w B]
240
+ exact mul_le_mul_of_nonneg_left hsourceNorm (residuePrimeCoordinateMassRatio_pos loX NX MX aX q K baseX uX).le
241
+ have hy : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι B)
242
+ (productSectionAverage ν K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f))) ≤
243
+ residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * siteNorm := by
244
+ rw [residuePrimeCoordinateDensity_section_norm loY NY MY aY hneY q hpair K baseY uY f B]
245
+ exact mul_le_mul_of_nonneg_left hsiteNorm (residuePrimeCoordinateMassRatio_pos loY NY MY aY q K baseY uY).le
246
+ have hshell := productKernel_conditioning_shell_of_truncated μ ν kernel C hC hbound hmean K B hKB
247
+ hκ0 hκ1 hcap baseX baseY
248
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) hx hy
249
+ change |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
250
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
251
+ productCouplingAtomMass c K baseX baseY * productTruncatedPairing c (conditioningCoreSupports K B)
252
+ (productSectionAverage μ K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w))
253
+ (productSectionAverage ν K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f))| ≤ _ at hshell
254
+ 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
255
+ exact hshell
256
+
257
+ end Erdos3
258
+
259
+ end
260
+
261
+ section
262
+
263
+ namespace Erdos3
264
+
265
+ open scoped BigOperators Classical
266
+
267
+ theorem residue_initial_conditioning_shell_of_lengths {ι σ τ : Type*}
268
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ]
269
+ (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ)
270
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
271
+ (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ)
272
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
273
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
274
+ (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i))
275
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
276
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
277
+ (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ → ZMod (q i)))
278
+ (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i)
279
+ (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 →
280
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤
281
+ C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2))
282
+ (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ),
283
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) =
284
+ (primeCoordinateReference (σ := τ) q i).mean f)
285
+ (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) (hKB : K.card ≤ B)
286
+ {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2)
287
+ (hMX : 0 < MX) (hMY : 0 < MY)
288
+ (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i))
289
+ (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX,
290
+ 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1)
291
+ (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY,
292
+ 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1)
293
+ (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog)
294
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P)
295
+ (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog)
296
+ (hdimX : (Fintype.card σ : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card τ : ℝ) ≤ Real.exp dimY)
297
+ (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤
298
+ (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ))
299
+ (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤
300
+ (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ)) :
301
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i)
302
+ (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i)
303
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
304
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
305
+ productCouplingAtomMass c K baseX baseY *
306
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
307
+ productTruncatedPairing (fun i : {i // i ∉ K} => c i.val)
308
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
309
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
310
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤
311
+ (2 : ℝ) ^ K.card * (κ ^ (B - K.card) *
312
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * 3) *
313
+ (residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * 3)) := by
314
+ have hx := residueCellOutsideDensity_norm_of_lengths (ι := ι) (σ := σ)
315
+ loX NX MX aX q hMX hpair K baseX hcopX uX w hw B P modLog dimX hP hmodLog hcount hmoduli hdimX hlengthX
316
+ have hy := residueCellOutsideDensity_norm_of_lengths (ι := ι) (σ := τ)
317
+ loY NY MY aY q hMY hpair K baseY hcopY uY f hf B P modLog dimY hP hmodLog hcount hmoduli hdimY hlengthY
318
+ exact residue_initial_conditioning_shell loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY
319
+ kernel C hC hbound hmean w f B hKB hκ0 hκ1 hcap hx hy
320
+
321
+ end Erdos3
322
+
323
+ end
324
+
325
+ section
326
+
327
+ namespace Erdos3
328
+
329
+ open scoped BigOperators Classical
330
+
331
+ theorem residue_initial_conditioning_shell_small {ι σ τ : Type*}
332
+ [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ]
333
+ (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ)
334
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
335
+ (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ)
336
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
337
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
338
+ (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i))
339
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
340
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
341
+ (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ ��� ZMod (q i)))
342
+ (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i)
343
+ (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 →
344
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤
345
+ C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2))
346
+ (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ),
347
+ (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) =
348
+ (primeCoordinateReference (σ := τ) q i).mean f)
349
+ (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ)
350
+ {κ : ℝ} (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2)
351
+ (hMX : 0 < MX) (hMY : 0 < MY)
352
+ (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i))
353
+ (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX,
354
+ 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1)
355
+ (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY,
356
+ 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1)
357
+ (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog)
358
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P)
359
+ (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog)
360
+ (hdimX : (Fintype.card σ : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card τ : ℝ) ≤ Real.exp dimY)
361
+ (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤
362
+ (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ))
363
+ (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤
364
+ (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ))
365
+ (shell : ℝ) (hshell : 0 < shell)
366
+ (hB : K.card + CyclicCrootSisask.spectralIterations shell
367
+ ((K.card : ℝ) * ((Fintype.card σ : ℝ) * modLog + (Fintype.card τ : ℝ) * modLog + 1) + 4) ≤ B) :
368
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i)
369
+ (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i)
370
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
371
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
372
+ productCouplingAtomMass c K baseX baseY *
373
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
374
+ productTruncatedPairing (fun i : {i // i ∉ K} => c i.val)
375
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
376
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
377
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by
378
+ have hsmallX : residuePrimeCoordinateMassRatio loX NX MX aX q K baseX ≤
379
+ Real.exp ((K.card : ℝ) * ((Fintype.card σ : ℝ) * modLog)) := by
380
+ simpa only [mul_assoc] using residuePrimeCoordinateMassRatio_le_exp loX NX MX aX q K baseX uX modLog hmoduli
381
+ have hsmallY : residuePrimeCoordinateMassRatio loY NY MY aY q K baseY ≤
382
+ Real.exp ((K.card : ℝ) * ((Fintype.card τ : ℝ) * modLog)) := by
383
+ simpa only [mul_assoc] using residuePrimeCoordinateMassRatio_le_exp loY NY MY aY q K baseY uY modLog hmoduli
384
+ have hbudget := initial_conditioning_error_small K.card B
385
+ (residuePrimeCoordinateMassRatio_pos loX NX MX aX q K baseX uX).le
386
+ (residuePrimeCoordinateMassRatio_pos loY NY MY aY q K baseY uY).le
387
+ hsmallX hsmallY hκ0 hκhalf hshell hB
388
+ have hresult := residue_initial_conditioning_shell_of_lengths
389
+ loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY kernel C hC hbound hmean
390
+ w f B (by omega) hκ0 (by linarith) hcap hMX hMY hcopX hcopY hw hf P modLog dimX dimY hP hmodLog
391
+ hcount (fun i _ => hmoduli i) hdimX hdimY hlengthX hlengthY
392
+ exact hresult.trans hbudget
393
+
394
+ end Erdos3
395
+
396
+ end
397
+
398
+ section
399
+
400
+ namespace Erdos3
401
+
402
+ open scoped BigOperators Classical
403
+
404
+ theorem affine_period_initial_conditioning_shell_small {ι J σ : Type*}
405
+ [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ]
406
+ (loX : (Option J × σ) → ℤ) (NX : (Option J × σ) → ℕ) (MX : ℕ) (aX : (Option J × σ) → ℤ)
407
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
408
+ (loY : σ → ℤ) (NY : σ → ℕ) (MY : ℕ) (aY : σ → ℤ)
409
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
410
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k)))
411
+ (K : Finset ι) (baseX : ∀ i, (Option J × σ) → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i))
412
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
413
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
414
+ (D : ℕ) (a : J → ℤ) (hDcop : ∀ i ∉ K, D.Coprime (q i))
415
+ (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime)
416
+ (hpower : ∀ i, q i = prime i ^ power i) (hJ : 2 ≤ Fintype.card J)
417
+ (w : ((Option J × σ) → ℤ) → ℝ) (f : (σ → ℤ) → ℝ) (B : ℕ)
418
+ {κ : ℝ} (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hlarge : ∀ i ∉ K, (prime i : ℝ)⁻¹ ≤ κ)
419
+ (hMX : 0 < MX) (hMY : 0 < MY)
420
+ (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i))
421
+ (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX,
422
+ 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1)
423
+ (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY,
424
+ 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1)
425
+ (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog)
426
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P)
427
+ (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog)
428
+ (hdimX : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card σ : ℝ) ≤ Real.exp dimY)
429
+ (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤
430
+ (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ))
431
+ (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤
432
+ (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ))
433
+ (shell : ℝ) (hshell : 0 < shell)
434
+ (hB : K.card + CyclicCrootSisask.spectralIterations shell
435
+ ((K.card : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B) :
436
+ let c := affinePeriodProductCoupling (σ := σ) q D a
437
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
438
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
439
+ productCouplingAtomMass c K baseX baseY *
440
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
441
+ affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val)
442
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
443
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
444
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by
445
+ let kernel := fun i => affineSampleParameterKernel (I := σ) (affinePeriodParameterLaw (q := q i) D a)
446
+ let C := fun i => if i ∈ K then (1 : ℝ) else κ ^ 2
447
+ have hC (i : ι) : 0 ≤ C i := by
448
+ dsimp only [C]
449
+ split_ifs <;> positivity
450
+ have hbound := affinePeriodParameterKernel_centered_sq (σ := σ) q D a K prime power
451
+ hprime hpower hDcop hκ0 hJ hlarge
452
+ have hmean := fun i => affineSampleParameterKernel_preserves_mean (I := σ)
453
+ (affinePeriodParameterLaw (q := q i) D a)
454
+ have hcap (i : ι) (hi : i ∉ K) : C i ≤ κ ^ 2 := by simp only [C, ite_eq_right hi, le_refl]
455
+ have hresult := residue_initial_conditioning_shell_small
456
+ loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY
457
+ kernel C hC hbound hmean w f B hκ0 hκhalf hcap hMX hMY hcopX hcopY hw hf
458
+ P modLog dimX dimY hP hmodLog hcount hmoduli hdimX hdimY hlengthX hlengthY shell hshell hB
459
+ change
460
+ |productAtomTruncatedPairing (affinePeriodProductCoupling (σ := σ) q D a) (lowDegreeCoordinateSets ι B) K baseX baseY
461
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
462
+ productCouplingAtomMass (affinePeriodProductCoupling (σ := σ) q D a) K baseX baseY *
463
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
464
+ productTruncatedPairing (fun i : {i // i ∉ K} => affinePeriodProductCoupling (σ := σ) q D a i.val)
465
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
466
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
467
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 at hresult
468
+ rw [affinePeriodProductCoupling_outside q D a K hDcop] at hresult
469
+ exact hresult
470
+
471
+ end Erdos3
472
+
473
+ end
474
+
475
+ section
476
+
477
+ namespace Erdos3
478
+
479
+ open scoped BigOperators Classical
480
+
481
+ theorem affine_masked_initial_conditioning_shell_small {ι J σ : Type*}
482
+ [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ]
483
+ (loX : (Option J × σ) → ℤ) (NX : (Option J × σ) → ℕ) (MX : ℕ) (aX : (Option J × σ) → ℤ)
484
+ (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX))
485
+ (loY : σ → ℤ) (NY : σ → ℕ) (MY : ℕ) (aY : σ → ℤ)
486
+ (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY))
487
+ (q : ι → ℕ) [∀ i, NeZero (q i)]
488
+ (K : Finset ι) (baseX : ∀ i, (Option J × σ) → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i))
489
+ (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX)
490
+ (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY)
491
+ (D : ℕ) (a : J → ���)
492
+ (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime)
493
+ (hpower : ∀ i, q i = prime i ^ power i) (hinj : Function.Injective prime) (hJ : 2 ≤ Fintype.card J)
494
+ (w : ((Option J × σ) → ℤ) → ℝ) (f : (σ → ℤ) → ℝ) (B : ℕ)
495
+ (hMX : 0 < MX) (hMY : 0 < MY)
496
+ (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX,
497
+ 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1)
498
+ (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY,
499
+ 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1)
500
+ (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog)
501
+ (ξ : ℝ) (hξ : 0 < ξ) (hmask : affineSamplerPrimeMask prime ξ P MX MY D ⊆ K)
502
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P)
503
+ (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog)
504
+ (hdimX : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card σ : ℝ) ≤ Real.exp dimY)
505
+ (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤
506
+ (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ))
507
+ (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤
508
+ (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ))
509
+ (shell : ℝ) (hshell : 0 < shell)
510
+ (hB : K.card + CyclicCrootSisask.spectralIterations shell
511
+ ((K.card : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B) :
512
+ let c := affinePeriodProductCoupling (σ := σ) q D a
513
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY
514
+ (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) -
515
+ productCouplingAtomMass c K baseX baseY *
516
+ (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY *
517
+ affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val)
518
+ (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card))
519
+ (residueCellOutsideDensity loX NX MX aX q K baseX uX w)
520
+ (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by
521
+ have hpair : Pairwise (fun i k => (q i).Coprime (q k)) := by
522
+ intro i k hik
523
+ rw [hpower i, hpower k]
524
+ exact selectedPrimePowers_pairwise_coprime prime power hprime hinj hik
525
+ have houtside := affineSamplerPrimeMask_outside prime power hprime hP K hmask
526
+ have hcopX (i : ι) (hi : i ∉ K) : MX.Coprime (q i) := by
527
+ rw [hpower i]
528
+ exact (houtside i hi).1
529
+ have hcopY (i : ι) (hi : i ∉ K) : MY.Coprime (q i) := by
530
+ rw [hpower i]
531
+ exact (houtside i hi).2.1
532
+ have hDcop (i : ι) (hi : i ∉ K) : D.Coprime (q i) := by
533
+ rw [hpower i]
534
+ exact (houtside i hi).2.2.1
535
+ have hlarge (i : ι) (hi : i ∉ K) : (prime i : ℝ)⁻¹ ≤ affineComparisonContraction ξ P :=
536
+ (houtside i hi).2.2.2
537
+ have hκ := affineComparisonContraction_bounds hξ hP
538
+ exact affine_period_initial_conditioning_shell_small
539
+ loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY
540
+ D a hDcop prime power hprime hpower hJ w f B hκ.1.le hκ.2.1 hlarge
541
+ hMX hMY hcopX hcopY hw hf P modLog dimX dimY hP hmodLog hcount hmoduli
542
+ hdimX hdimY hlengthX hlengthY shell hshell hB
543
+
544
+ end Erdos3
545
+
546
+ end
547
+
548
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshRetention.lean ADDED
@@ -0,0 +1,646 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.PhysicalBoundaryLabels
2
+ import OAI.Combinatorics.Progressions.Estimates.RealFiniteZeroExtension
3
+ import OAI.Combinatorics.Progressions.Estimates.WeightedSmoothSampledError
4
+ import OAI.Combinatorics.Progressions.Probability.LargeDivisorPairProbability
5
+ import OAI.Combinatorics.Progressions.Probability.RelativeFullSliceLaw
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3
12
+
13
+ open scoped BigOperators Classical
14
+
15
+ theorem interval_event_probability (a b : ℤ) (hab : a < b) (E : ℤ → Prop)
16
+ [DecidablePred E] :
17
+ (intervalUniformWeights a b hab).eventProbability (fun x => E (x : ℤ)) =
18
+ ((Finset.filter E (Finset.Ico a b)).card : ℝ) / ((b - a : ℤ) : ℝ) := by
19
+ unfold FiniteProbabilityWeights.eventProbability
20
+ rw [intervalUniformWeights_mean]
21
+ convert integerInterval_indicator_expect a b hab.le E using 1
22
+ congr 1
23
+ funext x
24
+ split_ifs <;> rfl
25
+
26
+ theorem interval_near_probability (a b v : ℤ) (hab : a < b) (r : ℕ) :
27
+ (intervalUniformWeights a b hab).eventProbability (fun x => |(x : ℤ) - v| ≤ (r : ℤ)) ≤
28
+ (2 * (r : ℝ) + 1) / ((b - a : ℤ) : ℝ) := by
29
+ rw [interval_event_probability a b hab (fun x => |x - v| ≤ (r : ℤ))]
30
+ have hsub : (Finset.filter (fun x => |x - v| ≤ (r : ℤ)) (Finset.Ico a b)) ⊆
31
+ Finset.Icc (v - (r : ℤ)) (v + (r : ℤ)) := by
32
+ intro x hx
33
+ have h := abs_le.mp (Finset.mem_filter.mp hx).2
34
+ exact Finset.mem_Icc.mpr ⟨by omega, by omega⟩
35
+ have he : (Finset.Icc (v - (r : ℤ)) (v + (r : ℤ))).card = 2 * r + 1 := by
36
+ rw [Int.card_Icc]
37
+ omega
38
+ have hc : ((Finset.filter (fun x => |x - v| ≤ (r : ℤ)) (Finset.Ico a b)).card : ℝ) ≤
39
+ 2 * (r : ℝ) + 1 := by
40
+ have h := Finset.card_le_card hsub
41
+ rw [he] at h
42
+ exact_mod_cast h
43
+ exact div_le_div_of_nonneg_right hc (by exact_mod_cast (sub_pos.mpr hab).le)
44
+
45
+ theorem integer_box_near_probability {J : Type*} [Fintype J] [DecidableEq J]
46
+ (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) (v : J → ℤ) (r : ℕ) :
47
+ (integerBoxUniformWeights lo hi hlen).eventProbability
48
+ (fun y => ∀ j, |(y j : ℤ) - v j| ≤ (r : ℤ)) ≤
49
+ ∏ j, (2 * (r : ℝ) + 1) / ((hi j - lo j : ℤ) : ℝ) := by
50
+ rw [integerBoxUniformWeights, FiniteProbabilityWeights.eventProbability_pi
51
+ (fun j => intervalUniformWeights (lo j) (hi j) (hlen j))
52
+ (fun j (y : Finset.Ico (lo j) (hi j)) => |(y : ℤ) - v j| ≤ (r : ℤ))]
53
+ apply Finset.prod_le_prod₀
54
+ · intro j _
55
+ exact FiniteProbabilityWeights.eventProbability_nonneg _ _
56
+ · intro j _
57
+ exact interval_near_probability (lo j) (hi j) (v j) (hlen j) r
58
+
59
+ theorem integer_box_pair_near_probability {J : Type*} [Fintype J] [DecidableEq J]
60
+ (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) (r : ℕ) :
61
+ ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability
62
+ (fun xy => ∀ j, |(xy.2 j : ℤ) - (xy.1 j : ℤ)| ≤ (r : ℤ)) ≤
63
+ ∏ j, (2 * (r : ℝ) + 1) / ((hi j - lo j : ℤ) : ℝ) := by
64
+ unfold FiniteProbabilityWeights.eventProbability
65
+ rw [FiniteProbabilityWeights.mean_prod]
66
+ apply (FiniteProbabilityWeights.mean_mono _ ?_).trans_eq (FiniteProbabilityWeights.mean_const _ _)
67
+ intro x
68
+ exact integer_box_near_probability lo hi hlen (fun j => (x j : ℤ)) r
69
+
70
+ theorem integer_box_pair_near_probability_of_lengths {J : Type*}
71
+ [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
72
+ (r : ℕ) {L : ℝ} (hL : 0 < L) (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) :
73
+ ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability
74
+ (fun xy => ∀ j, |(xy.2 j : ℤ) - (xy.1 j : ℤ)| ≤ (r : ℤ)) ≤
75
+ ((2 * (r : ℝ) + 1) / L) ^ Fintype.card J := by
76
+ apply (integer_box_pair_near_probability lo hi hlen r).trans
77
+ calc
78
+ _ ≤ ∏ _j : J, (2 * (r : ℝ) + 1) / L := by
79
+ apply Finset.prod_le_prod₀
80
+ · intro j _
81
+ have hj : (0 : ℝ) < ((hi j - lo j : ℤ) : ℝ) := hL.trans_le (hside j)
82
+ positivity
83
+ · intro j _
84
+ exact div_le_div_of_nonneg_left (by positivity) hL (hside j)
85
+ _ = _ := by simp [div_pow]
86
+
87
+ end Erdos3
88
+
89
+ end
90
+
91
+ section
92
+
93
+ namespace Erdos3
94
+
95
+ open scoped BigOperators Classical
96
+
97
+ theorem integer_vector_content_natAbs_scale {J : Type*} [Fintype J]
98
+ (D : ℕ) (z : J → ℤ) :
99
+ (BohrLattice.Primitive.content (fun j => (D : ℤ) * z j)).natAbs =
100
+ D * (BohrLattice.Primitive.content z).natAbs := by
101
+ simp only [BohrLattice.Primitive.content, Finset.gcd_mul_left, Int.normalize_coe_nat,
102
+ Int.natAbs_mul, Int.natAbs_natCast]
103
+
104
+ theorem affine_parameter_difference_gcd {J : Type*} [Fintype J]
105
+ (D : ℕ) (a x y : J → ℤ) :
106
+ (BohrLattice.Primitive.content (fun j => (a j + (D : ℤ) * y j) -
107
+ (a j + (D : ℤ) * x j))).natAbs =
108
+ D * (BohrLattice.Primitive.content (fun j => y j - x j)).natAbs := by
109
+ have he : (fun j => (a j + (D : ℤ) * y j) - (a j + (D : ℤ) * x j)) =
110
+ (fun j => (D : ��) * (y j - x j)) := by funext j; ring
111
+ rw [he, integer_vector_content_natAbs_scale]
112
+
113
+ theorem integer_box_pair_gcd_probability {J : Type*}
114
+ [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
115
+ (B R : ℕ) (hB : 0 < B) (hdim : 2 ≤ Fintype.card J)
116
+ {L : ℝ} (hL : 0 < L) (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ))
117
+ (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) :
118
+ ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability
119
+ (fun xy => B < (BohrLattice.Primitive.content
120
+ (fun j => (xy.2 j : ℤ) - (xy.1 j : ℤ))).natAbs) ≤
121
+ 2 ^ (Fintype.card J - 1) *
122
+ (1 / (B : ℝ) ^ (Fintype.card J - 1) + (R : ℝ) / L ^ Fintype.card J) := by
123
+ apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans
124
+ (integer_box_pair_nonzero_large_divisor_probability lo hi hlen B R hB hdim hL hside hwidth)
125
+ intro xy h
126
+ refine ⟨?_, (BohrLattice.Primitive.content (fun j => (xy.2 j : ℤ) - (xy.1 j : ℤ))).natAbs, h, ?_⟩
127
+ · intro he
128
+ have hz : Finset.univ.gcd (fun _ : J => (0 : ℤ)) = 0 :=
129
+ Finset.gcd_eq_zero_iff.mpr (fun _ _ => rfl)
130
+ simp [he, BohrLattice.Primitive.content, hz] at h
131
+ · intro j
132
+ exact Int.natAbs_dvd.mpr (BohrLattice.Primitive.content_dvd _ j)
133
+
134
+ theorem affine_parameter_pair_gcd_probability {J : Type*}
135
+ [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
136
+ (D Q B R : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B)
137
+ (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L)
138
+ (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ))
139
+ (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) :
140
+ ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability
141
+ (fun xy => Q < (BohrLattice.Primitive.content
142
+ (fun j => (a j + (D : ℤ) * (xy.2 j : ℤ)) -
143
+ (a j + (D : ℤ) * (xy.1 j : ℤ)))).natAbs) ≤
144
+ 2 ^ (Fintype.card J - 1) *
145
+ (1 / (B : ℝ) ^ (Fintype.card J - 1) + (R : ℝ) / L ^ Fintype.card J) := by
146
+ apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans
147
+ (integer_box_pair_gcd_probability lo hi hlen B R hB hdim hL hside hwidth)
148
+ intro xy h
149
+ rw [affine_parameter_difference_gcd] at h
150
+ exact Nat.lt_of_mul_lt_mul_left (hBQ.trans_lt h)
151
+
152
+ end Erdos3
153
+
154
+ end
155
+
156
+ section
157
+
158
+ namespace Erdos3
159
+
160
+ open scoped BigOperators Classical
161
+
162
+ theorem integerBoxUniformWeights_mean {J : Type*} [Fintype J] [DecidableEq J]
163
+ (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
164
+ (f : (∀ j, Finset.Ico (lo j) (hi j)) → ℝ) :
165
+ (integerBoxUniformWeights lo hi hlen).mean f = 𝔼 x, f x := by
166
+ let : ∀ j, Nonempty (Finset.Ico (lo j) (hi j)) :=
167
+ fun j => ⟨⟨lo j, Finset.mem_Ico.mpr ⟨le_rfl, hlen j⟩⟩⟩
168
+ have he : integerBoxUniformWeights lo hi hlen =
169
+ FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (lo j) (hi j)) := by
170
+ apply FiniteProbabilityWeights.eq_of_weight_eq
171
+ intro x
172
+ change (∏ j, (Fintype.card (Finset.Ico (lo j) (hi j)) : ℝ)⁻¹) =
173
+ (Fintype.card (∀ j, Finset.Ico (lo j) (hi j)) : ℝ)⁻¹
174
+ rw [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib]
175
+ rw [he, FiniteProbabilityWeights.uniform_mean]
176
+
177
+ theorem finite_event_probability_or_le {X : Type*} [Fintype X]
178
+ (p : FiniteProbabilityWeights X) (A B : X → Prop) :
179
+ p.eventProbability (fun x => A x ∨ B x) ≤ p.eventProbability A + p.eventProbability B := by
180
+ have hpoint (x : X) : (@ite ℝ (A x ∨ B x) (Classical.propDecidable _) 1 0) ≤
181
+ (@ite ℝ (A x) (Classical.propDecidable _) 1 0) +
182
+ (@ite ℝ (B x) (Classical.propDecidable _) 1 0) := by
183
+ by_cases ha : A x <;> by_cases hb : B x <;> simp [ha, hb]
184
+ exact (p.mean_mono hpoint).trans_eq (p.mean_add _ _)
185
+
186
+ def affineParameterBadPair {J : Type*} [Fintype J]
187
+ (D Q r : ℕ) (a x y : J → ℤ) : Prop :=
188
+ Q < (BohrLattice.Primitive.content
189
+ (fun j => (a j + (D : ℤ) * y j) - (a j + (D : ℤ) * x j))).natAbs ∨
190
+ ∀ j, |y j - x j| ≤ (r : ℤ)
191
+
192
+ noncomputable def integerBoxBadPairBudget (d B R r : ℕ) (L : ℝ) : ℝ :=
193
+ 2 ^ (d - 1) * (1 / (B : ℝ) ^ (d - 1) + (R : ℝ) / L ^ d) +
194
+ ((2 * (r : ℝ) + 1) / L) ^ d
195
+
196
+ theorem affine_parameter_bad_pair_probability {J : Type*}
197
+ [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
198
+ (D Q B R r : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B)
199
+ (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L)
200
+ (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ))
201
+ (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) :
202
+ ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability
203
+ (fun xy => affineParameterBadPair D Q r a
204
+ (fun j => (xy.1 j : ℤ)) (fun j => (xy.2 j : ℤ))) ≤
205
+ integerBoxBadPairBudget (Fintype.card J) B R r L := by
206
+ unfold affineParameterBadPair integerBoxBadPairBudget
207
+ apply (finite_event_probability_or_le _ _ _).trans
208
+ exact add_le_add
209
+ (affine_parameter_pair_gcd_probability lo hi hlen D Q B R a hBQ hB hdim hL hside hwidth)
210
+ (integer_box_pair_near_probability_of_lengths lo hi hlen r hL hside)
211
+
212
+ theorem sampled_affine_integer_box_error {Ω J : Type*}
213
+ [Fintype Ω] [Fintype J] [DecidableEq J]
214
+ (p : FiniteProbabilityWeights Ω) (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j)
215
+ (D Q B R r : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B)
216
+ (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L)
217
+ (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ))
218
+ (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ))
219
+ (e : Ω → (∀ j, Finset.Ico (lo j) (hi j)) → ℝ)
220
+ {C epsilon : ℝ} (hC : 0 ≤ C) (hepsilon : 0 ≤ epsilon)
221
+ (henergy : ∀ t, p.mean (fun x => e x t ^ 2) ≤ C)
222
+ (hgood : ∀ (t u : ∀ j, Finset.Ico (lo j) (hi j)), ¬ affineParameterBadPair D Q r a (fun j => (t j : ℤ)) (fun j => (u j : ℤ)) →
223
+ |p.mean (fun x => e x t * e x u)| ≤ epsilon)
224
+ (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ 1) :
225
+ |p.mean (fun x => w x * (𝔼 t, e x t))| ≤
226
+ Real.sqrt (C * integerBoxBadPairBudget (Fintype.card J) B R r L + epsilon) := by
227
+ have h := sampled_weighted_error_of_energy p (integerBoxUniformWeights lo hi hlen) e
228
+ (fun tu => affineParameterBadPair D Q r a (fun j => (tu.1 j : ℤ)) (fun j => (tu.2 j : ℤ)))
229
+ hC hepsilon henergy
230
+ (affine_parameter_bad_pair_probability lo hi hlen D Q B R r a hBQ hB hdim hL hside hwidth)
231
+ (fun tu htu => hgood tu.1 tu.2 htu) w hw
232
+ simpa only [integerBoxUniformWeights_mean] using h
233
+
234
+ end Erdos3
235
+
236
+ end
237
+
238
+ section
239
+
240
+ namespace Erdos3
241
+
242
+ open scoped BigOperators Classical
243
+
244
+ theorem expect_le_of_dependent_coordinate_slices {I : Type*} [Fintype I] [DecidableEq I]
245
+ {X : I → Type*} [∀ i, Fintype (X i)] [∀ i, Nonempty (X i)]
246
+ (i : I) (f : (∀ j, X j) → ℝ) (C : ℝ)
247
+ (hslice : ∀ x : ∀ j, X j, (𝔼 a : X i, f (Function.update x i a)) ≤ C) :
248
+ (𝔼 x : ∀ j, X j, f x) ≤ C := by
249
+ let e := Equiv.piSplitAt i X
250
+ have he := Fintype.expect_equiv e f (fun p => f (e.symm p)) (fun x => by simp)
251
+ rw [he, ← Finset.univ_product_univ, Finset.expect_product, Finset.expect_comm]
252
+ apply Finset.expect_le Finset.univ_nonempty
253
+ intro r _
254
+ let x : ∀ j, X j := e.symm (Classical.choice inferInstance, r)
255
+ have hupdate (a : X i) : e.symm (a, r) = Function.update x i a := by
256
+ funext j
257
+ by_cases hj : j = i
258
+ · subst j
259
+ simp [e, Equiv.piSplitAt]
260
+ · simp [e, x, Equiv.piSplitAt, hj]
261
+ simpa only [hupdate] using hslice x
262
+
263
+ theorem integer_box_affine_near_probability {J I : Type*}
264
+ [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I]
265
+ (lo hi : Option J × I → ℤ) (hlen : ∀ j, lo j < hi j)
266
+ (t : J → ℤ) (i : I) (b : ℤ) (r : ℕ) :
267
+ (integerBoxUniformWeights lo hi hlen).eventProbability
268
+ (fun z => |smoothAffineSample t (fun j => (z j : ℤ)) i - b| ≤ (r : ℤ)) ≤
269
+ (2 * (r : ℝ) + 1) / ((hi (none, i) - lo (none, i) : ℤ) : ℝ) := by
270
+ let : ∀ j, Nonempty (Finset.Ico (lo j) (hi j)) :=
271
+ fun j => ⟨⟨lo j, Finset.mem_Ico.mpr ⟨le_rfl, hlen j⟩⟩⟩
272
+ unfold FiniteProbabilityWeights.eventProbability
273
+ rw [integerBoxUniformWeights_mean]
274
+ apply expect_le_of_dependent_coordinate_slices (none, i)
275
+ intro z
276
+ have h := interval_near_probability (lo (none, i)) (hi (none, i))
277
+ (b - ∑ j, t j * (z (some j, i) : ℤ)) (hlen (none, i)) r
278
+ unfold FiniteProbabilityWeights.eventProbability at h
279
+ rw [intervalUniformWeights_mean] at h
280
+ convert h using 1
281
+ apply Finset.expect_congr rfl
282
+ intro a _
283
+ have he : smoothAffineSample t (fun j => ((Function.update z (none, i) a) j : ℤ)) i - b =
284
+ (a : ℤ) - (b - ∑ j, t j * (z (some j, i) : ℤ)) := by
285
+ simp [smoothAffineSample, Function.update]
286
+ ring
287
+ dsimp only
288
+ simp only [he]
289
+ split_ifs <;> rfl
290
+
291
+ end Erdos3
292
+
293
+ end
294
+
295
+ section
296
+
297
+ namespace Erdos3.ResidueBoxSlice
298
+
299
+ open scoped BigOperators Classical
300
+
301
+ variable {X : Type*} [Fintype X] [DecidableEq X] {N : X → ℕ} {q : ℕ}
302
+
303
+ theorem fullSliceLaw_mean_eq_rectangle (S : ResidueBoxSlice N q)
304
+ (hlen : ∀ i, 0 < S.length i) (f : (X → ℤ) → ℝ) :
305
+ (S.fullSliceLaw hlen).mean (fun x => f x.val) =
306
+ (integerBoxUniformWeights (fun _ : X => 0) (fun i => (S.length i : ℤ))
307
+ (fun i => by exact_mod_cast hlen i)).mean
308
+ (fun t => f (fun i => (S.start i : ℤ) + (q : ℤ) * (t i).val)) := by
309
+ rw [fullSliceLaw_mean, integerBoxUniformWeights_mean]
310
+ let forward (u : ∀ i, Fin (S.length i)) :
311
+ ∀ i, Finset.Ico (0 : ℤ) (S.length i : ℤ) := fun i =>
312
+ ⟨((u i).val : ℤ), Finset.mem_Ico.mpr ⟨Int.natCast_nonneg _, by exact_mod_cast (u i).isLt⟩⟩
313
+ apply Finset.expect_bij (fun u _ => forward u)
314
+ · intro u _
315
+ exact Finset.mem_univ _
316
+ · intro u _
317
+ simp only [forward, fullSlicePointInIntegerBox, point, Nat.cast_add, Nat.cast_mul]
318
+ · intro u _ v _ he
319
+ funext i
320
+ apply Fin.ext
321
+ have hi := congrArg (fun t => (t i).val) he
322
+ dsimp only [forward] at hi
323
+ exact_mod_cast hi
324
+ · intro t _
325
+ let u : ∀ i, Fin (S.length i) := fun i =>
326
+ ⟨(t i).val.toNat, by have := Finset.mem_Ico.mp (t i).property; omega⟩
327
+ refine ⟨u, Finset.mem_univ _, ?_⟩
328
+ funext i
329
+ apply Subtype.ext
330
+ change (((t i).val.toNat : ℕ) : ℤ) = (t i).val
331
+ exact Int.toNat_of_nonneg (Finset.mem_Ico.mp (t i).property).1
332
+
333
+ omit [Fintype X] [DecidableEq X] in
334
+ theorem fullSliceRectangle_endpoint_bounds (S : ResidueBoxSlice N q)
335
+ (hlen : ∀ i, 0 < S.length i) {L C : ℝ} (hL : 0 < L)
336
+ (hN : ∀ i, (N i : ℝ) ≤ C * L) (i : X) :
337
+ |(S.start i : ℝ) / L| ≤ C ∧
338
+ |((S.start i : ℝ) + (q : ℝ) * S.length i) / L| ≤ C + q / L := by
339
+ have hstart : S.start i < N i := by simpa using S.inside i 0 (hlen i)
340
+ have hlast := S.inside i (S.length i - 1) (by have := hlen i; omega)
341
+ have hend : S.start i + q * S.length i < N i + q := by
342
+ have he : S.start i + q * S.length i =
343
+ (S.start i + q * (S.length i - 1)) + q := by
344
+ have hl : S.length i = (S.length i - 1) + 1 := by have := hlen i; omega
345
+ conv_lhs => rw [hl]
346
+ ring
347
+ rw [he]
348
+ omega
349
+ have hstartR : (S.start i : ℝ) < N i := by exact_mod_cast hstart
350
+ have hendR : (S.start i : ℝ) + (q : ℝ) * S.length i < (N i : ℝ) + q := by
351
+ exact_mod_cast hend
352
+ constructor
353
+ · rw [abs_of_nonneg (div_nonneg (Nat.cast_nonneg _) hL.le)]
354
+ exact (div_le_iff₀ hL).mpr (hstartR.le.trans (hN i))
355
+ · rw [abs_of_nonneg (by positivity)]
356
+ apply (div_le_iff₀ hL).mpr
357
+ rw [add_mul, div_mul_cancel₀ _ hL.ne']
358
+ linarith [hN i]
359
+
360
+ omit [Fintype X] [DecidableEq X] in
361
+ theorem fullSliceRectangle_endpoint_bounds_two (S : ResidueBoxSlice N q)
362
+ (hlen : ∀ i, 2 ≤ S.length i) {L C : ℝ} (hL : 0 < L)
363
+ (hN : ∀ i, (N i : ℝ) ≤ C * L) (i : X) :
364
+ |(S.start i : ℝ) / L| ≤ C ∧
365
+ |((S.start i : ℝ) + (q : ℝ) * S.length i) / L| ≤ 2 * C := by
366
+ have hbase := fullSliceRectangle_endpoint_bounds S (fun i => by have := hlen i; omega) hL hN i
367
+ have hqN : q < N i := by
368
+ have h := S.inside i 1 (by have := hlen i; omega)
369
+ omega
370
+ have hqR : (q : ℝ) ≤ C * L :=
371
+ (show (q : ℝ) ≤ (N i : ℝ) by exact_mod_cast hqN.le).trans (hN i)
372
+ have hqL : (q : ℝ) / L ≤ C := (div_le_iff₀ hL).mpr hqR
373
+ exact ⟨hbase.1, hbase.2.trans (by linarith)⟩
374
+
375
+ end Erdos3.ResidueBoxSlice
376
+
377
+ end
378
+
379
+ section
380
+
381
+ namespace Erdos3
382
+
383
+ theorem integerBoxBadPairBudget_nonneg (d B R r : ℕ) {M : ℝ} (hM : 0 ≤ M) :
384
+ 0 ≤ integerBoxBadPairBudget d B R r M := by
385
+ unfold integerBoxBadPairBudget
386
+ positivity
387
+
388
+ theorem integerBoxBadPairBudget_le_separated (d B R r : ℕ) {M C nu : ℝ}
389
+ (hd : 2 ≤ d) (hB : 0 < B) (hBM : (B : ℝ) ≤ M) (hC : 0 ≤ C)
390
+ (hR : (R : ℝ) ≤ C * M) (hr : (r : ℝ) ≤ nu * M)
391
+ (hinv : 1 / M ≤ nu) :
392
+ integerBoxBadPairBudget d B R r M ≤
393
+ 2 ^ (d - 1) * (1 + C) / (B : ℝ) ^ (d - 1) + (3 * nu) ^ d := by
394
+ have hBp : (0 : ℝ) < B := by exact_mod_cast hB
395
+ have hM : 0 < M := hBp.trans_le hBM
396
+ have hpow : (B : ℝ) ^ (d - 1) ≤ M ^ (d - 1) :=
397
+ pow_le_pow_left₀ hBp.le hBM _
398
+ have hR' : (R : ℝ) / M ^ d ≤ C / (B : ℝ) ^ (d - 1) := by
399
+ calc
400
+ _ ≤ (C * M) / M ^ d := div_le_div_of_nonneg_right hR (by positivity)
401
+ _ = C / M ^ (d - 1) := by
402
+ conv_lhs => rw [show d = (d - 1) + 1 by omega, pow_succ]
403
+ field_simp
404
+ _ ≤ C / (B : ℝ) ^ (d - 1) := div_le_div_of_nonneg_left hC (by positivity) hpow
405
+ have hnear : (2 * (r : ℝ) + 1) / M ≤ 3 * nu := by
406
+ have hrr : (r : ℝ) / M ≤ nu := (div_le_iff₀ hM).mpr hr
407
+ calc
408
+ _ = 2 * ((r : ℝ) / M) + 1 / M := by ring
409
+ _ ≤ 3 * nu := by linarith
410
+ unfold integerBoxBadPairBudget
411
+ calc
412
+ _ ≤ 2 ^ (d - 1) * (1 / (B : ℝ) ^ (d - 1) + C / (B : ℝ) ^ (d - 1)) +
413
+ (3 * nu) ^ d := add_le_add
414
+ (mul_le_mul_of_nonneg_left (add_le_add le_rfl hR') (by positivity))
415
+ (pow_le_pow_left₀ (by positivity) hnear d)
416
+ _ = _ := by ring
417
+
418
+ theorem integerBoxBadPairBudget_le_linear (d B R r : ℕ) {M C nu : ℝ}
419
+ (hd : 2 ≤ d) (hB : 0 < B) (hBM : (B : ℝ) ≤ M) (hC : 0 ≤ C)
420
+ (hR : (R : ℝ) ≤ C * M) (hr : (r : ℝ) ≤ nu * M)
421
+ (hinv : 1 / M ≤ nu) (hnu : nu ≤ 1) :
422
+ integerBoxBadPairBudget d B R r M ≤
423
+ 2 ^ (d - 1) * (1 + C) / (B : ℝ) + 3 ^ d * nu := by
424
+ have hB1 : (1 : ℝ) ≤ B := by exact_mod_cast hB
425
+ have hBp : (0 : ℝ) < B := by exact_mod_cast hB
426
+ have hM : 0 < M := hBp.trans_le hBM
427
+ have hnu0 : 0 ≤ nu := (by positivity : 0 ≤ 1 / M).trans hinv
428
+ have hpow : (B : ℝ) ≤ (B : ℝ) ^ (d - 1) := by
429
+ simpa only [pow_one] using pow_le_pow_right₀ hB1 (show 1 ≤ d - 1 by omega)
430
+ have hnpow : nu ^ d ≤ nu := by
431
+ obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (show d ≠ 0 by omega)
432
+ rw [pow_succ]
433
+ exact (mul_le_mul_of_nonneg_right (pow_le_one₀ hnu0 hnu) hnu0).trans_eq (one_mul nu)
434
+ apply (integerBoxBadPairBudget_le_separated d B R r hd hB hBM hC hR hr hinv).trans
435
+ apply add_le_add
436
+ · exact div_le_div_of_nonneg_left (by positivity) hBp hpow
437
+ · rw [mul_pow]
438
+ exact mul_le_mul_of_nonneg_left hnpow (by positivity)
439
+
440
+ end Erdos3
441
+
442
+ end
443
+
444
+ section
445
+
446
+ namespace Erdos3
447
+
448
+ open scoped BigOperators Classical
449
+
450
+ theorem integerBox_weighted_joint_mean
451
+ {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
452
+ (lo hi : I → ℤ) (hsource : ∀ i, lo i < hi i)
453
+ (parLo parHi : J → ℤ) (hparam : ∀ j, parLo j < parHi j)
454
+ (w : (I → ℤ) → ℝ) (f : (I → ℤ) → (∀ j, Finset.Ico (parLo j) (parHi j)) → ℝ) :
455
+ ((integerBoxUniformWeights parLo parHi hparam).prod
456
+ (integerBoxUniformWeights lo hi hsource)).mean
457
+ (fun tx => w (fun i => (tx.2 i).val) * f (fun i => (tx.2 i).val) tx.1) =
458
+ 𝔼 z ∈ Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)), w z * (𝔼 t, f z t) := by
459
+ rw [FiniteProbabilityWeights.mean_prod, FiniteProbabilityWeights.mean_comm]
460
+ simp only [FiniteProbabilityWeights.mean_const_mul, integerBoxUniformWeights_mean]
461
+ rw [← finiteBoxPoints_expect (fun i => Finset.Ico (lo i) (hi i)) (fun z => w z * (𝔼 t, f z t))]
462
+ simp only [Finset.expect_eq_sum_div_card, Finset.card_univ, Fintype.card_coe]
463
+ congr 1
464
+ simpa only [Finset.expect_eq_sum_div_card, Finset.card_univ] using
465
+ Finset.sum_coe_sort (Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)))
466
+ (fun z => w z * (𝔼 t, f z t))
467
+
468
+ theorem integerBox_joint_error_of_window_tests
469
+ {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
470
+ (lo hi : I → ℤ) (hsource : ∀ i, lo i < hi i)
471
+ (parLo parHi : J → ℤ) (hparam : ∀ j, parLo j < parHi j)
472
+ (f : (I → ℤ) → (∀ j, Finset.Ico (parLo j) (parHi j)) → ℝ) (accuracy : ℝ)
473
+ (htest : ∀ v : (I → ℤ) → ℝ, (∀ z, 0 ≤ v z ∧ v z ≤ 1) →
474
+ |𝔼 z ∈ Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)), v z * (𝔼 t, f z t)| ≤ accuracy)
475
+ (w : (I → ℤ) → ℝ)
476
+ (hw : ∀ z : (∀ i, Finset.Ico (lo i) (hi i)),
477
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) :
478
+ |((integerBoxUniformWeights parLo parHi hparam).prod
479
+ (integerBoxUniformWeights lo hi hsource)).mean
480
+ (fun tx => w (fun i => (tx.2 i).val) * f (fun i => (tx.2 i).val) tx.1)| ≤ accuracy := by
481
+ let W := Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i))
482
+ have hwW (z) (hz : z ∈ W) : 0 ≤ w z ∧ w z ≤ 1 := by
483
+ exact hw (fun i => ⟨z i, Fintype.mem_piFinset.mp hz i⟩)
484
+ have h := htest (realZeroExtendFinset W w) (realZeroExtendFinset_unit W w hwW)
485
+ rw [integerBox_weighted_joint_mean lo hi hsource parLo parHi hparam w f]
486
+ convert h using 2
487
+ apply Finset.expect_congr rfl
488
+ intro z hz
489
+ rw [realZeroExtendFinset_on W w hz]
490
+
491
+ end Erdos3
492
+
493
+ end
494
+
495
+ section
496
+
497
+ namespace Erdos3
498
+
499
+ open scoped BigOperators Classical
500
+
501
+ noncomputable def physicalBoundaryBudget {I : Type*} [Fintype I]
502
+ (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) (width : I → ℝ) : ℝ :=
503
+ ∑ i, 2 * (Fintype.card (P i).Label : ℝ) * (2 * (r i : ℝ) + 1) / width i
504
+
505
+ theorem integer_box_physical_boundary_probability {J I : Type*}
506
+ [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I]
507
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j)
508
+ (t : J → ℤ) (lo : I → ℤ) (N : I → ℕ)
509
+ (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) :
510
+ (integerBoxUniformWeights sourceLo sourceHi hsource).eventProbability
511
+ (fun z => physicalBoundaryNear lo N P r (smoothAffineSample t (fun j => (z j : ℤ)))) ≤
512
+ physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by
513
+ let p := integerBoxUniformWeights sourceLo sourceHi hsource
514
+ let E := fun (e : Σ i, (P i).Label) (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) =>
515
+ |smoothAffineSample t (fun j => (z j : ℤ)) e.1 - intervalCellLower (lo e.1) (P e.1) e.2| ≤ (r e.1 : ℤ) ∨
516
+ |smoothAffineSample t (fun j => (z j : ℤ)) e.1 - intervalCellUpper (lo e.1) (P e.1) e.2| ≤ (r e.1 : ℤ)
517
+ have hE (e : Σ i, (P i).Label) : p.eventProbability (E e) ≤
518
+ 2 * ((2 * (r e.1 : ℝ) + 1) / ((sourceHi (none, e.1) - sourceLo (none, e.1) : ℤ) : ℝ)) := by
519
+ apply (p.eventProbability_or_le _ _).trans
520
+ have hleft := integer_box_affine_near_probability sourceLo sourceHi hsource t e.1
521
+ (intervalCellLower (lo e.1) (P e.1) e.2) (r e.1)
522
+ have hright := integer_box_affine_near_probability sourceLo sourceHi hsource t e.1
523
+ (intervalCellUpper (lo e.1) (P e.1) e.2) (r e.1)
524
+ linarith
525
+ have hcover (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j))
526
+ (h : physicalBoundaryNear lo N P r (smoothAffineSample t (fun j => (z j : ℤ)))) : ∃ e, E e z := by
527
+ obtain ⟨i, c, hc⟩ := h
528
+ exact ⟨⟨i, c⟩, hc⟩
529
+ apply (p.eventProbability_union_bound _ E hcover).trans
530
+ calc
531
+ _ ≤ ∑ e : Σ i, (P i).Label,
532
+ 2 * ((2 * (r e.1 : ℝ) + 1) / ((sourceHi (none, e.1) - sourceLo (none, e.1) : ℤ) : ℝ)) :=
533
+ Finset.sum_le_sum (fun e _ => hE e)
534
+ _ = _ := by
535
+ rw [Fintype.sum_sigma]
536
+ unfold physicalBoundaryBudget
537
+ apply Finset.sum_congr rfl
538
+ intro i _
539
+ dsimp only
540
+ rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
541
+ ring
542
+
543
+ theorem sampled_physical_boundary_probability {J I T : Type*}
544
+ [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] [Fintype T]
545
+ (parameterLaw : FiniteProbabilityWeights T) (parameter : T → J → ℤ)
546
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j)
547
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) :
548
+ (parameterLaw.prod (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability
549
+ (fun tz => physicalBoundaryNear lo N P r (smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ)))) ≤
550
+ physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by
551
+ unfold FiniteProbabilityWeights.eventProbability
552
+ rw [FiniteProbabilityWeights.mean_prod]
553
+ apply (parameterLaw.mean_mono (fun t =>
554
+ integer_box_physical_boundary_probability sourceLo sourceHi hsource (parameter t) lo N P r)).trans_eq
555
+ exact parameterLaw.mean_const _
556
+
557
+ end Erdos3
558
+
559
+ end
560
+
561
+ section
562
+
563
+ namespace Erdos3
564
+
565
+ open scoped BigOperators Classical
566
+
567
+ noncomputable def physicalMeshCrossing {I X M : Type*} [Fintype I] [DecidableEq I]
568
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
569
+ (mesh : X → M) (location : X → I → ℤ) (x : X) : Prop :=
570
+ ∃ y, mesh y = mesh x ∧ physicalBoxClassify lo N P (location x) ≠ physicalBoxClassify lo N P (location y)
571
+
572
+ theorem retained_mesh_cell_constant {I X M : Type*} [Fintype I] [DecidableEq I]
573
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
574
+ (mesh : X → M) (location : X → I → ℤ) (x : X)
575
+ (hx : ¬ physicalMeshCrossing lo N P mesh location x) :
576
+ ∀ y, mesh y = mesh x → physicalBoxClassify lo N P (location y) = physicalBoxClassify lo N P (location x) := by
577
+ intro y hy
578
+ by_contra h
579
+ exact hx ⟨y, hy, Ne.symm h⟩
580
+
581
+ theorem physicalMeshCrossing_congr {I X M : Type*} [Fintype I] [DecidableEq I]
582
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
583
+ (mesh : X → M) (location : X → I → ℤ) {x y : X} (hxy : mesh x = mesh y) :
584
+ physicalMeshCrossing lo N P mesh location x ↔ physicalMeshCrossing lo N P mesh location y := by
585
+ have transfer (u v : X) (huv : mesh u = mesh v)
586
+ (hu : physicalMeshCrossing lo N P mesh location u) : physicalMeshCrossing lo N P mesh location v := by
587
+ obtain ⟨z, hz, huz⟩ := hu
588
+ by_cases hvz : physicalBoxClassify lo N P (location v) = physicalBoxClassify lo N P (location z)
589
+ · exact ⟨u, huv, fun hvu => huz (hvu.symm.trans hvz)⟩
590
+ · exact ⟨z, hz.trans huv, hvz⟩
591
+ exact ⟨transfer x y hxy, transfer y x hxy.symm⟩
592
+
593
+ theorem physicalMeshCrossing_subset_boundary {I X M : Type*} [Fintype I] [DecidableEq I]
594
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
595
+ (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c)
596
+ (mesh : X → M) (location : X → I → ℤ) (r : I → ℕ)
597
+ (hmove : ∀ x y, mesh y = mesh x → ∀ i, |location x i - location y i| ≤ (r i : ℤ))
598
+ (x : X) (hx : physicalMeshCrossing lo N P mesh location x) :
599
+ physicalBoundaryNear lo N P r (location x) := by
600
+ by_contra hn
601
+ obtain ⟨y, hy, hxy⟩ := hx
602
+ exact hxy (physicalBoxClassify_stable lo N P hstep hpos r (location x) (location y) (hmove x y hy) hn)
603
+
604
+ theorem affine_mesh_crossing_probability {J I T SCell TCell : Type*}
605
+ [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] [Fintype T]
606
+ (parameterLaw : FiniteProbabilityWeights T) (parameter : T → J → ℤ)
607
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j)
608
+ (sourceCell : (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) → SCell) (parameterCell : T → TCell)
609
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
610
+ (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c)
611
+ (r : I → ℕ) (r0 rV V : I → ℝ) (Tcap rt : ℝ) (hT : 0 ≤ Tcap) (hV : ∀ i, 0 ≤ V i)
612
+ (ht : ∀ t j, |(parameter t j : ℝ)| ≤ Tcap)
613
+ (hv : ∀ (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) j i, |((z (some j, i) : ℤ) : ℝ)| ≤ V i)
614
+ (hbase : ∀ z w, sourceCell w = sourceCell z → ∀ i,
615
+ |((z (none, i) : ℤ) : ℝ) - ((w (none, i) : ℤ) : ℝ)| ≤ r0 i)
616
+ (hdir : ∀ z w, sourceCell w = sourceCell z → ∀ j i,
617
+ |((z (some j, i) : ℤ) : ℝ) - ((w (some j, i) : ℤ) : ℝ)| ≤ rV i)
618
+ (hparam : ∀ t u, parameterCell u = parameterCell t → ∀ j,
619
+ |(parameter t j : ℝ) - parameter u j| ≤ rt)
620
+ (hbudget : ∀ i, r0 i + (Fintype.card J : ℝ) * (Tcap * rV i + V i * rt) ≤ (r i : ℝ)) :
621
+ (parameterLaw.prod (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability
622
+ (physicalMeshCrossing lo N P
623
+ (fun tz => (sourceCell tz.2, parameterCell tz.1))
624
+ (fun tz => smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ)))) ≤
625
+ physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by
626
+ let mesh := fun tz : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) =>
627
+ (sourceCell tz.2, parameterCell tz.1)
628
+ let location := fun tz : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) =>
629
+ smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ))
630
+ have hmove (x y : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j))) (he : mesh y = mesh x) (i : I) :
631
+ |location x i - location y i| ≤ (r i : ℤ) := by
632
+ have hs : sourceCell y.2 = sourceCell x.2 := congrArg Prod.fst he
633
+ have hp : parameterCell y.1 = parameterCell x.1 := congrArg Prod.snd he
634
+ have h := (smoothAffineSample_variation (parameter x.1) (parameter y.1)
635
+ (fun j => (x.2 j : ℤ)) (fun j => (y.2 j : ℤ)) i hT (hV i) (ht x.1) (fun j => hv y.2 j i)
636
+ (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)
637
+ exact_mod_cast h
638
+ apply (FiniteProbabilityWeights.eventProbability_mono _ _ _
639
+ (physicalMeshCrossing_subset_boundary lo N P hstep hpos mesh location r hmove)).trans
640
+ exact sampled_physical_boundary_probability parameterLaw parameter sourceLo sourceHi hsource lo N P r
641
+
642
+ end Erdos3
643
+
644
+ end
645
+
646
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshScalarTail.lean ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.FiniteRetainedCellMean
2
+ import OAI.Combinatorics.Progressions.Estimates.PhysicalZeroExtension
3
+ import OAI.Combinatorics.Progressions.Estimates.RetainedPhysicalDifference
4
+ import OAI.Combinatorics.Progressions.Lattices.ConcreteAffineMeshBoundary
5
+
6
+ namespace OAI
7
+
8
+ section
9
+
10
+ namespace Erdos3
11
+
12
+ open scoped BigOperators Classical
13
+
14
+ theorem affine_mesh_truncation_bound
15
+ {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J]
16
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
17
+ (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c)
18
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i)
19
+ (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat)
20
+ (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c)
21
+ (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j)
22
+ (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat)
23
+ (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c)
24
+ (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ)
25
+ (w : (Option J × I → ℤ) → ℝ) (h g : (I → ℤ) → ℝ)
26
+ (hw : ∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)),
27
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1)
28
+ (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1)
29
+ (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1)
30
+ {etaParam etaSite r R beta : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite)
31
+ (hr : 0 ≤ r) (hR : 0 ≤ R)
32
+ (hcloseParam : ∀ ct : (∀ j, (T j).Label),
33
+ ProductMarginalsClose (primeCoordinateReference (σ := J) q)
34
+ (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j))
35
+ (fun j => (T j).length (ct j)) 1 (fun _ => 0)
36
+ (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct)
37
+ q (fun _ => 1)) etaParam b)
38
+ (hcloseSite : ∀ c : (∀ i, (P i).Label),
39
+ ProductMarginalsClose (primeCoordinateReference (σ := I) q)
40
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
41
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c)
42
+ q (fun _ => 1)) etaSite b)
43
+ (hreference : ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label),
44
+ productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b)
45
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i))
46
+ (fun i => (S i).length (cs i)) 1 (fun _ => 0)
47
+ (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w)
48
+ (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
49
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x -
50
+ r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
51
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R)
52
+ (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod
53
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability
54
+ (physicalMeshCrossing lo N P
55
+ (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1))
56
+ (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta) :
57
+ ((integerBoxUniformWeights paramLo paramHi hparam).prod
58
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
59
+ (fun tz => w (fun i => (tz.2 i).val) *
60
+ (physicalBoxTruncation lo N P hPpos q b h
61
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) -
62
+ r * physicalBoxTruncation lo N P hPpos q b g
63
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))) ≤
64
+ R + (1 + r) * (etaParam + beta) * residueTruncationCap ι b etaSite := by
65
+ let : Nonempty (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) :=
66
+ ⟨fun i => ⟨sourceLo i, Finset.mem_Ico.mpr ⟨le_rfl, hsource i⟩⟩⟩
67
+ let : Nonempty (∀ j, Finset.Ico (paramLo j) (paramHi j)) :=
68
+ ⟨fun j => ⟨paramLo j, Finset.mem_Ico.mpr ⟨le_rfl, hparam j⟩⟩⟩
69
+ let ps := FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (sourceLo i) (sourceHi i))
70
+ let pt := FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (paramLo j) (paramHi j))
71
+ let p := pt.prod ps
72
+ let ms := integerBoxMesh sourceLo sourceHi S
73
+ let mt := integerBoxMesh paramLo paramHi T
74
+ let mesh := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) ×
75
+ (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) => (ms tz.2, mt tz.1)
76
+ let location := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) ×
77
+ (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) =>
78
+ smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)
79
+ let bad := physicalMeshCrossing lo N P mesh location
80
+ let value := fun (z : Option J × I → ℤ) (t : J → ℤ) => w z *
81
+ (physicalBoxTruncation lo N P hPpos q b h (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z) -
82
+ r * physicalBoxTruncation lo N P hPpos q b g (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z))
83
+ let F := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) ×
84
+ (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) => value (fun i => (tz.2 i).val) (fun j => (tz.1 j).val)
85
+ let cap := residueTruncationCap ι b etaSite
86
+ let K := R + (1 + r) * etaParam * cap
87
+ have hcap0 : 0 ≤ cap := residueTruncationCap_nonneg ι b hetaSite
88
+ have hK : 0 ≤ K := by dsimp only [K]; positivity
89
+ have hsLaw : integerBoxUniformWeights sourceLo sourceHi hsource = ps :=
90
+ integerBoxUniformWeights_eq_uniform sourceLo sourceHi hsource
91
+ have htLaw : integerBoxUniformWeights paramLo paramHi hparam = pt :=
92
+ integerBoxUniformWeights_eq_uniform paramLo paramHi hparam
93
+ rw [hsLaw, htLaw] at hbad ⊢
94
+ change p.eventProbability bad ≤ beta at hbad
95
+ change p.mean F ≤ R + (1 + r) * (etaParam + beta) * cap
96
+ have hlocal (x) (hx : ¬ bad x) : finiteCellMean p mesh F (mesh x) ≤ K * (finiteCellWeights p mesh).weight (mesh x) := by
97
+ let cs := ms x.2
98
+ let ct := mt x.1
99
+ have hclass := retained_integer_mesh_boxes_classify lo N P sourceLo sourceHi S hSstep hSpos
100
+ paramLo paramHi T hTstep hTpos D a x hx
101
+ have hwcell (z) (hz : z ∈ translatedIntegerBox
102
+ (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun i => (S i).length (cs i))) :
103
+ 0 ≤ w z ∧ w z ≤ 1 := by
104
+ obtain ⟨y, _, hy⟩ := integerBoxMesh_cell_realize sourceLo sourceHi S hSstep hSpos cs z hz
105
+ simpa only [hy] using hw y
106
+ have havg : (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (sourceLo i) (S i) (cs i))
107
+ (fun i => intervalCellLower (sourceLo i) (S i) (cs i) + (S i).length (cs i)) (fun _ => 1) (fun _ => 0),
108
+ 𝔼 t : IntegerResidueBox (fun j => intervalCellLower (paramLo j) (T j) (ct j))
109
+ (fun j => intervalCellLower (paramLo j) (T j) (ct j) + (T j).length (ct j)) (fun _ => 1) (fun _ => 0),
110
+ value (fun i => (z i).val) (fun j => (t j).val)) ≤ K := by
111
+ cases hc : physicalBoxClassify lo N P (location x) with
112
+ | some c =>
113
+ have ht := retained_physical_truncation_difference_le lo N P hPstep hPpos c q
114
+ (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun i => (S i).length (cs i))
115
+ (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs)
116
+ (fun j => intervalCellLower (paramLo j) (T j) (ct j)) (fun j => (T j).length (ct j))
117
+ (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct)
118
+ D a b w h g hwcell hh hg
119
+ (fun z hz t ht => (hclass z hz t ht).trans hc) hetaParam hetaSite hr
120
+ (hcloseParam ct) (hcloseSite c) (hreference cs c)
121
+ simpa only [value, K, cap, ← Finset.mul_expect] using ht
122
+ | none =>
123
+ have he (z : IntegerResidueBox (fun i => intervalCellLower (sourceLo i) (S i) (cs i))
124
+ (fun i => intervalCellLower (sourceLo i) (S i) (cs i) + (S i).length (cs i)) (fun _ => 1) (fun _ => 0))
125
+ (t : IntegerResidueBox (fun j => intervalCellLower (paramLo j) (T j) (ct j))
126
+ (fun j => intervalCellLower (paramLo j) (T j) (ct j) + (T j).length (ct j)) (fun _ => 1) (fun _ => 0)) :
127
+ value (fun i => (z i).val) (fun j => (t j).val) = 0 := by
128
+ have hnone := (hclass (fun i => (z i).val)
129
+ ((mem_translatedIntegerBox _ _ _).mpr (fun i => Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1))
130
+ (fun j => (t j).val)
131
+ ((mem_translatedIntegerBox _ _ _).mpr (fun j => Finset.mem_Ico.mp (Finset.mem_filter.mp (t j).property).1))).trans hc
132
+ dsimp only [value]
133
+ rw [physicalBoxTruncation_of_classify_none lo N P hPpos q b h _ hnone,
134
+ physicalBoxTruncation_of_classify_none lo N P hPpos q b g _ hnone]
135
+ ring
136
+ simpa only [he, Finset.expect_const_zero] using hK
137
+ have hm := integerBoxMesh_pair_cell_mean sourceLo sourceHi S hSstep hSpos
138
+ paramLo paramHi T hTstep hTpos cs ct value
139
+ have hwgt := finiteCellWeights_product ps pt ms mt cs ct
140
+ change finiteCellMean p mesh F (cs,ct) ≤ K * (finiteCellWeights p mesh).weight (cs,ct)
141
+ rw [hm, hwgt]
142
+ exact (mul_le_mul_of_nonneg_left havg
143
+ (mul_nonneg ((finiteCellWeights ps ms).nonneg cs) ((finiteCellWeights pt mt).nonneg ct))).trans_eq (mul_comm _ _)
144
+ have hbound (x) (_ : bad x) : |F x| ≤ (1 + r) * cap := by
145
+ have hhc := physicalBoxTruncation_cap lo N P hPstep hPpos q b h hh hetaSite hcloseSite (location x)
146
+ have hgc := physicalBoxTruncation_cap lo N P hPstep hPpos q b g hg hetaSite hcloseSite (location x)
147
+ have hd : |physicalBoxTruncation lo N P hPpos q b h (location x) -
148
+ r * physicalBoxTruncation lo N P hPpos q b g (location x)| ≤ (1 + r) * cap := by
149
+ apply (abs_sub _ _).trans
150
+ rw [abs_mul, abs_of_nonneg hr]
151
+ exact (add_le_add hhc (mul_le_mul_of_nonneg_left hgc hr)).trans_eq (by dsimp only [cap]; ring)
152
+ change |w (fun i => (x.2 i).val) *
153
+ (physicalBoxTruncation lo N P hPpos q b h (location x) -
154
+ r * physicalBoxTruncation lo N P hPpos q b g (location x))| ≤ _
155
+ rw [abs_mul, abs_of_nonneg (hw x.2).1]
156
+ exact (mul_le_mul (hw x.2).2 hd (abs_nonneg _) zero_le_one).trans_eq (one_mul _)
157
+ have hall := finite_mean_le_of_retained_cells p mesh bad F
158
+ (fun x y hxy => physicalMeshCrossing_congr lo N P mesh location hxy)
159
+ hK (by positivity : 0 ≤ (1 + r) * cap) hbad hbound hlocal
160
+ exact hall.trans_eq (by dsimp only [K]; ring)
161
+
162
+ end Erdos3
163
+
164
+ end
165
+
166
+ section
167
+
168
+ namespace Erdos3
169
+
170
+ open scoped BigOperators Classical
171
+
172
+ theorem affine_mesh_zero_extension_bound
173
+ {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J]
174
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
175
+ (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c)
176
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i)
177
+ (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat)
178
+ (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c)
179
+ (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j)
180
+ (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat)
181
+ (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c)
182
+ (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ)
183
+ (w : (Option J × I → ℤ) → ℝ) (h g : (I → ℤ) → ℝ)
184
+ (hw : ∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)),
185
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1)
186
+ (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1)
187
+ (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1)
188
+ {etaParam etaSite r R beta accuracy : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite)
189
+ (hr : 0 ≤ r) (hR : 0 ≤ R)
190
+ (hcloseParam : ∀ ct : (∀ j, (T j).Label),
191
+ ProductMarginalsClose (primeCoordinateReference (σ := J) q)
192
+ (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j))
193
+ (fun j => (T j).length (ct j)) 1 (fun _ => 0)
194
+ (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct)
195
+ q (fun _ => 1)) etaParam b)
196
+ (hcloseSite : ∀ c : (∀ i, (P i).Label),
197
+ ProductMarginalsClose (primeCoordinateReference (σ := I) q)
198
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
199
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c)
200
+ q (fun _ => 1)) etaSite b)
201
+ (hreference : ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label),
202
+ productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b)
203
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i))
204
+ (fun i => (S i).length (cs i)) 1 (fun _ => 0)
205
+ (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w)
206
+ (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
207
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x -
208
+ r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
209
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R)
210
+ (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod
211
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability
212
+ (physicalMeshCrossing lo N P
213
+ (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1))
214
+ (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta)
215
+ (heh : |((integerBoxUniformWeights paramLo paramHi hparam).prod
216
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
217
+ (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b h
218
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy)
219
+ (heg : |((integerBoxUniformWeights paramLo paramHi hparam).prod
220
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
221
+ (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b g
222
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) :
223
+ ((integerBoxUniformWeights paramLo paramHi hparam).prod
224
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
225
+ (fun tz => w (fun i => (tz.2 i).val) *
226
+ (realZeroExtendFinset (translatedIntegerBox lo N) h
227
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) -
228
+ r * realZeroExtendFinset (translatedIntegerBox lo N) g
229
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))) ≤
230
+ R + (1 + r) * ((etaParam + beta) * residueTruncationCap ι b etaSite + accuracy) := by
231
+ have hlow := affine_mesh_truncation_bound lo N P hPstep hPpos
232
+ sourceLo sourceHi hsource S hSstep hSpos paramLo paramHi hparam T hTstep hTpos
233
+ D a q b w h g hw hh hg hetaParam hetaSite hr hR hcloseParam hcloseSite hreference hbad
234
+ have hrestore := physical_zero_extension_restore_difference
235
+ ((integerBoxUniformWeights paramLo paramHi hparam).prod
236
+ (integerBoxUniformWeights sourceLo sourceHi hsource))
237
+ (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))
238
+ (fun tz => w (fun i => (tz.2 i).val)) lo N P hPstep hPpos q b h g hr heh heg hlow
239
+ exact hrestore.trans_eq (by ring)
240
+
241
+ end Erdos3
242
+
243
+ end
244
+
245
+ section
246
+
247
+ namespace Erdos3
248
+
249
+ open scoped BigOperators Classical
250
+
251
+ theorem affine_mesh_scalar_tail
252
+ {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J]
253
+ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i))
254
+ (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c)
255
+ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i)
256
+ (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat)
257
+ (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c)
258
+ (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j)
259
+ (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat)
260
+ (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c)
261
+ (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ)
262
+ (h g : (I → ℤ) → ℝ)
263
+ (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1)
264
+ (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1)
265
+ {etaParam etaSite r R beta accuracy : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite)
266
+ (hr : 0 ≤ r) (hR : 0 ≤ R)
267
+ (hcloseParam : ∀ ct : (∀ j, (T j).Label),
268
+ ProductMarginalsClose (primeCoordinateReference (σ := J) q)
269
+ (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j))
270
+ (fun j => (T j).length (ct j)) 1 (fun _ => 0)
271
+ (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct)
272
+ q (fun _ => 1)) etaParam b)
273
+ (hcloseSite : ∀ c : (∀ i, (P i).Label),
274
+ ProductMarginalsClose (primeCoordinateReference (σ := I) q)
275
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
276
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c)
277
+ q (fun _ => 1)) etaSite b)
278
+ (hreference : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)),
279
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) →
280
+ ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label),
281
+ productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b)
282
+ (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i))
283
+ (fun i => (S i).length (cs i)) 1 (fun _ => 0)
284
+ (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w)
285
+ (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
286
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x -
287
+ r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i))
288
+ (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R)
289
+ (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod
290
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability
291
+ (physicalMeshCrossing lo N P
292
+ (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1))
293
+ (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta)
294
+ (heh : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)),
295
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) →
296
+ |((integerBoxUniformWeights paramLo paramHi hparam).prod
297
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
298
+ (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b h
299
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy)
300
+ (heg : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)),
301
+ 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) →
302
+ |((integerBoxUniformWeights paramLo paramHi hparam).prod
303
+ (integerBoxUniformWeights sourceLo sourceHi hsource)).mean
304
+ (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b g
305
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy)
306
+ (p dominationLog : ℝ)
307
+ (outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)))
308
+ (hdom : ∀ z, outer.weight z ≤ Real.exp dominationLog *
309
+ (integerBoxUniformWeights sourceLo sourceHi hsource).weight z)
310
+ (herror : R + (1 + r) * ((etaParam + beta) * residueTruncationCap ι b etaSite + accuracy) ≤
311
+ Real.exp (-(2 * p + dominationLog)) / 2) :
312
+ outer.eventProbability (fun z => Real.exp (-p) <
313
+ (integerBoxUniformWeights paramLo paramHi hparam).mean (fun t =>
314
+ realZeroExtendFinset (translatedIntegerBox lo N) h
315
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)) -
316
+ r * realZeroExtendFinset (translatedIntegerBox lo N) g
317
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤
318
+ Real.exp (-p) := by
319
+ apply fixedParameter_observed_tail_dominated
320
+ (integerBoxUniformWeights sourceLo sourceHi hsource) outer
321
+ (integerBoxUniformWeights paramLo paramHi hparam) (fun z i => (z i).val)
322
+ (fun t z => realZeroExtendFinset (translatedIntegerBox lo N) h
323
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) z) -
324
+ r * realZeroExtendFinset (translatedIntegerBox lo N) g
325
+ (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) z)) p dominationLog hdom
326
+ intro w hw
327
+ exact (affine_mesh_zero_extension_bound lo N P hPstep hPpos sourceLo sourceHi hsource
328
+ S hSstep hSpos paramLo paramHi hparam T hTstep hTpos D a q b w h g hw hh hg
329
+ hetaParam hetaSite hr hR hcloseParam hcloseSite (hreference w hw) hbad
330
+ (heh w hw) (heg w hw)).trans herror
331
+
332
+ end Erdos3
333
+
334
+ end
335
+
336
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineModerateGeometricApproximation.lean ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.AffineTorusGeometry
2
+ import OAI.Combinatorics.Progressions.Lattices.WeightedSliceIntegerImage
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped NNReal
11
+
12
+ noncomputable def affinePrimitiveEnvelope (I : Type*) [Fintype I]
13
+ (A B T : ℝ≥0) (M V : ℕ) : ℝ :=
14
+ max 1 (max (scalarCubePrimitiveEnvelope I A B T M)
15
+ (max (scalarCubePrimitiveEnvelope Empty A B T M) ((V * M : ℕ) : ℝ)))
16
+
17
+ theorem affinePrimitiveEnvelope_one_le (I : Type*) [Fintype I] (A B T : ℝ≥0) (M V : ℕ) :
18
+ 1 ≤ affinePrimitiveEnvelope I A B T M V := le_max_left _ _
19
+
20
+ theorem affinePrimitiveEnvelope_vector (I : Type*) [Fintype I] [DecidableEq I]
21
+ (s : NormalizedScalarCubeSource I) (A B T : ℝ≥0) (M V : ℕ)
22
+ (hM : s.modulusBound ≤ M) (hB : s.weightBound ≤ B) (hT : s.weightLipschitz ≤ T) :
23
+ ScalarCubePrimitiveBudget s A (affinePrimitiveEnvelope I A B T M V) :=
24
+ (scalarCubePrimitiveBudget_of_raw_bounds s A B T M hM hB hT).mono
25
+ ((le_max_left _ _).trans (le_max_right _ _))
26
+
27
+ theorem affinePrimitiveEnvelope_coefficient (I : Type*) [Fintype I]
28
+ (s : NormalizedScalarCubeSource Empty) (A B T : ℝ≥0) (M V : ℕ)
29
+ (hM : s.modulusBound ≤ M) (hB : s.weightBound ≤ B) (hT : s.weightLipschitz ≤ T) :
30
+ ScalarCubePrimitiveBudget s A (affinePrimitiveEnvelope I A B T M V) :=
31
+ (scalarCubePrimitiveBudget_of_raw_bounds s A B T M hM hB hT).mono
32
+ ((le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _)))
33
+
34
+ theorem affinePrimitiveEnvelope_stride (I : Type*) [Fintype I] (A B T : ℝ≥0) (M V : ℕ)
35
+ {v m : ℕ} (hv : v ≤ V) (hm : m ≤ M) :
36
+ ((v * m : ℕ) : ℝ) ≤ affinePrimitiveEnvelope I A B T M V := by
37
+ have hvm : ((v * m : ℕ) : ℝ) ≤ ((V * M : ℕ) : ℝ) := by exact_mod_cast Nat.mul_le_mul hv hm
38
+ exact hvm.trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _)))
39
+
40
+ end Erdos3
41
+
42
+ end
43
+
44
+ section
45
+
46
+ namespace Erdos3
47
+
48
+ open scoped BigOperators NNReal Classical
49
+
50
+ theorem affineCube_geometric_approximation {B I : Type*}
51
+ [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I]
52
+ {n K : ℕ} [NeZero K] (s : B → Fin (n + 1) → NormalizedScalarCubeSource I)
53
+ (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ)
54
+ (A W T : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (M V : ℕ)
55
+ (hM : ∀ b j, (s b j).modulusBound ≤ M) (hW : ∀ b j, (s b j).weightBound ≤ W)
56
+ (hT : ∀ b j, (s b j).weightLipschitz ≤ T) (hv : ∀ b j i, 0 < v b j i)
57
+ (hvV : ∀ b j i, v b j i ≤ V) {C F D E ε : ℝ}
58
+ (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1)
59
+ (hcoord : ∀ b j i, |(u b j i : ℝ)| + (v b j i : ℝ) * (s b j).length ≤ C * (s b j).length)
60
+ (hupper : ∀ b, (∏ j, ((s b j).length : ℝ)) ≤ F * K)
61
+ (hlower : ∀ b, (K : ℝ) ≤ D * ∏ j, ((s b j).length : ℝ))
62
+ (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p)
63
+ (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1)
64
+ (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) :
65
+ let U := affinePrimitiveEnvelope I A W T M V
66
+ let Q := affineTorusRadius (Fintype.card I) (n + 1) (Fintype.card B) C F
67
+ let R := affineTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) C F
68
+ let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε
69
+ ∃ S : Finset (J → Fin (R * K)),
70
+ (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card)
71
+ U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) /
72
+ ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧
73
+ (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) (R * K) J k‖) ≤
74
+ uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧
75
+ (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card)
76
+ U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧
77
+ ∃ (a : J → ℤ) (ξ : J → ℝ),
78
+ (∀ Z, |ξ Z| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧
79
+ ∀ Z, ((k Z).val : ℝ) / (R * K) = (a Z : ℝ) / d + ξ Z / K) ∧
80
+ ∀ center z : J → ℤ, centeredFundamentalBox Q K center z →
81
+ ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s)
82
+ (affineWeightedCubeIntegerSum s u v J center) z : ℝ) : ℂ) -
83
+ integerGridApproximation (weightedCubeIntegerSource s)
84
+ (affineWeightedCubeIntegerSum s u v J center) K (R * K) S z‖ ≤ ε := by
85
+ let U := affinePrimitiveEnvelope I A W T M V
86
+ let Q := affineTorusRadius (Fintype.card I) (n + 1) (Fintype.card B) C F
87
+ let R := affineTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) C F
88
+ have hU : 1 ≤ U := affinePrimitiveEnvelope_one_le I A W T M V
89
+ have h (b) (j) : ScalarCubePrimitiveBudget (s b j) A U :=
90
+ affinePrimitiveEnvelope_vector I (s b j) A W T M V (hM b j) (hW b j) (hT b j)
91
+ have hstride (b) (j) (i) : ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U :=
92
+ affinePrimitiveEnvelope_stride I A W T M V (hvV b j i) ((s b j).modulus_le i |>.trans (hM b j))
93
+ have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K)
94
+ have hR : 0 < R := affineTorusFactor_pos _ _ _ _ _
95
+ obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum
96
+ (fun x : B × Fin (n + 1) => (s x.1 x.2).length)
97
+ (fun x => (s x.1 x.2).length_pos) (R := R) p J.card (fun x => hpower x.1 x.2)
98
+ have hVD : 0 ≤ (R : ℝ) * D := by positivity
99
+ have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity
100
+ have hscale (b : B) : ((R * K : ℕ) : ℝ) / ∏ j, ((s b j).length : ℝ) ≤ (R : ℝ) * D := by
101
+ have hp : 0 < ∏ j, ((s b j).length : ℝ) :=
102
+ Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos)
103
+ simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp (hlower b)
104
+ let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε
105
+ let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ
106
+ refine ⟨S, ?_, ?_, ?_, ?_⟩
107
+ · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card
108
+ J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1
109
+ (by simpa only [Fintype.card_coe] using hsize)
110
+ · exact (affine_weightedCube_uniform_spectrum s (fun b j i => (u b j i : ℝ)) v A hA hU hVD hWE
111
+ (Nat.cast_nonneg m) hε h (fun b j => by exact_mod_cast hmin (b, j)) hv hstride
112
+ (R * K) (p * J.card) (Nat.mul_pos hR hK) J hJ hB hsize hscale).2
113
+ · intro k hk
114
+ obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε
115
+ obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK)
116
+ n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1
117
+ (by simpa only [Fintype.card_coe] using hsize) k hk
118
+ obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he)
119
+ refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩
120
+ · simpa only [Fintype.card_coe] using hdb
121
+ · simpa only [Fintype.card_coe] using hρ
122
+ · exact affine_weightedCube_fundamental_approximation s u v A hA hU hVD hWE (Nat.cast_nonneg m) hε
123
+ h (fun b j => by exact_mod_cast hmin (b, j)) hv hstride (p * J.card) J hJ
124
+ (fun Z => affineWeightedCube_bound_le_torus s u v hC hcoord hupper Z (hJ Z Z.property))
125
+ hB hsize hscale
126
+
127
+ end Erdos3
128
+
129
+ end
130
+
131
+ section
132
+
133
+ namespace Erdos3
134
+
135
+ open scoped BigOperators NNReal Classical
136
+
137
+ theorem affineModerate_geometric_approximation {B I : Type*}
138
+ [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I]
139
+ {n K : ℕ} [NeZero K] (c : B → NormalizedScalarCubeSource Empty)
140
+ (s : B → Fin n → NormalizedScalarCubeSource I) (offset : B → ℤ) (stride : B → ℕ)
141
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
142
+ (A W T : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (M V : ℕ)
143
+ (hcM : ∀ b, (c b).modulusBound ≤ M) (hcW : ∀ b, (c b).weightBound ≤ W)
144
+ (hcT : ∀ b, (c b).weightLipschitz ≤ T)
145
+ (hM : ∀ b j, (s b j).modulusBound ≤ M) (hW : ∀ b j, (s b j).weightBound ≤ W)
146
+ (hT : ∀ b j, (s b j).weightLipschitz ≤ T) (hv : ∀ b j i, 0 < v b j i)
147
+ (hvV : ∀ b j i, v b j i ≤ V) (ht : ∀ b, 0 < stride b) (htV : ∀ b, stride b ≤ V)
148
+ {C F D E ε : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1)
149
+ (hcoord : ∀ b j i, |(u b j i : ℝ)| + (v b j i : ℝ) * (s b j).length ≤ C * (s b j).length)
150
+ (hupper : ∀ b, (|(offset b : ℝ)| + (stride b : ℝ) * (c b).length) *
151
+ (∏ j, ((s b j).length : ℝ)) ≤ F * K)
152
+ (hlower : ∀ b, (K : ℝ) ≤ D * ((c b).length * ∏ j, ((s b j).length : ℝ)))
153
+ (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p)
154
+ (hcpower : ∀ b, (K : ℝ) ≤ E * ((c b).length : ℝ) ^ p)
155
+ (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n)
156
+ (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) :
157
+ let U := affinePrimitiveEnvelope I A W T M V
158
+ let Q := affineTorusRadius (Fintype.card I) n (Fintype.card B) C F
159
+ let R := affineTorusFactor (Fintype.card I) n (Fintype.card B) C F
160
+ let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε
161
+ ∃ S : Finset (J → Fin (R * K)),
162
+ (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card)
163
+ U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) /
164
+ ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧
165
+ (∑ k, ‖∏ b, affineWeightedModerateGridCoefficient (c b) (s b) (offset b : ℝ) (stride b)
166
+ (fun j i => (u b j i : ℝ)) (v b) (R * K) J k‖) ≤
167
+ uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧
168
+ (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card)
169
+ U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧
170
+ ∃ (a : J → ℤ) (ξ : J → ℝ),
171
+ (∀ Z, |ξ Z| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧
172
+ ∀ Z, ((k Z).val : ℝ) / (R * K) = (a Z : ℝ) / d + ξ Z / K) ∧
173
+ ∀ center z : J → ℤ, centeredFundamentalBox Q K center z →
174
+ ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s)
175
+ (affineWeightedModerateIntegerSum c s offset stride u v J center) z : ℝ) : ℂ) -
176
+ integerGridApproximation (weightedModerateIntegerProductSource c s)
177
+ (affineWeightedModerateIntegerSum c s offset stride u v J center) K (R * K) S z‖ ≤ ε := by
178
+ let U := affinePrimitiveEnvelope I A W T M V
179
+ let R := affineTorusFactor (Fintype.card I) n (Fintype.card B) C F
180
+ have hU : 1 ≤ U := affinePrimitiveEnvelope_one_le I A W T M V
181
+ have hc (b) : ScalarCubePrimitiveBudget (c b) A U :=
182
+ affinePrimitiveEnvelope_coefficient I (c b) A W T M V (hcM b) (hcW b) (hcT b)
183
+ have h (b) (j) : ScalarCubePrimitiveBudget (s b j) A U :=
184
+ affinePrimitiveEnvelope_vector I (s b j) A W T M V (hM b j) (hW b j) (hT b j)
185
+ have hstride (b) (j) (i) : ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U :=
186
+ affinePrimitiveEnvelope_stride I A W T M V (hvV b j i) ((s b j).modulus_le i |>.trans (hM b j))
187
+ have hcoeff (b) : ((stride b * (c b).modulus none : ℕ) : ℝ) ≤ U :=
188
+ affinePrimitiveEnvelope_stride I A W T M V (htV b) ((c b).modulus_le none |>.trans (hcM b))
189
+ have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K)
190
+ have hR : 0 < R := affineTorusFactor_pos _ _ _ _ _
191
+ let length (x : B × Option (Fin n)) : ℕ := x.2.elim (c x.1).length (fun j => (s x.1 j).length)
192
+ have hpos (x : B × Option (Fin n)) : 0 < length x := by
193
+ rcases x with ⟨b, _ | j⟩
194
+ · exact (c b).length_pos
195
+ · exact (s b j).length_pos
196
+ have hpow (x : B × Option (Fin n)) : (K : ℝ) ≤ E * (length x : ℝ) ^ p := by
197
+ rcases x with ⟨b, _ | j⟩
198
+ · exact hcpower b
199
+ · exact hpower b j
200
+ obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum length hpos (R := R) p J.card hpow
201
+ have hVD : 0 ≤ (R : ℝ) * D := by positivity
202
+ have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity
203
+ have hscale (b : B) : ((R * K : ℕ) : ℝ) /
204
+ ((((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) * ∏ j, ((s b j).length : ℝ)) ≤
205
+ (R : ℝ) * D := by
206
+ have hp : 0 < (((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) *
207
+ ∏ j, ((s b j).length : ℝ) := by
208
+ apply mul_pos
209
+ · exact mul_pos (by exact_mod_cast Nat.mul_pos (ht b) ((c b).modulus_pos none))
210
+ (by exact_mod_cast (c b).length_pos)
211
+ · exact Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos)
212
+ simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp
213
+ (affineModerate_physical_volume_lower (c b) (s b) (ht b) hD (hlower b))
214
+ let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε
215
+ let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ
216
+ refine ⟨S, ?_, ?_, ?_, ?_⟩
217
+ · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card
218
+ J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1
219
+ (by simpa only [Fintype.card_coe] using hsize)
220
+ · exact (affine_weightedModerate_uniform_spectrum c s (fun b => (offset b : ℝ)) stride
221
+ (fun b j i => (u b j i : ℝ)) v A hA hU hVD hWE (Nat.cast_nonneg m) hε hc h
222
+ (fun b => by exact_mod_cast hmin (b, none)) (fun b j => by exact_mod_cast hmin (b, some j))
223
+ ht hv hstride hcoeff (R * K) (p * J.card) (Nat.mul_pos hR hK) J hJ hB hsize hscale).2
224
+ · intro k hk
225
+ obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε
226
+ obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK)
227
+ n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1
228
+ (by simpa only [Fintype.card_coe] using hsize) k hk
229
+ obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he)
230
+ refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩
231
+ · simpa only [Fintype.card_coe] using hdb
232
+ · simpa only [Fintype.card_coe] using hρ
233
+ · exact affine_weightedModerate_fundamental_approximation c s offset stride u v A hA hU hVD hWE
234
+ (Nat.cast_nonneg m) hε hc h (fun b => by exact_mod_cast hmin (b, none))
235
+ (fun b j => by exact_mod_cast hmin (b, some j)) ht hv hstride hcoeff (p * J.card) J hJ
236
+ (fun Z => affineWeightedModerate_bound_le_torus c s offset stride u v hC hcoord hupper Z (hJ Z Z.property))
237
+ hB hsize hscale
238
+
239
+ end Erdos3
240
+
241
+ end
242
+
243
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauModel.lean ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.FixedPrincipalCoefficientSpectrum
2
+ import OAI.Combinatorics.Progressions.Probability.AllocatedActiveAxisSourceLaw
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped BigOperators NNReal
11
+
12
+ variable {A J : Type*} [Fintype A] [Fintype J]
13
+ variable (D : A → ℕ) [∀ a, NeZero (D a)] (frequency : A → J → ℤ)
14
+ variable (coefficient : A → ℂ) (mode : A → (J → ℝ) → ℂ)
15
+
16
+ noncomputable def finiteResidueModeModel (residue : ∀ a, J → ZMod (D a)) (x : J → ℝ) : ℂ :=
17
+ ∑ a, coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a x)
18
+
19
+ theorem finiteResidueModeModel_norm {C : ℝ}
20
+ (hcap : (∑ a, ‖coefficient a‖) ≤ C) (hmode : ∀ a x, ‖mode a x‖ ≤ 1)
21
+ (residue : ∀ a, J → ZMod (D a)) (x : J → ℝ) :
22
+ ‖finiteResidueModeModel D frequency coefficient mode residue x‖ ≤ C := by
23
+ apply (norm_sum_le _ _).trans
24
+ apply (Finset.sum_le_sum (fun a _ => ?_)).trans hcap
25
+ rw [norm_mul, norm_mul, norm_star, rationalGridPhase_norm, one_mul]
26
+ exact mul_le_of_le_one_right (norm_nonneg _) (hmode a x)
27
+
28
+ theorem finiteResidueModeModel_lipschitz (C L : ℝ≥0)
29
+ (hcap : (∑ a, ‖coefficient a‖) ≤ C) (hmode : ∀ a, LipschitzWith L (mode a))
30
+ (residue : ∀ a, J → ZMod (D a)) :
31
+ LipschitzWith (C * L) (finiteResidueModeModel D frequency coefficient mode residue) := by
32
+ apply LipschitzWith.of_dist_le_mul
33
+ intro x y
34
+ rw [dist_eq_norm]
35
+ unfold finiteResidueModeModel
36
+ rw [← Finset.sum_sub_distrib]
37
+ calc
38
+ _ ≤ ∑ a, ‖coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a x) -
39
+ coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a y)‖ :=
40
+ norm_sum_le _ _
41
+ _ ≤ ∑ a, ‖coefficient a‖ * ((L : ℝ) * dist x y) := by
42
+ apply Finset.sum_le_sum
43
+ intro a _
44
+ rw [← mul_sub, ← mul_sub, norm_mul, norm_mul, norm_star, rationalGridPhase_norm, one_mul]
45
+ exact mul_le_mul_of_nonneg_left
46
+ (by simpa only [dist_eq_norm] using (hmode a).dist_le_mul x y) (norm_nonneg _)
47
+ _ = (∑ a, ‖coefficient a‖) * ((L : ℝ) * dist x y) := (Finset.sum_mul _ _ _).symm
48
+ _ ≤ (C : ℝ) * ((L : ℝ) * dist x y) :=
49
+ mul_le_mul_of_nonneg_right hcap (mul_nonneg L.coe_nonneg dist_nonneg)
50
+ _ = _ := by rw [NNReal.coe_mul, mul_assoc]
51
+
52
+ theorem finiteResidueModeModel_residue_card [DecidableEq A] [DecidableEq J]
53
+ (Q : ℕ) (hQ : ∀ a, D a ≤ Q) :
54
+ Fintype.card (∀ a, J → ZMod (D a)) ≤ Q ^ (Fintype.card A * Fintype.card J) := by
55
+ classical
56
+ rw [Fintype.card_pi]
57
+ simp only [Fintype.card_fun, ZMod.card]
58
+ calc
59
+ ∏ a, D a ^ Fintype.card J ≤ ∏ _a : A, Q ^ Fintype.card J :=
60
+ Finset.prod_le_prod (fun a _ => Nat.pow_le_pow_left (hQ a) _)
61
+ _ = Q ^ (Fintype.card A * Fintype.card J) := by
62
+ simp only [Finset.prod_const, Finset.card_univ, ← pow_mul, Nat.mul_comm]
63
+
64
+ end Erdos3
65
+
66
+ end
67
+
68
+ section
69
+
70
+ namespace Erdos3
71
+
72
+ open scoped BigOperators Classical
73
+ open CircleFourier
74
+
75
+ noncomputable def weightedAffineModerateIntegerBlock {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
76
+ (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I)
77
+ (u : Fin n → Option I → ℤ) (v : Fin n → Option I → ℕ)
78
+ (J : Finset (Finset I)) (offset : ℤ)
79
+ (x : IntegerScalarCubeBox Empty c.length × (∀ j, IntegerScalarCubeBox I (s j).length)) : J → ℤ :=
80
+ fun S => (offset + (x.1 none : ℤ)) * integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u j) (v j) (fun r => (x.2 j r : ℤ))) S
81
+
82
+ theorem weightedAffineModerateGridCoefficient_eq_image {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
83
+ (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I)
84
+ (u : Fin n → Option I → ℤ) (v : Fin n → Option I → ℕ)
85
+ (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : ℤ) (k : J → Fin M) :
86
+ integerGridCoefficient (weightedModerateIntegerSource c s) (weightedAffineModerateIntegerBlock c s u v J offset) M k =
87
+ weightedAffineModerateGridCoefficient c s (fun j i => (u j i : ℝ)) v (offset : ℝ) M J k := by
88
+ unfold integerGridCoefficient weightedModerateIntegerSource
89
+ rw [FiniteProbabilityWeights.complexMean_prod]
90
+ change c.source.complexMean _ = c.source.complexMean _
91
+ congr 1
92
+ funext z
93
+ congr 1
94
+ funext x
95
+ rw [rectangularGridCharacter_eq]
96
+ simp only [weightedAffineModerateIntegerBlock, integerBooleanBlockJet_scaled_pairing]
97
+ simp only [affineIntegerCubeCoordinates, Int.cast_add, Int.cast_mul, Int.cast_natCast]
98
+ rfl
99
+
100
+ noncomputable def weightedAffineModerateIntegerJetSum {B : Type*} [Fintype B]
101
+ {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
102
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
103
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
104
+ (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ)
105
+ (x : ��� b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length)) : J → ℤ :=
106
+ shift + ∑ b, weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) J (offset b) (x b)
107
+
108
+ theorem weightedAffineModerateIntegerJetSum_coefficient {B : Type*} [Fintype B] [DecidableEq B]
109
+ {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
110
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
111
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
112
+ (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) (k : J → Fin M) :
113
+ integerGridCoefficient (weightedModerateIntegerProductSource c s)
114
+ (weightedAffineModerateIntegerJetSum c s u v J offset shift) M k =
115
+ 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
116
+ have h := independent_integerGridCoefficient (fun b => weightedModerateIntegerSource (c b) (s b))
117
+ (fun b => weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) J (offset b)) shift M k
118
+ unfold weightedModerateIntegerProductSource weightedAffineModerateIntegerJetSum
119
+ simpa only [weightedAffineModerateGridCoefficient_eq_image] using h
120
+
121
+ end Erdos3
122
+
123
+ end
124
+
125
+ section
126
+
127
+ namespace Erdos3
128
+
129
+ open scoped BigOperators Classical
130
+
131
+ theorem containedProgressionCoordinate_mem {L H step : ℕ} (c z : ℤ)
132
+ (hsubset : integerProgressionSupport c (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ))
133
+ (hz : z ∈ Finset.Ico (0 : ℤ) (H : ℤ)) :
134
+ c + (step : ℤ) * z ∈ Finset.Ico (0 : ℤ) (L : ℤ) := by
135
+ apply hsubset
136
+ rw [integerProgressionSupport, mem_translateSupport]
137
+ exact Finset.mem_image.mpr ⟨z, hz, by change (step : ℤ) * z = _; ring⟩
138
+
139
+ theorem NormalizedScalarCubeSource.source_cube {I : Type*} [Fintype I] [DecidableEq I]
140
+ (s : NormalizedScalarCubeSource I) (x : IntegerScalarCubeBox I s.length)
141
+ (hx : s.source.weight x ≠ 0) : IntegerScalarCube s.length (fun i => (x i : ℤ)) := by
142
+ have hb : s.baseLaw.weight x ≠ 0 := (mul_ne_zero_iff.mp hx).1
143
+ have hp := lt_of_le_of_ne (s.baseLaw.nonneg x) hb.symm
144
+ rw [NormalizedScalarCubeSource.baseLaw, scalarCubeResidueWeights,
145
+ FiniteProbabilityWeights.condition_weight_pos_iff] at hp
146
+ have h1 := hp.2
147
+ rw [integerScalarCubeWeights, FiniteProbabilityWeights.condition_weight_pos_iff] at h1
148
+ exact (mem_integerScalarCubeSet s.length x).mp h1.1
149
+
150
+ theorem containedProgressionCoordinate_bound {I : Type*} [Fintype I] [DecidableEq I]
151
+ {L H step : ℕ} (c : ℤ)
152
+ (hsubset : integerProgressionSupport c (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ))
153
+ (x : IntegerScalarCubeBox I H) (hx : IntegerScalarCube H (fun i => (x i : ℤ))) (i : Option I) :
154
+ |(if i = none then c else 0) + (step : ℤ) * (x i : ℤ)| ≤ L := by
155
+ have hb := integerScalarCube_coordinates (integerScalarCube_progression c hsubset _ hx) i
156
+ exact abs_le.mpr ⟨hb.1.le, hb.2.le⟩
157
+
158
+ theorem weightedAffineModerateIntegerJetSum_box_bound
159
+ {B I : Type*} [Fintype B] [Fintype I] [DecidableEq I] {n : ℕ}
160
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
161
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
162
+ (T : ℕ) (rows : Finset (Finset I)) (hrows : ∀ t ∈ rows, t.card ≤ n)
163
+ {A K : ℝ} (hA : 0 ≤ A) (hK : 0 ≤ K)
164
+ (hvol : ∀ b, ((c b).length : ℝ) * (T : ℝ) ^ n ≤ A * K)
165
+ (shift : rows → ℤ)
166
+ (x : ∀ b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length))
167
+ (hcoord : ∀ b j i,
168
+ |affineIntegerCubeCoordinates (u b j) (v b j) (fun i => ((x b).2 j i : ℤ)) i| ≤ T)
169
+ (t : rows) :
170
+ |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤
171
+ blockJetScaleBound (Fintype.card I) n (Fintype.card B) A * K := by
172
+ have hb (b : B) : |weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) rows 0 (x b) t| ≤
173
+ ((c b).length : ℤ) * ((2 : ℤ) ^ t.val.card *
174
+ ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℤ) * T) := by
175
+ unfold weightedAffineModerateIntegerBlock
176
+ rw [zero_add, abs_mul]
177
+ exact mul_le_mul (integerScalarCubeBox_coordinate_abs (x b).1 none)
178
+ (integerBooleanBlockJet_bound _ (fun _ => T) (fun j i => hcoord b j i) t)
179
+ (abs_nonneg _) (Nat.cast_nonneg _)
180
+ have hs : |weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t - shift t| ≤
181
+ ∑ b, ((c b).length : ℤ) * ((2 : ℤ) ^ t.val.card *
182
+ ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℤ) * T) := by
183
+ simp only [weightedAffineModerateIntegerJetSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left]
184
+ exact (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun b _ => hb b))
185
+ have hs' : |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤
186
+ ∑ b, ((c b).length : ℝ) * ((2 : ℝ) ^ t.val.card *
187
+ (((Fintype.card I + 1 : ℕ) : ℝ) ^ n * (T : ℝ) ^ n)) := by
188
+ have hh : |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤
189
+ ∑ b, ((c b).length : ℝ) * ((2 : ℝ) ^ t.val.card *
190
+ ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℝ) * T) := by
191
+ exact_mod_cast hs
192
+ simpa only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] using hh
193
+ apply hs'.trans
194
+ calc
195
+ _ = ∑ b, (2 : ℝ) ^ t.val.card * ((Fintype.card I + 1 : ℕ) : ℝ) ^ n *
196
+ (((c b).length : ℝ) * (T : ℝ) ^ n) := by
197
+ apply Finset.sum_congr rfl
198
+ intro b _
199
+ ring
200
+ _ ≤ ∑ _b : B, (2 : ℝ) ^ n * ((Fintype.card I + 1 : ℕ) : ℝ) ^ n * (A * K) := by
201
+ apply Finset.sum_le_sum
202
+ intro b _
203
+ apply (mul_le_mul_of_nonneg_left (hvol b) (by positivity)).trans
204
+ have hp := pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) (hrows t t.property)
205
+ exact mul_le_mul_of_nonneg_right
206
+ (mul_le_mul_of_nonneg_right hp (by positivity)) (mul_nonneg hA hK)
207
+ _ = _ := by
208
+ simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, blockJetScaleBound]
209
+ ring
210
+
211
+ end Erdos3
212
+
213
+ end
214
+
215
+ section
216
+
217
+ namespace Erdos3
218
+
219
+ open scoped BigOperators Classical
220
+
221
+ variable {B : Type*} [Fintype B] [DecidableEq B]
222
+ variable {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
223
+ variable (c : B → NormalizedScalarCubeSource Empty)
224
+ variable (s : B → Fin n → NormalizedScalarCubeSource I)
225
+
226
+ theorem weightedAffineModerateProductSource_jet_sum_law
227
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
228
+ (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) :
229
+ ((weightedModerateIntegerProductSource c s).toPMF).map
230
+ (weightedAffineModerateIntegerJetSum c s u v J offset shift) =
231
+ (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind
232
+ (fun a => (dependentProductPMF (fun b =>
233
+ (dependentProductPMF (fun j => (s b j).source.toPMF)).map
234
+ (fun y j q => (y j q : ℤ)))).map
235
+ (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
236
+ have hp := congrArg (fun p : PMF (B → ℤ × (Fin n → Option I → ℤ)) =>
237
+ p.map (fun z => shift + ∑ b, fun r : J =>
238
+ (offset b + (z b).1) * integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u b j) (v b j) ((z b).2 j)) r))
239
+ (weightedModerateProductSource_pair_law c s)
240
+ rw [PMF.map_comp, PMF.map_bind] at hp
241
+ change ((weightedModerateIntegerProductSource c s).toPMF).map
242
+ (fun x => shift + ∑ b, fun r : J => (offset b + ((x b).1 none : ℤ)) *
243
+ integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u b j) (v b j) (fun q => ((x b).2 j q : ℤ))) r) = _
244
+ simpa only [PMF.map_comp, Function.comp_def] using hp
245
+
246
+ theorem weightedAffineModerateProductSource_affine_law
247
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
248
+ (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) :
249
+ (weightedModerateIntegerProductSource c s).toPMF.map
250
+ (weightedAffineModerateIntegerJetSum c s u v J offset shift) =
251
+ (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind
252
+ (fun a => (dependentProductPMF (fun b =>
253
+ (dependentProductPMF (fun j => (s b j).source.toPMF)).map
254
+ (fun y j => affineIntegerCubeCoordinates (u b j) (v b j) (fun i => (y j i : ℤ))))).map
255
+ (fun y => shift + ∑ b, fun r : J => (offset b + a b) * integerBooleanBlockJet (y b) r)) := by
256
+ have hm := dependentProductPMF_map
257
+ (fun b => (dependentProductPMF (fun j => (s b j).source.toPMF)).map
258
+ (fun y j i => (y j i : ℤ)))
259
+ (fun b y j => affineIntegerCubeCoordinates (u b j) (v b j) (y j))
260
+ simp only [PMF.map_comp, Function.comp_def] at hm
261
+ have ht := congrArg (fun p : PMF (B → Fin n → Option I → ℤ) =>
262
+ (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind
263
+ (fun a => p.map (fun y => shift + ∑ b, fun r : J =>
264
+ (offset b + a b) * integerBooleanBlockJet (y b) r))) hm
265
+ refine (weightedAffineModerateProductSource_jet_sum_law c s u v J offset shift).trans ?_
266
+ simpa only [PMF.map_comp, Function.comp_def] using ht
267
+
268
+ end Erdos3
269
+
270
+ end
271
+
272
+ section
273
+
274
+ namespace Erdos3
275
+
276
+ open scoped BigOperators Classical
277
+
278
+ theorem affineWeightedCubeIntegerSum_box_bound
279
+ {B I : Type*} [Fintype B] [Fintype I] [DecidableEq I] {n : ℕ}
280
+ (s : B → Fin (n + 1) → NormalizedScalarCubeSource I)
281
+ (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ)
282
+ (T : ℕ) (rows : Finset (Finset I)) (hrows : ∀ t ∈ rows, t.card ≤ n + 1)
283
+ {A K : ℝ} (hA : 0 ≤ A) (hK : 0 ≤ K)
284
+ (hvol : (T : ℝ) ^ (n + 1) ≤ A * K)
285
+ (shift : rows → ℤ) (x : ∀ b j, IntegerScalarCubeBox I (s b j).length)
286
+ (hcoord : ∀ b j i,
287
+ |affineIntegerCubeCoordinates (u b j) (v b j) (fun i => (x b j i : ℤ)) i| ≤ T)
288
+ (t : rows) :
289
+ |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤
290
+ blockJetScaleBound (Fintype.card I) (n + 1) (Fintype.card B) A * K := by
291
+ have hs : |affineWeightedCubeIntegerSum s u v rows shift x t - shift t| ≤
292
+ ∑ _b : B, (2 : ℤ) ^ t.val.card *
293
+ ∏ _j : Fin (n + 1), ((Fintype.card I + 1 : ℕ) : ℤ) * T := by
294
+ simp only [affineWeightedCubeIntegerSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left]
295
+ apply (Finset.abs_sum_le_sum_abs _ _).trans
296
+ exact Finset.sum_le_sum (fun b _ =>
297
+ integerBooleanBlockJet_bound _ (fun _ => T) (fun j i => hcoord b j i) t)
298
+ have hs' : |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤
299
+ ∑ _b : B, (2 : ℝ) ^ t.val.card *
300
+ (((Fintype.card I + 1 : ℕ) : ℝ) ^ (n + 1) * (T : ℝ) ^ (n + 1)) := by
301
+ have hh : |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤
302
+ ∑ _b : B, (2 : ℝ) ^ t.val.card *
303
+ ∏ _j : Fin (n + 1), ((Fintype.card I + 1 : ℕ) : ℝ) * T := by exact_mod_cast hs
304
+ simpa only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] using hh
305
+ apply hs'.trans
306
+ calc
307
+ _ ≤ ∑ _b : B, (2 : ℝ) ^ (n + 1) * ((Fintype.card I + 1 : ℕ) : ℝ) ^ (n + 1) * (A * K) := by
308
+ apply Finset.sum_le_sum
309
+ intro b _
310
+ rw [← mul_assoc]
311
+ apply (mul_le_mul_of_nonneg_left hvol (by positivity)).trans
312
+ exact mul_le_mul_of_nonneg_right
313
+ (mul_le_mul_of_nonneg_right
314
+ (pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) (hrows t t.property)) (by positivity))
315
+ (mul_nonneg hA hK)
316
+ _ = _ := by
317
+ simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, blockJetScaleBound]
318
+ ring
319
+
320
+ end Erdos3
321
+
322
+ end
323
+
324
+ section
325
+
326
+ namespace Erdos3
327
+
328
+ open scoped BigOperators NNReal Classical
329
+
330
+ noncomputable def weightedAffineModerateGridApproximation {B : Type*} [Fintype B]
331
+ {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
332
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
333
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
334
+ (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift z : J → ℤ)
335
+ (S : Finset (J → Fin M)) : ℂ :=
336
+ ((K : ℂ) / M) ^ J.card * ∑ k ∈ S,
337
+ (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k) *
338
+ (rectangularGridCharacter M k shift * star (rectangularGridCharacter M k z))
339
+
340
+ theorem weightedAffineModerateGridDensity_fourier {B : Type*} [Fintype B] [DecidableEq B]
341
+ {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
342
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
343
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
344
+ (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift z : J → ℤ) :
345
+ (integerGridDensity (weightedModerateIntegerProductSource c s)
346
+ (weightedAffineModerateIntegerJetSum c s u v J offset shift) K M z : ℂ) =
347
+ weightedAffineModerateGridApproximation c s u v K M J offset shift z Finset.univ := by
348
+ rw [integerGridDensity_fourier]
349
+ simp only [weightedAffineModerateGridApproximation, Fintype.card_coe]
350
+ congr 1
351
+ apply Finset.sum_congr rfl
352
+ intro k _
353
+ rw [weightedAffineModerateIntegerJetSum_coefficient]
354
+ ring
355
+
356
+ theorem weightedAffineModerateGridDensity_error_of_tail {B : Type*} [Fintype B] [DecidableEq B]
357
+ {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I]
358
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
359
+ (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
360
+ (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (S : Finset (J → Fin M))
361
+ {ε : ℝ} (htail : spectrumTail S (fun k =>
362
+ ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k‖) ≤ ε)
363
+ (shift z : J → ℤ) :
364
+ ‖(integerGridDensity (weightedModerateIntegerProductSource c s)
365
+ (weightedAffineModerateIntegerJetSum c s u v J offset shift) K M z : ℂ) -
366
+ weightedAffineModerateGridApproximation c s u v K M J offset shift z S‖ ≤ ((K : ℝ) / M) ^ J.card * ε := by
367
+ let ψ k := rectangularGridCharacter M k shift * star (rectangularGridCharacter M k z)
368
+ have hψ k : ‖ψ k‖ ≤ 1 := by
369
+ simp only [ψ, norm_mul, norm_star, rectangularGridCharacter_norm, one_mul, le_refl]
370
+ have hb := (finite_series_truncation_le S
371
+ (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
372
+ rw [weightedAffineModerateGridDensity_fourier]
373
+ unfold weightedAffineModerateGridApproximation
374
+ rw [← mul_sub, norm_mul, norm_pow, norm_div, Complex.norm_natCast, Complex.norm_natCast]
375
+ exact mul_le_mul_of_nonneg_left hb (by positivity)
376
+
377
+ end Erdos3
378
+
379
+ end
380
+
381
+ section
382
+
383
+ namespace Erdos3
384
+
385
+ open MeasureTheory
386
+ open scoped BigOperators Classical NNReal
387
+
388
+ variable {B I T : Type*} [Fintype B] [Fintype I] [DecidableEq I]
389
+ variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T]
390
+ variable {n K M : ℕ} [NeZero M]
391
+ variable (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I)
392
+ variable (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ)
393
+ variable (offset : B → ℤ)
394
+
395
+ noncomputable def weightedAffineModeratePlateauApproximation (K : ℕ) (H : ℝ)
396
+ (rows : Finset (Finset I)) (shift z : rows → ℤ) (F : Finset (rows → Fin M)) : ℂ :=
397
+ (normalizedSupportPlateau H (fun t => ((z t : ℝ) - shift t) / K) : ℂ) *
398
+ weightedAffineModerateGridApproximation c s u v K M rows offset shift z F
399
+
400
+ theorem weightedAffineModeratePlateauApproximation_split_periods
401
+ (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I)) (shift z : rows → ℤ)
402
+ (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
403
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
404
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) :
405
+ weightedAffineModeratePlateauApproximation c s u v offset K H rows shift z F =
406
+ ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F,
407
+ (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k) *
408
+ (rationalGridPhase (D k) (a k) (integerGridResidue (D k) (shift - z)) *
409
+ plateauFourierMode H (fun t => -ω k t) (fun t => ((z t : ℝ) - shift t) / K)) := by
410
+ unfold weightedAffineModeratePlateauApproximation weightedAffineModerateGridApproximation
411
+ simp only [Finset.mul_sum]
412
+ apply Finset.sum_congr rfl
413
+ intro k hk
414
+ rw [← plateau_grid_character_split H hK k (a k) (ω k) (hfreq k hk) shift z]
415
+ ring
416
+
417
+ theorem weightedAffineModeratePlateauMixture_expansion
418
+ (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I))
419
+ (shift : T → rows → ℤ) (z : rows → ℤ)
420
+ (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
421
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
422
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) :
423
+ (∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta) z F ∂p.toMeasure) =
424
+ ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F,
425
+ (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k) *
426
+ (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) *
427
+ plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K)) := by
428
+ simp_rw [weightedAffineModeratePlateauApproximation_split_periods c s u v offset hK H rows _ z F D a ω hfreq]
429
+ rw [integral_const_mul, integral_finsetSum]
430
+ · congr 1
431
+ apply Finset.sum_congr rfl
432
+ intro k _
433
+ rw [integral_const_mul, plateauModeMixture_grid_factor]
434
+ · intro k _
435
+ apply Integrable.const_mul
436
+ apply pmf_integrable_of_norm_le p _ (B := 1)
437
+ intro zeta
438
+ rw [norm_mul, rationalGridPhase_norm, one_mul]
439
+ exact plateauFourierMode_norm _ _ _
440
+
441
+ noncomputable def weightedAffinePlateauModeCoefficient (K M : ℕ) (rows : Finset (Finset I))
442
+ (k : rows → Fin M) : ℂ :=
443
+ ((K : ℂ) / M) ^ rows.card *
444
+ ∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k
445
+
446
+ omit [NeZero M] in
447
+ theorem weightedAffinePlateauModeCoefficient_sum_le (rows : Finset (Finset I))
448
+ (F : Finset (rows → Fin M)) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ}
449
+ (hcap : (∑ k, ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k‖) ≤ C) :
450
+ (∑ k : F, ‖weightedAffinePlateauModeCoefficient c s u v offset K M rows k‖) ≤ C := by
451
+ rw [← Finset.sum_subtype F (fun _ => Iff.rfl)
452
+ (fun k => ‖weightedAffinePlateauModeCoefficient c s u v offset K M rows k‖)]
453
+ simp only [weightedAffinePlateauModeCoefficient, norm_mul, norm_pow, norm_div,
454
+ Complex.norm_natCast, ← Finset.mul_sum]
455
+ have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap
456
+ apply (mul_le_mul_of_nonneg_left
457
+ ((Finset.sum_le_univ_sum_of_nonneg (fun _ => norm_nonneg _)).trans hcap) (by positivity)).trans
458
+ exact mul_le_of_le_one_left hC hscale
459
+
460
+ noncomputable def weightedAffinePlateauModeModel (p : PMF T) (H : ℝ) (K : ℕ)
461
+ (rows : Finset (Finset I)) (F : Finset (rows → Fin M))
462
+ (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
463
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
464
+ (shift : T → rows → ℤ) (residue : ∀ k : F, rows → ZMod (D k)) (x : rows → ℝ) : ℂ :=
465
+ finiteResidueModeModel (fun k : F => D k) (fun k => a k)
466
+ (fun k => weightedAffinePlateauModeCoefficient c s u v offset K M rows k)
467
+ (fun k => plateauModeMixture p H (D k) K (a k) (ω k) shift) residue x
468
+
469
+ theorem weightedAffinePlateauModeModel_grid_value (p : PMF T) (hK : 0 < K) (H : ℝ)
470
+ (rows : Finset (Finset I)) (F : Finset (rows → Fin M))
471
+ (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
472
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
473
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K)
474
+ (shift : T → rows → ℤ) (z : rows → ℤ) :
475
+ (∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta) z F ∂p.toMeasure) =
476
+ weightedAffinePlateauModeModel c s u v offset p H K rows F D a ω shift
477
+ (fun k => integerGridResidue (D k) z) (fun t => (z t : ℝ) / K) := by
478
+ rw [weightedAffineModeratePlateauMixture_expansion c s u v offset p hK H rows shift z F D a ω hfreq]
479
+ let term (k : rows → Fin M) := weightedAffinePlateauModeCoefficient c s u v offset K M rows k *
480
+ (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) *
481
+ plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K))
482
+ calc
483
+ _ = ∑ k ∈ F, term k := by
484
+ simp only [term, weightedAffinePlateauModeCoefficient, Finset.mul_sum, mul_assoc]
485
+ _ = ∑ k : F, term k := Finset.sum_subtype F (fun _ => Iff.rfl) term
486
+ _ = _ := rfl
487
+
488
+ end Erdos3
489
+
490
+ end
491
+
492
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauSite.lean ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.WeightedPlateauSiteApproximation
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+ open scoped BigOperators Classical NNReal
11
+
12
+ variable {B α T : Type*} [Fintype B] [Fintype α] [DecidableEq α]
13
+ variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T]
14
+ variable {b K M : ℕ} [NeZero M]
15
+
16
+ theorem exists_weighted_affine_plateau_site_approximation
17
+ (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin b → NormalizedScalarCubeSource α)
18
+ (u : B → Fin b → Option α → ℤ) (v : B → Fin b → Option α → ℕ)
19
+ (offset : B → ℤ) (p : PMF T) (hK : 0 < K) (H : ℝ)
20
+ (rows : Finset (Finset α)) (F : Finset (rows → Fin M))
21
+ (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)]
22
+ (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ)
23
+ (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K)
24
+ (shift : T → rows → ℤ) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ}
25
+ (hcap : (∑ k, ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k‖) ≤ C)
26
+ (W : ℝ≥0) (hW : ∀ k ∈ F, ∀ t, |ω k t| ≤ W)
27
+ {R δ P : ℝ} (hR : 0 < R) (hδ : 0 < δ) (hP : 0 ≤ P)
28
+ (hRP : R ≤ Real.exp P) (hδP : (δ / (C + 1))⁻¹ ≤ Real.exp P)
29
+ (hLP : ((CircleFourier.characterLipConstant * (rows.card * W) + 4) *
30
+ (2 : ℝ≥0) ^ Fintype.card α : ℝ≥0) ≤ Real.exp P) :
31
+ ∃ n : F → ℕ, (∀ k, (n k : ℝ) ≤ Real.exp (4 * P + 8)) ∧
32
+ (Fintype.card (PlateauSiteIndex α F n) : ℝ) ≤
33
+ F.card * Real.exp (Fintype.card (Finset α) * (4 * P + 8)) ∧
34
+ ∃ (β : PlateauSiteIndex α F n → ℂ)
35
+ (f : (k : PlateauSiteIndex α F n) → Finset α → ZMod (D k.1) → ℝ → ℂ),
36
+ (∑ k, ‖β k‖) ≤ C * Real.exp (Fintype.card (Finset α) * (4 * P + 8) + P) ∧
37
+ (∀ k u r x, ‖f k u r x‖ ≤ 1) ∧
38
+ (∀ k u r, LipschitzWith ⟨Real.exp (1 + 6 * P + 12), Real.exp_nonneg _⟩ (f k u r)) ∧
39
+ ∀ y : Finset α → ℤ, (∀ u, |(y u : ℝ) / K| ≤ R) →
40
+ ‖(∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta)
41
+ (fun t => booleanCoefficient y t) F ∂p.toMeasure) -
42
+ ∑ k, β k * ∏ u, f k u (y u : ZMod (D k.1)) ((y u : ℝ) / K)‖ ≤ δ := by
43
+ have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap
44
+ have htol : 0 < δ / (C + 1) := div_pos hδ (by positivity)
45
+ obtain ⟨n, hn, hcard, β, f, hβ, hf, hLf, he⟩ :=
46
+ exists_integer_plateau_sum_site_approximation p H K rows (fun k : F => D k)
47
+ (fun k => a k) (fun k => ω k) shift
48
+ (fun k => weightedAffinePlateauModeCoefficient c s u v offset K M rows k)
49
+ (weightedAffinePlateauModeCoefficient_sum_le c s u v offset rows F hscale hcap)
50
+ W (fun k => hW k k.property) hR htol hP hRP hδP hLP
51
+ refine ⟨n, hn, ?_, β, f, hβ, hf, hLf, ?_⟩
52
+ · simpa only [Fintype.card_coe] using hcard
53
+ · intro y hy
54
+ rw [weightedAffinePlateauModeModel_grid_value c s u v offset p hK H rows F D a ω hfreq shift]
55
+ apply (he y hy).trans
56
+ rw [← mul_div_assoc]
57
+ apply (div_le_iff₀ (by positivity : 0 < C + 1)).mpr
58
+ nlinarith
59
+
60
+ end Erdos3
61
+
62
+ end
63
+
64
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineNormalizedScales.lean ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.NormalizedMeshLengths
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem affinePhysicalScales_lower {H L Q : ℝ} {exponent : ℕ}
10
+ (hL : 1 ≤ L) (hQ : 0 ≤ Q) (hexponent : 1 ≤ exponent)
11
+ (hH : Q * L ^ exponent ≤ H) : Q ≤ H ∧ Q ≤ H / L := by
12
+ have hpower : L ≤ L ^ exponent := by
13
+ simpa only [pow_one] using pow_le_pow_right₀ hL hexponent
14
+ have hQL : Q * L ≤ H := (mul_le_mul_of_nonneg_left hpower hQ).trans hH
15
+ have hLpos : 0 < L := lt_of_lt_of_le zero_lt_one hL
16
+ refine ⟨?_, (le_div_iff₀ hLpos).mpr hQL⟩
17
+ exact (by nlinarith : Q ≤ Q * L).trans hQL
18
+
19
+ theorem affineParameterScale_lower {L Q P : ℝ} {D : ℕ}
20
+ (hD : 0 < D) (hQ : 0 ≤ Q) (hDlog : (D : ℝ) ≤ Real.exp P)
21
+ (hL : Q * Real.exp P ≤ L) : Q ≤ L / (D : ℝ) := by
22
+ apply (le_div_iff₀ (by exact_mod_cast hD : (0 : ℝ) < D)).mpr
23
+ exact (mul_le_mul_of_nonneg_left hDlog hQ).trans hL
24
+
25
+ theorem affineNormalizedScales_lower {I J : Type*} (H : I → ℝ)
26
+ {L inverseLog lengthLog parameterLog : ℝ} {D exponent : ℕ}
27
+ (hL : 1 ≤ L) (hD : 0 < D) (hexponent : 1 ≤ exponent)
28
+ (hDlog : (D : ℝ) ≤ Real.exp parameterLog)
29
+ (hparam : 4 * Real.exp (inverseLog + lengthLog + parameterLog) ≤ L)
30
+ (hsite : ∀ i, 4 * Real.exp (inverseLog + lengthLog) * L ^ exponent ≤ H i) :
31
+ (∀ i, 4 * Real.exp (inverseLog + lengthLog) ≤ H i) ∧
32
+ (∀ z : Option J × I, 4 * Real.exp (inverseLog + lengthLog) ≤
33
+ smoothPairCoefficientScale (H z.2) L z.1) ∧
34
+ 4 * Real.exp (inverseLog + lengthLog) ≤ L / (D : ℝ) := by
35
+ have hQ : 0 ≤ 4 * Real.exp (inverseLog + lengthLog) := by positivity
36
+ have hs (i) := affinePhysicalScales_lower hL hQ hexponent (hsite i)
37
+ refine ⟨fun i => (hs i).1, ?_, ?_⟩
38
+ · rintro ⟨j,i⟩
39
+ cases j with
40
+ | none => exact (hs i).1
41
+ | some j => exact (hs i).2
42
+ · apply affineParameterScale_lower hD hQ hDlog
43
+ simpa only [Real.exp_add, mul_assoc] using hparam
44
+
45
+ end Erdos3
46
+
47
+ end
48
+
49
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineObservedTransport.lean ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.AffineSampleAlphabet
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped Classical
10
+
11
+ variable {ι J I Ω : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype I] [Fintype Ω]
12
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (p : FiniteProbabilityWeights Ω)
13
+ (F : Ω → Option J × I → ℤ) (w : Ω → ℝ)
14
+
15
+ noncomputable def affinePrimeObservedDensity : (∀ i, (J → I → ZMod (q i)) × (I → ZMod (q i))) → ℝ :=
16
+ observedProductDensity (fun i => residueAffineSource (J := J) (G := I → ZMod (q i)))
17
+ p (fun z => affinePrimeCoordinateObservation q (F z)) w
18
+
19
+ theorem affinePrimeObservedDensity_pullback (x : ∀ i, Option J × I → ZMod (q i)) :
20
+ affinePrimeObservedDensity q p F w (fun i => affineSampleAlphabetEquiv (x i)) =
21
+ observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
22
+ p (fun z => primeCoordinateObservation q (F z)) w x :=
23
+ observedProductDensity_coordinate_equiv _ _ (fun _ => affineSampleAlphabetEquiv)
24
+ (fun _ => affineSampleAlphabet_weight) p (fun z => primeCoordinateObservation q (F z)) w x
25
+
26
+ theorem affinePrimeObservedDensity_energy (D : Finset (Finset ι)) :
27
+ productANOVAEnergy (primeCoordinateReference (σ := Option J × I) q) D
28
+ (observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
29
+ p (fun z => primeCoordinateObservation q (F z)) w) =
30
+ productANOVAEnergy (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) D
31
+ (affinePrimeObservedDensity q p F w) :=
32
+ observedProductDensity_coordinate_energy _ _ (fun _ => affineSampleAlphabetEquiv)
33
+ (fun _ => affineSampleAlphabet_weight) p (fun z => primeCoordinateObservation q (F z)) w D
34
+
35
+ theorem affinePrimeObservedDensity_marginals_iff (η : ℝ) (r : ℕ) :
36
+ ProductMarginalsClose (fun i => residueAffineSource (J := J) (G := I → ZMod (q i)))
37
+ (affinePrimeObservedDensity q p F w) η r ↔
38
+ ProductMarginalsClose (primeCoordinateReference (σ := Option J × I) q)
39
+ (observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
40
+ p (fun z => primeCoordinateObservation q (F z)) w) η r := by
41
+ rw [productMarginalsClose_coordinate_equiv_iff
42
+ (primeCoordinateReference (σ := Option J × I) q)
43
+ (fun i => residueAffineSource (J := J) (G := I → ZMod (q i)))
44
+ (fun _ => affineSampleAlphabetEquiv) (fun _ => affineSampleAlphabet_weight)]
45
+ simp only [affinePrimeObservedDensity_pullback]
46
+
47
+ theorem affinePrimeObservedDensity_section (T A : Finset ι)
48
+ (z x : ∀ i, Option J × I → ZMod (q i)) :
49
+ productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z
50
+ (observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
51
+ p (fun v => primeCoordinateObservation q (F v)) w) x =
52
+ productSectionAverage (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) T A
53
+ (fun i => affineSampleAlphabetEquiv (z i)) (affinePrimeObservedDensity q p F w)
54
+ (fun i => affineSampleAlphabetEquiv (x i)) := by
55
+ have he := funext (affinePrimeObservedDensity_pullback q p F w)
56
+ rw [← he]
57
+ exact productSectionAverage_coordinate_transport _ _ (fun _ => affineSampleAlphabetEquiv)
58
+ (fun _ => affineSampleAlphabet_mean) T A z _ x
59
+
60
+ theorem affinePrimeObservedDensity_section_energy (T A : Finset ι)
61
+ (z : ∀ i, Option J × I → ZMod (q i)) (D : Finset (Finset ι)) :
62
+ productANOVAEnergy (primeCoordinateReference (σ := Option J × I) q) D
63
+ (productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z
64
+ (observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
65
+ p (fun v => primeCoordinateObservation q (F v)) w)) =
66
+ productANOVAEnergy (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) D
67
+ (productSectionAverage (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) T A
68
+ (fun i => affineSampleAlphabetEquiv (z i)) (affinePrimeObservedDensity q p F w)) := by
69
+ rw [show productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z
70
+ (observedProductDensity (primeCoordinateReference (σ := Option J × I) q)
71
+ p (fun v => primeCoordinateObservation q (F v)) w) = _ from
72
+ funext (affinePrimeObservedDensity_section q p F w T A z)]
73
+ exact productANOVAEnergy_coordinate_transport _ _ (fun _ => affineSampleAlphabetEquiv)
74
+ (fun _ => affineSampleAlphabet_mean) D _
75
+
76
+ end Erdos3
77
+
78
+ end
79
+
80
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineOneSiteNormalizedLaw.lean ADDED
@@ -0,0 +1,521 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.OneSiteWeightIdentity
2
+ import OAI.Combinatorics.Progressions.Fourier.CoefficientFourierTranslation
3
+ import OAI.Combinatorics.Progressions.Linear.ProductOneSiteProjectionCap
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ theorem selectedResidueDensityPMF_test_le {K I : Type*} [Fintype K] [Fintype I]
12
+ (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus))
13
+ (V : K × I → ℝ) (hV : ∀ z, 0 < V z)
14
+ (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x)
15
+ (D g φ : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x)
16
+ (hD : 0 < selectedResidueDensityMass modulus G V D)
17
+ {C ε a : ℝ} (ha : 0 < a) (hlower : a ≤ selectedResidueDensityMass modulus G V D)
18
+ (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x)
19
+ (he : |(∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (D x * φ x)) -
20
+ ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (g x * φ x)| ≤ ε) :
21
+ (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * φ x) ≤
22
+ (C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε) / a := by
23
+ let prob := selectedResidueFiniteLaw modulus G V hV hZ
24
+ have hmean (f : (K × I → ℤ) → ℝ) : prob.mean (fun x => f x.val) =
25
+ ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * f x :=
26
+ selectedResidueFiniteLaw_mean modulus G V hV hZ f
27
+ have hm : prob.mean (fun x => D x.val) = selectedResidueDensityMass modulus G V D :=
28
+ selectedResidueFiniteLaw_densityMass modulus G V hV hZ D
29
+ have hb := prob.mean_mul_le_of_capped_comparison (ε := ε) (fun x => D x.val) (fun x => g x.val)
30
+ (fun x => φ x.val) (fun x => hφ x.val) (fun x => hg x.val)
31
+ (by
32
+ rw [hmean (fun x => D x * φ x), hmean (fun x => g x * φ x)]
33
+ exact he)
34
+ have hn := prob.reweightPositive_test_le (fun x => D x.val) (fun x => hD0 x.val)
35
+ (hm.symm ▸ hD) (fun x => φ x.val) (fun x => hφ x.val) ha (hm.symm ▸ hlower) hb
36
+ rw [FiniteProbabilityWeights.reweightPositive_mean, hm,
37
+ hmean (fun x => D x * φ x), hmean φ] at hn
38
+ rw [selectedResidueDensityPMF_mean]
39
+ exact hn
40
+
41
+ theorem selectedResidueDensityPMF_test_le_of_complex {K I : Type*} [Fintype K] [Fintype I]
42
+ (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus))
43
+ (V : K × I → ℝ) (hV : ∀ z, 0 < V z)
44
+ (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x)
45
+ (D g φ : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x)
46
+ (hD : 0 < selectedResidueDensityMass modulus G V D)
47
+ {C ε a : ℝ} (ha : 0 < a) (hlower : a ≤ selectedResidueDensityMass modulus G V D)
48
+ (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x)
49
+ (he : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((φ x : ℂ) * (D x : ℂ))) -
50
+ ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((φ x : ℂ) * (g x : ℂ))‖ ≤ ε) :
51
+ (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * φ x) ≤
52
+ (C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε) / a := by
53
+ apply selectedResidueDensityPMF_test_le modulus G V hV hZ D g φ hD0 hD ha hlower hg hφ
54
+ simp only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub,
55
+ Complex.norm_real, Real.norm_eq_abs] at he
56
+ simpa only [mul_comm, mul_left_comm, mul_assoc] using he
57
+
58
+ end Erdos3
59
+
60
+ end
61
+
62
+ section
63
+
64
+ namespace Erdos3
65
+
66
+ theorem selectedResidueSmoothPMF_test_le_of_complex {K I : Type*} [Fintype K] [Fintype I]
67
+ (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus))
68
+ (V : K × I → ℝ) (hV : ∀ z, 0 < V z)
69
+ (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x)
70
+ (D g φ : (K × I → ℤ) → ℝ) {C ε : ℝ}
71
+ (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x)
72
+ (he : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) *
73
+ ((φ x : ℂ) * (D x : ℂ))) -
74
+ ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) *
75
+ ((φ x : ℂ) * (g x : ℂ))‖ ≤ ε) :
76
+ (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (φ x * D x)) ≤
77
+ C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε := by
78
+ let prob := selectedResidueFiniteLaw modulus G V hV hZ
79
+ have hmean (f : (K × I → ℤ) → ℝ) : prob.mean (fun x => f x.val) =
80
+ ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * f x :=
81
+ selectedResidueFiniteLaw_mean modulus G V hV hZ f
82
+ simp only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub,
83
+ Complex.norm_real, Real.norm_eq_abs] at he
84
+ have h := prob.mean_mul_le_of_capped_comparison (ε := ε) (fun x => D x.val)
85
+ (fun x => g x.val) (fun x => φ x.val) (fun x => hφ x.val) (fun x => hg x.val) (by
86
+ rw [hmean (fun x => D x * φ x), hmean (fun x => g x * φ x)]
87
+ simpa only [mul_comm, mul_left_comm, mul_assoc] using he)
88
+ rw [hmean (fun x => D x * φ x), hmean φ] at h
89
+ simpa only [mul_comm, mul_left_comm, mul_assoc] using h
90
+
91
+ end Erdos3
92
+
93
+ end
94
+
95
+ section
96
+
97
+ namespace Erdos3.BooleanCubeKernel
98
+
99
+ open VectorPolynomial
100
+
101
+ noncomputable def physicalAffineSite {I K : Type*} [Fintype K]
102
+ (root : K → ℤ) (z : Option K × I → ℤ) : I → ℝ :=
103
+ integerSiteValue (fun k => match k with | none => 1 | some k => root k)
104
+ (fun k j => (z (k,j) : ℝ))
105
+
106
+ theorem integerSiteValue_oneSite {I K : Type*} [Fintype K]
107
+ (root : K → ℤ) (difference : Fin 0 → K → ℤ) (z : Option K × I → ℤ) :
108
+ integerSiteValue (affineSite root difference ∅) (fun k j => (z (k,j) : ℝ)) =
109
+ physicalAffineSite root z := by
110
+ have hs : affineSite root difference ∅ = (fun k => match k with | none => 1 | some k => root k) := by
111
+ funext k
112
+ cases k <;> simp [affineSite]
113
+ rw [hs]
114
+ rfl
115
+
116
+ theorem layeredSiteWeight_physical {I K : Type*} [Fintype K]
117
+ (root : K → ℤ) (difference : Fin 0 → K → ℤ) (φ : (I → ℝ) → ℂ)
118
+ (z : Option K × I → ℤ) :
119
+ layeredSiteWeight 0 (fun s => affineSite root difference s) (fun _ => φ)
120
+ (fun k j => (z (k,j) : ℝ)) = φ (physicalAffineSite root z) := by
121
+ rw [layeredSiteWeight_oneSite, integerSiteValue_oneSite]
122
+
123
+ end Erdos3.BooleanCubeKernel
124
+
125
+ end
126
+
127
+ section
128
+
129
+ namespace Erdos3.BooleanCubeKernel
130
+
131
+ open MeasureTheory VectorPolynomial
132
+
133
+ theorem selectedResidue_oneSite_density_error {I K F : Type*} [Fintype I] [Fintype K] [Fintype F]
134
+ {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
135
+ (t : K → ℤ) (difference : Fin 0 → K → ℤ)
136
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
137
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ)
138
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
139
+ (D : CoefficientTorus (K := K) U → ℝ) {η ε : ℝ} (hη : 0 ≤ η)
140
+ (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η)
141
+ (hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U t y x)) μ)
142
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
143
+ (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
144
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
145
+ (stride : I → ℕ) (G : Finset (ColumnResiduePattern (Option K) I stride))
146
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
147
+ (hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x)
148
+ (w : (Option K × I → ℤ) → ℂ) (hw : ∀ x, ‖w x‖ ≤ 1)
149
+ (hprojection : ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) *
150
+ (w x * affineCubeFourierSum frequency p c (fun k j => (x (k, j) : ℝ)))) -
151
+ ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) *
152
+ (w x * affineCubeFourierProjection U t difference frequency p c (fun k j => (x (k, j) : ℝ)))‖ ≤ ε) :
153
+ ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) *
154
+ (w x * (D (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ))) : ℂ))) -
155
+ ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) *
156
+ (w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t
157
+ (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ)))) : ℝ) : ℂ))‖ ≤ 2 * η + ε := by
158
+ let prob := selectedResidueFiniteLaw stride G V hV hZ
159
+ have hmean (f : (Option K × I → ℤ) → ℂ) : prob.complexMean (fun x => f x.val) =
160
+ ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * f x :=
161
+ selectedResidueFiniteLaw_complexMean stride G V hV hZ f
162
+ have hw' : prob.mean (fun x => ‖w x.val‖) ≤ 1 :=
163
+ (prob.mean_mono (fun x => hw x.val)).trans_eq (prob.mean_const 1)
164
+ have he := oneSiteDensity_projection_error (ε := ε) U t difference frequency c μ D hη happrox p hp hm
165
+ prob (fun x k j => (x.val (k, j) : ℝ)) (fun x => w x.val) (fun _ _ => hD _) hw'
166
+ (by
167
+ rw [hmean (fun x => w x * affineCubeFourierSum frequency p c (fun k j => (x (k, j) : ℝ))),
168
+ hmean (fun x => w x * affineCubeFourierProjection U t difference frequency p c (fun k j => (x (k, j) : ℝ)))]
169
+ exact hprojection)
170
+ rw [hmean (fun x => w x * (D (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ))) : ℂ)),
171
+ hmean (fun x => w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t
172
+ (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ)))) : ℝ) : ℂ))] at he
173
+ simpa only [mul_one] using he
174
+
175
+ end Erdos3.BooleanCubeKernel
176
+
177
+ end
178
+
179
+ section
180
+
181
+ namespace Erdos3.BooleanCubeKernel
182
+
183
+ open MeasureTheory VectorPolynomial
184
+ open scoped BigOperators
185
+
186
+ theorem exists_affine_oneSite_density_comparison (m : ℕ) :
187
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
188
+ [Fintype I] [DecidableEq I] [Fintype K]
189
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
190
+ {F : Type*} [Fintype F]
191
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
192
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
193
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
194
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
195
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
196
+ (root : K → ℤ) (difference : Fin 0 → K → ℤ)
197
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
198
+ (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
199
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
200
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
201
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
202
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
203
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
204
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
205
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
206
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
207
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
208
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
209
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
210
+ (H : I → ℝ)
211
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
212
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
213
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
214
+ (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0)
215
+ (test : Finset (Fin 0) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1)
216
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
217
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
218
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
219
+ (D : CoefficientTorus (K := K) U → ℝ)
220
+ (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ)
221
+ {η : ℝ} (_hη : 0 ≤ η)
222
+ (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η),
223
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
224
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
225
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
226
+ (D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))) : ℂ))) -
227
+ (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
228
+ (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) *
229
+ ((coefficientFiberAverage U μ root D (coefficientEvaluationTorus U root
230
+ (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) : ℝ) : ℂ)))‖ ≤ 2 * η + ε := by
231
+ obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_fourier_projection m 0
232
+ refine ⟨A, hA, ?_⟩
233
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference
234
+ L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm
235
+ stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR Q hQ test htest
236
+ G hG V hV hwidth D hD η hη happrox
237
+ obtain ⟨hZ, he⟩ := hprojection hP hn hd U root difference linearIndependent_empty_type
238
+ hL hC hLP hCP hsite frequency hbound c hB hBP hcoefficients p hp hm stride hs
239
+ hS hSP hρ hε hρP hεP hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth
240
+ refine ⟨hZ, ?_⟩
241
+ exact selectedResidue_oneSite_density_error U root difference frequency c μ D hη happrox hD p hp hm
242
+ stride G V hV hZ
243
+ (fun z => layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)))
244
+ (fun z => layeredSiteWeight_norm_le Q _ test htest _) he
245
+
246
+ end Erdos3.BooleanCubeKernel
247
+
248
+ end
249
+
250
+ section
251
+
252
+ namespace Erdos3.BooleanCubeKernel
253
+
254
+ open MeasureTheory VectorPolynomial
255
+ open scoped BigOperators
256
+
257
+ theorem exists_affine_oneSite_test_domination (m : ℕ) :
258
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
259
+ [Fintype I] [DecidableEq I] [Fintype K]
260
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
261
+ {F : Type*} [Fintype F]
262
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
263
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
264
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
265
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
266
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
267
+ (root : K → ℤ) (difference : Fin 0 → K → ℤ)
268
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
269
+ (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
270
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
271
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
272
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
273
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
274
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
275
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
276
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
277
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
278
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
279
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
280
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
281
+ (H : I → ℝ)
282
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
283
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
284
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
285
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
286
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
287
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
288
+ (D : CoefficientTorus (K := K) U → ℝ)
289
+ (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ)
290
+ {η : ℝ} (_hη : 0 ≤ η)
291
+ (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η)
292
+ (_hD0 : ∀ x, 0 ≤ D x) {M a : ℝ} (_ha : 0 < a)
293
+ (_hlower : a ≤ selectedResidueDensityMass stride G V
294
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))))
295
+ (_hcap : ∀ y, coefficientFiberAverage U μ root D y ≤ M)
296
+ (φ : (I → ℝ) → ℝ) (_hφ : ∀ v, φ v ∈ Set.Icc (0 : ℝ) 1),
297
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
298
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
299
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))),
300
+ (∑' z, (selectedResidueDensityPMF stride G V hV hZ
301
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))
302
+ (fun _ => _hD0 _) hDpos z).toReal *
303
+ φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) ≤
304
+ (M * (∑' z, (selectedResidueSmoothPMF stride G V hV hZ z).toReal *
305
+ φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) +
306
+ (2 * η + ε)) / a := by
307
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_oneSite_density_comparison m
308
+ refine ⟨A, hA, ?_⟩
309
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference
310
+ L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm
311
+ stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR
312
+ G hG V hV hwidth D hD η hη happrox hD0 M a ha hlower hcap φ hφ
313
+ have hφn (v : I → ℝ) : ‖(φ v : ℂ)‖ ≤ 1 := by
314
+ rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hφ v).1]
315
+ exact (hφ v).2
316
+ obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ root difference hL hC hLP hCP hsite frequency hbound
317
+ c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR
318
+ 0 (by simp) (fun _ v => (φ v : ℂ)) (fun _ v => hφn v) G hG V hV hwidth D hD hη happrox
319
+ have hDpos : 0 < selectedResidueDensityMass stride G V
320
+ (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))) := ha.trans_le hlower
321
+ refine ⟨hZ, hDpos, ?_⟩
322
+ simp only [layeredSiteWeight_oneSite] at he
323
+ exact selectedResidueDensityPMF_test_le_of_complex (C := M) (ε := 2 * η + ε) (a := a) stride G V hV hZ
324
+ (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))))
325
+ (fun z => coefficientFiberAverage U μ root D (coefficientEvaluationTorus U root
326
+ (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))))
327
+ (fun z => φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ))))
328
+ (fun _ => hD0 _) hDpos ha hlower
329
+ (fun _ => hcap _) (fun _ => (hφ _).1) he
330
+
331
+ end Erdos3.BooleanCubeKernel
332
+
333
+ end
334
+
335
+ section
336
+
337
+ namespace Erdos3.BooleanCubeKernel
338
+
339
+ open MeasureTheory VectorPolynomial
340
+ open scoped BigOperators
341
+
342
+ theorem exists_affine_translated_oneSite_density_comparison (m : ℕ) :
343
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
344
+ [Fintype I] [DecidableEq I] [Fintype K]
345
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
346
+ {F : Type*} [Fintype F]
347
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
348
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
349
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
350
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
351
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
352
+ (root : K → ℤ)
353
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
354
+ (_hsite : ∀ k, |(root k : ℝ)| ≤ L)
355
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
356
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
357
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
358
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
359
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
360
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
361
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
362
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
363
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
364
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
365
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
366
+ (H : I → ℝ)
367
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
368
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
369
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
370
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
371
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
372
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
373
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Measurable D)
374
+ {M : ℝ} (_hDbound : ∀ x, ‖D x‖ ≤ M)
375
+ {η : ℝ} (_hη : 0 ≤ η)
376
+ (_happrox : ∀ x, ‖(D x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η)
377
+ (center : CoefficientTorus (K := K) U)
378
+ (φphysical : (I → ℝ) → ℂ) (_hφ : ∀ v, ‖φphysical v‖ ≤ 1),
379
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
380
+ ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
381
+ (φphysical (physicalAffineSite root z) *
382
+ (D (center + affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))) : ℂ))) -
383
+ (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) *
384
+ (φphysical (physicalAffineSite root z) *
385
+ (((coefficientFiberAverage U μ root (fun x => D (center + x))
386
+ (coefficientEvaluationTorus U root
387
+ (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))) : ℝ) : ℂ)))‖ ≤
388
+ 2 * η + ε := by
389
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_oneSite_density_comparison m
390
+ refine ⟨A, hA, ?_⟩
391
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root
392
+ L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm
393
+ stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR
394
+ G hG V hV hwidth D hD M hDbound η hη happrox center φphysical hφ
395
+ let difference : Fin 0 → K → ℤ := fun i => Fin.elim0 i
396
+ have hsite' (s : Finset (Fin 0)) (k : K) :
397
+ |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L := by
398
+ have hs : s = ∅ := Subsingleton.elim _ _
399
+ simpa [hs, affineSite] using hsite k
400
+ have hcoefficients' :
401
+ (∑ a, ‖c a * coefficientTorusCharacter U (frequency a) center‖) ≤ B := by
402
+ rw [coefficientFourier_translate_norm]
403
+ exact hcoefficients
404
+ have happrox' (x) :
405
+ ‖coefficientTorusFourierSum U frequency
406
+ (fun a => c a * coefficientTorusCharacter U (frequency a) center) x -
407
+ (D (center + x) : ℂ)‖ ≤ η := by
408
+ rw [norm_sub_rev]
409
+ exact coefficientFourier_translate_approx U D frequency c happrox center x
410
+ have hintegrable (y) :
411
+ Integrable (fun x => D (center + coefficientFiberMap U root y x)) μ :=
412
+ bounded_coefficient_translate_fiber_integrable U μ D hD hDbound center root y
413
+ obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ root difference hL hC hLP hCP hsite'
414
+ frequency hbound (fun a => c a * coefficientTorusCharacter U (frequency a) center)
415
+ hB hBP hcoefficients' p hp hm stride hs hS hSP hρ hε hρP hεP hstride
416
+ H hsize hrank hR 0 (by simp) (fun _ => φphysical) (fun _ => hφ)
417
+ G hG V hV hwidth (fun x => D (center + x)) hintegrable hη happrox'
418
+ refine ⟨hZ, ?_⟩
419
+ simpa only [layeredSiteWeight_physical] using he
420
+
421
+ end Erdos3.BooleanCubeKernel
422
+
423
+ end
424
+
425
+ section
426
+
427
+ namespace Erdos3.BooleanCubeKernel
428
+
429
+ open MeasureTheory VectorPolynomial
430
+ open scoped BigOperators
431
+
432
+ theorem exists_affine_oneSite_normalized_domination (m : ℕ) :
433
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
434
+ [Fintype I] [DecidableEq I] [Fintype K]
435
+ {J : Fin m → Type*} [∀ j, Fintype (J j)]
436
+ {F : Type*} [Fintype F]
437
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
438
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
439
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
440
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
441
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
442
+ (root : K → ℤ) (difference : Fin 0 → K → ℤ)
443
+ {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P)
444
+ (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L)
445
+ (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ)
446
+ (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C)
447
+ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
448
+ (_hcoefficients : (∑ a, ‖c a‖) ≤ B)
449
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
450
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
451
+ (_hm : ∀ j d, coefficients (p j) d ∈ U j)
452
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
453
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
454
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
455
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
456
+ (H : I → ℝ)
457
+ (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
458
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
459
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
460
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
461
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z)
462
+ (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
463
+ (D : CoefficientTorus (K := K) U → ℝ)
464
+ (_hDglobal : Integrable D μ) (_hDmass : (∫ x, D x ∂μ) = 1)
465
+ (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ)
466
+ {η : ℝ} (_hη : 0 ≤ η)
467
+ (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η)
468
+ (_hsmall : 2 * η + ε ≤ 1 / 2)
469
+ (_hD0 : ∀ x, 0 ≤ D x) {M : ℝ}
470
+ (_hcap : ∀ y, coefficientFiberAverage U μ root D y ≤ M)
471
+ (φ : (I → ℝ) → ℝ) (_hφ : ∀ v, φ v ∈ Set.Icc (0 : ℝ) 1),
472
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
473
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
474
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))),
475
+ |selectedResidueDensityMass stride G V
476
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧
477
+ 1 / 2 ≤ selectedResidueDensityMass stride G V
478
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) ∧
479
+ (∑' z, (selectedResidueDensityPMF stride G V hV hZ
480
+ (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))
481
+ (fun _ => _hD0 _) hDpos z).toReal *
482
+ φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) ≤
483
+ (M * (∑' z, (selectedResidueSmoothPMF stride G V hV hZ z).toReal *
484
+ φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) +
485
+ (2 * η + ε)) / (1 / 2 : ℝ) := by
486
+ obtain ⟨A₀, hA₀, hmass⟩ := exists_affine_coefficient_density_mass m
487
+ obtain ⟨A₁, _hA₁, hdom⟩ := exists_affine_oneSite_test_domination m
488
+ let A := max A₀ A₁
489
+ have hA : 2 ≤ A := hA₀.trans (le_max_left _ _)
490
+ refine ⟨A, hA, ?_⟩
491
+ intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference
492
+ L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm
493
+ stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR
494
+ G hG V hV hwidth D hDglobal hDmass hD η hη happrox hsmall hD0 M hcap φ hφ
495
+ have hthreshold (a : ℕ) (ha : a ≤ A) : Real.exp ((P + a) ^ a) ≤ Real.exp ((P + A) ^ A) := by
496
+ apply Real.exp_le_exp.mpr
497
+ have haa : (a : ℝ) ≤ A := by exact_mod_cast ha
498
+ have hbase : P + (a : ℝ) ≤ P + A := by linarith
499
+ have hAreal : (2 : ℝ) ≤ A := by exact_mod_cast hA
500
+ exact (pow_le_pow_left₀ (by positivity) hbase a).trans
501
+ (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ P + A) ha)
502
+ have h₀ := hthreshold A₀ (le_max_left _ _)
503
+ have h₁ := hthreshold A₁ (le_max_right _ _)
504
+ obtain ⟨_hZ₀, he⟩ := hmass hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients p hp hm
505
+ stride hs hS hSP hρ hε hρP hεP hstride H (fun k => h₀.trans (hsize k)) hrank (h₀.trans hR)
506
+ G hG V hV hwidth D hDglobal hDmass hη (fun x => by rw [norm_sub_rev]; exact happrox x)
507
+ have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V
508
+ (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))) := by
509
+ have hh := (abs_le.mp he).1
510
+ linarith
511
+ obtain ⟨hZ, hDpos, hb⟩ := hdom hP hn hd U μ root difference hL hC hLP hCP hsite frequency hbound
512
+ c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride
513
+ H (fun k => h₁.trans (hsize k)) hrank (h₁.trans hR) G hG V hV hwidth D hD hη happrox
514
+ hD0 (by norm_num : (0 : ℝ) < 1 / 2) hlower hcap φ hφ
515
+ exact ⟨hZ, hDpos, he, hlower, hb⟩
516
+
517
+ end Erdos3.BooleanCubeKernel
518
+
519
+ end
520
+
521
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffinePrecisionBudget.lean ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.AdaptiveRatioNormalization
2
+ import OAI.Combinatorics.Progressions.Estimates.GlobalCutoffAtomComparison
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped BigOperators Classical
11
+
12
+ theorem normalized_adaptive_affine_comparison
13
+ {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ]
14
+ {q : ι → ℕ} [∀ i, NeZero (q i)]
15
+ (lo a : σ → ℤ) (N : σ → ℕ)
16
+ (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (1 : ℤ)) a))
17
+ (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ)
18
+ (hneSource : Nonempty (IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k)
19
+ (fun _ => (1 : ℤ)) sourceA))
20
+ (h g : (σ → ℤ) → ℂ) (w : (Option J × σ → ℤ) → ℝ)
21
+ (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1)
22
+ (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1)
23
+ (hw : ∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ w z ∧ w z ≤ 1)
24
+ {ε L T C shell totalShell modLog level dimLog sourceDimLog : ℝ}
25
+ (hε : 0 < ε) (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C)
26
+ (hshell : 0 < shell) (hlower : Real.exp (-L) ≤ level) (hlevel2 : level ≤ 2)
27
+ (hmodLog : 0 ≤ modLog) (hdimLog : 0 ≤ dimLog) (hsourceDimLog : 0 ≤ sourceDimLog)
28
+ (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog)
29
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C)
30
+ (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog)
31
+ (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog)
32
+ (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime)
33
+ (hpower : ∀ i, q i = prime i ^ power i) (hinj : Function.Injective prime)
34
+ (hJ : 2 ≤ Fintype.card J) (D : ℕ) (parameterA : J → ℤ)
35
+ (tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i)))
36
+ (baseX : ∀ i, Option J × σ → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i))
37
+ {d A B : ℕ}
38
+ (htree : CoordinateDecisionTree.Valid (fun K base =>
39
+ affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D ⊆ K ∧
40
+ ResiduePrimeCoordinateStable g lo N 1 a q (affineRemovalDepth T + affineComparisonTail ε L T)
41
+ (affineStabilityTolerance T) K base ∧
42
+ PrimeRefinementUpperBound h g lo N 1 a q (affineRemovalDepth T + affineComparisonTail ε L T)
43
+ level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base)
44
+ ∅ baseY tree d)
45
+ (hA : d ≤ A)
46
+ (hB : A + affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ)
47
+ ε L T C shell modLog ≤ B)
48
+ (hBinitial : A + CyclicCrootSisask.spectralIterations shell
49
+ ((A : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog +
50
+ (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B)
51
+ (hside : ∀ k, Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog dimLog + 2) ≤ (N k : ℝ))
52
+ (hsourceSide : ∀ k, Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog sourceDimLog + 2) ≤ (sourceN k : ℝ))
53
+ (hallocation : Real.exp ((A : ℝ) * (affineComparisonScale ε L T C +
54
+ (Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1)) * shell ≤ totalShell) :
55
+ productTruncatedPairing (affinePeriodProductCoupling (σ := σ) q D parameterA)
56
+ (lowDegreeCoordinateSets ι B)
57
+ (residuePrimeCoordinateDensity sourceLo sourceN 1 sourceA hneSource q w)
58
+ (fun z => residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (h x).re) z -
59
+ (1 + ε) * level * residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (g x).re) z) ≤
60
+ (1 + affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) *
61
+ (1 + affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) *
62
+ (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
63
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) +
64
+ (1 + (1 + ε) * level) * (totalShell / 16) := by
65
+ have hpair : Pairwise (fun i k => (q i).Coprime (q k)) := by
66
+ intro i k hik
67
+ rw [hpower i, hpower k]
68
+ exact selectedPrimePowers_pairwise_coprime prime power hprime hinj hik
69
+ have hAB : A ≤ B := (Nat.le_add_right _ _).trans hB
70
+ have hsite := unconditioned_affine_cell_bounds lo N a hne q hpair hAB hL hT hC
71
+ hmodLog hdimLog hmoduli hdim hside
72
+ have hsource := unconditioned_affine_cell_bounds sourceLo sourceN sourceA hneSource q hpair hAB
73
+ hL hT hC hmodLog hsourceDimLog hmoduli hsourceDim hsourceSide
74
+ let c := affinePeriodProductCoupling (σ := σ) q D parameterA
75
+ let source := residuePrimeCoordinateDensity sourceLo sourceN 1 sourceA hneSource q w
76
+ let target := fun z => residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (h x).re) z -
77
+ (1 + ε) * level * residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (g x).re) z
78
+ let eta := affineComparisonAccuracy B (affineComparisonScale ε L T C) L T
79
+ let R := level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
80
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)
81
+ let coeff := 1 + (1 + ε) * level
82
+ let pairs := CoordinateDecisionTree.leafSourceAssignments (fun i => Option J × σ → ZMod (q i)) tree ∅ baseY
83
+ let ratioX := fun z : Σ leaf : ProductCylinder (fun i => σ → ZMod (q i)),
84
+ ∀ i : leaf.1, Option J × σ → ZMod (q i.val) =>
85
+ residuePrimeCoordinateMassRatio sourceLo sourceN 1 sourceA q z.1.1 (productSubtypePoint z.1.1 z.2 baseX)
86
+ let ratioY := fun z : Σ leaf : ProductCylinder (fun i => σ → ZMod (q i)),
87
+ ∀ i : leaf.1, Option J × σ → ZMod (q i.val) =>
88
+ residuePrimeCoordinateMassRatio lo N 1 a q z.1.1 (z.1.assignment baseY)
89
+ have hA' : (∅ : Finset ι).card + d ≤ A := by simpa using hA
90
+ have hleaf (z) (hz : z ∈ pairs) : z.1 ∈ CoordinateDecisionTree.leafCylinders tree ∅ baseY :=
91
+ (CoordinateDecisionTree.mem_leafSourceAssignments (fun i => Option J × σ → ZMod (q i)) tree ∅ baseY z).mp hz
92
+ have hsize (z) (hz : z ∈ pairs) : z.1.1.card ≤ A :=
93
+ (htree.leaf_card_le z.1 (hleaf z hz)).trans hA'
94
+ have hratioX (z) (hz : z ∈ pairs) : |ratioX z - 1| ≤ eta :=
95
+ residuePrimeCoordinateMassRatio_close_of_marginals sourceLo sourceN 1 sourceA hneSource q
96
+ hsource.1 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX)
97
+ have hratioY (z) (hz : z ∈ pairs) : |ratioY z - 1| ≤ eta :=
98
+ residuePrimeCoordinateMassRatio_close_of_marginals lo N 1 a hne q
99
+ hsite.1 z.1.1 (hsize z hz) (z.1.assignment baseY)
100
+ have hbound (z) (hz : z ∈ pairs) :
101
+ productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) z.1.1
102
+ (productSubtypePoint z.1.1 z.2 baseX) (z.1.assignment baseY) source target ≤
103
+ adaptiveLeafPairMass c baseX baseY z * (ratioX z * ratioY z) * R + coeff * (shell / 16) := by
104
+ have hcert := htree.leaf_good z.1 (hleaf z hz)
105
+ let u := (hsite.2.1 z.1.1 (hsize z hz) (z.1.assignment baseY)).some
106
+ let uX := (hsource.2.1 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX)).some
107
+ have hwX (v : ResiduePrimeCoordinateCell sourceLo sourceN 1 sourceA q z.1.1
108
+ (productSubtypePoint z.1.1 z.2 baseX)) :
109
+ 0 ≤ w (fun k => (v.val k).val) ∧ w (fun k => (v.val k).val) ≤ 1 := by
110
+ apply hw
111
+ apply (mem_translatedIntegerBox sourceLo sourceN _).mpr
112
+ intro k
113
+ exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (v.val k).property).1)
114
+ have ha := global_cutoff_initial_atom_comparison
115
+ (hKcard := hsize z hz) (hB := hB) (hstable := hcert.2.1) (hupper := hcert.2.2)
116
+ (hM := by decide) (u := u) (hg := hg) (hh := hh) (hL := hL) (hT := hT)
117
+ (hlower := hlower) (prime := prime) (power := power) (hprime := hprime) (hpower := hpower)
118
+ (hJ := hJ) (hshell := hshell) (hlevel2 := hlevel2) (hmodLog := hmodLog) (hmoduli := hmoduli)
119
+ (hε := hε) (hC := hC) (hcount := hcount) (dimLog := dimLog) (hdim := hdim)
120
+ (hlength := hsite.2.2 z.1.1 (hsize z hz) (z.1.assignment baseY) u)
121
+ (sourceLo := sourceLo) (sourceA := sourceA) (sourceN := sourceN) (sourceM := 1)
122
+ (sourceBase := productSubtypePoint z.1.1 z.2 baseX) (sourceCell := uX) (w := w) (hw := hwX)
123
+ (hsourceM := by decide) (sourceDimLog := sourceDimLog) (hsourceDim := hsourceDim)
124
+ (hsourceLength := hsource.2.2 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX) uX)
125
+ (hinj := hinj) (D := D) (parameterA := parameterA) (hmask := hcert.1) (hBinitial := hBinitial)
126
+ exact ha
127
+ have hlevel : 0 ≤ level := (Real.exp_pos (-L)).le.trans hlower
128
+ have hcoeff : 0 ≤ coeff := by dsimp only [coeff]; positivity
129
+ have hR : 0 ≤ R := by dsimp only [R]; positivity
130
+ have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1
131
+ have hcountP := affineComparisonScale_count (ι := ι) (ε := ε) hL hT hC hcount
132
+ have hcard := affine_leaf_source_assignments_card_le_exp (J := J) q htree hA' hP hmodLog hcountP hmoduli
133
+ have herror : (∑ _z ∈ pairs, coeff * (shell / 16)) ≤ coeff * (totalShell / 16) := by
134
+ have hpay := (mul_le_mul_of_nonneg_right hcard hshell.le).trans hallocation
135
+ have hscale := mul_le_mul_of_nonneg_left hpay (div_nonneg hcoeff (by norm_num : (0 : ℝ) ≤ 16))
136
+ calc
137
+ _ = ((pairs.card : ℝ) * shell) * (coeff / 16) := by simp only [Finset.sum_const, nsmul_eq_mul]; ring
138
+ _ ≤ totalShell * (coeff / 16) := by nlinarith only [hscale]
139
+ _ = _ := by ring
140
+ exact productTruncatedPairing_leaf_normalized_bound c tree (lowDegreeCoordinateSets ι B)
141
+ baseX baseY source target ratioX ratioY (fun _ => coeff * (shell / 16)) hR hratioX hratioY hbound herror
142
+
143
+ end Erdos3
144
+
145
+ end
146
+
147
+ section
148
+
149
+ namespace Erdos3
150
+
151
+ theorem normalized_affine_error_le {ε T level eta shell totalShell : ℝ}
152
+ (hε : 0 ≤ ε) (hT : 0 ≤ T) (hlevel : 0 ≤ level) (hlevel2 : level ≤ 2)
153
+ (heta0 : 0 ≤ eta) (heta1 : eta ≤ 1) (hshell : 0 ≤ shell) (htotal : shell ≤ totalShell) :
154
+ (1 + eta) * (1 + eta) *
155
+ (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
156
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) +
157
+ (1 + (1 + ��) * level) * (totalShell / 16) ≤
158
+ 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell := by
159
+ have he : 0 < Real.exp (-T / 2) := Real.exp_pos _
160
+ have he0 : 0 < Real.exp (-T) := Real.exp_pos _
161
+ have htotal0 : 0 ≤ totalShell := hshell.trans htotal
162
+ have hdecay : Real.exp (-T) ≤ Real.exp (-T / 2) := Real.exp_le_exp.mpr (by linarith)
163
+ have hsquare : (Real.exp (-T / 2)) ^ 2 = Real.exp (-T) := by
164
+ rw [pow_two, ← Real.exp_add]
165
+ congr 1
166
+ ring
167
+ have hsqrt : Real.sqrt (3 * Real.exp (-T)) ≤ 2 * Real.exp (-T / 2) := by
168
+ apply (Real.sqrt_le_left (by positivity : 0 ≤ 2 * Real.exp (-T / 2))).mpr
169
+ nlinarith only [hsquare, he0]
170
+ have hfirstCoeff : level * (1 + 2 * ε) ≤ 4 * (1 + ε) := by nlinarith
171
+ have hfirst := mul_le_mul hfirstCoeff hdecay he0.le (by positivity : 0 ≤ 4 * (1 + ε))
172
+ have htailCoeff : 3 + (1 + ε) * level * 3 ≤ 9 * (1 + ε) := by nlinarith
173
+ have htail := mul_le_mul hsqrt htailCoeff
174
+ (by positivity : 0 ≤ 3 + (1 + ε) * level * 3)
175
+ (by positivity : 0 ≤ 2 * Real.exp (-T / 2))
176
+ have hmain : level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
177
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3) ≤
178
+ 22 * (1 + ε) * Real.exp (-T / 2) + shell / 16 := by nlinarith only [hfirst, htail]
179
+ have hmain0 : 0 ≤ level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
180
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3) := by positivity
181
+ have hfactor : (1 + eta) * (1 + eta) ≤ 4 := by nlinarith
182
+ have hcoeff : 1 + (1 + ε) * level ≤ 3 * (1 + ε) := by nlinarith
183
+ have herr := mul_le_mul_of_nonneg_right hcoeff (div_nonneg htotal0 (by norm_num : (0 : ℝ) ≤ 16))
184
+ have hrest : shell / 4 + 3 * (1 + ε) * (totalShell / 16) ≤ (1 + ε) * totalShell := by
185
+ nlinarith only [htotal, htotal0, mul_nonneg hε htotal0]
186
+ calc
187
+ _ ≤ 4 * (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 +
188
+ Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) +
189
+ 3 * (1 + ε) * (totalShell / 16) :=
190
+ add_le_add (mul_le_mul_of_nonneg_right hfactor hmain0) herr
191
+ _ ≤ 4 * (22 * (1 + ε) * Real.exp (-T / 2) + shell / 16) +
192
+ 3 * (1 + ε) * (totalShell / 16) := by
193
+ linarith only [hmain]
194
+ _ ≤ _ := by nlinarith only [hrest, mul_nonneg (by linarith : 0 ≤ 1 + ε) he.le]
195
+
196
+ theorem affine_error_envelope_at_precision {ε Q : ℝ} (hε : 0 ≤ ε) :
197
+ 100 * (1 + ε) * Real.exp (-(2 * (Q + Real.log (400 * (1 + ε)))) / 2) +
198
+ (1 + ε) * (Real.exp (-Q) / (4 * (1 + ε))) = Real.exp (-Q) / 2 := by
199
+ have ha : 0 < 1 + ε := by linarith
200
+ have hc : 0 < 400 * (1 + ε) := by positivity
201
+ have harg : -(2 * (Q + Real.log (400 * (1 + ε)))) / 2 =
202
+ -Q - Real.log (400 * (1 + ε)) := by ring
203
+ rw [harg, Real.exp_sub, Real.exp_log hc]
204
+ field_simp
205
+ ring
206
+
207
+ end Erdos3
208
+
209
+ end
210
+
211
+ section
212
+
213
+ namespace Erdos3
214
+
215
+ noncomputable def affineStabilityInputBudget (p ε L T C modLog parameterLog : ℝ) : ℝ :=
216
+ max p (max (T + 4) (max modLog
217
+ (max (affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog)
218
+ ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ))))
219
+
220
+ theorem affineStabilityInputBudget_bounds (p ε L T C modLog parameterLog : ℝ) :
221
+ p ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧
222
+ T + 4 ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧
223
+ modLog ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧
224
+ affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog ≤
225
+ affineStabilityInputBudget p ε L T C modLog parameterLog ∧
226
+ ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ) ≤
227
+ affineStabilityInputBudget p ε L T C modLog parameterLog := by
228
+ unfold affineStabilityInputBudget
229
+ refine ⟨le_max_left _ _, ?_, ?_, ?_, ?_⟩
230
+ · exact (le_max_left _ _).trans (le_max_right _ _)
231
+ · exact (le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _))
232
+ · exact (le_max_left _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _)))
233
+ · exact (le_max_right _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _)))
234
+
235
+ theorem affineStabilityInputBudget_mask {ι : Type*} [Fintype ι]
236
+ (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime)
237
+ (p ε modLog : ℝ) {L T C parameterLog : ℝ} {D : ℕ}
238
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hD : 0 < D)
239
+ (hparameter : (D : ℝ) ≤ Real.exp parameterLog) :
240
+ ((affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D).card : ℝ) ≤
241
+ affineStabilityInputBudget p ε L T C modLog parameterLog := by
242
+ have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1
243
+ have hm := affineSamplerPrimeMask_card_le (ξ := ε / (2 + ε)) prime hprime hinj hP
244
+ (sourceM := 1) (siteM := 1) (sourceLog := 0) (siteLog := 0)
245
+ (by decide) (by decide) hD (by simp) (by simp) hparameter
246
+ have hm' : ((affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D).card : ℝ) ≤
247
+ affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog := by
248
+ simpa only [mul_zero, add_zero] using hm
249
+ exact hm'.trans (affineStabilityInputBudget_bounds p ε L T C modLog parameterLog).2.2.2.1
250
+
251
+ noncomputable def affineReferenceTargetTime (ε Q : ℝ) : ℝ :=
252
+ 2 * (Q + Real.log (400 * (1 + ε)))
253
+
254
+ noncomputable def affineReferenceTargetShell (ε Q : ℝ) : ℝ :=
255
+ Real.exp (-Q) / (4 * (1 + ε))
256
+
257
+ theorem affineReferenceTargetTime_nonneg {ε Q : ℝ} (hε : 0 ≤ ε) (hQ : 0 ≤ Q) :
258
+ 0 ≤ affineReferenceTargetTime ε Q := by
259
+ have hlog : 0 ≤ Real.log (400 * (1 + ε)) := Real.log_nonneg (by linarith)
260
+ unfold affineReferenceTargetTime
261
+ positivity
262
+
263
+ theorem affineReferenceTargetShell_pos {ε : ℝ} (Q : ℝ) (hε : 0 ≤ ε) :
264
+ 0 < affineReferenceTargetShell ε Q := by
265
+ unfold affineReferenceTargetShell
266
+ positivity
267
+
268
+ theorem affine_error_envelope_le_precision {ε Q T totalShell : ℝ} (hε : 0 ≤ ε)
269
+ (hT : affineReferenceTargetTime ε Q ≤ T)
270
+ (hshell : totalShell ≤ affineReferenceTargetShell ε Q) :
271
+ 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell ≤ Real.exp (-Q) / 2 := by
272
+ have ht : Real.exp (-T / 2) ≤ Real.exp (-affineReferenceTargetTime ε Q / 2) :=
273
+ Real.exp_le_exp.mpr (by linarith)
274
+ have hfirst := mul_le_mul_of_nonneg_left ht (by positivity : 0 ≤ 100 * (1 + ε))
275
+ have hsecond := mul_le_mul_of_nonneg_left hshell (by linarith : 0 ≤ 1 + ε)
276
+ exact (add_le_add hfirst hsecond).trans_eq (affine_error_envelope_at_precision hε)
277
+
278
+ theorem affine_error_envelope_lt_target {ε Q T totalShell : ℝ} (hε : 0 ≤ ε)
279
+ (hT : affineReferenceTargetTime ε Q ≤ T)
280
+ (hshell : totalShell ≤ affineReferenceTargetShell ε Q) :
281
+ 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell < Real.exp (-Q) := by
282
+ have h := affine_error_envelope_le_precision hε hT hshell
283
+ linarith [Real.exp_pos (-Q)]
284
+
285
+ end Erdos3
286
+
287
+ end
288
+
289
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffinePrimitiveLogBudget.lean ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.AffineDegreeChoice
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def affineComparisonTail (ε L T : ℝ) : ℕ :=
10
+ CyclicCrootSisask.spectralIterations (ε / (2 + ε)) (L + 2 * T + 4)
11
+
12
+ noncomputable def affineComparisonScale (ε L T C : ℝ) : ℝ :=
13
+ L + T + 2 + (affineRemovalDepth T + affineComparisonTail ε L T : ℕ) + C
14
+
15
+ noncomputable def affineComparisonMoment (P : ℝ) : ℕ :=
16
+ 2 * (Nat.floor (P / 2) + 1)
17
+
18
+ theorem affineComparisonScale_bounds {ε L T C : ℝ}
19
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) :
20
+ 0 ≤ affineComparisonScale ε L T C ∧
21
+ L + T + 2 ≤ affineComparisonScale ε L T C ∧
22
+ ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ) ≤ affineComparisonScale ε L T C ∧
23
+ C ≤ affineComparisonScale ε L T C := by
24
+ have hn : (0 : ℝ) ≤ (affineRemovalDepth T + affineComparisonTail ε L T : ℕ) := Nat.cast_nonneg _
25
+ unfold affineComparisonScale
26
+ constructor
27
+ · positivity
28
+ constructor
29
+ · linarith
30
+ constructor <;> linarith
31
+
32
+ theorem affineComparisonScale_count {ι : Type*} [Fintype ι] {ε L T C : ℝ}
33
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C)
34
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) :
35
+ (Fintype.card ι : ℝ) ≤ Real.exp (affineComparisonScale ε L T C) :=
36
+ hcount.trans (Real.exp_le_exp.mpr (affineComparisonScale_bounds (ε := ε) hL hT hC).2.2.2)
37
+
38
+ theorem affineComparisonMoment_bounds {P : ℝ} (hP : 0 ≤ P) :
39
+ 2 ≤ affineComparisonMoment P ∧ Even (affineComparisonMoment P) ∧
40
+ P ≤ (affineComparisonMoment P : ℝ) ∧ (affineComparisonMoment P : ℝ) ≤ P + 2 := by
41
+ unfold affineComparisonMoment
42
+ refine ⟨by omega, even_two_mul _, ?_, ?_⟩
43
+ · have h := Nat.lt_floor_add_one (P / 2)
44
+ push_cast
45
+ linarith
46
+ · have h := Nat.floor_le (by positivity : 0 ≤ P / 2)
47
+ push_cast
48
+ linarith
49
+
50
+ end Erdos3
51
+
52
+ end
53
+
54
+ section
55
+
56
+ namespace Erdos3
57
+
58
+ noncomputable def affinePrimitiveLogBudget (P : ℝ) : ℝ := 16 * (P + 3)
59
+
60
+ theorem affinePrimitiveLogBudget_nonneg {P : ℝ} (hP : 0 ≤ P) :
61
+ 0 ≤ affinePrimitiveLogBudget P := by unfold affinePrimitiveLogBudget; positivity
62
+
63
+ theorem affineRemovalDepth_le_logBudget {T P : ℝ} (hT : 0 ≤ T) (hTP : T ≤ P) :
64
+ (affineRemovalDepth T : ℝ) ≤ 2 * P + 10 := by
65
+ have h := CyclicCrootSisask.spectralIterations_le_logBudget (epsilon := 1) (A := 0)
66
+ (by norm_num) hT le_rfl (by simp)
67
+ change (affineRemovalDepth T : ℝ) ≤ _ at h
68
+ linarith
69
+
70
+ theorem affineComparisonTail_le_logBudget {epsilon L T P : ℝ}
71
+ (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P)
72
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hLP : L ≤ P) (hTP : T ≤ P)
73
+ (hinverse : epsilon⁻¹ ≤ Real.exp P) :
74
+ (affineComparisonTail epsilon L T : ℝ) ≤ 8 * P + 22 := by
75
+ have h := CyclicCrootSisask.spectralIterations_le_logBudget
76
+ (epsilon := epsilon / (2 + epsilon)) (p := L + 2 * T + 4) (A := P + 2)
77
+ (by positivity) (by positivity) (by positivity)
78
+ (affineAllowance_inverse_le_exp hepsilon hepsilon1 hinverse)
79
+ change (affineComparisonTail epsilon L T : ℝ) ≤ _ at h
80
+ linarith
81
+
82
+ theorem affineComparisonPrimitive_bounds {epsilon L T C P : ℝ}
83
+ (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P)
84
+ (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C)
85
+ (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P)
86
+ (hinverse : epsilon⁻¹ ≤ Real.exp P) :
87
+ ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ affinePrimitiveLogBudget P ∧
88
+ affineComparisonScale epsilon L T C ≤ affinePrimitiveLogBudget P ∧
89
+ (affineComparisonMoment (affineComparisonScale epsilon L T C) : ℝ) ≤ affinePrimitiveLogBudget P + 2 := by
90
+ have hj := affineRemovalDepth_le_logBudget hT hTP
91
+ have ht := affineComparisonTail_le_logBudget hepsilon hepsilon1 hP hL hT hLP hTP hinverse
92
+ have hsum : ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤
93
+ 10 * P + 32 := by push_cast; linarith
94
+ have hs : affineComparisonScale epsilon L T C ≤ affinePrimitiveLogBudget P := by
95
+ unfold affineComparisonScale affinePrimitiveLogBudget
96
+ linarith
97
+ refine ⟨?_, hs, ?_⟩
98
+ · unfold affinePrimitiveLogBudget
99
+ linarith
100
+ · have hm := (affineComparisonMoment_bounds (affineComparisonScale_bounds (ε := epsilon) hL hT hC).1).2.2.2
101
+ linarith
102
+
103
+ end Erdos3
104
+
105
+ end
106
+
107
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineProfileTranslationL1.lean ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.ScalarSupportTranslationL1
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+ open scoped BigOperators
11
+
12
+ theorem affineProductProfile_translation_l1 {I : Type*} [Fintype I]
13
+ (c w : I → ℝ) {δ : ℝ} (hδ : 0 < δ) (hw : ∀ i, δ ≤ w i) (a b : I → ℝ) :
14
+ (∫ x, |affineProductProfile c w (x + a) - affineProductProfile c w (x + b)|) ≤
15
+ (Fintype.card I * (4 * (probabilityProfileLipschitz : ℝ) / δ)) * dist a b := by
16
+ classical
17
+ have hwp (i) : 0 < w i := hδ.trans_le (hw i)
18
+ have hi (z : I → ℝ) (i) : Integrable (fun x => affineProbabilityProfile (c i) (w i) (x + z i)) :=
19
+ (affineProbabilityProfile_integrable (c i) (hwp i)).comp_add_right (z i)
20
+ have hm (z : I → ℝ) (i) : (∫ x, affineProbabilityProfile (c i) (w i) (x + z i)) = 1 := by
21
+ rw [integral_add_right_eq_self, affineProbabilityProfile_integral (c i) (hwp i)]
22
+ have h := product_density_l1_le_sum
23
+ (fun i x => affineProbabilityProfile (c i) (w i) (x + a i))
24
+ (fun i x => affineProbabilityProfile (c i) (w i) (x + b i))
25
+ (hi a) (hi b) (fun i _ => affineProbabilityProfile_nonneg (c i) (hwp i) _)
26
+ (fun i _ => affineProbabilityProfile_nonneg (c i) (hwp i) _) (hm a) (hm b)
27
+ change (∫ x, |affineProductProfile c w (x + a) - affineProductProfile c w (x + b)|) ≤ _ at h
28
+ refine h.trans ?_
29
+ calc
30
+ _ ≤ ∑ _i : I, (4 * (probabilityProfileLipschitz : ℝ) / δ) * dist a b := by
31
+ apply Finset.sum_le_sum
32
+ intro i _
33
+ apply (affineProbabilityProfile_translation_l1 (c i) (a i) (b i) (hwp i)).trans
34
+ apply mul_le_mul
35
+ · exact div_le_div_of_nonneg_left (by positivity) hδ (hw i)
36
+ · simpa only [Real.dist_eq] using dist_le_pi_dist a b i
37
+ · exact abs_nonneg _
38
+ · positivity
39
+ _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring
40
+
41
+ end Erdos3
42
+
43
+ end
44
+
45
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineRefinedCoefficients.lean ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Linear.SharedFreeCommonProjection
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.VectorPolynomial
8
+
9
+ open scoped TensorProduct BigOperators
10
+
11
+ theorem affine_refined_coefficient_mem {L ι : Type*} [AddCommGroup L] [Module ℚ L]
12
+ [Fintype ι] {s : ℕ} (C D : Fin s → Submodule ℚ L)
13
+ (K : Fin s → Submodule ℚ (Fin 4 → L))
14
+ (G : VectorPolynomial Unit ℚ (ℝ ⊗[ℚ] L))
15
+ (α : Fin s → ℝ ⊗[ℚ] L) (β : ι → Fin s → ℝ ⊗[ℚ] L) (x : ι → ℝ)
16
+ (hG : ∀ d : Fin s, coefficients G (Finsupp.single () (d.val + 1)) ∈
17
+ ((fourRefinedRelation (C d) (D d) (K d)).map (LinearMap.proj 0)).baseChange ℝ)
18
+ (hα : ∀ d, α d ∈ (D d).baseChange ℝ)
19
+ (hβ : ∀ j d, β j d ∈ (D d).baseChange ℝ) (d : Fin s) :
20
+ coefficients (G + positiveUnivariate (fun d => α d + ∑ j, x j • β j d))
21
+ (Finsupp.single () (d.val + 1)) ∈
22
+ ((fourRefinedRelation (C d) (D d) (K d)).map (LinearMap.proj 0)).baseChange ℝ := by
23
+ rw [map_add, Finsupp.add_apply, positiveUnivariate_coefficient]
24
+ apply Submodule.add_mem _ (hG d)
25
+ apply Submodule.baseChange_mono ℝ (dependent_le_refined_firstProjection (C d) (D d) (K d))
26
+ exact Submodule.add_mem _ (hα d)
27
+ (Submodule.sum_mem _ (fun j _ => Submodule.smul_mem _ _ (hβ j d)))
28
+
29
+ end Erdos3.VectorPolynomial
30
+
31
+ end
32
+
33
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineResidualRecovery.lean ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Linear.WeightedPatchKernel
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped NNReal
10
+
11
+ def recoveredIntegerLift {d m : ℕ} (M : Fin m → Fin d → ℤ) (c : Fin m → ℤ)
12
+ (k : Fin d → ℤ) : Fin m → ℤ := fun i => c i + ∑ j, M i j * k j
13
+
14
+ noncomputable def realIntegerMatrix {d m : ℕ} (M : Fin m → Fin d → ℤ)
15
+ (x : Fin d → ℝ) : Fin m → ℝ := fun i => ∑ j, (M i j : ℝ) * x j
16
+
17
+ noncomputable def recoveredSmallLift {d m : ℕ} (M : Fin m → Fin d → ℤ)
18
+ (a : Fin d → ℝ) (c : Fin m → ℤ) (e : Fin d → ℝ) : Fin m → ℝ :=
19
+ fun i => (∑ j, (M i j : ℝ) * (a j - e j)) - c i
20
+
21
+ theorem recoveredSmallLift_at_integer {d m : ℕ} (M : Fin m → Fin d → ℤ)
22
+ (a x : Fin d → ℝ) (c : Fin m → ℤ) (k : Fin d → ℤ) :
23
+ recoveredSmallLift M a c (fun j => (k j : ℝ) - (x - a) j) =
24
+ fun i => realIntegerMatrix M x i - (recoveredIntegerLift M c k i : ℝ) := by
25
+ funext i
26
+ simp only [recoveredSmallLift, realIntegerMatrix, recoveredIntegerLift, Pi.sub_apply]
27
+ push_cast
28
+ simp only [mul_sub, Finset.sum_sub_distrib]
29
+ ring
30
+
31
+ theorem recoveredSmallLift_lipschitz {d m : ℕ} (M : Fin m → Fin d → ℤ)
32
+ (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0)
33
+ (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : LipschitzWith K (recoveredSmallLift M a c) := by
34
+ apply LipschitzWith.of_dist_le_mul
35
+ intro x y
36
+ apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr
37
+ intro i
38
+ simp only [recoveredSmallLift, Real.dist_eq]
39
+ rw [sub_sub_sub_cancel_right, ← Finset.sum_sub_distrib]
40
+ calc
41
+ _ ≤ ∑ j, |(M i j : ℝ) * (a j - x j) - (M i j : ℝ) * (a j - y j)| :=
42
+ Finset.abs_sum_le_sum_abs _ _
43
+ _ ≤ ∑ j, |(M i j : ℝ)| * dist x y := by
44
+ apply Finset.sum_le_sum
45
+ intro j _
46
+ rw [← mul_sub, abs_mul]
47
+ apply mul_le_mul_of_nonneg_left _ (abs_nonneg _)
48
+ simpa only [sub_sub_sub_cancel_left, abs_sub_comm, Real.dist_eq] using dist_le_pi_dist x y j
49
+ _ = (∑ j, |(M i j : ℝ)|) * dist x y := (Finset.sum_mul _ _ _).symm
50
+ _ ≤ K * dist x y := mul_le_mul_of_nonneg_right (hM i) dist_nonneg
51
+
52
+ noncomputable def recoveredCellKernel {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m)
53
+ (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0)
54
+ (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : PatchKernel d :=
55
+ Φ.weightAlong Ψ (recoveredSmallLift M a c) K (recoveredSmallLift_lipschitz M a c K hM)
56
+
57
+ @[simp] theorem recoveredCellKernel_lip {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m)
58
+ (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0)
59
+ (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) :
60
+ (recoveredCellKernel Φ Ψ M a c K hM).lip = Φ.lip + Ψ.lip * K := rfl
61
+
62
+ @[simp] theorem recoveredCellKernel_value {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m)
63
+ (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0)
64
+ (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) (e : Fin d → ℝ) :
65
+ (recoveredCellKernel Φ Ψ M a c K hM).value e = Φ.value e * Ψ.value (recoveredSmallLift M a c e) := rfl
66
+
67
+ end Erdos3
68
+
69
+ end
70
+
71
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueAccuracy.lean ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.PhysicalPairAccuracyLogBounds
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def affineComparisonAccuracyLog (b : ℕ) (P L T : ℝ) : ℝ :=
10
+ (P + 3) ^ 3 + 2 * (b : ℝ) * (P + 2) + L + T + 4
11
+
12
+ noncomputable def affineComparisonAccuracy (b : ℕ) (P L T : ℝ) : ℝ :=
13
+ Real.exp (-affineComparisonAccuracyLog b P L T)
14
+
15
+ theorem affineComparisonAccuracy_bounds {P L T level : ℝ} (b : ℕ)
16
+ (hP : 0 ≤ P) (hL : 0 ≤ L) (hT : 0 ≤ T) (hlevel : Real.exp (-L) ≤ level) :
17
+ 0 < affineComparisonAccuracy b P L T ∧ affineComparisonAccuracy b P L T < 1 ∧
18
+ affineComparisonAccuracy b P L T ≤ Real.exp (-T) / 8 ∧
19
+ affineComparisonAccuracy b P L T ≤ level * Real.exp (-T) / 8 ∧
20
+ affineComparisonAccuracy b P L T ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3)) := by
21
+ have hp : 0 ≤ (P + 3) ^ 3 := by positivity
22
+ have hb : 0 ≤ 2 * (b : ℝ) * (P + 2) := by positivity
23
+ have hpos : 0 < affineComparisonAccuracyLog b P L T := by
24
+ unfold affineComparisonAccuracyLog
25
+ linarith
26
+ refine ⟨Real.exp_pos _, ?_, ?_, ?_, ?_⟩
27
+ · exact Real.exp_lt_one_iff.mpr (by linarith)
28
+ · exact exp_neg_le_exp_neg_div_eight (by unfold affineComparisonAccuracyLog; linarith)
29
+ · calc
30
+ _ ≤ Real.exp (-(L + T)) / 8 :=
31
+ exp_neg_le_exp_neg_div_eight (by unfold affineComparisonAccuracyLog; linarith)
32
+ _ ≤ level * Real.exp (-T) / 8 := by
33
+ rw [neg_add, Real.exp_add]
34
+ exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hlevel (Real.exp_pos _).le) (by norm_num)
35
+ · exact exp_neg_le_half_exp_neg (by unfold affineComparisonAccuracyLog; linarith)
36
+
37
+ theorem affineComparisonAccuracy_gram {ι : Type*} [Fintype ι] [DecidableEq ι]
38
+ {P L T : ℝ} (b : ℕ) (hP : 0 ≤ P) (hL : 0 ≤ L) (hT : 0 ≤ T)
39
+ (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) :
40
+ 2 * affineComparisonAccuracy b P L T * ((lowDegreeCoordinateSets ι b).card : ℝ) ^ 2 *
41
+ (4 : ℝ) ^ b * (1 + affineComparisonAccuracy b P L T) ^ 2 ≤ Real.exp (-T) := by
42
+ let η := affineComparisonAccuracy b P L T
43
+ have he := affineComparisonAccuracy_bounds (level := Real.exp (-L)) b hP hL hT le_rfl
44
+ have hη0 : 0 < η := he.1
45
+ have hη1 : η < 1 := he.2.1
46
+ have hc := lowDegreeCoordinateSets_card_le_exp hP hcount b
47
+ have hc2 : ((lowDegreeCoordinateSets ι b).card : ℝ) ^ 2 ≤
48
+ Real.exp (2 * (b : ℝ) * (P + 1)) := by
49
+ calc
50
+ _ ≤ (Real.exp ((b : ℝ) * (P + 1))) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hc 2
51
+ _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring
52
+ have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)]
53
+ have hfour : (4 : ℝ) ≤ Real.exp 2 := by
54
+ calc
55
+ 4 = (2 : ℝ) ^ 2 := by norm_num
56
+ _ ≤ (Real.exp 1) ^ 2 := pow_le_pow_left₀ (by norm_num) htwo 2
57
+ _ = _ := by rw [← Real.exp_nat_mul]; norm_num
58
+ have hp4 : (4 : ℝ) ^ b ≤ Real.exp (2 * (b : ℝ)) := by
59
+ exact (pow_le_pow_left₀ (by norm_num) hfour b).trans_eq (by rw [← Real.exp_nat_mul]; congr 1; ring)
60
+ have hsq : (1 + η) ^ 2 ≤ 4 := by nlinarith
61
+ have hsmall : η ≤ Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) / 8 := by
62
+ apply exp_neg_le_exp_neg_div_eight
63
+ unfold affineComparisonAccuracyLog
64
+ have hp : 0 ≤ (P + 3) ^ 3 := by positivity
65
+ linarith
66
+ change 2 * η * _ ^ 2 * _ ^ b * (1 + η) ^ 2 ≤ _
67
+ calc
68
+ _ ≤ 2 * η * Real.exp (2 * (b : ℝ) * (P + 1)) * Real.exp (2 * (b : ℝ)) * 4 := by gcongr
69
+ _ = 8 * η * (Real.exp (2 * (b : ℝ) * (P + 1)) * Real.exp (2 * (b : ℝ))) := by ring
70
+ _ = 8 * η * Real.exp (2 * (b : ℝ) * (P + 2)) := by rw [← Real.exp_add]; congr 2; ring
71
+ _ ≤ 8 * (Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) / 8) * Real.exp (2 * (b : ℝ) * (P + 2)) := by gcongr
72
+ _ = Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) * Real.exp (2 * (b : ℝ) * (P + 2)) := by ring
73
+ _ = Real.exp (-T) := by rw [← Real.exp_add]; congr 1; ring
74
+
75
+ end Erdos3
76
+
77
+ end
78
+
79
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueCoordinateEquiv.lean ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.Group.Equiv.Basic
2
+ import Mathlib.Algebra.Group.Units.Equiv
3
+ import Mathlib.Data.ZMod.Basic
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ noncomputable def affineResidueCoordinateEquiv {σ : Type*} (M q : ℕ) (a : σ → ℤ)
12
+ (hcop : M.Coprime q) : (σ → ZMod q) ≃ (σ → ZMod q) :=
13
+ Equiv.piCongrRight fun j =>
14
+ (ZMod.unitOfCoprime M hcop).mulLeft.trans (Equiv.addLeft (a j : ZMod q))
15
+
16
+ theorem affineResidueCoordinateEquiv_apply {σ : Type*} (M q : ℕ) (a : σ → ℤ)
17
+ (hcop : M.Coprime q) (x : σ → ZMod q) (j : σ) :
18
+ affineResidueCoordinateEquiv M q a hcop x j = (a j : ZMod q) + (M : ZMod q) * x j := rfl
19
+
20
+ theorem affineResidueCoordinateEquiv_intCast {σ : Type*} (M q : ℕ) (a : σ → ℤ)
21
+ (hcop : M.Coprime q) (z : σ → ℤ) :
22
+ affineResidueCoordinateEquiv M q a hcop (fun j => (z j : ZMod q)) =
23
+ (fun j => ((a j + (M : ℤ) * z j : ℤ) : ZMod q)) := by
24
+ funext j
25
+ simp only [affineResidueCoordinateEquiv_apply, Int.cast_add, Int.cast_mul, Int.cast_natCast]
26
+
27
+ end Erdos3
28
+
29
+ end
30
+
31
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineSampleAlphabet.lean ADDED
@@ -0,0 +1,635 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Data.ZMod.Basic
2
+ import OAI.Combinatorics.Progressions.Lattices.PrimeCoordinateCells
3
+ import OAI.Combinatorics.Progressions.Linear.KernelCoreComparison
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open scoped BigOperators Classical
12
+
13
+ variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J]
14
+ [AddCommGroup G] [Module (ZMod q) G]
15
+
16
+ noncomputable def residueColumnMap (V : J → G) : (J → ZMod q) →+ G where
17
+ toFun t := ∑ j, t j • V j
18
+ map_zero' := by simp
19
+ map_add' t u := by simp [add_smul, Finset.sum_add_distrib]
20
+
21
+ omit [NeZero q] in
22
+ theorem residueColumnMap_single (V : J → G) (j : J) :
23
+ residueColumnMap (q := q) V (Pi.single j (1 : ZMod q)) = V j := by
24
+ simp [residueColumnMap, Pi.single_apply, ite_smul]
25
+
26
+ theorem additiveCharacter_zmod_smul (χ : AddChar G ℂ) (t : ZMod q) (x : G) :
27
+ χ (t • x) = χ x ^ t.val := by
28
+ conv_lhs => rw [← ZMod.natCast_zmod_val t, Nat.cast_smul_eq_nsmul]
29
+ exact χ.map_nsmul_eq_pow t.val x
30
+
31
+ theorem residueColumn_character_zero_iff (V : J → G) (χ : AddChar G ℂ) :
32
+ χ.compAddMonoidHom (residueColumnMap (q := q) V) = 0 ↔ ∀ j, χ (V j) = 1 := by
33
+ constructor
34
+ · intro h j
35
+ have hh := DFunLike.congr_fun h (Pi.single j (1 : ZMod q))
36
+ simpa only [AddChar.compAddMonoidHom_apply, residueColumnMap_single, AddChar.zero_apply] using hh
37
+ · intro h
38
+ ext t
39
+ change χ (∑ j, t j • V j) = 1
40
+ exact (additiveCharacterKernel χ).sum_mem (fun j _ => by
41
+ change χ (t j • V j) = 1
42
+ rw [additiveCharacter_zmod_smul, h, one_pow])
43
+
44
+ theorem residueColumn_character_mean (V : J → G) (χ : AddChar G ℂ) :
45
+ (𝔼 t : J → ZMod q, χ (residueColumnMap (q := q) V t)) =
46
+ if ∀ j, χ (V j) = 1 then 1 else 0 := by
47
+ have h := AddChar.expect_eq_ite (χ.compAddMonoidHom (residueColumnMap (q := q) V))
48
+ simpa only [AddChar.compAddMonoidHom_apply, residueColumn_character_zero_iff] using h
49
+
50
+ noncomputable def residueColumnAverage (V : J → G) (f : G → ℂ) (x : G) : ℂ :=
51
+ 𝔼 t : J → ZMod q, f (x + residueColumnMap (q := q) V t)
52
+
53
+ variable [Fintype G]
54
+
55
+ theorem finiteFourierCoeff_residueColumnAverage (V : J → G) (f : G → ℂ) (χ : AddChar G ℂ) :
56
+ finiteFourierCoeff (residueColumnAverage (q := q) V f) χ =
57
+ (if ∀ j, χ (V j) = 1 then 1 else 0) * finiteFourierCoeff f χ := by
58
+ have htranslate (a : G) : finiteFourierCoeff (fun x => f (x + a)) χ =
59
+ χ a * finiteFourierCoeff f χ := by
60
+ have h := finiteFourierCoeff_translate f (-a) χ
61
+ rw [AddChar.map_neg_eq_conj] at h
62
+ simpa only [sub_neg_eq_add, Complex.star_def, starRingEnd_self_apply] using h
63
+ unfold finiteFourierCoeff residueColumnAverage
64
+ simp_rw [Finset.expect_mul]
65
+ rw [Finset.expect_comm]
66
+ change (𝔼 t : J → ZMod q, finiteFourierCoeff (fun x => f (x + residueColumnMap (q := q) V t)) χ) = _
67
+ simp_rw [htranslate]
68
+ rw [← Finset.expect_mul, residueColumn_character_mean]
69
+ rfl
70
+
71
+ end Erdos3
72
+
73
+ end
74
+
75
+ section
76
+
77
+ namespace Erdos3
78
+
79
+ open scoped BigOperators Classical
80
+
81
+ variable {J G : Type*} [Fintype J] [AddCommGroup G] [Fintype G]
82
+
83
+ theorem residueColumn_survival_probability (χ : AddChar G ℂ) :
84
+ (𝔼 V : J → G, if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) =
85
+ (𝔼 x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J := by
86
+ have hpoint (V : J → G) :
87
+ (if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) =
88
+ ∏ j, if χ (V j) = 1 then (1 : ℝ) else 0 := by
89
+ by_cases h : ∀ j, χ (V j) = 1
90
+ · simp [h]
91
+ · rw [ite_eq_right h]
92
+ push Not at h
93
+ obtain ⟨j, hj⟩ := h
94
+ exact (Finset.prod_eq_zero (Finset.mem_univ j) (by simp [hj])).symm
95
+ calc
96
+ _ = 𝔼 V : J → G, ∏ j, if χ (V j) = 1 then (1 : ℝ) else 0 :=
97
+ Finset.expect_congr rfl (fun V _ => hpoint V)
98
+ _ = (∑ x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J /
99
+ (Fintype.card G : ℝ) ^ Fintype.card J := by
100
+ rw [Fintype.expect_eq_sum_div_card, Fintype.card_fun, Nat.cast_pow]
101
+ congr 1
102
+ simpa using (Fintype.prod_sum
103
+ (fun _j : J => fun x : G => if χ x = 1 then (1 : ℝ) else 0)).symm
104
+ _ = _ := by rw [Fintype.expect_eq_sum_div_card, div_pow]
105
+
106
+ variable {q : ℕ} [NeZero q] [Module (ZMod q) G]
107
+
108
+ theorem residueColumnAverage_energy (V : J → G) (f : G → ℂ) :
109
+ (𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) =
110
+ ∑ χ : AddChar G ℂ,
111
+ (if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) * ‖finiteFourierCoeff f χ‖ ^ 2 := by
112
+ rw [← finiteFourier_parseval]
113
+ apply Finset.sum_congr rfl
114
+ intro χ _
115
+ rw [finiteFourierCoeff_residueColumnAverage]
116
+ split_ifs <;> simp
117
+
118
+ theorem residueColumnAverage_mean_energy (f : G → ℂ) :
119
+ (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) =
120
+ ∑ χ : AddChar G ℂ,
121
+ (𝔼 x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J *
122
+ ‖finiteFourierCoeff f χ‖ ^ 2 := by
123
+ simp_rw [residueColumnAverage_energy]
124
+ rw [Finset.expect_sum_comm]
125
+ apply Finset.sum_congr rfl
126
+ intro χ _
127
+ rw [← Finset.expect_mul, residueColumn_survival_probability]
128
+
129
+ theorem primeAffine_contraction_sq {p a : ℕ} (hp : p.Prime)
130
+ (hG : Fintype.card G = p ^ a) (f : G → ℂ) (hf : (𝔼 x, f x) = 0) :
131
+ (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) ≤
132
+ (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, ‖f x‖ ^ 2) := by
133
+ rw [residueColumnAverage_mean_energy]
134
+ calc
135
+ _ ≤ ∑ χ : AddChar G ℂ, (p : ℝ)⁻¹ ^ Fintype.card J *
136
+ ‖finiteFourierCoeff f χ‖ ^ 2 := by
137
+ apply Finset.sum_le_sum
138
+ intro χ _
139
+ by_cases hχ : χ = 0
140
+ · subst χ
141
+ have hz : finiteFourierCoeff f 0 = 0 := by
142
+ simpa [finiteFourierCoeff] using hf
143
+ simp [hz]
144
+ · apply mul_le_mul_of_nonneg_right _ (sq_nonneg _)
145
+ exact pow_le_pow_left₀
146
+ (Finset.expect_nonneg (fun x _ => by split_ifs <;> norm_num))
147
+ (primePowerCharacter_kernel_probability hp hG hχ) _
148
+ _ = _ := by rw [← Finset.mul_sum, finiteFourier_parseval]
149
+
150
+ theorem primeAffine_contraction {p a : ℕ} (hp : p.Prime)
151
+ (hG : Fintype.card G = p ^ a) (f : G → ℂ) (hf : (𝔼 x, f x) = 0) :
152
+ Real.sqrt (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) ≤
153
+ (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) * Real.sqrt (𝔼 x : G, ‖f x‖ ^ 2) := by
154
+ have hs : Real.sqrt ((p : ℝ)⁻¹ ^ Fintype.card J) =
155
+ (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) := by
156
+ rw [Real.sqrt_eq_rpow]
157
+ calc
158
+ _ = ((p : ℝ) ^ (-(Fintype.card J : ℝ))) ^ (1 / (2 : ℝ)) := by
159
+ rw [Real.rpow_neg (Nat.cast_nonneg p), Real.rpow_natCast, inv_pow]
160
+ _ = (p : ℝ) ^ (-(Fintype.card J : ℝ) * (1 / 2)) :=
161
+ (Real.rpow_mul (Nat.cast_nonneg p) _ _).symm
162
+ _ = _ := by congr 1; ring
163
+ calc
164
+ _ ≤ Real.sqrt ((p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, ‖f x‖ ^ 2)) :=
165
+ Real.sqrt_le_sqrt (primeAffine_contraction_sq (q := q) hp hG f hf)
166
+ _ = _ := by rw [Real.sqrt_mul (by positivity), hs]
167
+
168
+ end Erdos3
169
+
170
+ end
171
+
172
+ section
173
+
174
+ namespace Erdos3
175
+
176
+ open scoped BigOperators Classical
177
+
178
+ variable {I J : Type*} [Fintype I] [Fintype J]
179
+ {p a : ℕ} [NeZero (p ^ a)]
180
+
181
+ theorem primePowerResidue_contraction_sq (hp : p.Prime)
182
+ (f : (I → ZMod (p ^ a)) → ℂ) (hf : (𝔼 x, f x) = 0) :
183
+ (𝔼 V : J → I → ZMod (p ^ a), 𝔼 X : I → ZMod (p ^ a),
184
+ ‖𝔼 t : J → ZMod (p ^ a), f (X + ∑ j, t j • V j)‖ ^ 2) ≤
185
+ (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 X, ‖f X‖ ^ 2) := by
186
+ have hG : Fintype.card (I → ZMod (p ^ a)) = p ^ (a * Fintype.card I) := by
187
+ simp [pow_mul]
188
+ simpa only [residueColumnAverage, residueColumnMap, AddMonoidHom.coe_mk,
189
+ ZeroHom.coe_mk] using primeAffine_contraction_sq (J := J) (q := p ^ a) hp hG f hf
190
+
191
+ theorem primePowerResidue_contraction (hp : p.Prime)
192
+ (f : (I → ZMod (p ^ a)) → ℂ) (hf : (𝔼 x, f x) = 0) :
193
+ Real.sqrt (𝔼 V : J → I → ZMod (p ^ a), 𝔼 X : I → ZMod (p ^ a),
194
+ ‖𝔼 t : J → ZMod (p ^ a), f (X + ∑ j, t j • V j)‖ ^ 2) ≤
195
+ (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) * Real.sqrt (𝔼 X, ‖f X‖ ^ 2) := by
196
+ have hG : Fintype.card (I → ZMod (p ^ a)) = p ^ (a * Fintype.card I) := by
197
+ simp [pow_mul]
198
+ simpa only [residueColumnAverage, residueColumnMap, AddMonoidHom.coe_mk,
199
+ ZeroHom.coe_mk] using primeAffine_contraction (J := J) (q := p ^ a) hp hG f hf
200
+
201
+ end Erdos3
202
+
203
+ end
204
+
205
+ section
206
+
207
+ namespace Erdos3
208
+
209
+ open scoped BigOperators Classical
210
+
211
+ variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J]
212
+ [AddCommGroup G] [Module (ZMod q) G]
213
+
214
+ noncomputable def residueColumnRealAverage (V : J → G) (f : G → ℝ) (x : G) : ℝ :=
215
+ 𝔼 t : J → ZMod q, f (x + residueColumnMap (q := q) V t)
216
+
217
+ theorem residueColumnAverage_ofReal (V : J → G) (f : G → ℝ) (x : G) :
218
+ residueColumnAverage (q := q) V (fun y => (f y : ℂ)) x =
219
+ (residueColumnRealAverage (q := q) V f x : ℂ) := by
220
+ simp only [residueColumnAverage, residueColumnRealAverage, Fintype.expect_eq_sum_div_card,
221
+ Complex.ofReal_div, Complex.ofReal_sum, Complex.ofReal_natCast]
222
+
223
+ variable [Fintype G]
224
+
225
+ theorem residueColumnRealAverage_mean (V : J → G) (f : G → ℝ) :
226
+ (𝔼 x : G, residueColumnRealAverage (q := q) V f x) = 𝔼 x : G, f x := by
227
+ unfold residueColumnRealAverage
228
+ rw [Finset.expect_comm]
229
+ have hshift (t : J → ZMod q) : (𝔼 x : G, f (x + residueColumnMap (q := q) V t)) = 𝔼 x : G, f x :=
230
+ Fintype.expect_equiv (Equiv.addRight (residueColumnMap (q := q) V t)) _ _ (fun _ => rfl)
231
+ simp only [hshift, Fintype.expect_const]
232
+
233
+ theorem primeAffine_real_contraction_sq {p a : ℕ} (hp : p.Prime)
234
+ (hG : Fintype.card G = p ^ a) (f : G → ℝ) (hf : (𝔼 x, f x) = 0) :
235
+ (𝔼 V : J → G, 𝔼 x : G, residueColumnRealAverage (q := q) V f x ^ 2) ≤
236
+ (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, f x ^ 2) := by
237
+ have hfc : (𝔼 x : G, (f x : ℂ)) = 0 := by
238
+ have hc := congrArg (fun y : ℝ => (y : ℂ)) hf
239
+ simpa only [Fintype.expect_eq_sum_div_card, Complex.ofReal_div, Complex.ofReal_sum,
240
+ Complex.ofReal_natCast, Complex.ofReal_zero] using hc
241
+ have h := primeAffine_contraction_sq (q := q) (J := J) hp hG (fun x => (f x : ℂ)) hfc
242
+ simpa only [residueColumnAverage_ofReal, Complex.norm_real, Real.norm_eq_abs, sq_abs] using h
243
+
244
+ end Erdos3
245
+
246
+ end
247
+
248
+ section
249
+
250
+ namespace Erdos3
251
+
252
+ open scoped BigOperators Classical
253
+
254
+ variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J]
255
+ [AddCommGroup G] [Module (ZMod q) G] [Fintype G]
256
+
257
+ noncomputable def residueAffineSource : FiniteProbabilityWeights ((J → G) × G) :=
258
+ (FiniteProbabilityWeights.uniform (J → G)).prod (FiniteProbabilityWeights.uniform G)
259
+
260
+ noncomputable def residueAffineKernel (z : (J → G) × G) : FiniteProbabilityWeights G :=
261
+ (FiniteProbabilityWeights.uniform (J → ZMod q)).fiberLaw
262
+ (fun t => z.2 + residueColumnMap (q := q) z.1 t)
263
+
264
+ theorem residueAffineKernel_mean (z : (J → G) × G) (f : G → ℝ) :
265
+ (residueAffineKernel (q := q) z).mean f = residueColumnRealAverage (q := q) z.1 f z.2 := by
266
+ rw [residueAffineKernel, FiniteProbabilityWeights.fiberLaw_mean, FiniteProbabilityWeights.uniform_mean]
267
+ rfl
268
+
269
+ theorem residueAffineKernel_preserves_mean (f : G → ℝ) :
270
+ (residueAffineSource (J := J) (G := G)).mean (fun z => (residueAffineKernel (q := q) z).mean f) =
271
+ (FiniteProbabilityWeights.uniform G).mean f := by
272
+ simp only [residueAffineSource, FiniteProbabilityWeights.mean_prod, residueAffineKernel_mean,
273
+ FiniteProbabilityWeights.uniform_mean, residueColumnRealAverage_mean, Fintype.expect_const]
274
+
275
+ noncomputable def residueAffineCoupling :
276
+ FiniteProbabilityCoupling (residueAffineSource (J := J) (G := G)) (FiniteProbabilityWeights.uniform G) :=
277
+ FiniteProbabilityCoupling.ofKernel _ _ (residueAffineKernel (q := q))
278
+ (residueAffineKernel_preserves_mean (q := q))
279
+
280
+ theorem residueAffineKernel_centered_sq {p a : ℕ} (hp : p.Prime)
281
+ (hG : Fintype.card G = p ^ a) (f : G → ℝ)
282
+ (hf : (FiniteProbabilityWeights.uniform G).mean f = 0) :
283
+ (residueAffineSource (J := J) (G := G)).mean (fun z => (residueAffineKernel (q := q) z).mean f ^ 2) ≤
284
+ (p : ℝ)⁻¹ ^ Fintype.card J * (FiniteProbabilityWeights.uniform G).mean (fun x => f x ^ 2) := by
285
+ simp only [residueAffineSource, FiniteProbabilityWeights.mean_prod, residueAffineKernel_mean,
286
+ FiniteProbabilityWeights.uniform_mean]
287
+ exact primeAffine_real_contraction_sq hp hG f (by simpa only [FiniteProbabilityWeights.uniform_mean] using hf)
288
+
289
+ end Erdos3
290
+
291
+ end
292
+
293
+ section
294
+
295
+ namespace Erdos3
296
+
297
+ open scoped BigOperators Classical
298
+
299
+ variable {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J]
300
+ (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*}
301
+ [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)]
302
+ (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i)
303
+
304
+ include hp hcard
305
+
306
+ theorem affineCoupling_level_abs_le {κ : ℝ} (hκ : 0 ≤ κ)
307
+ (hcap : ∀ i, (p i : ℝ)⁻¹ ^ Fintype.card J ≤ κ ^ 2)
308
+ (k : ℕ) (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) :
309
+ let μ := fun i => residueAffineSource (J := J) (G := G i)
310
+ let ν := fun i => FiniteProbabilityWeights.uniform (G i)
311
+ |productCouplingPairing (fun i => residueAffineCoupling (q := q i) (J := J) (G := G i))
312
+ (productANOVATruncation μ (Finset.univ.powersetCard k) w)
313
+ (productANOVATruncation ν (Finset.univ.powersetCard k) f)| ≤
314
+ κ ^ k * Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) *
315
+ Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) := by
316
+ exact productCouplingPairing_level_abs_le _ _ (fun i => residueAffineKernel (q := q i))
317
+ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity)
318
+ (fun i => residueAffineKernel_centered_sq (hp i) (hcard i))
319
+ (fun i => residueAffineKernel_preserves_mean (q := q i)) hκ hcap k w f
320
+
321
+ theorem affineCoupling_tail_abs_le {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1)
322
+ (hcap : ∀ i, (p i : ℝ)⁻¹ ^ Fintype.card J ≤ κ ^ 2)
323
+ (r : ℕ) (D : Finset (Finset ι)) (hmin : ∀ S ∈ D, r ≤ S.card)
324
+ (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) :
325
+ let μ := fun i => residueAffineSource (J := J) (G := G i)
326
+ let ν := fun i => FiniteProbabilityWeights.uniform (G i)
327
+ |productCouplingPairing (fun i => residueAffineCoupling (q := q i) (J := J) (G := G i))
328
+ (productANOVATruncation μ D w) (productANOVATruncation ν D f)| ≤
329
+ κ ^ r * Real.sqrt (productANOVAEnergy μ D w) * Real.sqrt (productANOVAEnergy ν D f) := by
330
+ exact productCouplingPairing_tail_abs_le _ _ (fun i => residueAffineKernel (q := q i))
331
+ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity)
332
+ (fun i => residueAffineKernel_centered_sq (hp i) (hcard i))
333
+ (fun i => residueAffineKernel_preserves_mean (q := q i)) hκ0 hκ1 hcap r D hmin w f
334
+
335
+ end Erdos3
336
+
337
+ end
338
+
339
+ section
340
+
341
+ namespace Erdos3
342
+
343
+ open scoped BigOperators Classical
344
+
345
+ theorem productAffine_centered_contraction_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J]
346
+ (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*}
347
+ [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)]
348
+ (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i)
349
+ (f : (∀ i, G i) → ℝ) :
350
+ (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean
351
+ (fun x => productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i))
352
+ (residueAffineKernel (q := q i) (J := J))) f x ^ 2) ≤
353
+ (∏ i, (p i : ℝ)⁻¹ ^ Fintype.card J) *
354
+ (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean
355
+ (fun y => f y ^ 2) := by
356
+ apply productMatrixApply_sq_le _ _ _ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity)
357
+ intro i g
358
+ apply centeredKernelMatrix_sq_le _ _ _ (by positivity)
359
+ intro h hh
360
+ exact residueAffineKernel_centered_sq (hp i) (hcard i) h hh
361
+
362
+ theorem productAffine_centered_pairing_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J]
363
+ (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*}
364
+ [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)]
365
+ (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i)
366
+ (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) :
367
+ ((FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean
368
+ (fun x => w x * productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i))
369
+ (residueAffineKernel (q := q i) (J := J))) f x)) ^ 2 ≤
370
+ (∏ i, (p i : ℝ)⁻¹ ^ Fintype.card J) *
371
+ (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean
372
+ (fun x => w x ^ 2) *
373
+ (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean
374
+ (fun y => f y ^ 2) := by
375
+ apply productMatrixApply_pairing_sq_le _ _ _ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity)
376
+ intro i g
377
+ apply centeredKernelMatrix_sq_le _ _ _ (by positivity)
378
+ intro h hh
379
+ exact residueAffineKernel_centered_sq (hp i) (hcard i) h hh
380
+
381
+ theorem productAffine_uniform_centered_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J]
382
+ (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*}
383
+ [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)]
384
+ (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i)
385
+ {P : ℝ} (hP : 0 < P) (hmin : ∀ i, P ≤ (p i : ℝ)) (f : (∀ i, G i) → ℝ) :
386
+ (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean
387
+ (fun x => productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i))
388
+ (residueAffineKernel (q := q i) (J := J))) f x ^ 2) ≤
389
+ (P⁻¹ ^ Fintype.card J) ^ Fintype.card ι *
390
+ (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean
391
+ (fun y => f y ^ 2) := by
392
+ apply (productAffine_centered_contraction_sq p q a hp hcard f).trans
393
+ apply mul_le_mul_of_nonneg_right _ (FiniteProbabilityWeights.mean_nonneg _ (fun y => sq_nonneg (f y)))
394
+ have hi (i : ι) : (p i : ℝ)⁻¹ ≤ P⁻¹ := by
395
+ simpa only [one_div] using one_div_le_one_div_of_le hP (hmin i)
396
+ have hh := Finset.prod_le_prod₀ (s := (Finset.univ : Finset ι))
397
+ (fun i _ => pow_nonneg (inv_nonneg.mpr (Nat.cast_nonneg (p i))) (Fintype.card J))
398
+ (fun i _ => pow_le_pow_left₀ (inv_nonneg.mpr (Nat.cast_nonneg (p i))) (hi i) (Fintype.card J))
399
+ simpa only [Finset.prod_const, Finset.card_univ] using hh
400
+
401
+ end Erdos3
402
+
403
+ end
404
+
405
+ section
406
+
407
+ namespace Erdos3
408
+
409
+ open scoped BigOperators
410
+
411
+ theorem primeCoordinateCell_mono {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
412
+ (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) {I J : Finset ι}
413
+ {x y : ∀ i, σ → ZMod (q i)} (hIJ : I ⊆ J) (hxy : ∀ i ∈ I, y i = x i) :
414
+ primeCoordinateCell lo N q J y ⊆ primeCoordinateCell lo N q I x := by
415
+ intro z hz
416
+ obtain ⟨hz, heq⟩ := (mem_primeCoordinateCell lo N q J y z).mp hz
417
+ exact (mem_primeCoordinateCell lo N q I x z).mpr ⟨hz, fun i hi => (heq i (hIJ hi)).trans (hxy i hi)⟩
418
+
419
+ noncomputable def primeCoordinateMean {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
420
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ)
421
+ (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℂ :=
422
+ 𝔼 z : primeCoordinateCell lo N q I x, f z.val
423
+
424
+ theorem primeCoordinateMean_eq_physical {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
425
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ)
426
+ (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) (x : ∀ i, σ → ZMod (q i))
427
+ (u : σ → ℤ) (hu : u ∈ primeCoordinateCell lo N q I x) :
428
+ primeCoordinateMean f lo N q I x = physicalResidueMean f lo N (∏ i ∈ I, q i) u := by
429
+ unfold primeCoordinateMean
430
+ rw [primeCoordinateCell_anchor lo N q I x u hu]
431
+ exact primeCoordinateCell_mean lo N q hcop I u f
432
+
433
+ noncomputable def PrimeCoordinateStable {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
434
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ)
435
+ (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : Prop :=
436
+ ∀ J : Finset ι, Disjoint I J → J.card ≤ r → ∀ y : ∀ i, σ → ZMod (q i),
437
+ (∀ i ∈ I, y i = x i) → (primeCoordinateCell lo N q (I ∪ J) y).Nonempty →
438
+ ‖primeCoordinateMean f lo N q I x - primeCoordinateMean f lo N q (I ∪ J) y‖ ≤ δ
439
+
440
+ theorem primeCoordinateStable_of_empty {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
441
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ)
442
+ (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i))
443
+ (hempty : ¬ (primeCoordinateCell lo N q I x).Nonempty) : PrimeCoordinateStable f lo N q r δ I x := by
444
+ intro J hIJ hJ y hxy hnonempty
445
+ obtain ⟨z, hz⟩ := hnonempty
446
+ exact False.elim (hempty ⟨z, primeCoordinateCell_mono lo N q Finset.subset_union_left hxy hz⟩)
447
+
448
+ universe u v
449
+
450
+ theorem exists_prime_cell_physical_comparison
451
+ {ι : Type*} [DecidableEq ι] {σ : Type u} [Fintype σ] [DecidableEq σ]
452
+ {s bound : ℕ} {gap : ℝ} (base : PhysicalEpochSource.{u, v} σ s bound)
453
+ (T : base.model.Niltest (fun _ : σ => 1)) (horbit : T.orbit = base.fixedMap.orbit)
454
+ (hpositive : T.UnitIntervalValued) (hcomplexity : T.ComplexityLE base.incomingBudget)
455
+ (q : ι → ℕ) (hq : ∀ i, 0 < q i) (hcop : Pairwise (fun i j => (q i).Coprime (q j)))
456
+ (I J : Finset ι) (hIJ : Disjoint I J) (x y : ∀ i, σ → ZMod (q i))
457
+ (hxy : ∀ i ∈ I, y i = x i) (u v : σ → ℤ)
458
+ (hu : u ∈ primeCoordinateCell base.lower base.sides q I x)
459
+ (hv : v ∈ primeCoordinateCell base.lower base.sides q (I ∪ J) y)
460
+ (hgap : 0 < gap) (hgap1 : gap ≤ 1) (hinverse : gap⁻¹ ≤ Real.exp base.incomingBudget)
461
+ (hrecord : 2 ≤ base.recordBudget)
462
+ (hdiscrepancy : gap ≤ ‖primeCoordinateMean T.eval base.lower base.sides q I x -
463
+ primeCoordinateMean T.eval base.lower base.sides q (I ∪ J) y‖) :
464
+ ∃ c : PhysicalEpochComparison base (∏ i ∈ I, q i) 1 (∏ i ∈ J, q i) gap,
465
+ c.Controlled ∧ c.anchor = u ∧ c.refined = v := by
466
+ have hvmem := primeCoordinateCell_mono base.lower base.sides q Finset.subset_union_left hxy hv
467
+ have hanchorCell := primeCoordinateCell_anchor base.lower base.sides q I x u hu
468
+ have hcompat : ∀ i, v i ≡ u i [ZMOD ((∏ j ∈ I, q j : ℕ) : ℤ)] := by
469
+ rw [hanchorCell] at hvmem
470
+ exact ((mem_primeCoordinateCell_anchor base.lower base.sides q hcop I u v).mp hvmem).2
471
+ have huinside := (mem_translatedIntegerBox base.lower base.sides u).mp
472
+ ((mem_primeCoordinateCell base.lower base.sides q I x u).mp hu).1
473
+ have hvinside := (mem_translatedIntegerBox base.lower base.sides v).mp
474
+ ((mem_primeCoordinateCell base.lower base.sides q (I ∪ J) y v).mp hv).1
475
+ have hm : 0 < ∏ i ∈ I, q i := Finset.prod_pos (fun i _ => hq i)
476
+ have hJ : 0 < ∏ i ∈ J, q i := Finset.prod_pos (fun i _ => hq i)
477
+ have hphysical : gap ≤ ‖physicalResidueMean T.eval base.lower base.sides (∏ i ∈ I, q i) u -
478
+ physicalResidueMean T.eval base.lower base.sides ((∏ i ∈ I, q i) * ∏ i ∈ J, q i) v‖ := by
479
+ rw [primeCoordinateMean_eq_physical T.eval base.lower base.sides q hcop I x u hu,
480
+ primeCoordinateMean_eq_physical T.eval base.lower base.sides q hcop (I ∪ J) y v hv,
481
+ Finset.prod_union hIJ] at hdiscrepancy
482
+ exact hdiscrepancy
483
+ obtain ⟨c, hc, hcu, hcv, _, _⟩ := exists_initial_physical_comparison base T horbit hpositive hcomplexity
484
+ hm hJ u v huinside hvinside hcompat hgap hgap1 hinverse hrecord hphysical
485
+ exact ⟨c, hc, hcu, hcv⟩
486
+
487
+ end Erdos3
488
+
489
+ end
490
+
491
+ section
492
+
493
+ namespace Erdos3
494
+
495
+ open scoped BigOperators
496
+
497
+ def primeCoordinateObservation {ι σ : Type*} (q : ι → ℕ) (z : σ → ℤ) : ∀ i, σ → ZMod (q i) :=
498
+ fun i j => (z j : ZMod (q i))
499
+
500
+ noncomputable def primeCoordinateReference {ι σ : Type*} [Fintype σ] [DecidableEq σ]
501
+ (q : ι → ℕ) [∀ i, NeZero (q i)] : ∀ i, FiniteProbabilityWeights (σ → ZMod (q i)) :=
502
+ fun i => FiniteProbabilityWeights.uniform (σ → ZMod (q i))
503
+
504
+ theorem primeCoordinateReference_weight_pos {ι σ : Type*} [Fintype σ] [DecidableEq σ]
505
+ (q : ι → ℕ) [∀ i, NeZero (q i)] (i : ι) (x : σ → ZMod (q i)) :
506
+ 0 < (primeCoordinateReference (σ := σ) q i).weight x := by
507
+ dsimp only [primeCoordinateReference, FiniteProbabilityWeights.uniform]
508
+ positivity
509
+
510
+ noncomputable def primeCoordinateLaw {ι σ : Type*} [Fintype ι] [DecidableEq ι]
511
+ [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ)
512
+ (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] :
513
+ FiniteProbabilityWeights (∀ i, σ → ZMod (q i)) :=
514
+ (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox).fiberLaw
515
+ (fun z => primeCoordinateObservation q z.val)
516
+
517
+ noncomputable def primeCoordinateDensity {ι σ : Type*} [Fintype ι] [DecidableEq ι]
518
+ [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ)
519
+ (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)]
520
+ (f : (σ → ℤ) → ℝ) : (∀ i, σ → ZMod (q i)) → ℝ :=
521
+ observedProductDensity (primeCoordinateReference (σ := σ) q)
522
+ (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox)
523
+ (fun z => primeCoordinateObservation q z.val) (fun z => f z.val)
524
+
525
+ theorem primeCoordinateDensity_nonneg {ι σ : Type*} [Fintype ι] [DecidableEq ι]
526
+ [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ)
527
+ (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)]
528
+ (f : (σ → ℤ) → ℝ) (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z)
529
+ (x : ∀ i, σ → ZMod (q i)) : 0 ≤ primeCoordinateDensity lo N hbox q f x := by
530
+ unfold primeCoordinateDensity observedProductDensity
531
+ apply finiteWeightDensity_nonneg
532
+ intro y
533
+ apply FiniteProbabilityWeights.fiberMean_nonneg
534
+ intro z
535
+ exact hf z.val z.property
536
+
537
+ theorem primeCoordinateDensity_one {ι σ : Type*} [Fintype ι] [DecidableEq ι]
538
+ [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ)
539
+ (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)]
540
+ (x : ∀ i, σ → ZMod (q i)) :
541
+ primeCoordinateDensity lo N hbox q (fun _ => 1) x =
542
+ (primeCoordinateLaw lo N hbox q).weight x /
543
+ (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight x := rfl
544
+
545
+ end Erdos3
546
+
547
+ end
548
+
549
+ section
550
+
551
+ namespace Erdos3
552
+
553
+ open scoped BigOperators
554
+
555
+ abbrev ResiduePrimeCoordinateCell {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ]
556
+ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ)
557
+ (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) :=
558
+ {z : IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a //
559
+ ∀ i ∈ I, (fun j => ((z j).val : ZMod (q i))) = x i}
560
+
561
+ noncomputable def residuePrimeCoordinateMean {ι σ : Type*}
562
+ [DecidableEq ι] [Fintype σ] [DecidableEq σ]
563
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ)
564
+ (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℂ := by
565
+ classical
566
+ exact 𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val)
567
+
568
+ noncomputable def ResiduePrimeCoordinateStable {ι σ : Type*}
569
+ [DecidableEq ι] [Fintype σ] [DecidableEq σ]
570
+ (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ)
571
+ (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : Prop :=
572
+ ∀ J : Finset ι, Disjoint I J → J.card ≤ r → ∀ y : ∀ i, σ → ZMod (q i),
573
+ (∀ i ∈ I, y i = x i) → Nonempty (ResiduePrimeCoordinateCell lo N M a q (I ∪ J) y) →
574
+ ‖residuePrimeCoordinateMean f lo N M a q I x -
575
+ residuePrimeCoordinateMean f lo N M a q (I ∪ J) y‖ ≤ δ
576
+
577
+ noncomputable def primeCoordinateCell_subtypeEquiv {ι σ : Type*}
578
+ [DecidableEq ι] [Fintype σ] [DecidableEq σ]
579
+ (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) :
580
+ primeCoordinateCell lo N q I x ≃
581
+ {z : translatedIntegerBox lo N // ∀ i ∈ I, (fun j => (z.val j : ZMod (q i))) = x i} where
582
+ toFun z := ⟨⟨z.val, ((mem_primeCoordinateCell lo N q I x z.val).mp z.property).1⟩,
583
+ ((mem_primeCoordinateCell lo N q I x z.val).mp z.property).2⟩
584
+ invFun z := ⟨z.val.val, (mem_primeCoordinateCell lo N q I x z.val.val).mpr ⟨z.val.property, z.property⟩⟩
585
+ left_inv _ := rfl
586
+ right_inv _ := rfl
587
+
588
+ end Erdos3
589
+
590
+ end
591
+
592
+ section
593
+
594
+ namespace Erdos3
595
+
596
+ open scoped BigOperators Classical
597
+
598
+ def affineSampleAlphabetEquiv {J I R : Type*} :
599
+ (Option J × I → R) ≃ (J → I → R) × (I → R) where
600
+ toFun z := (fun j i => z (some j, i), fun i => z (none, i))
601
+ invFun z := baseArrayJoin (fun k => z.1 k.1 k.2) z.2
602
+ left_inv z := baseArrayJoin_eta z
603
+ right_inv _ := rfl
604
+
605
+ theorem affineSampleAlphabet_weight {J I R : Type*} [Fintype J] [Fintype I]
606
+ [Fintype R] [AddCommGroup R] (z : Option J × I → R) :
607
+ (residueAffineSource (J := J) (G := I → R)).weight (affineSampleAlphabetEquiv z) =
608
+ (FiniteProbabilityWeights.uniform (Option J × I → R)).weight z := by
609
+ change (Fintype.card (J → I → R) : ℝ)⁻¹ * (Fintype.card (I → R) : ℝ)⁻¹ =
610
+ (Fintype.card (Option J × I → R) : ℝ)⁻¹
611
+ rw [Fintype.card_congr (affineSampleAlphabetEquiv (J := J) (I := I) (R := R))]
612
+ simp only [Fintype.card_prod, Nat.cast_mul, mul_inv_rev]
613
+ ring
614
+
615
+ theorem affineSampleAlphabet_mean {J I R : Type*} [Fintype J] [Fintype I]
616
+ [Fintype R] [AddCommGroup R] (f : ((J → I → R) × (I → R)) → ℝ) :
617
+ (FiniteProbabilityWeights.uniform (Option J × I → R)).mean
618
+ (fun z => f (affineSampleAlphabetEquiv z)) =
619
+ (residueAffineSource (J := J) (G := I → R)).mean f :=
620
+ FiniteProbabilityWeights.mean_equiv _ _ affineSampleAlphabetEquiv affineSampleAlphabet_weight f
621
+
622
+ def affinePrimeCoordinateObservation {ι J I : Type*} (q : ι → ℕ)
623
+ (z : Option J × I → ℤ) : ∀ i, (J → I → ZMod (q i)) × (I → ZMod (q i)) :=
624
+ fun i => affineSampleAlphabetEquiv (primeCoordinateObservation q z i)
625
+
626
+ theorem affinePrimeCoordinateObservation_apply {ι J I : Type*} (q : ι → ℕ)
627
+ (z : Option J × I → ℤ) (i : ι) :
628
+ affinePrimeCoordinateObservation q z i =
629
+ (fun j k => (z (some j, k) : ZMod (q i)), fun k => (z (none, k) : ZMod (q i))) := rfl
630
+
631
+ end Erdos3
632
+
633
+ end
634
+
635
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineSiteCoverTilt.lean ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.PhysicalSingleSiteCommonCover
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.BooleanCubeKernel
8
+
9
+ open VectorPolynomial MeasureTheory
10
+ open scoped BigOperators Classical
11
+
12
+ theorem exists_affine_site_cover_tilted_comparison (m r : ℕ) :
13
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*}
14
+ [Fintype I] [DecidableEq I] [Fintype K]
15
+ {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F]
16
+ {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P)
17
+ (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P)
18
+ (U : ∀ j, Submodule ℝ (J j → ℝ))
19
+ (root : K → ℤ) (difference : Fin r → K → ℤ)
20
+ [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)]
21
+ [MeasurableSpace (SiteTorus (Finset (Fin r)) U)] [BorelSpace (SiteTorus (Finset (Fin r)) U)]
22
+ (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ]
23
+ {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P)
24
+ (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ)
25
+ (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C)
26
+ (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P)
27
+ (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B)
28
+ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ))
29
+ (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j))
30
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
31
+ (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P)
32
+ (stride : I → ℕ) (_hs : ∀ k, 0 < stride k)
33
+ {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε)
34
+ (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P)
35
+ (_hstride : ∀ k, (stride k : ℝ) ≤ S)
36
+ (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k)
37
+ (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i))
38
+ (_hR : Real.exp ((P + A) ^ A) ≤ R)
39
+ (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty)
40
+ (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z)
41
+ (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ)
42
+ (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x)
43
+ (f : SiteTorus (Finset (Fin r)) U → ℂ) (_hf : Measurable f)
44
+ (_hfbound : ∀ x, ‖f x‖ ≤ 1)
45
+ {η : ℝ} (_hη : 0 ≤ η)
46
+ (_happrox : ∀ b x,
47
+ ‖(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‖ ≤ η)
48
+ (_hsmall : 2 * η + ε ≤ 1 / 2),
49
+ ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x,
50
+ ∃ hDpos : 0 < selectedResidueDensityMass stride G V
51
+ (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))),
52
+ |selectedResidueDensityMass stride G V
53
+ (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧
54
+ (1 / 2 ≤ selectedResidueDensityMass stride G V
55
+ (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ))))) ∧
56
+ (selectedResidueDensityMass stride G V
57
+ (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧
58
+ ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ
59
+ (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ))))
60
+ (fun _z => _hD0 _) hDpos z).toReal : ℂ) *
61
+ f (affineCoveredSiteSample U root difference q p hm (fun k j => (z (k, j) : ℝ)))) -
62
+ (∫ x, (D x : ℂ) * f (coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) x) ∂μ)‖ ≤ 4 * (2 * η + ε) := by
63
+ obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_cover_tilted_comparison m
64
+ refine ⟨A, hA, ?_⟩
65
+ intro I K _ _ _ J _ F _ P hP hn hd U root difference _ _ _ _ μ _ _
66
+ C hC hCP frequency hbound c B hB hBP hcoefficients p hp hm q hq hqP
67
+ stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth
68
+ D hD hDmass hD0 f hf hfbound η hη happrox hsmall
69
+ let g : CoefficientTorus (K := K) U → ℂ := fun x =>
70
+ f (coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) x)
71
+ have hg : AEStronglyMeasurable g μ :=
72
+ (hf.comp (coefficientSiteTorusMap_continuous U _).measurable).aestronglyMeasurable
73
+ obtain ⟨hZ, hDpos, hmass, hlower, hupper, he⟩ :=
74
+ hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients
75
+ p hp hm q hq hqP stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR
76
+ G hG V hV hwidth D hD hDmass hD0 g hg (fun _ => hfbound _) hη happrox hsmall
77
+ refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩
78
+ simpa only [g, coefficientSiteTorusMap_coverSample U root difference q p hp hm] using he
79
+
80
+ end Erdos3.BooleanCubeKernel
81
+
82
+ end
83
+
84
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineSliceC2Difference.lean ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Analysis.Calculus.ContDiff.Operations
2
+ import Mathlib.Analysis.Calculus.FDeriv.CompCLM
3
+ import Mathlib.Tactic
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ variable {E X Y : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
12
+ [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAddCommGroup Y] [NormedSpace ℝ Y]
13
+
14
+ noncomputable def operatorPrecompose (J : E →L[ℝ] X) :
15
+ (X →L[ℝ] Y) →L[ℝ] (E →L[ℝ] Y) :=
16
+ (ContinuousLinearMap.compL ℝ E X Y).flip J
17
+
18
+ theorem operatorPrecompose_apply (J : E →L[ℝ] X) (A : X →L[ℝ] Y) :
19
+ operatorPrecompose J A = A.comp J := rfl
20
+
21
+ theorem operatorPrecompose_norm_le (J : E →L[ℝ] X) :
22
+ ‖operatorPrecompose (Y := Y) J‖ ≤ ‖J‖ := by
23
+ apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg J)
24
+ intro A
25
+ exact (A.opNorm_comp_le J).trans_eq (mul_comm _ _)
26
+
27
+ theorem affineSlice_fderiv (F : X → Y) (c : X) (J : E →L[ℝ] X) (x : E)
28
+ (hF : DifferentiableAt ℝ F (c + J x)) :
29
+ fderiv ℝ (fun y => F (c + J y)) x = (fderiv ℝ F (c + J x)).comp J := by
30
+ exact (hF.hasFDerivAt.comp x (J.hasFDerivAt.const_add c)).fderiv
31
+
32
+ theorem affineSlice_fderiv_norm_le (F : X → Y) (c : X) (J : E →L[ℝ] X) (x : E)
33
+ (hF : DifferentiableAt ℝ F (c + J x)) (hJ : ‖J‖ ≤ 1) {H : ℝ}
34
+ (hH : ‖fderiv ℝ F (c + J x)‖ ≤ H) :
35
+ ‖fderiv ℝ (fun y => F (c + J y)) x‖ ≤ H := by
36
+ rw [affineSlice_fderiv F c J x hF]
37
+ calc
38
+ _ ≤ ‖fderiv ℝ F (c + J x)‖ * ‖J‖ := ContinuousLinearMap.opNorm_comp_le _ _
39
+ _ ≤ H * 1 := mul_le_mul hH hJ (norm_nonneg J) ((norm_nonneg _).trans hH)
40
+ _ = H := mul_one H
41
+
42
+ theorem affineSlice_second_fderiv_norm_le (F : X → Y) (hF : ContDiff ℝ 2 F)
43
+ (c : X) (J : E →L[ℝ] X) (x : E) (hJ : ‖J‖ ≤ 1) {H : ℝ}
44
+ (hH : ‖fderiv ℝ (fderiv ℝ F) (c + J x)‖ ≤ H) :
45
+ ‖fderiv ℝ (fderiv ℝ (fun y => F (c + J y))) x‖ ≤ H := by
46
+ let L : (X →L[ℝ] Y) →L[ℝ] (E →L[ℝ] Y) := operatorPrecompose J
47
+ let g : E → (X →L[ℝ] Y) := fun y => fderiv ℝ F (c + J y)
48
+ have hD : ContDiff ℝ 1 (fderiv ℝ F) := hF.fderiv_right (by norm_num)
49
+ have hg := ((hD.differentiable one_ne_zero (c + J x)).hasFDerivAt.comp x
50
+ (J.hasFDerivAt.const_add c))
51
+ have hg' : HasFDerivAt g ((fderiv ℝ (fderiv ℝ F) (c + J x)).comp J) x := hg
52
+ have he : fderiv ℝ (fun y => F (c + J y)) = L ∘ g := by
53
+ funext y
54
+ exact affineSlice_fderiv F c J y (hF.differentiable (by norm_num) _)
55
+ rw [he, fderiv_comp x L.differentiableAt hg'.differentiableAt, L.fderiv, hg'.fderiv]
56
+ have hL : ‖L‖ ≤ 1 := (operatorPrecompose_norm_le J).trans hJ
57
+ have hinner : ‖(fderiv ℝ (fderiv ℝ F) (c + J x)).comp J‖ ≤ H := by
58
+ calc
59
+ _ ≤ ‖fderiv ℝ (fderiv ℝ F) (c + J x)‖ * ‖J‖ := ContinuousLinearMap.opNorm_comp_le _ _
60
+ _ ≤ H * 1 := mul_le_mul hH hJ (norm_nonneg J)
61
+ ((norm_nonneg (fderiv ℝ (fderiv ℝ F) (c + J x))).trans hH)
62
+ _ = H := mul_one H
63
+ calc
64
+ _ ≤ ‖L‖ * ‖(fderiv ℝ (fderiv ℝ F) (c + J x)).comp J‖ := ContinuousLinearMap.opNorm_comp_le _ _
65
+ _ ≤ 1 * H := mul_le_mul hL hinner
66
+ (norm_nonneg ((fderiv ℝ (fderiv ℝ F) (c + J x)).comp J)) zero_le_one
67
+ _ = H := one_mul H
68
+
69
+ end Erdos3
70
+
71
+ end
72
+
73
+ section
74
+
75
+ namespace Erdos3
76
+
77
+ variable {E X Y : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
78
+ [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAddCommGroup Y] [NormedSpace ℝ Y]
79
+
80
+ theorem second_fderiv_sub (F G : X → Y) (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (x : X) :
81
+ fderiv ℝ (fderiv ℝ (fun y => F y - G y)) x =
82
+ fderiv ℝ (fderiv ℝ F) x - fderiv ℝ (fderiv ℝ G) x := by
83
+ have he : fderiv ℝ (fun y => F y - G y) = fun y => fderiv ℝ F y - fderiv ℝ G y := by
84
+ funext y
85
+ exact fderiv_sub (hF.differentiable (by norm_num) y) (hG.differentiable (by norm_num) y)
86
+ rw [he]
87
+ exact fderiv_sub ((hF.fderiv_right (by norm_num : 1 + 1 ≤ (2 : WithTop ℕ∞))).differentiable one_ne_zero x)
88
+ ((hG.fderiv_right (by norm_num : 1 + 1 ≤ (2 : WithTop ℕ∞))).differentiable one_ne_zero x)
89
+
90
+ theorem affineSlice_first_difference_bound (F G : X → Y)
91
+ (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X)
92
+ (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ}
93
+ (herr : ‖fderiv ℝ F (b + J x) - fderiv ℝ G (b + J x)‖ ≤ ε) :
94
+ ‖fderiv ℝ (fun y => F (b + J y)) x - fderiv ℝ (fun y => G (b + J y)) x‖ ≤ ε := by
95
+ rw [affineSlice_fderiv F b J x (hF.differentiable (by norm_num) _),
96
+ affineSlice_fderiv G b J x (hG.differentiable (by norm_num) _), ← ContinuousLinearMap.sub_comp]
97
+ exact ((ContinuousLinearMap.opNorm_comp_le _ _).trans
98
+ (mul_le_of_le_one_right (norm_nonneg _) hJ)).trans herr
99
+
100
+ theorem affineSlice_second_difference_bound (F G : X → Y)
101
+ (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X)
102
+ (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ}
103
+ (herr : ‖fderiv ℝ (fderiv ℝ F) (b + J x) - fderiv ℝ (fderiv ℝ G) (b + J x)‖ ≤ ε) :
104
+ ‖fderiv ℝ (fderiv ℝ (fun y => F (b + J y))) x -
105
+ fderiv ℝ (fderiv ℝ (fun y => G (b + J y))) x‖ ≤ ε := by
106
+ have hs : ‖fderiv ℝ (fderiv ℝ (fun y => F y - G y)) (b + J x)‖ ≤ ε := by
107
+ rw [second_fderiv_sub F G hF hG]
108
+ exact herr
109
+ have ht := affineSlice_second_fderiv_norm_le (fun y => F y - G y) (hF.sub hG) b J x hJ hs
110
+ have hFs : ContDiff ℝ 2 (fun y => F (b + J y)) := hF.comp (contDiff_const.add J.contDiff)
111
+ have hGs : ContDiff ℝ 2 (fun y => G (b + J y)) := hG.comp (contDiff_const.add J.contDiff)
112
+ rw [second_fderiv_sub (fun y => F (b + J y)) (fun y => G (b + J y)) hFs hGs] at ht
113
+ exact ht
114
+
115
+ theorem affineSlice_c2_difference_bound (F G : X → Y)
116
+ (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X)
117
+ (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ}
118
+ (herr : ‖F (b + J x) - G (b + J x)‖ ≤ ε ∧
119
+ ‖fderiv ℝ F (b + J x) - fderiv ℝ G (b + J x)‖ ≤ ε ∧
120
+ ‖fderiv ℝ (fderiv ℝ F) (b + J x) - fderiv ℝ (fderiv ℝ G) (b + J x)‖ ≤ ε) :
121
+ ‖F (b + J x) - G (b + J x)‖ ≤ ε ∧
122
+ ‖fderiv ℝ (fun y => F (b + J y)) x - fderiv ℝ (fun y => G (b + J y)) x‖ ≤ ε ∧
123
+ ‖fderiv ℝ (fderiv ℝ (fun y => F (b + J y))) x -
124
+ fderiv ℝ (fderiv ℝ (fun y => G (b + J y))) x‖ ≤ ε :=
125
+ ⟨herr.1, affineSlice_first_difference_bound F G hF hG b J hJ x herr.2.1,
126
+ affineSlice_second_difference_bound F G hF hG b J hJ x herr.2.2⟩
127
+
128
+ end Erdos3
129
+
130
+ end
131
+
132
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineSourceAccuracy.lean ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.SlicedSourceAccuracy
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+ open scoped BigOperators NNReal
9
+
10
+ theorem affineSourceAccuracy_budget
11
+ {ι κ : Type*} [Fintype ι] [Fintype κ]
12
+ {Dout Dgrid Prho Pbox Op E F C : ℝ}
13
+ (hDout : 0 ≤ Dout) (hDgrid : 0 ≤ Dgrid) (hPrho : 0 ≤ Prho)
14
+ (hPbox : 0 ≤ Pbox) (hE : 0 ≤ E) (hF : 0 ≤ F)
15
+ (hout : (Fintype.card κ : ℝ) ≤ Dout) (hgrid : (Fintype.card ι : ℝ) ≤ Dgrid)
16
+ (ρ : ℝ≥0) (hρ : (ρ : ℝ)⁻¹ ≤ Real.exp Prho)
17
+ (hC0 : 0 ≤ C) (hC : C ≤ Real.exp F) :
18
+ let G := Dgrid * max Op 0
19
+ let εgrid := Real.exp (-(Dout * Prho + (E + F) + 1))
20
+ let εlong := Real.exp (-(G + (E + F) + 1))
21
+ let Plong := Pbox + Prho + G + (E + F) + 2
22
+ 0 < εgrid ∧ εgrid ≤ 1 ∧ εgrid⁻¹ = Real.exp (Dout * Prho + (E + F) + 1) ∧
23
+ 0 < εlong ∧ εlong ≤ 1 ∧ εlong⁻¹ ≤ Real.exp Plong ∧
24
+ 0 ≤ Plong ∧ Pbox ≤ Plong ∧ (ρ : ℝ)⁻¹ ≤ Real.exp Plong ∧
25
+ C * ((ρ⁻¹ ^ Fintype.card κ : ℝ≥0) * εgrid +
26
+ εlong * ∏ _i : ι, Real.exp Op) ≤ Real.exp (-E) := by
27
+ intro G εgrid εlong Plong
28
+ have hG : 0 ≤ G := mul_nonneg hDgrid (le_max_right _ _)
29
+ obtain ⟨hg0, hg1, hgi, hl0, hl1, hli, herr⟩ :=
30
+ slicedSourceAccuracy_bounds (mul_nonneg hDout hPrho) hG (add_nonneg hE hF)
31
+ have hPlong : G + (E + F) + 1 ≤ Plong := by dsimp [Plong]; linarith
32
+ have hb : Pbox ≤ Plong := by dsimp [Plong]; linarith
33
+ have hr : Prho ≤ Plong := by dsimp [Plong]; linarith
34
+ have hcap : (ρ⁻¹ ^ Fintype.card κ : ℝ≥0) ≤ Real.exp (Dout * Prho) := by
35
+ rw [NNReal.coe_pow, NNReal.coe_inv]
36
+ calc
37
+ _ ≤ (Real.exp Prho) ^ Fintype.card κ := pow_le_pow_left₀ (inv_nonneg.mpr ρ.coe_nonneg) hρ _
38
+ _ = Real.exp (Fintype.card κ * Prho) := (Real.exp_nat_mul _ _).symm
39
+ _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hout hPrho)
40
+ have hprod : (∏ _i : ι, Real.exp Op) ≤ Real.exp G := by
41
+ simp only [Finset.prod_const, Finset.card_univ, ← Real.exp_nat_mul]
42
+ apply Real.exp_le_exp.mpr
43
+ exact (mul_le_mul_of_nonneg_left (le_max_left _ _) (Nat.cast_nonneg _)).trans
44
+ (mul_le_mul_of_nonneg_right hgrid (le_max_right _ _))
45
+ refine ⟨hg0, hg1, hgi, hl0, hl1, hli.trans_le (Real.exp_le_exp.mpr hPlong),
46
+ hPbox.trans hb, hb, hρ.trans (Real.exp_le_exp.mpr hr), ?_⟩
47
+ calc
48
+ _ ≤ C * (Real.exp (Dout * Prho) * εgrid + εlong * ∏ _i : ι, Real.exp Op) := by
49
+ apply mul_le_mul_of_nonneg_left _ hC0
50
+ exact add_le_add (mul_le_mul_of_nonneg_right hcap hg0.le) le_rfl
51
+ _ ≤ C * Real.exp (-(E + F)) := mul_le_mul_of_nonneg_left (herr _ hprod) hC0
52
+ _ ≤ Real.exp F * Real.exp (-(E + F)) := mul_le_mul_of_nonneg_right hC (Real.exp_nonneg _)
53
+ _ = _ := by rw [← Real.exp_add]; congr 1; ring
54
+
55
+ end Erdos3
56
+
57
+ end
58
+
59
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineSquareErrorAccuracy.lean ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Sampling.SquareSamplingAccuracy
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def affineSquareErrorAccuracy (target capLog : ℝ) : ℝ :=
10
+ Real.exp (-(target + capLog + 24))
11
+
12
+ theorem affineSquareErrorAccuracy_pos (target capLog : ℝ) :
13
+ 0 < affineSquareErrorAccuracy target capLog := Real.exp_pos _
14
+
15
+ theorem affineSquareErrorAccuracy_inv (target capLog : ℝ) :
16
+ (affineSquareErrorAccuracy target capLog)⁻¹ = Real.exp (target + capLog + 24) := by
17
+ rw [affineSquareErrorAccuracy, ← Real.exp_neg, neg_neg]
18
+
19
+ theorem affineSquareErrorAccuracy_bound {target capLog cap e₁ e₂ e₃ : ℝ}
20
+ (hcap0 : 0 ≤ cap) (hcap : cap ≤ Real.exp capLog)
21
+ (h₁ : e₁ ≤ affineSquareErrorAccuracy target capLog)
22
+ (h₂ : e₂ ≤ affineSquareErrorAccuracy target capLog)
23
+ (h₃ : e₃ ≤ affineSquareErrorAccuracy target capLog) :
24
+ cap * (e₁ + e₂ + e₃) ≤ Real.exp (-(target + 20)) := by
25
+ have hb := (affineSquareErrorAccuracy_pos target capLog).le
26
+ have he : e₁ + e₂ + e₃ ≤ 3 * affineSquareErrorAccuracy target capLog := by
27
+ linarith only [h₁, h₂, h₃]
28
+ have h3 : (3 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)]
29
+ calc
30
+ _ ≤ cap * (3 * affineSquareErrorAccuracy target capLog) := mul_le_mul_of_nonneg_left he hcap0
31
+ _ ≤ Real.exp capLog * (Real.exp 4 * affineSquareErrorAccuracy target capLog) := by gcongr
32
+ _ = _ := by
33
+ unfold affineSquareErrorAccuracy
34
+ rw [← Real.exp_add, ← Real.exp_add]
35
+ congr 1
36
+ ring
37
+
38
+ end Erdos3
39
+
40
+ end
41
+
42
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineTopCoefficient.lean ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.TopSupportSubstitution
2
+ import OAI.Combinatorics.Progressions.Polynomial.AffineShiftPolynomial
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open MvPolynomial
11
+ open scoped BigOperators Classical
12
+
13
+ theorem affineShiftPullback_translate {I : Type*} {n : ℕ}
14
+ (base : I → ℝ) (direction : Fin n → I → ℝ) (P : MvPolynomial I ℝ) :
15
+ affineShiftPullback (fun _ => 0) direction (polynomialTranslate base P) =
16
+ affineShiftPullback base direction P := by
17
+ have he : (affineShiftPullback (fun _ => 0) direction).comp (polynomialTranslate base) =
18
+ affineShiftPullback base direction := by
19
+ apply algHom_ext
20
+ intro i
21
+ simp [AlgHom.comp_apply, polynomialTranslate_X, affineShiftPullback,
22
+ affineShiftCoordinate, add_comm]
23
+ exact AlgHom.congr_fun he P
24
+
25
+ theorem affineShift_full_coefficient_base {I : Type*} {n : ℕ}
26
+ (base : I → ℝ) (direction : Fin n → I → ℝ)
27
+ (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) :
28
+ (affineShiftPullback base direction P).coeff (fullShiftExponent n) =
29
+ (affineShiftPullback (fun _ => 0) direction P).coeff (fullShiftExponent n) := by
30
+ have hc (i : I) : affineShiftCoordinate (fun _ => 0) direction i ∈
31
+ weightedSupportLE (1 : Fin n → ℕ) ((1 : I → ℕ) i) :=
32
+ (mem_weightedSupportLE_one_iff _ 1).mpr (affineShiftCoordinate_degree _ _ _)
33
+ have hp := (mem_weightedSupportLE_one_iff P n).mpr hP
34
+ have ht := polynomialTranslate_sub_mem_weightedSupportLT base (1 : I → ℕ)
35
+ (fun _ => by simp) hp
36
+ have hl := weightedSupportLT_aeval (1 : I → ℕ) (1 : Fin n → ℕ)
37
+ (affineShiftCoordinate (fun _ => 0) direction) hc ht
38
+ have hz := full_coefficient_zero_of_lower_support hl
39
+ change (affineShiftPullback (fun _ => 0) direction (polynomialTranslate base P - P)).coeff
40
+ (fullShiftExponent n) = 0 at hz
41
+ rw [map_sub, coeff_sub, affineShiftPullback_translate] at hz
42
+ exact sub_eq_zero.mp hz
43
+
44
+ theorem sub_topComponent_mem_lowerSupport {I R : Type*} [CommRing R] {n : ℕ}
45
+ (P : MvPolynomial I R) (hP : P.totalDegree ≤ n) :
46
+ P - homogeneousComponent n P ∈ weightedSupportLT (1 : I → ℕ) n := by
47
+ intro a ha
48
+ change Finsupp.weight (1 : I → ℕ) a < n
49
+ have hne : (P - homogeneousComponent n P).coeff a ≠ 0 := mem_support_iff.mp ha
50
+ simp only [coeff_sub, coeff_homogeneousComponent] at hne
51
+ by_cases hd : a.degree = n
52
+ · simp only [hd, ite_true, sub_self, ne_eq, not_true_eq_false] at hne
53
+ · have haP : P.coeff a ≠ 0 := by
54
+ intro hz
55
+ simp only [hz, hd, ite_false, sub_self, ne_eq, not_true_eq_false] at hne
56
+ have hle : Finsupp.weight (1 : I → ℕ) a ≤ n :=
57
+ (mem_weightedSupportLE_one_iff P n).mpr hP (mem_support_iff.mpr haP)
58
+ have hn : Finsupp.weight (1 : I → ℕ) a ≠ n := by
59
+ simpa only [Finsupp.degree_eq_weight_one, Pi.one_def] using hd
60
+ omega
61
+
62
+ theorem affineShift_full_coefficient_top {I : Type*} {n : ℕ}
63
+ (base : I → ℝ) (direction : Fin n → I → ℝ)
64
+ (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) :
65
+ (affineShiftPullback base direction P).coeff (fullShiftExponent n) =
66
+ (affineShiftPullback base direction (homogeneousComponent n P)).coeff (fullShiftExponent n) := by
67
+ have hc (i : I) : affineShiftCoordinate base direction i ∈
68
+ weightedSupportLE (1 : Fin n → ℕ) ((1 : I → ℕ) i) :=
69
+ (mem_weightedSupportLE_one_iff _ 1).mpr (affineShiftCoordinate_degree _ _ _)
70
+ have hl := weightedSupportLT_aeval (1 : I → ℕ) (1 : Fin n → ℕ)
71
+ (affineShiftCoordinate base direction) hc (sub_topComponent_mem_lowerSupport P hP)
72
+ have hz := full_coefficient_zero_of_lower_support hl
73
+ change (affineShiftPullback base direction (P - homogeneousComponent n P)).coeff
74
+ (fullShiftExponent n) = 0 at hz
75
+ rw [map_sub, coeff_sub] at hz
76
+ exact sub_eq_zero.mp hz
77
+
78
+ noncomputable def polynomialTopSymbol {I : Type*} (n : ℕ) (P : MvPolynomial I ℝ)
79
+ (direction : Fin n → I → ℝ) : ℝ :=
80
+ (affineShiftPullback (fun _ => 0) direction (homogeneousComponent n P)).coeff (fullShiftExponent n)
81
+
82
+ theorem affineShift_difference_eq_topSymbol {I : Type*} {n : ℕ}
83
+ (base : I → ℝ) (direction : Fin n → I → ℝ)
84
+ (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) (u v : Fin n → ℝ) :
85
+ additiveBoxDifference n
86
+ (fun t (_ : Unit) => eval (fun i => base i + ∑ j, direction j i * t j) P) u v () =
87
+ polynomialTopSymbol n P direction * ∏ i, (u i - v i) := by
88
+ rw [affineShift_full_difference base direction P hP,
89
+ affineShift_full_coefficient_base base direction P hP,
90
+ affineShift_full_coefficient_top (fun _ => 0) direction P hP]
91
+ rfl
92
+
93
+ end Erdos3
94
+
95
+ end
96
+
97
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AffineWindowGoodKernelBound.lean ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.CubeTranslation
2
+ import OAI.Combinatorics.Progressions.Estimates.ScalarCubeRootTranslation
3
+ import OAI.Combinatorics.Progressions.Linear.WindowGoodKernelBound
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open scoped BigOperators
12
+
13
+ def integerStrideHom (m : ℤ) : ℤ →+ ℤ where
14
+ toFun x := m * x
15
+ map_zero' := mul_zero m
16
+ map_add' := mul_add m
17
+
18
+ theorem integerStride_reflectsPairSums (m : ℤ) (hm : m ≠ 0) (Q : Set ℤ) :
19
+ ReflectsPairSums (integerStrideHom m) Q := by
20
+ intro a _ b _ c _ d _ h
21
+ apply mul_left_cancel₀ hm
22
+ simpa only [integerStrideHom, AddMonoidHom.coe_mk, ZeroHom.coe_mk, mul_add] using h
23
+
24
+ noncomputable def integerProgressionSupport (c m : ℤ) (L : ℕ) : Finset ℤ :=
25
+ translateSupport c ((Finset.Ico (0 : ℤ) (L : ℤ)).image (integerStrideHom m))
26
+
27
+ noncomputable def supportedIntervalProgressionEquiv (q L : ℕ) (c m : ℤ) (hm : m ≠ 0) :
28
+ SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)) ≃
29
+ SupportedCube q (integerProgressionSupport c m L : Set ℤ) := by
30
+ let e := supportedCubeEquiv (integerStride_reflectsPairSums m hm (Set.Ico 0 (L : ℤ))) q
31
+ let e' : SupportedCube q (integerStrideHom m '' Set.Ico (0 : ℤ) (L : ℤ)) ≃
32
+ SupportedCube q (((Finset.Ico (0 : ℤ) (L : ℤ)).image (integerStrideHom m)) : Set ℤ) :=
33
+ Equiv.subtypeEquivRight (fun p => by simp only [Finset.coe_image, Finset.coe_Ico])
34
+ exact (e.trans e').trans (supportedCubeTranslateEquiv q _ c)
35
+
36
+ theorem supportedIntervalProgressionEquiv_value (q L : ℕ) (c m : ℤ) (hm : m ≠ 0)
37
+ (p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ))) :
38
+ (supportedIntervalProgressionEquiv q L c m hm p).val =
39
+ (fun i => m * p.val.1 i, c + m * p.val.2) := rfl
40
+
41
+ theorem integerScalarCubeWeights_progression_mean (q L : ℕ) (hL : 0 < L)
42
+ (c m : ℤ) (hm : m ≠ 0) (f : ((Fin q → ℤ) × ℤ) → ℝ) :
43
+ (integerScalarCubeWeights (Fin q) L hL).mean
44
+ (fun x => f (fun i => m * (x (some i) : ℤ), c + m * (x none : ℤ))) =
45
+ 𝔼 p : SupportedCube q (integerProgressionSupport c m L : Set ℤ), f p.val := by
46
+ calc
47
+ _ = 𝔼 p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)),
48
+ f (fun i => m * p.val.1 i, c + m * p.val.2) :=
49
+ integerScalarCubeWeights_supported_mean q L hL
50
+ (fun p => f (fun i => m * p.1 i, c + m * p.2))
51
+ _ = _ := Fintype.expect_equiv (supportedIntervalProgressionEquiv q L c m hm) _ _
52
+ (fun _ => rfl)
53
+
54
+ end Erdos3
55
+
56
+ end
57
+
58
+ section
59
+
60
+ namespace Erdos3
61
+
62
+ abbrev TranslatedResidueSupportedCube (q K : ℕ) (c : ℤ) (m : Option (Fin q) → ℕ)
63
+ (r : ∀ i, ZMod (m i)) :=
64
+ {p : SupportedCube q (Set.Ico c (c + K)) //
65
+ ∀ i, ((supportedCubeCoordinates p.val i : ℤ) : ZMod (m i)) = r i}
66
+
67
+ noncomputable def shiftedScalarCubeResidueEquiv (q K : ℕ) (c : ℤ)
68
+ (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i)) :
69
+ ↥((integerScalarCubeSet (Fin q) K) ∩
70
+ scalarCubeResidueSet (Fin q) K m (shiftScalarCubeResidues c m r)) ≃
71
+ TranslatedResidueSupportedCube q K c m r := by
72
+ let e := shiftedScalarCubeEquiv q K c
73
+ refine {
74
+ toFun := fun x => ⟨e ⟨x.val, (Finset.mem_inter.mp x.property).1⟩, ?_⟩
75
+ invFun := fun y => ⟨(e.symm y.val).val, ?_⟩
76
+ left_inv := ?_
77
+ right_inv := ?_ }
78
+ · change ∀ i, ((supportedCubeCoordinates (shiftedScalarCubeEquiv q K c
79
+ ⟨x.val, (Finset.mem_inter.mp x.property).1⟩).val i : ℤ) : ZMod (m i)) = r i
80
+ rw [shiftedScalarCubeEquiv_coordinates]
81
+ exact (shiftScalarCube_residues_iff c m r _).mpr
82
+ ((mem_scalarCubeResidueSet K m (shiftScalarCubeResidues c m r) x.val).mp
83
+ (Finset.mem_inter.mp x.property).2)
84
+ · refine Finset.mem_inter.mpr ⟨(e.symm y.val).property, ?_⟩
85
+ apply (mem_scalarCubeResidueSet K m (shiftScalarCubeResidues c m r) _).mpr
86
+ apply (shiftScalarCube_residues_iff c m r _).mp
87
+ rw [← shiftedScalarCubeEquiv_coordinates]
88
+ simpa only [e, Equiv.apply_symm_apply] using y.property
89
+ · intro x
90
+ apply Subtype.ext
91
+ change (e.symm (e ⟨x.val, (Finset.mem_inter.mp x.property).1⟩)).val = x.val
92
+ rw [e.symm_apply_apply]
93
+ · intro y
94
+ apply Subtype.ext
95
+ change e (e.symm y.val) = y.val
96
+ exact e.apply_symm_apply y.val
97
+
98
+ theorem shiftedScalarCubeResidueEquiv_coordinates (q K : ℕ) (c : ℤ)
99
+ (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i))
100
+ (x : ↥((integerScalarCubeSet (Fin q) K) ∩
101
+ scalarCubeResidueSet (Fin q) K m (shiftScalarCubeResidues c m r))) :
102
+ supportedCubeCoordinates (shiftedScalarCubeResidueEquiv q K c m r x).val.val =
103
+ shiftScalarCube c (fun i => (x.val i : ℤ)) := by
104
+ funext i
105
+ cases i <;> rfl
106
+
107
+ end Erdos3
108
+
109
+ end
110
+
111
+ section
112
+
113
+ namespace Erdos3
114
+
115
+ theorem mem_integerProgressionSupport_iff (c : ℤ) (m H : ℕ) (hm : 0 < m) (x : ℤ) :
116
+ x ∈ integerProgressionSupport c (m : ℤ) H ↔
117
+ c ≤ x ∧ x < c + (m * H : ℕ) ∧ (x : ZMod m) = (c : ZMod m) := by
118
+ have hm' : (0 : ℤ) < m := by exact_mod_cast hm
119
+ rw [integerProgressionSupport, mem_translateSupport, Finset.mem_image]
120
+ constructor
121
+ · rintro ⟨y, hy, he⟩
122
+ have hy' := Finset.mem_Ico.mp hy
123
+ change (m : ℤ) * y = x - c at he
124
+ have hx : x = c + (m : ℤ) * y := by omega
125
+ constructor
126
+ · nlinarith
127
+ constructor
128
+ · push_cast
129
+ nlinarith
130
+ · rw [hx]
131
+ simp
132
+ · rintro ⟨hlo, hhi, hr⟩
133
+ have hz : ((x - c : ℤ) : ZMod m) = 0 := by simp [hr]
134
+ obtain ⟨y, hy⟩ := (ZMod.intCast_zmod_eq_zero_iff_dvd (x - c) m).mp hz
135
+ have hy0 : 0 ≤ y := by nlinarith
136
+ have hyH : y < H := by push_cast at hhi; nlinarith
137
+ exact ⟨y, Finset.mem_Ico.mpr ⟨hy0, hyH⟩, hy.symm⟩
138
+
139
+ def progressionCubeResidues (q m : ℕ) (c : ℤ) : Option (Fin q) → ZMod m
140
+ | none => (c : ZMod m)
141
+ | some _ => 0
142
+
143
+ noncomputable def progressionResidueSupportedCubeEquiv (q m H : ℕ) (c : ℤ) (hm : 0 < m) :
144
+ SupportedCube q (integerProgressionSupport c (m : ℤ) H : Set ℤ) ≃
145
+ TranslatedResidueSupportedCube q (m * H) c (fun _ => m) (progressionCubeResidues q m c) where
146
+ toFun p := by
147
+ let p' : SupportedCube q (Set.Ico c (c + (m * H : ℕ))) := ⟨p.val, fun ω => by
148
+ have h := (mem_integerProgressionSupport_iff c m H hm _).mp (p.property ω)
149
+ exact ⟨h.1, h.2.1⟩⟩
150
+ refine ⟨p', ?_⟩
151
+ intro i
152
+ cases i with
153
+ | none => exact ((mem_integerProgressionSupport_iff c m H hm _).mp p.base_mem).2.2
154
+ | some i =>
155
+ have h0 := ((mem_integerProgressionSupport_iff c m H hm _).mp p.base_mem).2.2
156
+ have hi := ((mem_integerProgressionSupport_iff c m H hm _).mp (p.axis_mem i)).2.2
157
+ change (p.val.1 i : ZMod m) = 0
158
+ push_cast at hi
159
+ rw [h0] at hi
160
+ exact add_left_cancel (hi.trans (add_zero _).symm)
161
+ invFun p := by
162
+ refine ⟨p.val.val, fun ω => ?_⟩
163
+ apply (mem_integerProgressionSupport_iff c m H hm _).mpr
164
+ have h := p.val.property ω
165
+ refine ⟨h.1, h.2, ?_⟩
166
+ have h0 : (p.val.val.2 : ZMod m) = (c : ZMod m) := p.property none
167
+ have hi (i : Fin q) : (p.val.val.1 i : ZMod m) = 0 := p.property (some i)
168
+ simp only [Int.cast_add, h0, cubeShift, Int.cast_sum, apply_ite, hi, Int.cast_zero, ite_self,
169
+ Finset.sum_const_zero, add_zero]
170
+ left_inv p := by apply Subtype.ext; rfl
171
+ right_inv p := by apply Subtype.ext; apply Subtype.ext; rfl
172
+
173
+ end Erdos3
174
+
175
+ end
176
+
177
+ section
178
+
179
+ namespace Erdos3
180
+
181
+ open scoped BigOperators
182
+
183
+ noncomputable def affineScalarCubeWindowWeights (I : Type*) [Fintype I] [DecidableEq I]
184
+ (L K M D : ℕ) (c : ℤ) (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K)
185
+ (m : Option I → ℕ) (r : ∀ i, ZMod (m i))
186
+ (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M)
187
+ (hsize : (Fintype.card I + 1) * M ≤ K) :
188
+ FiniteProbabilityWeights (IntegerScalarCubeBox I L) :=
189
+ scalarCubeWindowWeights I L K M D hL hKL hDK m (shiftScalarCubeResidues c m r) hm hmM hsize
190
+
191
+ theorem affineScalarCubeWindowWeights_supported_mean (q L K M D : ℕ) (c : ℤ)
192
+ (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K)
193
+ (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i))
194
+ (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M)
195
+ (hsize : (Fintype.card (Fin q) + 1) * M ≤ K) (f : (Option (Fin q) → ℤ) → ℝ) :
196
+ (affineScalarCubeWindowWeights (Fin q) L K M D c hL hKL hDK m r hm hmM hsize).mean
197
+ (fun x => f (shiftScalarCube c (fun i => (x i : ℤ)))) =
198
+ 𝔼 p : TranslatedResidueSupportedCube q K c m r, f (supportedCubeCoordinates p.val.val) := by
199
+ classical
200
+ have hM : 0 < M := (hm none).trans_le (hmM none)
201
+ have hK : 0 < K := (Nat.mul_pos (Nat.succ_pos _) hM).trans_le hsize
202
+ unfold affineScalarCubeWindowWeights
203
+ rw [scalarCubeWindowWeights_small_mean (Fin q) L K M D hL hK hKL hDK,
204
+ scalarCubeResidueWeights_mean]
205
+ apply Fintype.expect_equiv (shiftedScalarCubeResidueEquiv q K c m r)
206
+ intro x
207
+ rw [shiftedScalarCubeResidueEquiv_coordinates]
208
+ rfl
209
+
210
+ theorem affineScalarCubeWindowWeights_weight_le (I : Type*) [Fintype I] [DecidableEq I]
211
+ (L K M D : ℕ) (c : ℤ) (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K)
212
+ (m : Option I → ℕ) (r : ∀ i, ZMod (m i))
213
+ (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M)
214
+ (hsize : (Fintype.card I + 1) * M ≤ K) (x : IntegerScalarCubeBox I L) :
215
+ (affineScalarCubeWindowWeights I L K M D c hL hKL hDK m r hm hmM hsize).weight x ≤
216
+ scalarCubeResidueDensityCap I (M * D) * (integerScalarCubeWeights I L hL).weight x :=
217
+ scalarCubeWindowWeights_weight_le I L K M D hL hKL hDK m (shiftScalarCubeResidues c m r) hm hmM hsize x
218
+
219
+ end Erdos3
220
+
221
+ end
222
+
223
+ section
224
+
225
+ namespace Erdos3
226
+
227
+ open scoped BigOperators
228
+
229
+ theorem affineScalarCubeWindowWeights_progression_mean (q L m H M D : ℕ) (c : ℤ)
230
+ (hL : 0 < L) (hm : 0 < m) (hmM : m ≤ M) (hKL : m * H ≤ L) (hDK : L ≤ D * (m * H))
231
+ (hsize : (Fintype.card (Fin q) + 1) * M ≤ m * H) (f : (Option (Fin q) → ℤ) → ℝ) :
232
+ (affineScalarCubeWindowWeights (Fin q) L (m * H) M D c hL hKL hDK
233
+ (fun _ => m) (progressionCubeResidues q m c) (fun _ => hm) (fun _ => hmM) hsize).mean
234
+ (fun x => f (shiftScalarCube c (fun i => (x i : ℤ)))) =
235
+ 𝔼 p : SupportedCube q (integerProgressionSupport c (m : ℤ) H : Set ℤ),
236
+ f (supportedCubeCoordinates p.val) := by
237
+ rw [affineScalarCubeWindowWeights_supported_mean]
238
+ exact (Fintype.expect_equiv (progressionResidueSupportedCubeEquiv q m H c hm) _ _
239
+ (fun _ => rfl)).symm
240
+
241
+ end Erdos3
242
+
243
+ end
244
+
245
+ section
246
+
247
+ namespace Erdos3
248
+
249
+ theorem scalarKernelCutoff_window_size (I J : Type*) [Fintype I] [Fintype J]
250
+ {M D L K : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η)
251
+ (hlarge : scalarKernelCutoff I J M D η ≤ L) (hDK : L ≤ D * K) :
252
+ (Fintype.card I + 1) * M ≤ K :=
253
+ scalarCubeWindow_size hD ((scalarKernelCutoff_bounds I J hM hD hη).2.2.1.trans hlarge) hDK
254
+
255
+ theorem affineKernel_explicit_probability_le (I J : Type*)
256
+ [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J]
257
+ (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) (s : I ↪ J)
258
+ {M D L : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hL : 0 < L)
259
+ (hlarge : scalarKernelCutoff I J M D η ≤ L) (K : J → ℕ)
260
+ (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) (c : J → ℤ)
261
+ (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i))
262
+ (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M) :
263
+ (FiniteProbabilityWeights.pi (fun j =>
264
+ affineScalarCubeWindowWeights I L (K j) M D (c j) hL (hKL j) (hDK j)
265
+ (m j) (r j) (hm j) (hmM j) (scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j)))).eventProbability
266
+ (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ))
267
+ (scalarKernelCutoff I J M D η) x) ≤ η := by
268
+ let C := scalarKernelConditioningConstant I J M D
269
+ have hC : 0 < C := scalarKernelConditioningConstant_pos I J hM hD
270
+ have h := scalarCubeWindow_pi_eventProbability_le I J L M D K hL hKL hDK m
271
+ (fun j => shiftScalarCubeResidues (c j) (m j) (r j)) hm hmM
272
+ (fun j => scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j))
273
+ (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ))
274
+ (scalarKernelCutoff I J M D η) x)
275
+ apply h.trans
276
+ calc
277
+ _ ≤ C * scalarKernelAdjustedAccuracy I J M D η := mul_le_mul_of_nonneg_left
278
+ (scalarKernel_explicit_probability_le I J hJ s hM hD hη hL hlarge) hC.le
279
+ _ = η := by
280
+ change C * (η / C) = η
281
+ field_simp
282
+
283
+ end Erdos3
284
+
285
+ end
286
+
287
+ section
288
+
289
+ namespace Erdos3
290
+
291
+ theorem exists_affine_window_good_scalar_kernel_bound (I J : Type*)
292
+ [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J]
293
+ (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) :
294
+ ∃ s : I ↪ J, ∀ (M D : ℕ), 0 < M → ∀ hD : 0 < D, ∀ η : ℝ, 0 < η → ∃ B L₀ : ℕ,
295
+ 0 < B ∧ ∃ hsize : D * ((Fintype.card I + 1) * M) ≤ L₀,
296
+ ∀ (L : ℕ) (hL : 0 < L) (hlarge : L₀ ≤ L) (K : J → ℕ)
297
+ (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) (c : J → ℤ)
298
+ (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i))
299
+ (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M),
300
+ (FiniteProbabilityWeights.pi (fun j =>
301
+ affineScalarCubeWindowWeights I L (K j) M D (c j) hL (hKL j) (hDK j)
302
+ (m j) (r j) (hm j) (hmM j)
303
+ (scalarCubeWindow_size hD (hsize.trans hlarge) (hDK j)))).eventProbability
304
+ (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) ≤ η := by
305
+ obtain ⟨s, hs⟩ := exists_window_good_scalar_kernel_bound I J hJ
306
+ refine ⟨s, fun M D hM hD η hη => ?_⟩
307
+ obtain ⟨B, L₀, hB, hsize, hprob⟩ := hs M D hM hD η hη
308
+ refine ⟨B, L₀, hB, hsize, ?_⟩
309
+ intro L hL hlarge K hKL hDK c m r hm hmM
310
+ exact hprob L hL hlarge K hKL hDK m (fun j => shiftScalarCubeResidues (c j) (m j) (r j)) hm hmM
311
+
312
+ end Erdos3
313
+
314
+ end
315
+
316
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorIntegerRestoration.lean ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.IntegerPolynomialDenominatorGrid
2
+ import OAI.Combinatorics.Progressions.Polynomial.TranslationPhaseQuotient
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open MvPolynomial
11
+
12
+ variable {σ τ : Type*}
13
+
14
+ theorem weightedHomogeneousComponent_fractional_restoration
15
+ (F : MvPolynomial σ ℝ) (w : σ → ℕ) (d : ℕ) :
16
+ weightedHomogeneousComponent w d F =
17
+ weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F) +
18
+ MvPolynomial.map (Int.castRingHom ℝ)
19
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) := by
20
+ classical
21
+ conv_lhs => rw [← floorIntegerPolynomial_add_fractionalCoefficientPolynomial F]
22
+ rw [map_add, add_comm]
23
+ congr 1
24
+ ext a
25
+ simp only [coeff_weightedHomogeneousComponent, coeff_map]
26
+ split_ifs <;> simp
27
+
28
+ noncomputable def restoredMajorRemainder (F : MvPolynomial σ ℝ)
29
+ (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) : MvPolynomial σ ℚ :=
30
+ R + MvPolynomial.map (Int.castRingHom ℚ)
31
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F))
32
+
33
+ theorem restoredMajorRemainder_coefficientGrid (F : MvPolynomial σ ℝ)
34
+ (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) (q : ℕ)
35
+ (hR : (fun a => R.coeff a) ∈ denominatorGrid q) :
36
+ (fun a => (restoredMajorRemainder F w d R).coeff a) ∈ denominatorGrid q :=
37
+ add_integerPolynomial_coefficientGrid R
38
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) q hR
39
+
40
+ theorem integerPolynomial_map_rat_real (I : MvPolynomial σ ℤ) :
41
+ MvPolynomial.map (algebraMap ℚ ℝ) (MvPolynomial.map (Int.castRingHom ℚ) I) =
42
+ MvPolynomial.map (Int.castRingHom ℝ) I := by
43
+ ext a
44
+ simp only [coeff_map]
45
+ simp
46
+
47
+ theorem restoredMajorRemainder_eval (F : MvPolynomial σ ℝ)
48
+ (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) (z : σ → ℝ) :
49
+ eval₂ (algebraMap ℚ ℝ) z (restoredMajorRemainder F w d R) =
50
+ eval₂ (algebraMap ℚ ℝ) z R +
51
+ eval z (MvPolynomial.map (Int.castRingHom ℝ)
52
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F))) := by
53
+ rw [restoredMajorRemainder, eval₂_add]
54
+ congr 1
55
+ rw [← eval_map, integerPolynomial_map_rat_real]
56
+
57
+ theorem restoredMajorRemainder_isWeightedHomogeneous (F : MvPolynomial σ ℝ)
58
+ (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ)
59
+ (hR : R.IsWeightedHomogeneous w d) :
60
+ (restoredMajorRemainder F w d R).IsWeightedHomogeneous w d := by
61
+ apply hR.add
62
+ intro a ha
63
+ apply weightedHomogeneousComponent_isWeightedHomogeneous
64
+ (w := w) d (floorIntegerPolynomial F)
65
+ intro hz
66
+ apply ha
67
+ simp only [coeff_map, hz, map_zero]
68
+
69
+ theorem restoredMajorRemainder_degree (F : MvPolynomial σ ℝ)
70
+ (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ)
71
+ (hR : R ∈ weightedSupportLE w d) :
72
+ restoredMajorRemainder F w d R ∈ weightedSupportLE w d := by
73
+ apply (weightedSupportLE w d).add_mem hR
74
+ intro a ha
75
+ have hi : (MvPolynomial.map (Int.castRingHom ℚ)
76
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F))).IsWeightedHomogeneous w d := by
77
+ intro a ha
78
+ apply weightedHomogeneousComponent_isWeightedHomogeneous
79
+ (w := w) d (floorIntegerPolynomial F)
80
+ intro hz
81
+ apply ha
82
+ simp only [coeff_map, hz, map_zero]
83
+ exact (hi (mem_support_iff.mp ha)).le
84
+
85
+ theorem restoredMajorRemainder_totalDegree_le (F : MvPolynomial σ ℝ)
86
+ (w : σ → ℕ) (hw : ∀ i, 0 < w i) (d : ℕ) (R : MvPolynomial σ ℚ)
87
+ {r : ℕ} (hR : R.totalDegree ≤ r) (hdr : d ≤ r) :
88
+ (restoredMajorRemainder F w d R).totalDegree ≤ r := by
89
+ have hI : MvPolynomial.map (Int.castRingHom ℚ)
90
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) ∈
91
+ weightedSupportLE w d := by
92
+ simpa only [restoredMajorRemainder, zero_add] using
93
+ restoredMajorRemainder_degree F w d 0 (Submodule.zero_mem _)
94
+ have hdeg : (MvPolynomial.map (Int.castRingHom ℚ)
95
+ (weightedHomogeneousComponent w d (floorIntegerPolynomial F))).totalDegree ≤ d := by
96
+ unfold totalDegree
97
+ apply Finset.sup_le
98
+ intro a ha
99
+ exact (exponentSum_le_positive_weight w hw a).trans (hI ha)
100
+ exact (totalDegree_add _ _).trans (max_le hR (hdeg.trans hdr))
101
+
102
+ theorem algebraic_major_integer_restoration_identity
103
+ (F : MvPolynomial σ ℝ) (w : σ → ℕ) (d : ℕ)
104
+ (S : MvPolynomial τ ℝ) (R : MvPolynomial σ ℚ)
105
+ (chart : (σ → ℝ) → (τ → ℝ)) (Ω : Set (σ → ℝ))
106
+ (hidentity : ∀ z ∈ Ω,
107
+ eval z (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) =
108
+ eval (chart z) S + eval₂ (algebraMap ℚ ℝ) z R)
109
+ (z : σ → ℝ) (hz : z ∈ Ω) :
110
+ eval z (weightedHomogeneousComponent w d F) =
111
+ eval (chart z) S + eval₂ (algebraMap ℚ ℝ) z (restoredMajorRemainder F w d R) := by
112
+ rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity z hz,
113
+ restoredMajorRemainder_eval, add_assoc]
114
+
115
+ theorem algebraic_major_restore_integer_coefficients
116
+ {U B : Type*} (F : MvPolynomial (U ⊕ B) ℝ)
117
+ (w : U ⊕ B → ℕ) (d : ℕ) (K : Submodule ℝ (B → ℝ))
118
+ (A : B → MvPolynomial U ℝ) (H : U → ℝ)
119
+ (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ)
120
+ (hgrid : (fun a => R.coeff a) ∈ denominatorGrid q)
121
+ (hdegree : R ∈ weightedSupportLE w d)
122
+ (hidentity : ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
123
+ eval (Sum.elim u b)
124
+ (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) =
125
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S +
126
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R) :
127
+ let R' := restoredMajorRemainder F w d R
128
+ (fun a => R'.coeff a) ∈ denominatorGrid q ∧ R' ∈ weightedSupportLE w d ∧
129
+ ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
130
+ eval (Sum.elim u b) (weightedHomogeneousComponent w d F) =
131
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S +
132
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R' := by
133
+ refine ⟨restoredMajorRemainder_coefficientGrid F w d R q hgrid,
134
+ restoredMajorRemainder_degree F w d R hdegree, ?_⟩
135
+ intro u b hb
136
+ rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity u b hb,
137
+ restoredMajorRemainder_eval, add_assoc]
138
+
139
+ theorem algebraic_major_restore_integer_coefficients_totalDegree
140
+ {U B : Type*} (F : MvPolynomial (U ⊕ B) ℝ)
141
+ (w : U ⊕ B → ℕ) (hw : ∀ i, 0 < w i) (d : ℕ)
142
+ (K : Submodule ℝ (B → ℝ)) (A : B → MvPolynomial U ℝ) (H : U → ℝ)
143
+ (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) (q r : ℕ)
144
+ (hgrid : (fun a => R.coeff a) ∈ denominatorGrid q)
145
+ (hdegree : R.totalDegree ≤ r) (hdr : d ≤ r)
146
+ (hidentity : ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
147
+ eval (Sum.elim u b)
148
+ (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) =
149
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S +
150
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R) :
151
+ let R' := restoredMajorRemainder F w d R
152
+ (fun a => R'.coeff a) ∈ denominatorGrid q ∧ R'.totalDegree ≤ r ∧
153
+ ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
154
+ eval (Sum.elim u b) (weightedHomogeneousComponent w d F) =
155
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S +
156
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R' := by
157
+ refine ⟨restoredMajorRemainder_coefficientGrid F w d R q hgrid,
158
+ restoredMajorRemainder_totalDegree_le F w hw d R hdegree hdr, ?_⟩
159
+ intro u b hb
160
+ rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity u b hb,
161
+ restoredMajorRemainder_eval, add_assoc]
162
+
163
+ end Erdos3
164
+
165
+ end
166
+
167
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorWeightedAffineTopPullback.lean ADDED
@@ -0,0 +1,528 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.MajorTranslationPolynomialSymbolDegree
2
+ import OAI.Combinatorics.Progressions.Polynomial.TranslationPhaseQuotient
3
+ import OAI.Combinatorics.Progressions.Polynomial.TranslationTopDegree
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+ open MvPolynomial
11
+
12
+ variable {U B : Type*}
13
+
14
+ noncomputable def majorSlowDilationPullback (q : ℕ) (H T : U → ℝ)
15
+ (S : MvPolynomial (U ⊕ B) ℝ) : MvPolynomial (U ⊕ B) ℝ :=
16
+ scaleMvPolynomialAxes
17
+ (Sum.elim (fun i => H i / ((q : ℝ) * T i)) (fun _ : B => 1)) S
18
+
19
+ theorem majorSlowDilationPullback_eval (q : ℕ) (hq : 0 < q) (H T : U → ℝ)
20
+ (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
21
+ (S : MvPolynomial (U ⊕ B) ℝ) (u : U → ℝ) (z : B → ℝ) :
22
+ eval (Sum.elim (fun i => u i / H i) z) (majorSlowDilationPullback q H T S) =
23
+ eval (Sum.elim (fun i => (u i / (q : ℝ)) / T i) z) S := by
24
+ rw [majorSlowDilationPullback, scaleMvPolynomialAxes_eval]
25
+ apply congrArg (fun x : U ⊕ B → ℝ => eval x S)
26
+ funext j
27
+ cases j with
28
+ | inl i =>
29
+ dsimp only [Sum.elim_inl]
30
+ field_simp [(hH i).ne', (hT i).ne', (Nat.cast_pos.mpr hq : (0 : ℝ) < q).ne']
31
+ | inr j => simp only [Sum.elim_inr, one_mul]
32
+
33
+ theorem majorSlowDilationPullback_totalDegree_le (q : ℕ) (H T : U → ℝ)
34
+ (S : MvPolynomial (U ⊕ B) ℝ) :
35
+ (majorSlowDilationPullback q H T S).totalDegree ≤ S.totalDegree :=
36
+ scaleMvPolynomialAxes_totalDegree_le _ _
37
+
38
+ theorem algebraic_major_dilation_pullback_identity
39
+ (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ)
40
+ (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ)
41
+ (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q)
42
+ (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
43
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
44
+ eval (Sum.elim (fun i => (q : ℝ) * v i) b) D =
45
+ eval (Sum.elim (fun i => v i / T i)
46
+ (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S +
47
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
48
+ (u : U → ℝ) (b : B → ℝ) (hb : b ∈ K) :
49
+ eval (Sum.elim u b) D =
50
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j)))
51
+ (majorSlowDilationPullback q H T S) +
52
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) (jointRationalPolynomialDilation q R) := by
53
+ rw [majorSlowDilationPullback_eval q hq H T hH hT,
54
+ jointRationalPolynomialDilation_eval₂]
55
+ have hcancel : (fun i => (q : ℝ) * (u i / (q : ℝ))) = u := by
56
+ funext i
57
+ exact mul_div_cancel₀ (u i) (Nat.cast_ne_zero.mpr hq.ne')
58
+ simpa only [hcancel] using hsource (fun i => u i / (q : ℝ)) b hb
59
+
60
+ theorem majorSlowDilationPullback_mass_le (q : ℕ) (hq : 0 < q) (H T : U → ℝ)
61
+ (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
62
+ (S : MvPolynomial (U ⊕ B) ℝ) {c : ℝ} (hc : 1 ≤ c)
63
+ (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) {d : ℕ} (hS : S.totalDegree ≤ d) :
64
+ realPolynomialMass (majorSlowDilationPullback q H T S) ≤ c^d * realPolynomialMass S := by
65
+ apply jointPolynomialDilation_mass_le _ S hc _ hS
66
+ intro i
67
+ have hqT : 0 < (q : ℝ) * T i := mul_pos (Nat.cast_pos.mpr hq) (hT i)
68
+ rw [abs_of_nonneg (div_nonneg (hH i).le hqT.le)]
69
+ apply (div_le_iff₀ hqT).mpr
70
+ simpa only [mul_assoc] using hHT i
71
+
72
+ theorem algebraic_major_dilation_pullback_decomposition
73
+ (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ)
74
+ (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ)
75
+ (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q)
76
+ (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
77
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
78
+ eval (Sum.elim (fun i => (q : ℝ) * v i) b) D =
79
+ eval (Sum.elim (fun i => v i / T i)
80
+ (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S +
81
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
82
+ (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i)
83
+ (d l : ℕ) (hS : S.totalDegree ≤ d) (hR : R.totalDegree ≤ d)
84
+ (hSmass : realPolynomialMass S ≤ C)
85
+ (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) :
86
+ ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ),
87
+ (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
88
+ eval (Sum.elim u b) D =
89
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S' +
90
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧
91
+ realPolynomialMass S' ≤ c^d * C ∧ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧
92
+ (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := by
93
+ refine ⟨majorSlowDilationPullback q H T S, jointRationalPolynomialDilation q R,
94
+ algebraic_major_dilation_pullback_identity K D A S R q hq H T hH hT hsource, ?_,
95
+ (majorSlowDilationPullback_totalDegree_le q H T S).trans hS,
96
+ (jointRationalPolynomialDilation_totalDegree_le q R).trans hR, ?_⟩
97
+ · exact (majorSlowDilationPullback_mass_le q hq H T hH hT S hc hHT hS).trans
98
+ (mul_le_mul_of_nonneg_left hSmass (pow_nonneg (le_trans zero_le_one hc) d))
99
+ · exact jointRationalPolynomialDilation_denominatorGrid R q l d hq hR hRgrid
100
+
101
+ end Erdos3
102
+
103
+ end
104
+
105
+ section
106
+
107
+ namespace Erdos3
108
+
109
+ open MvPolynomial
110
+
111
+ variable {U B : Type*}
112
+
113
+ theorem majorSlowDilationPullback_mem_weightedSupportLE
114
+ (q : ℕ) (H T : U → ℝ) (S : MvPolynomial (U ⊕ B) ℝ)
115
+ (w : U ⊕ B → ℕ) (d : ℕ) (hS : S ∈ weightedSupportLE w d) :
116
+ majorSlowDilationPullback q H T S ∈ weightedSupportLE w d :=
117
+ scaleMvPolynomialAxes_mem_weightedSupportLE _ w d hS
118
+
119
+ theorem algebraic_major_weighted_dilation_pullback_decomposition
120
+ (w : B → ℕ) (hw : ∀ i, 0 < w i)
121
+ (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ)
122
+ (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ)
123
+ (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q)
124
+ (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
125
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
126
+ eval (Sum.elim (fun i => (q : ℝ) * v i) b) D =
127
+ eval (Sum.elim (fun i => v i / T i)
128
+ (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S +
129
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
130
+ (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i)
131
+ (d l : ℕ)
132
+ (hS : S ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d)
133
+ (hR : R ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d)
134
+ (hSmass : realPolynomialMass S ≤ C)
135
+ (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) :
136
+ ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ),
137
+ S' = majorSlowDilationPullback q H T S ∧
138
+ R' = jointRationalPolynomialDilation q R ∧
139
+ (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
140
+ eval (Sum.elim u b) D =
141
+ eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S' +
142
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧
143
+ realPolynomialMass S' ≤ c^d * C ∧
144
+ S' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧
145
+ R' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧
146
+ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧
147
+ (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := by
148
+ have hpos : ∀ i : U ⊕ B, 0 < Sum.elim (fun _ : U => 1) w i :=
149
+ Sum.rec (fun _ => Nat.zero_lt_one) hw
150
+ have hSdeg := weightedSupportLE_totalDegree_le_of_pos hpos hS
151
+ have hRdeg := weightedSupportLE_totalDegree_le_of_pos hpos hR
152
+ have hS' := majorSlowDilationPullback_mem_weightedSupportLE q H T S _ d hS
153
+ have hR' := jointRationalPolynomialDilation_mem_weightedSupportLE q R _ d hR
154
+ refine ⟨majorSlowDilationPullback q H T S, jointRationalPolynomialDilation q R,
155
+ rfl, rfl,
156
+ algebraic_major_dilation_pullback_identity K D A S R q hq H T hH hT hsource,
157
+ ?_, hS', hR', weightedSupportLE_totalDegree_le_of_pos hpos hS',
158
+ weightedSupportLE_totalDegree_le_of_pos hpos hR', ?_⟩
159
+ · exact (majorSlowDilationPullback_mass_le q hq H T hH hT S hc hHT hSdeg).trans
160
+ (mul_le_mul_of_nonneg_left hSmass (pow_nonneg (le_trans zero_le_one hc) d))
161
+ · exact jointRationalPolynomialDilation_denominatorGrid R q l d hq hRdeg hRgrid
162
+
163
+ end Erdos3
164
+
165
+ end
166
+
167
+ section
168
+
169
+ namespace Erdos3
170
+
171
+ open MvPolynomial
172
+ open scoped BigOperators TensorProduct
173
+
174
+ variable {U R : Type*} [CommRing R]
175
+
176
+ theorem homogeneousComponent_polynomialTranslate (h : ℕ) (r : U → R)
177
+ (P : MvPolynomial U R) (hP : P.totalDegree ≤ h) :
178
+ homogeneousComponent h (polynomialTranslate r P) = homogeneousComponent h P := by
179
+ have hp : VectorPolynomial.DegreeLE (1 : U → ℕ) h (P ⊗ₜ[R] (1 : R)) := by
180
+ intro α hα
181
+ have hz : P.coeff α = 0 := coeff_eq_zero_of_totalDegree_lt (hP.trans_lt (by
182
+ simpa only [Finsupp.weight_apply, Finsupp.sum, Pi.one_apply,
183
+ smul_eq_mul, mul_one] using hα))
184
+ simp only [VectorPolynomial.coefficients_tmul, hz, zero_smul]
185
+ have ht := VectorPolynomial.homogeneousPart_translate r (P ⊗ₜ[R] (1 : R)) hp
186
+ ext α
187
+ have hc := congrArg (fun p => VectorPolynomial.coefficients p α) ht
188
+ simpa only [VectorPolynomial.translate_tmul, VectorPolynomial.homogeneousPart_tmul,
189
+ VectorPolynomial.coefficients_tmul, smul_eq_mul, mul_one] using hc
190
+
191
+ theorem polynomial_dilation_monomial (a c : R) (α : U →₀ ℕ) :
192
+ aeval (fun i => C a * X i) (monomial α c) = monomial α (a ^ α.degree * c) := by
193
+ classical
194
+ rw [aeval_monomial]
195
+ simp only [algebraMap_eq, Finsupp.prod, mul_pow, Finset.prod_mul_distrib,
196
+ ← map_pow, ← map_prod, Finset.prod_pow_eq_pow_sum, prod_X_pow_eq_monomial]
197
+ rw [monomial_eq, monomial_eq]
198
+ simp only [map_one, one_mul, map_mul]
199
+ have hd : (∑ i ∈ α.support, α i) = α.degree := rfl
200
+ rw [hd]
201
+ ring
202
+
203
+ theorem coeff_polynomial_dilation (a : R) (P : MvPolynomial U R) (α : U →₀ ℕ) :
204
+ (aeval (fun i => C a * X i) P).coeff α = a ^ α.degree * P.coeff α := by
205
+ classical
206
+ conv_lhs => rw [P.as_sum]
207
+ simp only [map_sum, polynomial_dilation_monomial, coeff_sum, coeff_monomial]
208
+ by_cases hα : α ∈ P.support
209
+ · rw [Finset.sum_eq_single α]
210
+ · simp
211
+ · intro β hβ hβα
212
+ simp [hβα]
213
+ · exact fun h => (h hα).elim
214
+ · rw [Finset.sum_eq_zero]
215
+ · have hz : P.coeff α = 0 := not_ne_iff.mp (fun h => hα (mem_support_iff.mpr h))
216
+ simp only [hz, mul_zero]
217
+ · intro β hβ
218
+ have hβα : β ≠ α := by rintro rfl; exact hα hβ
219
+ simp [hβα]
220
+
221
+ theorem homogeneousComponent_polynomial_dilation (h : ℕ) (a : R)
222
+ (P : MvPolynomial U R) :
223
+ homogeneousComponent h (aeval (fun i => C a * X i) P) =
224
+ C (a ^ h) * homogeneousComponent h P := by
225
+ classical
226
+ ext α
227
+ rw [coeff_homogeneousComponent, coeff_polynomial_dilation, coeff_C_mul,
228
+ coeff_homogeneousComponent]
229
+ by_cases hα : α.degree = h
230
+ · simp only [hα, ite_true]
231
+ · simp only [hα, ite_false, mul_zero]
232
+
233
+ theorem residueAffinePolynomial_eq_dilation_translate (q : ℕ) (r : U → ℤ)
234
+ (P : MvPolynomial U ℝ) :
235
+ residueAffinePolynomial q r P =
236
+ aeval (fun i => C (q : ℝ) * X i) (polynomialTranslate (fun i => (r i : ℝ)) P) := by
237
+ induction P using MvPolynomial.induction_on with
238
+ | C c => simp [residueAffinePolynomial]
239
+ | add P Q hP hQ =>
240
+ simpa only [residueAffinePolynomial, map_add] using congrArg₂ (· + ·) hP hQ
241
+ | mul_X P i hP =>
242
+ simp only [residueAffinePolynomial, map_mul, eval₂Hom_X', polynomialTranslate_X,
243
+ map_add, aeval_X, aeval_C, algebraMap_eq] at *
244
+ rw [hP, add_comm (C (r i : ℝ))]
245
+
246
+ theorem residueAffinePolynomial_homogeneousComponent (q h : ℕ) (r : U → ℤ)
247
+ (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ h) :
248
+ homogeneousComponent h (residueAffinePolynomial q r P) =
249
+ C ((q : ℝ) ^ h) * homogeneousComponent h P := by
250
+ rw [residueAffinePolynomial_eq_dilation_translate,
251
+ homogeneousComponent_polynomial_dilation, homogeneousComponent_polynomialTranslate h _ P hP]
252
+
253
+ end Erdos3
254
+
255
+ end
256
+
257
+ section
258
+
259
+ namespace Erdos3
260
+
261
+ open MvPolynomial
262
+
263
+ variable {U : Type*}
264
+
265
+ theorem residueAffinePolynomial_homogeneousComponent_eval
266
+ (q h : ℕ) (r : U → ℤ) (P : MvPolynomial U ℝ)
267
+ (hP : P.totalDegree ≤ h) (v : U → ℝ) :
268
+ eval v (homogeneousComponent h (residueAffinePolynomial q r P)) =
269
+ eval (fun i => (q : ℝ) * v i) (homogeneousComponent h P) := by
270
+ have hdil : C ((q : ℝ) ^ h) * homogeneousComponent h P =
271
+ aeval (fun i => C (q : ℝ) * X i) (homogeneousComponent h P) := by
272
+ classical
273
+ ext α
274
+ rw [coeff_C_mul, coeff_polynomial_dilation, coeff_homogeneousComponent]
275
+ by_cases hα : α.degree = h
276
+ · simp only [hα, ite_true]
277
+ · simp only [hα, ite_false, mul_zero]
278
+ rw [residueAffinePolynomial_homogeneousComponent q h r P hP, hdil]
279
+ change (aeval v) (aeval (fun i => C (q : ℝ) * X i)
280
+ (homogeneousComponent h P)) = _
281
+ rw [comp_aeval_apply]
282
+ simp only [map_mul, aeval_C, aeval_X, Algebra.algebraMap_self, RingHom.id_apply,
283
+ aeval_eq_eval]
284
+
285
+ theorem residueAffinePolynomial_weightedHomogeneousComponent_eval
286
+ (q h : ℕ) (r : U → ℤ) (P : MvPolynomial U ℝ)
287
+ (hP : P.totalDegree ≤ h) (v : U → ℝ) :
288
+ eval v (weightedHomogeneousComponent (fun _ : U => 1) h
289
+ (residueAffinePolynomial q r P)) =
290
+ eval (fun i => (q : ℝ) * v i)
291
+ (weightedHomogeneousComponent (fun _ : U => 1) h P) :=
292
+ residueAffinePolynomial_homogeneousComponent_eval q h r P hP v
293
+
294
+ end Erdos3
295
+
296
+ end
297
+
298
+ section
299
+
300
+ namespace Erdos3
301
+
302
+ open MvPolynomial
303
+
304
+ variable {U B : Type*}
305
+
306
+ noncomputable def jointResidueAffinePolynomial (q : ℕ) (r : U → ℤ)
307
+ (D : MvPolynomial (U ⊕ B) ℝ) : MvPolynomial (U ⊕ B) ℝ :=
308
+ aeval (Sum.elim (fun i => C (r i : ℝ) + C (q : ℝ) * X (Sum.inl i))
309
+ (fun j => X (Sum.inr j))) D
310
+
311
+ theorem jointResidueAffinePolynomial_eval (q : ℕ) (r : U → ℤ)
312
+ (D : MvPolynomial (U ⊕ B) ℝ) (u : U → ℝ) (b : B → ℝ) :
313
+ eval (Sum.elim u b) (jointResidueAffinePolynomial q r D) =
314
+ eval (Sum.elim (fun i => (r i : ℝ) + (q : ℝ) * u i) b) D := by
315
+ induction D using MvPolynomial.induction_on with
316
+ | C c => simp [jointResidueAffinePolynomial]
317
+ | add D E hD hE => simpa only [jointResidueAffinePolynomial, map_add] using congrArg₂ (· + ·) hD hE
318
+ | mul_X D i hD =>
319
+ cases i <;> simp [jointResidueAffinePolynomial, map_mul] at hD ⊢ <;> rw [hD] <;> simp
320
+
321
+ private theorem jointResidueAffine_variables_degree (w : B → ℕ) (q : ℕ) (r : U → ℤ)
322
+ (i : U ⊕ B) :
323
+ Sum.elim (fun j => C (r j : ℝ) + C (q : ℝ) * X (Sum.inl j))
324
+ (fun j => X (Sum.inr j)) i ∈
325
+ weightedSupportLE (Sum.elim (fun _ : U => 1) w) (Sum.elim (fun _ : U => 1) w i) := by
326
+ cases i with
327
+ | inl i =>
328
+ apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _)
329
+ simpa only [zero_add] using weightedSupportLE_mul
330
+ (weightedSupportLE_C (Sum.elim (fun _ : U => 1) w) 0 (q : ℝ))
331
+ (weightedSupportLE_X (Sum.elim (fun _ : U => 1) w) (Sum.inl i))
332
+ | inr j => exact weightedSupportLE_X (Sum.elim (fun _ : U => 1) w) (Sum.inr j)
333
+
334
+ theorem jointResidueAffinePolynomial_degree (w : B → ℕ) (q : ℕ) (r : U → ℤ)
335
+ {d : ℕ} {D : MvPolynomial (U ⊕ B) ℝ}
336
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) :
337
+ jointResidueAffinePolynomial q r D ∈
338
+ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d :=
339
+ weightedSupportLE_aeval _ _ _ (jointResidueAffine_variables_degree w q r) hD
340
+
341
+ theorem jointResidueAffinePolynomial_sub_axes_lower (w : B → ℕ) (q : ℕ) (r : U → ℤ)
342
+ {d : ℕ} {D : MvPolynomial (U ⊕ B) ℝ}
343
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) :
344
+ jointResidueAffinePolynomial q r D -
345
+ scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)) D ∈
346
+ weightedSupportLT (Sum.elim (fun _ : U => 1) w) d := by
347
+ let v := Sum.elim (fun _ : U => 1) w
348
+ let F : MvPolynomial (U ⊕ B) ℝ →ₐ[ℝ] MvPolynomial (U ⊕ B) ℝ := aeval (R := ℝ) (Sum.elim
349
+ (fun i => C (r i : ℝ) + C (q : ℝ) * X (Sum.inl i)) (fun j => X (Sum.inr j)))
350
+ let T := Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)
351
+ let G := aeval (R := ℝ) (fun i : U ⊕ B => C (T i) * X i)
352
+ have hF : ∀ i, F (X i) ∈ weightedSupportLE v (v i) := by
353
+ intro i
354
+ simpa only [F, aeval_X] using jointResidueAffine_variables_degree w q r i
355
+ have hG : ∀ i, G (X i) ∈ weightedSupportLE v (v i) := by
356
+ intro i
357
+ simpa only [G, aeval_X, zero_add] using
358
+ weightedSupportLE_mul (weightedSupportLE_C v 0 (T i)) (weightedSupportLE_X v i)
359
+ have hdiff : ∀ i, F (X i) - G (X i) ∈ weightedSupportLT v (v i) := by
360
+ intro i
361
+ cases i with
362
+ | inl i =>
363
+ simp only [F, G, T, aeval_X, Sum.elim_inl, add_sub_cancel_right]
364
+ exact weightedSupportLE_lt_succ (weightedSupportLE_C v 0 (r i : ℝ))
365
+ | inr j =>
366
+ simp only [F, G, T, aeval_X, Sum.elim_inr, map_one, one_mul, sub_self]
367
+ exact Submodule.zero_mem _
368
+ rw [scaleMvPolynomialAxes_eq_aeval]
369
+ exact weightedComparison_difference v v F G hF hG hdiff hD
370
+
371
+ theorem jointResidueAffinePolynomial_weightedHomogeneousComponent (w : B → ℕ)
372
+ (q d : ℕ) (r : U → ℤ) (D : MvPolynomial (U ⊕ B) ℝ)
373
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) :
374
+ weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d
375
+ (jointResidueAffinePolynomial q r D) =
376
+ scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1))
377
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d D) := by
378
+ have hlower := jointResidueAffinePolynomial_sub_axes_lower w q r hD
379
+ have hzero : weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d
380
+ (jointResidueAffinePolynomial q r D -
381
+ scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)) D) = 0 :=
382
+ weightedHomogeneousComponent_eq_zero' d _ (fun α hα => (hlower hα).ne)
383
+ rw [map_sub, sub_eq_zero] at hzero
384
+ rw [hzero, scaleMvPolynomialAxes_weightedHomogeneousComponent]
385
+
386
+ end Erdos3
387
+
388
+ end
389
+
390
+ section
391
+
392
+ namespace Erdos3
393
+ open MvPolynomial
394
+
395
+ variable {U B : Type*}
396
+
397
+ theorem jointResidueAffinePolynomial_weightedHomogeneousComponent_eval
398
+ (w : B → ℕ) (q d : ℕ) (r : U → ℤ) (D : MvPolynomial (U ⊕ B) ℝ)
399
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d)
400
+ (v : U → ℝ) (b : B → ℝ) :
401
+ eval (Sum.elim v b)
402
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d
403
+ (jointResidueAffinePolynomial q r D)) =
404
+ eval (Sum.elim (fun i => (q : ℝ) * v i) b)
405
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d D) := by
406
+ rw [jointResidueAffinePolynomial_weightedHomogeneousComponent w q d r D hD,
407
+ scaleMvPolynomialAxes_eval]
408
+ apply congrArg (fun x : U ⊕ B → ℝ => eval x _)
409
+ funext i
410
+ cases i <;> simp only [Sum.elim_inl, Sum.elim_inr, one_mul]
411
+
412
+ theorem algebraic_major_affine_top_dilation_identity
413
+ (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (n : ℕ)
414
+ (D : MvPolynomial (U ⊕ B) ℝ)
415
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n)
416
+ (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j)
417
+ (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ)
418
+ (q : ℕ) (r : U → ℤ) (T : U → ℝ)
419
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
420
+ eval (Sum.elim v b)
421
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n
422
+ (jointResidueAffinePolynomial q r D)) =
423
+ eval (Sum.elim (fun i => v i / T i)
424
+ (fun j => b j - eval v
425
+ (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S +
426
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
427
+ (v : U → ℝ) (b : B → ℝ) (hb : b ∈ K) :
428
+ eval (Sum.elim (fun i => (q : ℝ) * v i) b)
429
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) =
430
+ eval (Sum.elim (fun i => v i / T i)
431
+ (fun j => b j - eval (fun i => (q : ℝ) * v i) (majorTranslationTopCoordinates w A j))) S +
432
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R := by
433
+ have h := hsource v b hb
434
+ rw [jointResidueAffinePolynomial_weightedHomogeneousComponent_eval w q n r D hD] at h
435
+ simp only [majorTranslationTopCoordinates,
436
+ residueAffinePolynomial_weightedHomogeneousComponent_eval q _ r _ (hA _)] at h
437
+ exact h
438
+
439
+ theorem algebraic_major_affine_top_pullback_decomposition
440
+ (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (n : ℕ)
441
+ (D : MvPolynomial (U ⊕ B) ℝ)
442
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n)
443
+ (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j)
444
+ (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ)
445
+ (q : ℕ) (hq : 0 < q) (r : U → ℤ)
446
+ (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
447
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
448
+ eval (Sum.elim v b)
449
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n
450
+ (jointResidueAffinePolynomial q r D)) =
451
+ eval (Sum.elim (fun i => v i / T i)
452
+ (fun j => b j - eval v
453
+ (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S +
454
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
455
+ (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i)
456
+ (d l : ℕ) (hS : S.totalDegree ≤ d) (hR : R.totalDegree ≤ d)
457
+ (hSmass : realPolynomialMass S ≤ C)
458
+ (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) :
459
+ ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ),
460
+ (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
461
+ eval (Sum.elim u b)
462
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) =
463
+ eval (Sum.elim (fun i => u i / H i)
464
+ (fun j => b j - eval u (majorTranslationTopCoordinates w A j))) S' +
465
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧
466
+ realPolynomialMass S' ≤ c^d * C ∧ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧
467
+ (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) :=
468
+ algebraic_major_dilation_pullback_decomposition K _ _ S R q hq H T hH hT
469
+ (algebraic_major_affine_top_dilation_identity K w n D hD A hA S R q r T hsource)
470
+ c C hc hHT d l hS hR hSmass hRgrid
471
+
472
+ end Erdos3
473
+
474
+ end
475
+
476
+ section
477
+
478
+ namespace Erdos3
479
+
480
+ open MvPolynomial
481
+
482
+ variable {U B : Type*}
483
+
484
+ theorem algebraic_major_weighted_affine_top_pullback_decomposition
485
+ (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (hw : ∀ i, 0 < w i) (n : ℕ)
486
+ (D : MvPolynomial (U ⊕ B) ℝ)
487
+ (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n)
488
+ (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j)
489
+ (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ)
490
+ (q : ℕ) (hq : 0 < q) (r : U → ℤ)
491
+ (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i)
492
+ (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K →
493
+ eval (Sum.elim v b)
494
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n
495
+ (jointResidueAffinePolynomial q r D)) =
496
+ eval (Sum.elim (fun i => v i / T i)
497
+ (fun j => b j - eval v
498
+ (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S +
499
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R)
500
+ (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i)
501
+ (d l : ℕ)
502
+ (hS : S ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d)
503
+ (hR : R ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d)
504
+ (hSmass : realPolynomialMass S ≤ C)
505
+ (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) :
506
+ ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ),
507
+ S' = majorSlowDilationPullback q H T S ∧
508
+ R' = jointRationalPolynomialDilation q R ∧
509
+ (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K →
510
+ eval (Sum.elim u b)
511
+ (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) =
512
+ eval (Sum.elim (fun i => u i / H i)
513
+ (fun j => b j - eval u (majorTranslationTopCoordinates w A j))) S' +
514
+ eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧
515
+ realPolynomialMass S' ≤ c^d * C ∧
516
+ S' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧
517
+ R' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧
518
+ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧
519
+ (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) :=
520
+ algebraic_major_weighted_dilation_pullback_decomposition w hw K _ _ S R q hq H T hH hT
521
+ (algebraic_major_affine_top_dilation_identity K w n D hD A hA S R q r T hsource)
522
+ c C hc hHT d l hS hR hSmass hRgrid
523
+
524
+ end Erdos3
525
+
526
+ end
527
+
528
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResidueComparison.lean ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialInputStepLaw
2
+ import OAI.Combinatorics.Progressions.Sampling.AllocatedPeriodicGridQuadrature
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+ open scoped BigOperators Classical
10
+
11
+ theorem integerBox_residue_fiberLaw_l1
12
+ {I : Type*} [Fintype I] [DecidableEq I]
13
+ (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q]
14
+ (hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2) :
15
+ (∑ r : I → ZMod q,
16
+ |((integerBoxUniformWeights lo hi hlen).fiberLaw
17
+ (fun x => integerVectorResidue q (fun i => (x i).val))).weight r -
18
+ (FiniteProbabilityWeights.uniform (I → ZMod q)).weight r|) ≤
19
+ 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by
20
+ let E := 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)
21
+ let μ := (integerBoxUniformWeights lo hi hlen).fiberLaw
22
+ (fun x => integerVectorResidue q (fun i => (x i).val))
23
+ let u := FiniteProbabilityWeights.uniform (I → ZMod q)
24
+ have hc : (0 : ℝ) < (q : ℝ) ^ Fintype.card I := pow_pos (by exact_mod_cast NeZero.pos q) _
25
+ have hw (r : I → ZMod q) : |μ.weight r - u.weight r| ≤ E * u.weight r := by
26
+ have h := integerBox_residue_fiberLaw_relative_error lo hi hlen q r hsmall
27
+ change |(q : ℝ) ^ Fintype.card I * μ.weight r - 1| ≤ E at h
28
+ have hu : u.weight r = ((q : ℝ) ^ Fintype.card I)⁻¹ := by
29
+ simp only [u, FiniteProbabilityWeights.uniform, Fintype.card_fun, ZMod.card, Nat.cast_pow]
30
+ rw [hu]
31
+ have heq : μ.weight r - ((q : ℝ) ^ Fintype.card I)⁻¹ =
32
+ ((q : ℝ) ^ Fintype.card I * μ.weight r - 1) * ((q : ℝ) ^ Fintype.card I)⁻¹ := by
33
+ field_simp
34
+ rw [heq, abs_mul, abs_of_pos (inv_pos.mpr hc)]
35
+ exact mul_le_mul_of_nonneg_right h (inv_nonneg.mpr hc.le)
36
+ calc
37
+ _ ≤ ∑ r, E * u.weight r := Finset.sum_le_sum (fun r _ => hw r)
38
+ _ = E := by rw [← Finset.mul_sum, u.total, mul_one]
39
+
40
+ theorem integerBox_affine_residue_complexMean_error
41
+ {I Y : Type*} [Fintype I] [DecidableEq I]
42
+ (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q]
43
+ (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ)
44
+ (hf : ∀ y, ‖f y‖ ≤ 1)
45
+ (hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2) :
46
+ ‖(integerBoxUniformWeights lo hi hlen).complexMean
47
+ (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) -
48
+ (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean
49
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤
50
+ 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by
51
+ let μ := (integerBoxUniformWeights lo hi hlen).fiberLaw
52
+ (fun x => integerVectorResidue q (fun i => (x i).val))
53
+ let g := fun r : I → ZMod q => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i))
54
+ have h := (FiniteProbabilityWeights.norm_complexMean_sub_le_weight_l1 μ
55
+ (FiniteProbabilityWeights.uniform (I → ZMod q)) g (fun r => hf _)).trans
56
+ (integerBox_residue_fiberLaw_l1 lo hi hlen q hsmall)
57
+ dsimp only [μ] at h
58
+ rw [FiniteProbabilityWeights.fiberLaw_complexMean] at h
59
+ simpa only [g, integerVectorResidue, Int.cast_add, Int.cast_mul] using h
60
+
61
+ theorem integerBox_affine_residue_complexMean_error_unconditional
62
+ {I Y : Type*} [Fintype I] [DecidableEq I]
63
+ (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q]
64
+ (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ)
65
+ (hf : ∀ y, ‖f y‖ ≤ 1) :
66
+ ‖(integerBoxUniformWeights lo hi hlen).complexMean
67
+ (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) -
68
+ (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean
69
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤
70
+ 4 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by
71
+ by_cases hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2
72
+ · apply (integerBox_affine_residue_complexMean_error lo hi hlen q origin stride F f hf hsmall).trans
73
+ have hn : 0 ≤ ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) :=
74
+ Finset.sum_nonneg (fun i _ => div_nonneg (Nat.cast_nonneg _)
75
+ (by exact_mod_cast (sub_pos.mpr (hlen i)).le))
76
+ linarith
77
+ · have h1 := (integerBoxUniformWeights lo hi hlen).norm_complexMean_le_mean_norm
78
+ (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q))))
79
+ have h2 := (FiniteProbabilityWeights.uniform (I → ZMod q)).norm_complexMean_le_mean_norm
80
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))
81
+ have hb1 := (integerBoxUniformWeights lo hi hlen).mean_mono (fun x => hf
82
+ (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q))))
83
+ have hb2 := (FiniteProbabilityWeights.uniform (I → ZMod q)).mean_mono (fun r => hf
84
+ (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))
85
+ rw [FiniteProbabilityWeights.mean_const] at hb1 hb2
86
+ have ht := norm_sub_le
87
+ ((integerBoxUniformWeights lo hi hlen).complexMean
88
+ (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))))
89
+ ((FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean
90
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i))))
91
+ linarith
92
+
93
+ theorem originalActiveCube_affine_residue_complexMean_error
94
+ {I Y : Type*} [Fintype I] [DecidableEq I]
95
+ (L : I → ℕ) (hL : ∀ i, 0 < L i) (q : ℕ) [NeZero q]
96
+ (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ)
97
+ (hf : ∀ y, ‖f y‖ ≤ 1) :
98
+ ‖(FiniteProbabilityWeights.pi (fun i => integerScalarCubeWeights Empty (L i) (hL i))).complexMean
99
+ (fun x => f (F (fun i => ((origin i + stride i * (x i none : ℤ) : ℤ) : ZMod q)))) -
100
+ (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean
101
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤
102
+ 4 * ∑ i, (q : ℝ) / L i := by
103
+ have he := FiniteProbabilityWeights.complexMean_pi_transport_fintype
104
+ (fun i => integerScalarCubeWeights Empty (L i) (hL i))
105
+ (fun i => intervalUniformWeights 0 (L i : ℤ) (by exact_mod_cast hL i))
106
+ (fun _ x => (x none : ℤ)) (fun _ x => (x : ℤ))
107
+ (fun i g => integerScalarCubeWeights_zero_complexMean Empty (L i) (hL i) g)
108
+ (fun z : I → ℤ => f (F (fun i => ((origin i + stride i * z i : ℤ) : ZMod q))))
109
+ rw [he]
110
+ simpa only [integerBoxUniformWeights, sub_zero, Int.cast_natCast] using
111
+ integerBox_affine_residue_complexMean_error_unconditional (fun _ => 0)
112
+ (fun i => (L i : ℤ)) (fun i => by exact_mod_cast hL i) q origin stride F f hf
113
+
114
+ end Erdos3
115
+
116
+ end
117
+
118
+ section
119
+
120
+ namespace Erdos3
121
+ open scoped BigOperators Classical
122
+ variable {L V : Type*} [Fintype L] [Fintype V]
123
+ local instance activeCRTModulusNeZero (p A : L → ℕ) [∀ l, NeZero (p l)] :
124
+ NeZero (∏ l, p l ^ A l) :=
125
+ ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩
126
+
127
+ theorem originalActiveCube_crt_input_comparison
128
+ (length : V → ℕ) (hlength : ∀ v, 0 < length v)
129
+ (p A e : L → ℕ) [∀ l, NeZero (p l)]
130
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
131
+ (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k)))
132
+ (origin : ∀ l, V → ZMod (p l ^ A l))
133
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l)
134
+ (f : (V → ZMod q) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) :
135
+ let c : V → ℤ := fun v => (crtInput (fun l => p l ^ A l) hq origin v).val
136
+ let step : ℤ := (∏ l, p l ^ e l : ℕ)
137
+ ‖(FiniteProbabilityWeights.pi (fun v => integerScalarCubeWeights Empty (length v) (hlength v))).complexMean
138
+ (fun x => f (fun v => ((c v + step * (x v none : ℤ) : ℤ) : ZMod q))) -
139
+ (crtPolynomialInputLaw p A e hq origin).complexMean
140
+ (fun x => f (tupleResidueReduction hdiv x))‖ ≤
141
+ 4 * ∑ v, (q : ℝ) / length v := by
142
+ intro c step
143
+ rw [crtPolynomialInputLaw_divisor_integerOrigin_complexMean p A e hp hinj hq origin hdiv f]
144
+ simpa only [c, step, Int.cast_natCast, id_eq] using
145
+ originalActiveCube_affine_residue_complexMean_error length hlength q c (fun _ => step) id f hf
146
+
147
+ theorem crtPolynomialInputLaw_unrestricted_divisor_complexMean
148
+ (p A : L → ℕ) [∀ l, NeZero (p l)]
149
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
150
+ (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k)))
151
+ (origin : ∀ l, V → ZMod (p l ^ A l))
152
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l)
153
+ (f : (V → ZMod q) → ℂ) :
154
+ (crtPolynomialInputLaw p A (fun _ => 0) hq origin).complexMean
155
+ (fun x => f (tupleResidueReduction hdiv x)) =
156
+ (FiniteProbabilityWeights.uniform (V → ZMod q)).complexMean f := by
157
+ rw [crtPolynomialInputLaw_divisor_complexMean p A (fun _ => 0) hp hinj hq origin hdiv f]
158
+ simp only [pow_zero, Finset.prod_const_one, Nat.cast_one, one_mul]
159
+ rw [FiniteProbabilityWeights.uniform_complexMean, FiniteProbabilityWeights.uniform_complexMean]
160
+ exact Fintype.expect_equiv
161
+ (Equiv.addLeft (tupleResidueReduction hdiv (crtInput (fun l => p l ^ A l) hq origin)))
162
+ _ _ (fun _ => rfl)
163
+
164
+ theorem originalActiveCube_crt_unrestricted_input_comparison
165
+ (length : V → ℕ) (hlength : ∀ v, 0 < length v)
166
+ (p A : L → ℕ) [∀ l, NeZero (p l)]
167
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
168
+ (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k)))
169
+ (origin : ∀ l, V → ZMod (p l ^ A l))
170
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l)
171
+ (f : (V → ZMod q) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) :
172
+ ‖(FiniteProbabilityWeights.pi (fun v => integerScalarCubeWeights Empty (length v) (hlength v))).complexMean
173
+ (fun x => f (fun v => ((x v none : ℤ) : ZMod q))) -
174
+ (crtPolynomialInputLaw p A (fun _ => 0) hq origin).complexMean
175
+ (fun x => f (tupleResidueReduction hdiv x))‖ ≤
176
+ 4 * ∑ v, (q : ℝ) / length v := by
177
+ rw [crtPolynomialInputLaw_unrestricted_divisor_complexMean p A hp hinj hq origin hdiv f]
178
+ simpa only [zero_add, one_mul, Int.cast_one, Int.cast_zero, id_eq] using
179
+ originalActiveCube_affine_residue_complexMean_error length hlength q (fun _ => 0)
180
+ (fun _ => 1) id f hf
181
+
182
+ end Erdos3
183
+
184
+ end
185
+
186
+ section
187
+
188
+ namespace Erdos3
189
+
190
+ open scoped BigOperators Classical
191
+
192
+ variable {L A I J : Type*} [Fintype L] [Fintype A] [Fintype J] [DecidableEq J]
193
+
194
+ local instance unrestrictedForecastModulusNeZero (p e : L → ℕ) [∀ l, NeZero (p l)] :
195
+ NeZero (∏ l, p l ^ e l) :=
196
+ ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩
197
+
198
+ theorem rationalPolynomialForecast_unrestrictedCRT_marginal
199
+ (p e : L → ℕ) [∀ l, NeZero (p l)]
200
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
201
+ (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k)))
202
+ (origin : ∀ l, A → ZMod (p l ^ e l))
203
+ (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactive : I → ℤ)
204
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l)
205
+ (test : (J → ZMod q) → ℂ) :
206
+ (𝔼 b : J → ZMod (∏ l, p l ^ e l),
207
+ (rationalOutputDensity (crtPolynomialInputLaw p e (fun _ => 0) hcoprime origin)
208
+ (integerLongPolynomialOutput poly inactive (∏ l, p l ^ e l))
209
+ (∏ l, p l ^ e l) b : ℂ) *
210
+ test (fun j => ZMod.castHom hdiv (ZMod q) (b j))) =
211
+ 𝔼 t : A → ZMod q, test (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
212
+ (Sum.elim t (fun i => (inactive i : ZMod q))) (poly j)) := by
213
+ rw [rationalOutputDensity_divisor_test _ _ hdiv]
214
+ simp_rw [integerLongPolynomialOutput_reduce poly inactive hdiv]
215
+ exact (crtPolynomialInputLaw_unrestricted_divisor_complexMean p e hp hinj hcoprime origin hdiv
216
+ (fun t => test (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
217
+ (Sum.elim t (fun i => (inactive i : ZMod q))) (poly j)))).trans
218
+ (FiniteProbabilityWeights.uniform_complexMean _)
219
+
220
+ theorem rationalInactivePolynomialForecast_conditionalUnrestrictedCRT_tsum_marginal
221
+ {Ω Z : Type*} [Fintype Ω]
222
+ (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z)
223
+ (p e : L → ℕ) [∀ l, NeZero (p l)]
224
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
225
+ (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k)))
226
+ (origin : Ω → ∀ l, A → ZMod (p l ^ e l))
227
+ (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactiveCoord : Ω → I → ℤ)
228
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l)
229
+ {gridVolume : ℝ} (hV : gridVolume ≠ 0) (test : Z → (J → ZMod q) → ℂ) :
230
+ (∑' z, 𝔼 b : J → ZMod (∏ l, p l ^ e l),
231
+ ((rationalInactiveForecast inactive
232
+ (fun i => crtPolynomialInputLaw p e (fun _ => 0) hcoprime (origin i)) gridPoint
233
+ (fun i => integerLongPolynomialOutput poly (inactiveCoord i) (∏ l, p l ^ e l))
234
+ (∏ l, p l ^ e l) gridVolume z b / gridVolume : ℝ) : ℂ) *
235
+ test z (fun j => ZMod.castHom hdiv (ZMod q) (b j))) =
236
+ inactive.complexMean (fun i => 𝔼 t : A → ZMod q,
237
+ test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
238
+ (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j))) := by
239
+ rw [rationalInactiveForecast_divisor_tsum_test _ _ _ _ hdiv hV]
240
+ congr 1
241
+ funext i
242
+ simp_rw [integerLongPolynomialOutput_reduce poly (inactiveCoord i) hdiv]
243
+ exact (crtPolynomialInputLaw_unrestricted_divisor_complexMean p e hp hinj hcoprime (origin i) hdiv
244
+ (fun t => test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
245
+ (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j)))).trans
246
+ (FiniteProbabilityWeights.uniform_complexMean _)
247
+
248
+ theorem rationalInactivePolynomialForecast_unrestrictedCRT_tsum_marginal
249
+ {Ω Z : Type*} [Fintype Ω]
250
+ (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z)
251
+ (p e : L → ℕ) [∀ l, NeZero (p l)]
252
+ (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p)
253
+ (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k)))
254
+ (origin : ∀ l, A → ZMod (p l ^ e l))
255
+ (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactiveCoord : Ω → I → ℤ)
256
+ {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l)
257
+ {gridVolume : ℝ} (hV : gridVolume ≠ 0) (test : Z → (J → ZMod q) → ℂ) :
258
+ (∑' z, 𝔼 b : J → ZMod (∏ l, p l ^ e l),
259
+ ((rationalInactiveForecast inactive
260
+ (fun _ => crtPolynomialInputLaw p e (fun _ => 0) hcoprime origin) gridPoint
261
+ (fun i => integerLongPolynomialOutput poly (inactiveCoord i) (∏ l, p l ^ e l))
262
+ (∏ l, p l ^ e l) gridVolume z b / gridVolume : ℝ) : ℂ) *
263
+ test z (fun j => ZMod.castHom hdiv (ZMod q) (b j))) =
264
+ inactive.complexMean (fun i => 𝔼 t : A → ZMod q,
265
+ test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
266
+ (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j))) :=
267
+ rationalInactivePolynomialForecast_conditionalUnrestrictedCRT_tsum_marginal
268
+ inactive gridPoint p e hp hinj hcoprime (fun _ => origin) poly inactiveCoord hdiv hV test
269
+
270
+ end Erdos3
271
+
272
+ end
273
+
274
+ section
275
+
276
+ namespace Erdos3.VectorPolynomial
277
+
278
+ open scoped BigOperators Classical
279
+
280
+ variable {m : ℕ} {G : Type*} [Fintype G]
281
+ variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ}
282
+ variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)]
283
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)]
284
+ variable (U : ∀ j, Submodule ℝ (J j → ℝ))
285
+ variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
286
+ variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ)
287
+
288
+ local notation "degree" => layerSamplerDegree I n
289
+ local notation "short" => allocatedShortAxis (I := I) U basis S.value
290
+ local notation "sides" => allocatedPrincipalSides B U basis S
291
+ local notation "hSides" => allocatedPrincipalSides_pos B U basis S
292
+ local notation "Active" => {a : LayerSamplerAxis I n // ¬short a}
293
+ local notation "activeB" => (fun a : Active => B (Subtype.val a))
294
+ local notation "activeDegree" => (fun a : Active => degree (Subtype.val a))
295
+ local notation "ActiveInput" => PrincipalTupleIndex activeB activeDegree
296
+ local notation "activeLength" => principalAxisLength (fun a => ¬short a) sides
297
+ local notation "activePos" => (fun j : ActiveInput => hSides (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)))
298
+ local notation "Original" => PrincipalIntegerTuples B degree Empty sides
299
+
300
+ variable (q : ℕ)
301
+ variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q)
302
+ variable (hcell : 0 < (principalTupleWeights (α := Empty) B (layerSamplerDegree I n)
303
+ (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass
304
+ (Finset.univ.filter (fun y => principalResidueLabel q y = r)))
305
+
306
+ noncomputable def allocatedShortPrincipalResidueLaw :=
307
+ principalSupportedAxisWeights B degree sides hSides q r hcell short
308
+
309
+ noncomputable def allocatedActivePrincipalResidueLaw :=
310
+ principalSupportedAxisWeights B degree sides hSides q r hcell (fun a => ¬short a)
311
+
312
+ theorem allocatedPrincipalResidue_partition (f : Original → ℂ) :
313
+ ((principalTupleWeights (α := Empty) B degree sides hSides).condition
314
+ (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean f =
315
+ (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean (fun u =>
316
+ (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean
317
+ (fun v => f (principalAxisJoin short u v))) :=
318
+ principalSupportedResidueWeights_partition B degree sides hSides q r hcell short f
319
+
320
+ theorem allocatedActivePrincipalResidue_length (j : ActiveInput) : activeLength j = S.value :=
321
+ allocatedPrincipalSides_long_of_not_short B U basis S j.1.val j.1.property j.2.1 j.2.2
322
+
323
+ theorem allocatedActivePrincipalResidueLaw_eq (hq : 0 < q) (hsize : q ≤ S.value) :
324
+ allocatedActivePrincipalResidueLaw B U basis S q r hcell =
325
+ principalResidueWeights activeB activeDegree activeLength activePos q hq
326
+ (fun j => r ⟨j.1.val, j.2⟩)
327
+ (fun j => by simpa only [Fintype.card_empty, zero_add, one_mul,
328
+ allocatedActivePrincipalResidue_length B U basis S] using hsize) := by
329
+ exact principalSupportedAxisWeights_eq_residueWeights B degree sides hSides q r hcell
330
+ (fun a => ¬short a) hq _
331
+
332
+ theorem allocatedPrincipalResidue_partition_mul
333
+ (φ : PrincipalAxisTuples (α := Empty) short sides → ℂ)
334
+ (ψ : PrincipalAxisTuples (α := Empty) (fun a => ¬short a) sides → ℂ) :
335
+ ((principalTupleWeights (α := Empty) B degree sides hSides).condition
336
+ (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean
337
+ (fun y => φ (principalAxisRestrict short y) *
338
+ ψ (principalAxisRestrict (fun a => ¬short a) y)) =
339
+ (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean φ *
340
+ (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean ψ :=
341
+ principalSupportedResidueWeights_partition_mul B degree sides hSides q r hcell short φ ψ
342
+
343
+ private theorem scalarResidueIntegerMean_congr
344
+ (L₁ L₂ q : ℕ) (hL₁ : 0 < L₁) (hL₂ : 0 < L₂) (hq : 0 < q)
345
+ (r : Option Empty → ZMod q) (hsize₁ : (Fintype.card Empty + 1) * q ≤ L₁)
346
+ (hsize₂ : (Fintype.card Empty + 1) * q ≤ L₂) (he : L₁ = L₂) (f : ℤ → ℂ) :
347
+ (scalarCubeResidueWeights Empty L₁ q hL₁ (fun _ => q) r
348
+ (fun _ => hq) (fun _ => le_rfl) hsize₁).complexMean (fun z => f (z none : ℤ)) =
349
+ (scalarCubeResidueWeights Empty L₂ q hL₂ (fun _ => q) r
350
+ (fun _ => hq) (fun _ => le_rfl) hsize₂).complexMean (fun z => f (z none : ℤ)) := by
351
+ subst L₂
352
+ rfl
353
+
354
+ theorem allocatedActivePrincipalResidueLaw_integer_mean (hq : 0 < q) (hsize : q ≤ S.value)
355
+ (f : (ActiveInput → ℤ) → ℂ) :
356
+ (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean
357
+ (fun y => f (fun j => (y j none : ℤ))) =
358
+ (principalResidueWeights activeB activeDegree (fun _ => S.value) (fun _ => S.positive)
359
+ q hq (fun j => r ⟨j.1.val, j.2⟩)
360
+ (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean
361
+ (fun y => f (fun j => (y j none : ℤ))) := by
362
+ rw [allocatedActivePrincipalResidueLaw_eq B U basis S q r hcell hq hsize]
363
+ exact FiniteProbabilityWeights.complexMean_pi_transport_fintype
364
+ (fun j => scalarCubeResidueWeights Empty (activeLength j) q (activePos j)
365
+ (fun _ => q) (r ⟨j.1.val, j.2⟩) (fun _ => hq) (fun _ => le_rfl)
366
+ (by simpa only [Fintype.card_empty, zero_add, one_mul,
367
+ allocatedActivePrincipalResidue_length B U basis S] using hsize))
368
+ (fun j => scalarCubeResidueWeights Empty S.value q S.positive
369
+ (fun _ => q) (r ⟨j.1.val, j.2⟩) (fun _ => hq) (fun _ => le_rfl)
370
+ (by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize))
371
+ (fun _ z => (z none : ℤ)) (fun _ z => (z none : ℤ))
372
+ (fun j g => scalarResidueIntegerMean_congr (activeLength j) S.value q (activePos j)
373
+ S.positive hq (r ⟨j.1.val, j.2⟩) _ _
374
+ (allocatedActivePrincipalResidue_length B U basis S j) g) f
375
+
376
+ theorem allocatedPrincipalResidue_integer_partition (hq : 0 < q) (hsize : q ≤ S.value)
377
+ (f : PrincipalAxisTuples (α := Empty) short sides → (ActiveInput → ℤ) → ℂ) :
378
+ ((principalTupleWeights (α := Empty) B degree sides hSides).condition
379
+ (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean
380
+ (fun y => f (principalAxisRestrict short y)
381
+ (fun j => ((principalAxisRestrict (fun a => ¬short a) y) j none : ℤ))) =
382
+ (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean (fun u =>
383
+ (principalResidueWeights activeB activeDegree (fun _ => S.value) (fun _ => S.positive)
384
+ q hq (fun j => r ⟨j.1.val, j.2⟩)
385
+ (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean
386
+ (fun v => f u (fun j => (v j none : ℤ)))) := by
387
+ rw [allocatedPrincipalResidue_partition B U basis S q r hcell]
388
+ simp only [principalAxisRestrict_join_left, principalAxisRestrict_join_right]
389
+ congr 1
390
+ funext u
391
+ exact allocatedActivePrincipalResidueLaw_integer_mean B U basis S q r hcell hq hsize (f u)
392
+
393
+ end Erdos3.VectorPolynomial
394
+
395
+ end
396
+
397
+ section
398
+
399
+ namespace Erdos3.VectorPolynomial
400
+ open scoped BigOperators Classical
401
+ variable {m : ℕ} {G : Type*} [Fintype G]
402
+ variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ}
403
+ variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)]
404
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)]
405
+ variable (U : ∀ j, Submodule ℝ (J j → ℝ))
406
+ variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
407
+ variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ)
408
+ local notation "short" => allocatedShortAxis (I := I) U basis S.value
409
+ local notation "Active" => {a : LayerSamplerAxis I n // ¬short a}
410
+ local notation "AB" => (fun a : Active => B (Subtype.val a))
411
+ local notation "Ah" => (fun a : Active => layerSamplerDegree I n (Subtype.val a))
412
+ local notation "AI" => PrincipalTupleIndex AB Ah
413
+ local notation "L" => principalAxisLength (fun a => ¬short a) (allocatedPrincipalSides B U basis S)
414
+ local notation "hL" => (fun j : AI => allocatedPrincipalSides_pos B U basis S (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)))
415
+
416
+ theorem allocatedActive_affine_residue_comparison
417
+ {Y : Type*} (q : ℕ) [NeZero q] (origin stride : AI → ℤ)
418
+ (F : (AI → ZMod q) → Y) (f : Y → ℂ) (hf : ∀ y, ‖f y‖ ≤ 1) :
419
+ ‖(principalTupleWeights (α := Empty) AB Ah L hL).complexMean
420
+ (fun x => f (F (fun i => ((origin i + stride i * (x i none : ℤ) : ℤ) : ZMod q)))) -
421
+ (FiniteProbabilityWeights.uniform (AI → ZMod q)).complexMean
422
+ (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤
423
+ 4 * Fintype.card AI * ((q : ℝ) / S.value) := by
424
+ classical
425
+ have he := originalActiveCube_affine_residue_complexMean_error L hL q origin stride F f hf
426
+ have hs : (∑ i : AI, (q : ℝ) / L i) = Fintype.card AI * ((q : ℝ) / S.value) := by
427
+ simp only [allocatedActivePrincipalResidue_length B U basis S, Finset.sum_const,
428
+ Finset.card_univ, nsmul_eq_mul]
429
+ rw [hs] at he
430
+ exact he.trans_eq (by ring)
431
+
432
+ end Erdos3.VectorPolynomial
433
+
434
+ end
435
+
436
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResiduePointMass.lean ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.AllocatedSupportedResidueSpectrum
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.VectorPolynomial
8
+
9
+ open scoped BigOperators Classical NNReal
10
+
11
+ variable {m : ℕ} {G : Type*} [Fintype G]
12
+ variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)]
13
+ variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*)
14
+ variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)]
15
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)]
16
+ variable (U : ∀ j, Submodule ℝ (J j → ℝ))
17
+ variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
18
+ variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j)
19
+ variable (S : LayerSamplerScale (G := G) B U basis R σ)
20
+ variable {α : Type*} [Fintype α] [DecidableEq α]
21
+ variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q)
22
+ variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n)
23
+ (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass
24
+ (Finset.univ.filter (fun y => principalResidueLabel q y = r)))
25
+ variable (j : Fin m) (i : Fin (n j))
26
+
27
+ variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i)
28
+ variable (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value)
29
+
30
+ local notation "sources" => allocatedActiveResidueSources B U basis S j i hactive q hq r hsize
31
+ local notation "csource" => allocatedPrincipalNormalizedSource B U basis hR S j i hactive
32
+ local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i))
33
+ local notation "torus" => blockTorusFactor (Fintype.card α) (j.val + 1)
34
+ (Fintype.card (B (Sigma.mk j (Sum.inr i)))) (4 * gamma)
35
+
36
+ omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in
37
+ noncomputable def allocatedActiveResiduePointApproximation
38
+ (M : ℕ) [NeZero M] (rows : Finset (Finset α)) (shift z : rows → ℤ)
39
+ (F : Finset (rows → Fin M)) : ℂ :=
40
+ if ∀ t, |(z t : ℝ) - shift t| ≤
41
+ blockJetScaleBound (Fintype.card α) (j.val + 1) (Fintype.card (B ⟨j, Sum.inr i⟩))
42
+ (4 * gamma) * basisAxisScale (basis j) i then
43
+ weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources
44
+ (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F
45
+ else 0
46
+
47
+ theorem allocatedActiveResiduePointMass_error_of_tail
48
+ {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i)
49
+ (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1)
50
+ (shift z : rows → ℤ)
51
+ (F : Finset (rows → Fin M)) {ε : ℝ} (hε : 0 ≤ ε)
52
+ (htail : spectrumTail F (fun k => ‖∏ b : B ⟨j, Sum.inr i⟩,
53
+ weightedModerateGridCoefficient csource ((sources) b) 0 M rows k‖) ≤ ε) :
54
+ ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card *
55
+ (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift z).toReal : ℝ) : ℂ) -
56
+ allocatedActiveResiduePointApproximation B U basis hR S q r j i hactive hq hsize
57
+ M rows shift z F‖ ≤ ε := by
58
+ have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _
59
+ exact weightedModeratePointMass_error_cutoff (fun _ : B ⟨j, Sum.inr i⟩ => csource)
60
+ sources (fun _ => 0) (by positivity) (basisAxisScale_pos (basis j) i)
61
+ (allocatedActiveResidueSources_volume B U basis S j i hactive q hq r hsize hR)
62
+ hM rows hrows shift z
63
+ (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift)
64
+ (allocatedSupportedResidueJetPMF_source B U basis hR hσ S q r hcell j i hactive hq hsize rows shift)
65
+ F hε (by
66
+ simp only [Int.cast_zero]
67
+ exact htail)
68
+
69
+ theorem allocatedActiveResiduePointMass_error_of_grid
70
+ (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩)
71
+ (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ)
72
+ (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P)
73
+ (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P)
74
+ {ζ ε : ℝ} {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i)
75
+ (hζ : 0 < ζ) (hζ1 : ζ ≤ 1) (hε : 0 ≤ ε)
76
+ (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1)
77
+ (hB : positiveModerateSpectrumBlockCount j.val rows.card
78
+ ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩))
79
+ (haccuracy : (2 * positiveModerateSpectrumConstant j.val rows.card P ((torus : ℝ) / (2 * gamma)) *
80
+ 2 ^ positiveModerateSpectrumExponent j.val rows.card +
81
+ (torus : ℝ) ^ rows.card *
82
+ (2 ^ positiveModerateLengthExponent j.val * positiveModerateLengthConstant j.val P) ^
83
+ ((layerTailDegree m + 1) * rows.card)) * ζ ≤ ε)
84
+ (shift z : rows → ℤ) :
85
+ ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card *
86
+ (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift z).toReal : ℝ) : ℂ) -
87
+ allocatedActiveResiduePointApproximation B U basis hR S q r j i hactive hq hsize
88
+ M rows shift z
89
+ (positiveModerateSpectrumCover rows M j.val P ((torus : ℝ) / (2 * gamma)) S.value ζ)‖ ≤ ε := by
90
+ have hMK : (M : ℝ) ≤ (torus : ℝ) * basisAxisScale (basis j) i := by
91
+ simp only [hM, Nat.cast_mul, le_refl]
92
+ apply allocatedActiveResiduePointMass_error_of_tail B U basis hR hσ S q r hcell j i hactive hq hsize
93
+ hM rows hrows shift z _ hε
94
+ exact allocatedActiveResidueSpectrum_tail B U basis S j i hactive q hq r hsize hR
95
+ A hA P hcP hsP (Nat.cast_nonneg torus) (pow_nonneg (Nat.cast_nonneg torus) _)
96
+ hζ hζ1 hε (Nat.pos_of_ne_zero (NeZero.ne M)) hMK rows hrows hB
97
+ (allocatedGrid_modulus_cardinality B U basis S j i hgrid (Nat.cast_nonneg torus) hMK rows.card)
98
+ haccuracy
99
+
100
+ end Erdos3.VectorPolynomial
101
+
102
+ end
103
+
104
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActualCRTRationalMarginal.lean ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.AllocatedActualRationalMarginal
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.VectorPolynomial
8
+
9
+ open MeasureTheory
10
+ open scoped BigOperators Classical
11
+
12
+ variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X]
13
+ variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] {n : Fin m → ℕ}
14
+ variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)]
15
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)]
16
+ variable (U : ∀ j, Submodule ℝ (J j → ℝ))
17
+ variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
18
+ variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ)
19
+
20
+ local notation "short" => allocatedShortAxis (I := I) U basis S.value
21
+ local notation "degree" => layerSamplerDegree I n
22
+ local notation "sides" => allocatedPrincipalSides B U basis S
23
+ local notation "hSides" => allocatedPrincipalSides_pos B U basis S
24
+ local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides
25
+ local notation "Long" => LayerSamplerLongVariables short G B
26
+ local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E short)
27
+ local notation "law" => principalTupleWeights (α := Empty) B degree sides hSides
28
+
29
+ variable {PrimeIndex : Type*} [Fintype PrimeIndex]
30
+ variable (primes exponent : PrimeIndex → ℕ) [∀ l, NeZero (primes l)]
31
+ local notation "N" => (∏ l, primes l ^ exponent l)
32
+ local instance actualCRTModulusNeZero : NeZero N :=
33
+ ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (primes l)))⟩
34
+
35
+ theorem allocatedActual_crtRationalForecast_tsum_marginal
36
+ (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j)
37
+ {A : Type*} (selected : A → Σ j : Fin m, Fin (n j))
38
+ (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤
39
+ S.value ^ ((selected a).1.val + 1))
40
+ (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B)
41
+ ((selected a).1.val + 1) → ℤ)
42
+ (hc : ∀ a d, c a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S
43
+ (selected a).1 (selected a).2 d).support)
44
+ (x : G → IntegerScalarCubeBox Empty S.value)
45
+ (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ)
46
+ (deck : ∀ j : Fin m,
47
+ BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ)
48
+ (projection : ∀ j, AllocatedDegreeActiveAxis short j →
49
+ BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ)
50
+ (hp : ∀ l, (primes l).Prime) (hinj : Function.Injective primes)
51
+ (hcoprime : Pairwise (fun l k => (primes l ^ exponent l).Coprime (primes k ^ exponent k)))
52
+ (origin : ∀ l, Long → ZMod (primes l ^ exponent l))
53
+ {q : ℕ} [NeZero q] (hq : q ∣ N)
54
+ {gridVolume : ℝ} (hV : gridVolume ≠ 0)
55
+ (test : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ) →
56
+ (Out → ZMod q) → ℂ) :
57
+ let poly := allocatedForecastPolynomial short base noise deck projection
58
+ (∑' z, 𝔼 b : Out → ZMod N,
59
+ ((rationalInactiveForecast (law)
60
+ (fun _ => crtPolynomialInputLaw primes exponent (fun _ => 0) hcoprime origin)
61
+ (forecastInactiveFixedOutput B U basis S selected c x)
62
+ (fun v => integerLongPolynomialOutput poly (fun k => (v k.1 k.2 : ℤ)) N)
63
+ N gridVolume z b / gridVolume : ℝ) : ℂ) *
64
+ test z (fun j => ZMod.castHom hq (ZMod q) (b j))) =
65
+ (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u =>
66
+ 𝔼 t : Long → ZMod q,
67
+ test (forecastInactiveShortGrid B U basis S selected c u)
68
+ (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q))
69
+ (Sum.elim t (fun k => (allocatedShortPrincipalRaw B U basis S u k : ZMod q)))
70
+ (poly o))) := by
71
+ intro poly
72
+ have hcrt := rationalInactivePolynomialForecast_unrestrictedCRT_tsum_marginal (law)
73
+ (forecastInactiveFixedOutput B U basis S selected c x) primes exponent hp hinj hcoprime origin
74
+ poly (fun v k => (v k.1 k.2 : ℤ)) hq hV test
75
+ have huniform := rationalInactivePolynomialForecast_tsum_marginal (law)
76
+ (forecastInactiveFixedOutput B U basis S selected c x) poly
77
+ (fun v k => (v k.1 k.2 : ℤ)) hq hV test
78
+ exact hcrt.trans (huniform.symm.trans
79
+ (allocatedActual_rationalForecast_tsum_marginal B U basis S hR hσ selected hsmall c hc x
80
+ base noise deck projection hq hV test))
81
+
82
+ end Erdos3.VectorPolynomial
83
+
84
+ end
85
+
86
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineAnalyticBudget.lean ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.AllocatedFiniteIdealMaskBudget
2
+ import OAI.Combinatorics.Progressions.Sampling.AllocatedSlicedGridResourceBudget
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3.VectorPolynomial
9
+
10
+ open scoped NNReal
11
+
12
+ theorem allocatedAffineFactor_exp_bound {B Q Op Pper cutoff coord Qgrid Mp period r radius : ℝ}
13
+ (axes gridaxes : ℕ) (hB : 0 ≤ B) (hQ : 0 ≤ Q) (hOp : 0 ≤ Op) (hPper : 0 ≤ Pper)
14
+ (ha : (axes : ℝ) ≤ B) (hg : (gridaxes : ℝ) ≤ B)
15
+ (hc0 : 0 ≤ cutoff) (hcoord0 : 0 ≤ coord) (hgrid0 : 0 ≤ Qgrid) (hMp0 : 0 ≤ Mp)
16
+ (hper0 : 0 ≤ period) (hc : cutoff ≤ Real.exp B) (hcoord : coord ≤ Real.exp B)
17
+ (hQgrid : Qgrid ≤ Real.exp B) (hMp : Mp ≤ Real.exp Pper) (hper : period ≤ Real.exp Pper)
18
+ (hr : 1 ≤ r) (hradius : 1 ≤ radius) :
19
+ let Llong := (axes * cutoff / (2 * r)) * coord +
20
+ max ((Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius)) * coord * Mp) (4 * Mp)
21
+ let Lgrid := max (gridaxes * Real.exp Op * Qgrid * coord * (Real.exp Op) ^ gridaxes)
22
+ (4 * (Real.exp Op) ^ gridaxes)
23
+ (Llong + Lgrid) * (period * (Real.exp Op) ^ gridaxes) ≤
24
+ Real.exp (10 * B + 6 * Q + 2 * Pper + (2 * B + 1) * Op + 19) := by
25
+ intro Llong Lgrid
26
+ have hax : (axes : ℝ) ≤ Real.exp B := ha.trans (by linarith [Real.add_one_le_exp B])
27
+ have hgx : (gridaxes : ℝ) ≤ Real.exp B := hg.trans (by linarith [Real.add_one_le_exp B])
28
+ have hcut (z : ℝ) (hz : 1 ≤ z) : (axes : ℝ) * cutoff / (2 * z) ≤ Real.exp (2 * B) := by
29
+ calc
30
+ _ ≤ (axes : ℝ) * cutoff := div_le_self (mul_nonneg (Nat.cast_nonneg _) hc0) (by linarith)
31
+ _ ≤ Real.exp B * Real.exp B := mul_le_mul hax hc hc0 (Real.exp_nonneg _)
32
+ _ = _ := by rw [← Real.exp_add, ← two_mul]
33
+ have hfirst : (axes * cutoff / (2 * r)) * coord ≤ Real.exp (3 * B) := by
34
+ calc
35
+ _ ≤ Real.exp (2 * B) * Real.exp B := mul_le_mul (hcut r hr) hcoord hcoord0 (Real.exp_nonneg _)
36
+ _ = _ := by rw [← Real.exp_add]; congr 1; ring
37
+ have hsum : Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius) ≤
38
+ Real.exp (3 * B + 6 * Q + 13) := by
39
+ have hs := add_le_exp_add_one (show 0 ≤ B + 6 * Q + 12 by positivity)
40
+ (show 0 ≤ 2 * B by positivity)
41
+ (Real.exp_le_exp.mpr (add_le_add (add_le_add ha le_rfl) le_rfl)) (hcut radius hradius)
42
+ exact hs.trans_eq (by congr 1; ring)
43
+ have hsecond : (Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius)) * coord * Mp ≤
44
+ Real.exp (4 * B + 6 * Q + Pper + 13) := by
45
+ calc
46
+ _ ≤ Real.exp (3 * B + 6 * Q + 13) * Real.exp B * Real.exp Pper :=
47
+ mul_le_mul (mul_le_mul hsum hcoord hcoord0 (Real.exp_nonneg _)) hMp hMp0 (by positivity)
48
+ _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring
49
+ have hfour : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)]
50
+ have hthird : 4 * Mp ≤ Real.exp (4 * B + 6 * Q + Pper + 13) := by
51
+ calc
52
+ _ ≤ Real.exp 4 * Real.exp Pper := mul_le_mul hfour hMp hMp0 (Real.exp_nonneg _)
53
+ _ = Real.exp (4 + Pper) := (Real.exp_add _ _).symm
54
+ _ ≤ _ := Real.exp_le_exp.mpr (by linarith)
55
+ have hlong : Llong ≤ Real.exp (7 * B + 6 * Q + Pper + 14) := by
56
+ have h := add_le_exp_add_one (show 0 ≤ 3 * B by positivity)
57
+ (show 0 ≤ 4 * B + 6 * Q + Pper + 13 by positivity) hfirst (max_le hsecond hthird)
58
+ exact h.trans_eq (by congr 1; ring)
59
+ have hpower : (Real.exp Op) ^ gridaxes ≤ Real.exp (B * Op) := by
60
+ rw [← Real.exp_nat_mul]
61
+ exact Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hg hOp)
62
+ have hgridFirst : gridaxes * Real.exp Op * Qgrid * coord * (Real.exp Op) ^ gridaxes ≤
63
+ Real.exp (3 * B + (B + 1) * Op) := by
64
+ calc
65
+ _ ≤ Real.exp B * Real.exp Op * Real.exp B * Real.exp B * Real.exp (B * Op) := by gcongr
66
+ _ = _ := by simp only [← Real.exp_add]; congr 1; ring
67
+ have hgrid : Lgrid ≤ Real.exp (3 * B + (B + 1) * Op + 4) := by
68
+ apply max_le
69
+ · exact hgridFirst.trans (Real.exp_le_exp.mpr (by linarith))
70
+ · calc
71
+ _ ≤ Real.exp 4 * Real.exp (B * Op) := mul_le_mul hfour hpower (by positivity) (Real.exp_nonneg _)
72
+ _ = Real.exp (4 + B * Op) := (Real.exp_add _ _).symm
73
+ _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith)
74
+ have hboth := add_le_exp_add_one (show 0 ≤ 7 * B + 6 * Q + Pper + 14 by positivity)
75
+ (show 0 ≤ 3 * B + (B + 1) * Op + 4 by positivity) hlong hgrid
76
+ have hcover : period * (Real.exp Op) ^ gridaxes ≤ Real.exp (Pper + B * Op) :=
77
+ (mul_le_mul hper hpower (by positivity) (Real.exp_nonneg _)).trans_eq (Real.exp_add _ _).symm
78
+ calc
79
+ _ ≤ Real.exp ((7 * B + 6 * Q + Pper + 14) + (3 * B + (B + 1) * Op + 4) + 1) *
80
+ Real.exp (Pper + B * Op) := mul_le_mul hboth hcover (by positivity) (Real.exp_nonneg _)
81
+ _ = _ := by rw [← Real.exp_add]; congr 1; ring
82
+
83
+ theorem allocatedAffineCover_exp_bound {B Op Pper period : ℝ}
84
+ (gridaxes : ℕ) (hB : 0 ≤ B) (hOp : 0 ≤ Op)
85
+ (hg : (gridaxes : ℝ) ≤ B) (hperiod : period ≤ Real.exp Pper) :
86
+ period * (Real.exp Op) ^ gridaxes ≤ Real.exp (Pper + B * Op) := by
87
+ have hpower : (Real.exp Op) ^ gridaxes ≤ Real.exp (B * Op) := by
88
+ rw [← Real.exp_nat_mul]
89
+ exact Real.exp_le_exp.mpr (mul_le_mul hg le_rfl hOp hB)
90
+ exact (mul_le_mul hperiod hpower (by positivity) (Real.exp_nonneg _)).trans_eq
91
+ (Real.exp_add _ _).symm
92
+
93
+ theorem allocatedAffineFactor_nnreal_exp_bound {B Q Op Pper : ℝ}
94
+ (cutoff coord Qgrid Mp period r radius : ℝ≥0) (axes gridaxes : ℕ)
95
+ (hB : 0 ≤ B) (hQ : 0 ≤ Q) (hOp : 0 ≤ Op) (hPper : 0 ≤ Pper)
96
+ (ha : (axes : ℝ) ≤ B) (hg : (gridaxes : ℝ) ≤ B)
97
+ (hc : (cutoff : ℝ) ≤ Real.exp B) (hcoord : (coord : ℝ) ≤ Real.exp B)
98
+ (hQgrid : (Qgrid : ℝ) ≤ Real.exp B) (hMp : (Mp : ℝ) ≤ Real.exp Pper)
99
+ (hper : (period : ℝ) ≤ Real.exp Pper) (hr : 1 ≤ r) (hradius : 1 ≤ radius) :
100
+ let Llong : ℝ≥0 := (axes * cutoff / (2 * r)) * coord +
101
+ max ((⟨Real.exp (axes + 6 * Q + 12), Real.exp_nonneg _⟩ + axes * cutoff / (2 * radius)) * coord * Mp) (4 * Mp)
102
+ let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg _⟩
103
+ let Lgrid : ℝ≥0 := max (gridaxes * Lprimitive * Qgrid * coord * Lprimitive ^ gridaxes)
104
+ (4 * Lprimitive ^ gridaxes)
105
+ (((Llong + Lgrid) * (period * Lprimitive ^ gridaxes) : ℝ≥0) : ℝ) ≤
106
+ Real.exp (10 * B + 6 * Q + 2 * Pper + (2 * B + 1) * Op + 19) := by
107
+ exact
108
+ allocatedAffineFactor_exp_bound axes gridaxes hB hQ hOp hPper ha hg
109
+ cutoff.coe_nonneg coord.coe_nonneg Qgrid.coe_nonneg Mp.coe_nonneg period.coe_nonneg
110
+ hc hcoord hQgrid hMp hper (show (1 : ℝ) ≤ r from hr) (show (1 : ℝ) ≤ radius from hradius)
111
+
112
+ end Erdos3.VectorPolynomial
113
+
114
+ end
115
+
116
+ section
117
+
118
+ namespace Erdos3.VectorPolynomial
119
+ open scoped BigOperators
120
+
121
+ theorem exists_allocatedAffineModelMass_budget (m dim : ℕ) :
122
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {D p v F Prho Pk target : ℝ},
123
+ 0 ≤ D → 0 ≤ p → 0 ≤ v → 0 ≤ F → 0 ≤ Prho → 0 ≤ Pk → 0 ≤ target →
124
+ ∀ (outputs axes gridaxes ambient : ℕ),
125
+ (outputs : ℝ) ≤ D → (axes : ℝ) ≤ D → (gridaxes : ℝ) ≤ D → (ambient : ℝ) ≤ D →
126
+ (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D →
127
+ let Eg := outputs * Prho + (target + F) + 1
128
+ let Op := allocatedSlicedGridResourceLog m dim D p v Eg
129
+ let Plong := ((m : ℝ) + 2) * dim + m + 4 + Prho + axes * max Op 0 + (target + F) + 2
130
+ let Q := idealSiteLogBudget outputs dim Plong
131
+ 2 * (2 : ℝ) ^ dim + F + (2 : ℝ) ^ dim * (ambient * ((m + 1 : ℕ) * Pk)) +
132
+ ((2 : ℝ) ^ dim * axes * (4 * Q + 8) + Q) + gridaxes * Op ≤
133
+ (D + p + v + F + Prho + Pk + target + A) ^ A := by
134
+ obtain ⟨b, hb, hgrid⟩ := exists_allocatedSlicedGridResource_budget m dim
135
+ let X : Polynomial ℕ := Polynomial.X
136
+ let O : Polynomial ℕ := (3 * X + (X ^ 2 + 2 * X + 1) + Polynomial.C b) ^ b
137
+ let Pbox : Polynomial ℕ := Polynomial.C ((m + 2) * dim + m + 4)
138
+ let Pl : Polynomial ℕ := Pbox + X + X * O + 2 * X + 2
139
+ let Qp := allocatedFiniteIdealProfileLog X Pl
140
+ let poly : Polynomial ℕ := 2 * (2 : Polynomial ℕ) ^ dim + X + (2 : Polynomial ℕ) ^ dim *
141
+ (X * ((m + 1 : ℕ) * X)) + ((2 : Polynomial ℕ) ^ dim * X * (4 * Qp + 8) + Qp) + X * O
142
+ obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly
143
+ refine ⟨A, hA, ?_⟩
144
+ intro D p v F Prho Pk target hD hp hv hF hPrho hPk htarget outputs axes gridaxes ambient
145
+ hout haxes hgridaxes hamb hdim hprofile Eg Op Plong Q
146
+ let R := D + p + v + F + Prho + Pk + target
147
+ have hR : 0 ≤ R := by dsimp [R]; positivity
148
+ have hDR : D ≤ R := by dsimp [R]; linarith
149
+ have hpR : p ≤ R := by dsimp [R]; linarith
150
+ have hvR : v ≤ R := by dsimp [R]; linarith
151
+ have hFR : F ≤ R := by dsimp [R]; linarith
152
+ have hPrhoR : Prho ≤ R := by dsimp [R]; linarith
153
+ have hPkR : Pk ≤ R := by dsimp [R]; linarith
154
+ have htR : target ≤ R := by dsimp [R]; linarith
155
+ have hEg : 0 ≤ Eg := by dsimp [Eg]; positivity
156
+ have hEgR : Eg ≤ R ^ 2 + 2 * R + 1 := by
157
+ have hprod := mul_le_mul (hout.trans hDR) hPrhoR hPrho hR
158
+ dsimp only [Eg]
159
+ nlinarith only [hprod, htR, hFR]
160
+ let Ob := (3 * R + (R ^ 2 + 2 * R + 1) + b) ^ b
161
+ have hOb : 0 ≤ Ob := by dsimp [Ob]; positivity
162
+ have hOp : 0 ≤ Op := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg
163
+ have hOpR : Op ≤ Ob := (hgrid hD hp hv hEg).trans
164
+ (pow_le_pow_left₀ (by positivity) (by linarith only [hDR, hpR, hvR, hEgR]) b)
165
+ let Plb := (((m + 2) * dim + m + 4 : ℕ) : ℝ) + R + R * Ob + 2 * R + 2
166
+ have hPlb : 0 ≤ Plb := by dsimp [Plb]; positivity
167
+ have hPl : 0 ≤ Plong := by dsimp [Plong]; positivity
168
+ have hPlR : Plong ≤ Plb := by
169
+ have hm : (axes : ℝ) * max Op 0 ≤ R * Ob := by
170
+ rw [max_eq_left hOp]
171
+ exact mul_le_mul (haxes.trans hDR) hOpR hOp hR
172
+ dsimp only [Plong, Plb]
173
+ push_cast
174
+ linarith only [hPrhoR, htR, hFR, hm]
175
+ let Qb := allocatedFiniteIdealProfileLog R Plb
176
+ have hQb : 0 ≤ Qb := (allocatedFiniteIdeal_budget_nonneg m hR hPlb (le_refl (0 : ℝ))).1
177
+ have hQ : 0 ≤ Q := (idealSiteLogBudget_bounds outputs dim hPl).1
178
+ have hQR : Q ≤ Qb := by
179
+ apply (idealSiteLogBudget_le_finite_profile hPl hout hdim hprofile).trans
180
+ change allocatedFiniteIdealProfileLog D Plong ≤ allocatedFiniteIdealProfileLog R Plb
181
+ unfold allocatedFiniteIdealProfileLog
182
+ gcongr
183
+ have hmass : 2 * (2 : ℝ) ^ dim + F + (2 : ℝ) ^ dim * (ambient * ((m + 1 : ℕ) * Pk)) +
184
+ ((2 : ℝ) ^ dim * axes * (4 * Q + 8) + Q) + gridaxes * Op ≤
185
+ 2 * (2 : ℝ) ^ dim + R + (2 : ℝ) ^ dim * (R * ((m + 1 : ℕ) * R)) +
186
+ ((2 : ℝ) ^ dim * R * (4 * Qb + 8) + Qb) + R * Ob := by
187
+ gcongr
188
+ · exact hamb.trans hDR
189
+ · exact haxes.trans hDR
190
+ · exact hgridaxes.trans hDR
191
+ apply hmass.trans
192
+ simpa [poly, X, O, Pbox, Pl, Qp, Ob, Plb, Qb, allocatedFiniteIdealProfileLog,
193
+ Polynomial.eval₂_pow] using hbound R hR
194
+
195
+ end Erdos3.VectorPolynomial
196
+
197
+ end
198
+
199
+ section
200
+
201
+ namespace Erdos3.VectorPolynomial
202
+ open scoped BigOperators NNReal
203
+
204
+ theorem exists_allocatedAffineAnalytic_budget (m dim : ℕ) :
205
+ ∃ A : ℕ, 2 ≤ A ∧ ∀ {D p v F Prho Pk target B : ℝ},
206
+ 0 ≤ D → 0 ≤ p → 0 ≤ v → 0 ≤ F → 0 ≤ Prho → 0 ≤ Pk → 0 ≤ target → 0 ≤ B →
207
+ ∀ (outputs axes : ℕ), (outputs : ℝ) ≤ D → (axes : ℝ) ≤ D →
208
+ (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D →
209
+ let Eg := outputs * Prho + (target + F) + 1
210
+ let Op := allocatedSlicedGridResourceLog m dim D p v Eg
211
+ let Plong := ((m : ℝ) + 2) * dim + m + 4 + Prho + axes * max Op 0 + (target + F) + 2
212
+ let Q := idealSiteLogBudget outputs dim Plong
213
+ 10 * B + 6 * Q + 2 * ((m + 1 : ℕ) * Pk) + (2 * B + 1) * Op + 19 ≤
214
+ (D + p + v + F + Prho + Pk + target + B + A) ^ A := by
215
+ obtain ⟨b, hb, hgrid⟩ := exists_allocatedSlicedGridResource_budget m dim
216
+ let X : Polynomial ℕ := Polynomial.X
217
+ let O : Polynomial ℕ := (3 * X + (X ^ 2 + 2 * X + 1) + Polynomial.C b) ^ b
218
+ let Pbox : Polynomial ℕ := Polynomial.C ((m + 2) * dim + m + 4)
219
+ let Pl : Polynomial ℕ := Pbox + X + X * O + 2 * X + 2
220
+ let Qp := allocatedFiniteIdealProfileLog X Pl
221
+ let poly : Polynomial ℕ := 10 * X + 6 * Qp + 2 * ((m + 1 : ℕ) * X) + (2 * X + 1) * O + 19
222
+ obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly
223
+ refine ⟨A, hA, ?_⟩
224
+ intro D p v F Prho Pk target B hD hp hv hF hPrho hPk htarget hB outputs axes
225
+ hout haxes hdim hprofile Eg Op Plong Q
226
+ let R := D + p + v + F + Prho + Pk + target + B
227
+ have hR : 0 ≤ R := by dsimp [R]; positivity
228
+ have hBR : B ≤ R := by dsimp [R]; linarith
229
+ have hDR : D ≤ R := by dsimp [R]; linarith
230
+ have hpR : p ≤ R := by dsimp [R]; linarith
231
+ have hvR : v ≤ R := by dsimp [R]; linarith
232
+ have hFR : F ≤ R := by dsimp [R]; linarith
233
+ have hPrhoR : Prho ≤ R := by dsimp [R]; linarith
234
+ have hPkR : Pk ≤ R := by dsimp [R]; linarith
235
+ have htR : target ≤ R := by dsimp [R]; linarith
236
+ have hEg : 0 ≤ Eg := by dsimp [Eg]; positivity
237
+ have hEgR : Eg ≤ R ^ 2 + 2 * R + 1 := by
238
+ have hprod := mul_le_mul (hout.trans hDR) hPrhoR hPrho hR
239
+ dsimp only [Eg]
240
+ nlinarith only [hprod, htR, hFR]
241
+ let Ob := (3 * R + (R ^ 2 + 2 * R + 1) + b) ^ b
242
+ have hOb : 0 ≤ Ob := by dsimp [Ob]; positivity
243
+ have hOp : 0 ≤ Op := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg
244
+ have hOpR : Op ≤ Ob := (hgrid hD hp hv hEg).trans
245
+ (pow_le_pow_left₀ (by positivity) (by linarith only [hDR, hpR, hvR, hEgR]) b)
246
+ let Plb := (((m + 2) * dim + m + 4 : ℕ) : ℝ) + R + R * Ob + 2 * R + 2
247
+ have hPlb : 0 ≤ Plb := by dsimp [Plb]; positivity
248
+ have hPl : 0 ≤ Plong := by dsimp [Plong]; positivity
249
+ have hPlR : Plong ≤ Plb := by
250
+ have hm : (axes : ℝ) * max Op 0 ≤ R * Ob := by
251
+ rw [max_eq_left hOp]
252
+ exact mul_le_mul (haxes.trans hDR) hOpR hOp hR
253
+ dsimp only [Plong, Plb]
254
+ push_cast
255
+ linarith only [hPrhoR, htR, hFR, hm]
256
+ let Qb := allocatedFiniteIdealProfileLog R Plb
257
+ have hQb : 0 ≤ Qb := (allocatedFiniteIdeal_budget_nonneg m hR hPlb (le_refl (0 : ℝ))).1
258
+ have hQ : 0 ≤ Q := (idealSiteLogBudget_bounds outputs dim hPl).1
259
+ have hQR : Q ≤ Qb := by
260
+ apply (idealSiteLogBudget_le_finite_profile hPl hout hdim hprofile).trans
261
+ change allocatedFiniteIdealProfileLog D Plong ≤ allocatedFiniteIdealProfileLog R Plb
262
+ unfold allocatedFiniteIdealProfileLog
263
+ gcongr
264
+ have hcost : 10 * B + 6 * Q + 2 * ((m + 1 : ℕ) * Pk) + (2 * B + 1) * Op + 19 ≤
265
+ 10 * R + 6 * Qb + 2 * ((m + 1 : ℕ) * R) + (2 * R + 1) * Ob + 19 := by
266
+ gcongr
267
+ apply hcost.trans
268
+ simpa [poly, X, O, Pbox, Pl, Qp, Ob, Plb, Qb, allocatedFiniteIdealProfileLog,
269
+ Polynomial.eval₂_pow] using hbound R hR
270
+
271
+ theorem allocatedAffineAnalytic_bounds (m dim outputs axes gridaxes : ℕ)
272
+ {D p v F Prho Pk target B : ℝ}
273
+ (hD : 0 ≤ D) (hp : 0 ≤ p) (hv : 0 ≤ v) (hF : 0 ≤ F)
274
+ (hPrho : 0 ≤ Prho) (hPk : 0 ≤ Pk) (htarget : 0 ≤ target) (hB : 0 ≤ B)
275
+ (hout : (outputs : ℝ) ≤ D) (haxes : (axes : ℝ) ≤ D)
276
+ (hdim : (dim : ℝ) ≤ D) (hprofile : (probabilityProfileLipschitz : ℝ) ≤ D)
277
+ (hDB : D ≤ B) (hgrid : (gridaxes : ℝ) ≤ B)
278
+ (cutoff coord Qgrid r radius : ℝ≥0) (hr : 1 ≤ r) (hradius : 1 ≤ radius)
279
+ (hc : (cutoff : ℝ) ≤ Real.exp B) (hcoord : (coord : ℝ) ≤ Real.exp B)
280
+ (hQgrid : (Qgrid : ℝ) ≤ Real.exp B)
281
+ (M period : ℕ) (hM : (M : ℝ) ≤ Real.exp Pk) (hperiod : period ≤ M ^ (m + 1)) :
282
+ let A := Classical.choose (exists_allocatedAffineAnalytic_budget m dim)
283
+ let Eg := outputs * Prho + (target + F) + 1
284
+ let Op := allocatedSlicedGridResourceLog m dim D p v Eg
285
+ let Plong := ((m : ℝ) + 2) * Fintype.card (Fin dim) + m + 4 + Prho + axes * max Op 0 + (target + F) + 2
286
+ let Q := idealSiteLogBudget outputs (Fintype.card (Fin dim)) Plong
287
+ let Llong : ℝ≥0 := (axes * cutoff / (2 * r)) * coord +
288
+ max ((⟨Real.exp (axes + 6 * Q + 12), Real.exp_nonneg _⟩ + axes * cutoff / (2 * radius)) * coord * (M ^ (m + 1))) (4 * (M ^ (m + 1)))
289
+ let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg _⟩
290
+ let Lgrid : ℝ≥0 := max (gridaxes * Lprimitive * Qgrid * coord * Lprimitive ^ gridaxes)
291
+ (4 * Lprimitive ^ gridaxes)
292
+ (((Llong + Lgrid) * (period * Lprimitive ^ gridaxes) : ℝ≥0) : ℝ) ≤
293
+ Real.exp ((D + p + v + F + Prho + Pk + target + B + A) ^ A) ∧
294
+ (period : ℝ) * (Real.exp Op) ^ gridaxes ≤
295
+ Real.exp ((D + p + v + F + Prho + Pk + target + B + A) ^ A) := by
296
+ intro A Eg Op Plong Q Llong Lprimitive Lgrid
297
+ have hEg : 0 ≤ Eg := by dsimp only [Eg]; positivity
298
+ have hOp := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg
299
+ have hPlong : 0 ≤ Plong := by dsimp only [Plong]; positivity
300
+ have hQ := (idealSiteLogBudget_bounds outputs (Fintype.card (Fin dim)) hPlong).1
301
+ have hMp : ((M ^ (m + 1) : ℝ≥0) : ℝ) ≤ Real.exp (((m + 1 : ℕ) : ℝ) * Pk) := by
302
+ change (M : ℝ) ^ (m + 1) ≤ _
303
+ calc
304
+ _ ≤ (Real.exp Pk) ^ (m + 1) := pow_le_pow_left₀ (Nat.cast_nonneg _) hM _
305
+ _ = _ := (Real.exp_nat_mul _ _).symm
306
+ have hper : (period : ℝ) ≤ Real.exp (((m + 1 : ℕ) : ℝ) * Pk) :=
307
+ (by exact_mod_cast hperiod : (period : ℝ) ≤ (M : ℝ) ^ (m + 1)).trans hMp
308
+ have hlog : 10 * B + 6 * Q + 2 * (((m + 1 : ℕ) : ℝ) * Pk) + (2 * B + 1) * Op + 19 ≤
309
+ (D + p + v + F + Prho + Pk + target + B + A) ^ A := by
310
+ simpa only [Q, Plong, Fintype.card_fin] using
311
+ (Classical.choose_spec (exists_allocatedAffineAnalytic_budget m dim)).2
312
+ hD hp hv hF hPrho hPk htarget hB outputs axes hout haxes hdim hprofile
313
+ exact ⟨(allocatedAffineFactor_nnreal_exp_bound cutoff coord Qgrid (M ^ (m + 1)) period r radius
314
+ axes gridaxes hB hQ hOp (by positivity) (haxes.trans hDB) hgrid hc hcoord hQgrid hMp hper
315
+ hr hradius).trans (Real.exp_le_exp.mpr hlog),
316
+ (allocatedAffineCover_exp_bound gridaxes hB hOp hgrid hper).trans
317
+ (Real.exp_le_exp.mpr (le_trans (by
318
+ have hper0 : 0 ≤ (((m + 1 : ℕ) : ℝ) * Pk) := mul_nonneg (Nat.cast_nonneg _) hPk
319
+ nlinarith only [hB, hQ, hOp, hper0, mul_nonneg hB hOp]) hlog))⟩
320
+
321
+ end Erdos3.VectorPolynomial
322
+
323
+ end
324
+
325
+ end OAI
lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineCanonicalBackendBudget.lean ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateThresholdSuccessor
2
+ import OAI.Combinatorics.Progressions.Lattices.AllocatedAffinePhysicalTerminalReset
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3.VectorPolynomial
9
+
10
+ def allocatedAffineResetHeightLog (p : ℝ) : ℝ := (p + 4) ^ 12
11
+
12
+ theorem allocatedAffineResetHeightLog_bounds {p : ℝ} (hp : 0 ≤ p) :
13
+ 0 ≤ allocatedAffineResetHeightLog p ∧
14
+ p ≤ allocatedAffineResetHeightLog p ∧
15
+ (p + 4) ^ 11 ≤ allocatedAffineResetHeightLog p ∧
16
+ (p + 3) ^ 7 ≤ allocatedAffineResetHeightLog p ∧
17
+ (p + 2) ^ 4 ≤ allocatedAffineResetHeightLog p := by
18
+ have hbase : 1 ≤ p + 4 := by linarith
19
+ have hlinear : p + 4 ≤ (p + 4) ^ 12 := by
20
+ simpa only [pow_one] using pow_le_pow_right₀ hbase (by norm_num : 1 ≤ 12)
21
+ have h11 : (p + 4) ^ 11 ≤ (p + 4) ^ 12 :=
22
+ pow_le_pow_right₀ hbase (by norm_num)
23
+ have h7 : (p + 3) ^ 7 ≤ (p + 4) ^ 12 :=
24
+ (pow_le_pow_left₀ (by linarith : 0 ≤ p + 3)
25
+ (by linarith : p + 3 ≤ p + 4) 7).trans
26
+ (pow_le_pow_right₀ hbase (by norm_num))
27
+ have h4 : (p + 2) ^ 4 ≤ (p + 4) ^ 12 :=
28
+ (pow_le_pow_left₀ (by linarith : 0 ≤ p + 2)
29
+ (by linarith : p + 2 ≤ p + 4) 4).trans
30
+ (pow_le_pow_right₀ hbase (by norm_num))
31
+ dsimp only [allocatedAffineResetHeightLog]
32
+ exact ⟨pow_nonneg (by linarith) _, (by linarith), h11, h7, h4⟩
33
+
34
+ theorem allocatedAffineResetHeightLog_exp_bounds {p : ℝ} (hp : 0 ≤ p) :
35
+ 1 ≤ Real.exp (allocatedAffineResetHeightLog p) ∧
36
+ Real.exp p ≤ Real.exp (allocatedAffineResetHeightLog p) ∧
37
+ Real.exp ((p + 4) ^ 11) ≤ Real.exp (allocatedAffineResetHeightLog p) ∧
38
+ Real.exp ((p + 3) ^ 7) ≤ Real.exp (allocatedAffineResetHeightLog p) ∧
39
+ Real.exp ((p + 2) ^ 4) ≤ Real.exp (allocatedAffineResetHeightLog p) := by
40
+ obtain ⟨h0, hp', h11, h7, h4⟩ := allocatedAffineResetHeightLog_bounds hp
41
+ exact ⟨Real.one_le_exp_iff.mpr h0, Real.exp_le_exp.mpr hp',
42
+ Real.exp_le_exp.mpr h11, Real.exp_le_exp.mpr h7, Real.exp_le_exp.mpr h4⟩
43
+
44
+ end Erdos3.VectorPolynomial
45
+
46
+ end
47
+
48
+ section
49
+
50
+ namespace Erdos3.VectorPolynomial
51
+ open NilpotentLieFiltration
52
+
53
+ noncomputable def allocatedAffineResetRightLog (s : ℕ) (pFull : ℝ) : ℝ :=
54
+ (pFull + allocatedEarlyAffineRightExponent (s + 1) 4) ^
55
+ allocatedEarlyAffineRightExponent (s + 1) 4
56
+
57
+ noncomputable def allocatedAffineResetLeftLog (s : ℕ) (pFull : ℝ) : ℝ :=
58
+ (pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^
59
+ allocatedEarlyAffineLeftExponent (s + 1) 4
60
+
61
+ noncomputable def allocatedAffineResetCompareLog (s : ℕ) (pNative : ℝ) : ℝ :=
62
+ (pNative + allocatedAffineResetCompareExponent s) ^ allocatedAffineResetCompareExponent s
63
+
64
+ noncomputable def allocatedAffineResetMapBudget (s : ℕ) (p0 pFull : ℝ) : ℝ :=
65
+ ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 + allocatedAffineResetHeightLog p0 + 1 + p0 +
66
+ allocatedAffineResetRightLog s pFull
67
+
68
+ noncomputable def allocatedAffineCanonicalNativeBudget (s : ℕ) (p0 pFull : ℝ) : ℝ :=
69
+ allocatedAffineResetNativeBudget s pFull (allocatedAffineResetMapBudget s p0 pFull) p0
70
+
71
+ noncomputable def allocatedAffineCanonicalBudget (s : ℕ) (p0 pFull : ℝ) : ℝ :=
72
+ p0 + pFull + allocatedAffineResetMapBudget s p0 pFull +
73
+ allocatedAffineCanonicalNativeBudget s p0 pFull +
74
+ allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) +
75
+ allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) +
76
+ allocatedAffineResetLeftLog s pFull + (s + 2 : ℕ)
77
+
78
+ structure AllocatedAffineResetMapBudgetBounds (s : ℕ) (p0 pFull : ℝ) : Prop where
79
+ nonnegative : 0 ≤ allocatedAffineResetMapBudget s p0 pFull
80
+ input : p0 ≤ allocatedAffineResetMapBudget s p0 pFull
81
+ pointwise : ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 ≤
82
+ allocatedAffineResetMapBudget s p0 pFull
83
+ height : allocatedAffineResetHeightLog p0 + 1 ≤ allocatedAffineResetMapBudget s p0 pFull
84
+ denominatorLog : p0 + allocatedAffineResetRightLog s pFull ≤
85
+ allocatedAffineResetMapBudget s p0 pFull
86
+
87
+ theorem allocatedAffineResetMapBudget_bounds (s : ℕ) {p0 pFull : ℝ}
88
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) :
89
+ AllocatedAffineResetMapBudgetBounds s p0 pFull := by
90
+ have hsection : 0 ≤ ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 :=
91
+ hp0.trans (ordinaryImagePointwiseBudget_ge (s + 1) (s + 1) hp0)
92
+ have hheight : 0 ≤ allocatedAffineResetHeightLog p0 := by
93
+ unfold allocatedAffineResetHeightLog
94
+ positivity
95
+ have hright : 0 ≤ allocatedAffineResetRightLog s pFull := by
96
+ unfold allocatedAffineResetRightLog
97
+ positivity
98
+ constructor <;> dsimp only [allocatedAffineResetMapBudget] <;> linarith
99
+
100
+ theorem allocatedAffineResetMapBudget_denominator (s : ℕ) {p0 pFull : ℝ}
101
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) {l n : ℕ}
102
+ (hl : (l : ℝ) ≤ Real.exp p0)
103
+ (hn : (n : ℝ) ≤ Real.exp (allocatedAffineResetRightLog s pFull)) :
104
+ ((l * n : ℕ) : ℝ) ≤ Real.exp (allocatedAffineResetMapBudget s p0 pFull) := by
105
+ rw [Nat.cast_mul]
106
+ calc
107
+ (l : ℝ) * n ≤ Real.exp p0 * Real.exp (allocatedAffineResetRightLog s pFull) :=
108
+ mul_le_mul hl hn (Nat.cast_nonneg _) (Real.exp_pos _).le
109
+ _ = Real.exp (p0 + allocatedAffineResetRightLog s pFull) := (Real.exp_add _ _).symm
110
+ _ ≤ _ := Real.exp_le_exp.mpr (allocatedAffineResetMapBudget_bounds s hp0 hFull).denominatorLog
111
+
112
+ theorem allocatedAffineResetLogBudget_nonnegative (s : ℕ) {p : ℝ} (hp : 0 ≤ p) :
113
+ 0 ≤ allocatedAffineResetLogBudget s p := by
114
+ unfold allocatedAffineResetLogBudget markedNativeLiftInput fullMarkedNativeInput
115
+ pointwiseFastSectionInput
116
+ positivity
117
+
118
+ structure AllocatedAffineCanonicalBudgetBounds (s : ℕ) (p0 pFull : ℝ) : Prop where
119
+ nonnegative : 0 ≤ allocatedAffineCanonicalBudget s p0 pFull
120
+ map_nonnegative : 0 ≤ allocatedAffineResetMapBudget s p0 pFull
121
+ native_nonnegative : 0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull
122
+ input : p0 ≤ allocatedAffineCanonicalBudget s p0 pFull
123
+ full : pFull ≤ allocatedAffineCanonicalBudget s p0 pFull
124
+ map : allocatedAffineResetMapBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s p0 pFull
125
+ native : allocatedAffineCanonicalNativeBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s p0 pFull
126
+ native_input : p0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull
127
+ native_full : pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull
128
+ native_map : allocatedAffineResetMapBudget s p0 pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull
129
+ reset : allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤
130
+ allocatedAffineCanonicalBudget s p0 pFull
131
+ compare : allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤
132
+ allocatedAffineCanonicalBudget s p0 pFull
133
+ physical : allocatedAffineResetLeftLog s pFull ≤ allocatedAffineCanonicalBudget s p0 pFull
134
+ interpolation_log : p0 + (s + 2 : ℕ) ≤ allocatedAffineCanonicalBudget s p0 pFull
135
+
136
+ theorem allocatedAffineCanonicalBudget_bounds (s : ℕ) {p0 pFull : ℝ}
137
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) :
138
+ AllocatedAffineCanonicalBudgetBounds s p0 pFull := by
139
+ have hm := allocatedAffineResetMapBudget_bounds s hp0 hFull
140
+ obtain ⟨hn, hnf, hnm, hnq, hnl, hn4, hn3⟩ :=
141
+ affineResetNativeBudget_bounds (allocatedEarlyAffineLeftExponent (s + 1) 4)
142
+ hFull hm.nonnegative (q := p0)
143
+ change 0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hn
144
+ change pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hnf
145
+ change allocatedAffineResetMapBudget s p0 pFull ≤
146
+ allocatedAffineCanonicalNativeBudget s p0 pFull at hnm
147
+ change p0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hnq
148
+ have hreset := allocatedAffineResetLogBudget_nonnegative s hn
149
+ have hcompare : 0 ≤ allocatedAffineResetCompareLog s
150
+ (allocatedAffineCanonicalNativeBudget s p0 pFull) := by
151
+ unfold allocatedAffineResetCompareLog
152
+ positivity
153
+ have hleft : 0 ≤ allocatedAffineResetLeftLog s pFull := by
154
+ unfold allocatedAffineResetLeftLog
155
+ positivity
156
+ have hs : (0 : ℝ) ≤ (s + 2 : ℕ) := Nat.cast_nonneg _
157
+ constructor
158
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
159
+ · exact hm.nonnegative
160
+ · exact hn
161
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
162
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
163
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith
164
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
165
+ · exact hnq
166
+ · exact hnf
167
+ · exact hnm
168
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
169
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
170
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
171
+ · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative]
172
+
173
+ structure AllocatedAffineCanonicalExpBounds (s : ℕ) (p0 pFull : ℝ) : Prop where
174
+ map_absorption : Real.exp ((allocatedAffineResetMapBudget s p0 pFull + 2) ^ 4) ≤
175
+ Real.exp (allocatedAffineCanonicalNativeBudget s p0 pFull)
176
+ physical_absorption : Real.exp (allocatedAffineResetLeftLog s pFull) ≤
177
+ Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ))
178
+ original_absorption : Real.exp p0 ≤
179
+ Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ))
180
+ mapped_absorption : Real.exp ((allocatedAffineResetMapBudget s p0 pFull + 2) ^ 3 + p0) ≤
181
+ Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ))
182
+ compare_cutoff : Real.exp
183
+ (allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull)) ≤
184
+ Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull))
185
+ cost_cutoff : ∀ cost : ℝ, cost ≤ p0 → Real.exp cost ≤
186
+ Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull))
187
+ interpolation : ∀ cost : ℝ, cost ��� p0 → Real.exp cost * (s + 2 : ℕ) ≤
188
+ Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull))
189
+
190
+ theorem allocatedAffineCanonicalBudget_exp_bounds (s : ℕ) {p0 pFull : ℝ}
191
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) :
192
+ AllocatedAffineCanonicalExpBounds s p0 pFull := by
193
+ have hb := allocatedAffineCanonicalBudget_bounds s hp0 hFull
194
+ obtain ⟨_, _, _, hm, hf, hq, hmq⟩ :=
195
+ allocatedAffineResetNativeBudget_exp_bounds s hFull hb.map_nonnegative (q := p0)
196
+ have hcut := candidatePrimitiveFreezingCutoff_ge_input s 1 hb.nonnegative
197
+ refine ⟨hm, hf, hq, hmq, Real.exp_le_exp.mpr (hb.compare.trans hcut), ?_, ?_⟩
198
+ · intro cost hcost
199
+ exact Real.exp_le_exp.mpr ((hcost.trans hb.input).trans hcut)
200
+ · intro cost hcost
201
+ have hs : ((s + 2 : ℕ) : ℝ) ≤ Real.exp (s + 2 : ℕ) := by
202
+ linarith [Real.add_one_le_exp ((s + 2 : ℕ) : ℝ)]
203
+ calc
204
+ Real.exp cost * (s + 2 : ℕ) ≤ Real.exp cost * Real.exp (s + 2 : ℕ) :=
205
+ mul_le_mul_of_nonneg_left hs (Real.exp_pos _).le
206
+ _ = Real.exp (cost + (s + 2 : ℕ)) := (Real.exp_add _ _).symm
207
+ _ ≤ _ := Real.exp_le_exp.mpr
208
+ ((add_le_add hcost le_rfl).trans (hb.interpolation_log.trans hcut))
209
+
210
+ end Erdos3.VectorPolynomial
211
+
212
+ end
213
+
214
+ section
215
+
216
+ namespace Erdos3.VectorPolynomial
217
+
218
+ open NilpotentLieFiltration
219
+
220
+ theorem allocatedAffineCanonicalBudget_le_diagonal (s : ℕ) {p0 pFull B : ℝ}
221
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) :
222
+ allocatedAffineCanonicalBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s B B := by
223
+ have hB : 0 ≤ B := hp0.trans hp0B
224
+ have hmap0 := (allocatedAffineResetMapBudget_bounds s hp0 hFull).nonnegative
225
+ have hnative0 := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).native_nonnegative
226
+ have hpoint : ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 ≤
227
+ ordinaryImagePointwiseBudget (s + 1) (s + 1) B := by
228
+ unfold ordinaryImagePointwiseBudget pointwiseFastSectionInput
229
+ gcongr
230
+ have hmap : allocatedAffineResetMapBudget s p0 pFull ≤
231
+ allocatedAffineResetMapBudget s B B := by
232
+ unfold allocatedAffineResetMapBudget allocatedAffineResetHeightLog allocatedAffineResetRightLog
233
+ gcongr
234
+ have hnative : allocatedAffineCanonicalNativeBudget s p0 pFull ≤
235
+ allocatedAffineCanonicalNativeBudget s B B := by
236
+ unfold allocatedAffineCanonicalNativeBudget allocatedAffineResetNativeBudget affineResetNativeBudget
237
+ gcongr
238
+ have hreset : allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤
239
+ allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s B B) := by
240
+ unfold allocatedAffineResetLogBudget markedNativeLiftInput fullMarkedNativeInput
241
+ pointwiseFastSectionInput
242
+ gcongr
243
+ have hcompare : allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤
244
+ allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s B B) := by
245
+ unfold allocatedAffineResetCompareLog
246
+ gcongr
247
+ have hleft : allocatedAffineResetLeftLog s pFull ≤ allocatedAffineResetLeftLog s B := by
248
+ unfold allocatedAffineResetLeftLog
249
+ gcongr
250
+ unfold allocatedAffineCanonicalBudget
251
+ linarith
252
+
253
+ end Erdos3.VectorPolynomial
254
+
255
+ end
256
+
257
+ section
258
+
259
+ namespace Erdos3.VectorPolynomial
260
+ open NilpotentLieFiltration
261
+
262
+ private noncomputable def canonicalSectionPolynomial (s : ℕ) (P : Polynomial ℕ) : Polynomial ℕ :=
263
+ 2 * (P + Polynomial.C (s + 3)) ^ (s + 3) +
264
+ ((P + Polynomial.C (s + 3)) ^ (s + 3)) ^ 2 + P
265
+
266
+ noncomputable def allocatedAffineCanonicalBudgetPolynomial (s : ℕ) : Polynomial ℕ :=
267
+ let X := Polynomial.X
268
+ let sectionPoly := canonicalSectionPolynomial (s + 1) X
269
+ let right := (X + Polynomial.C (allocatedEarlyAffineRightExponent (s + 1) 4)) ^
270
+ allocatedEarlyAffineRightExponent (s + 1) 4
271
+ let left := (X + Polynomial.C (allocatedEarlyAffineLeftExponent (s + 1) 4)) ^
272
+ allocatedEarlyAffineLeftExponent (s + 1) 4
273
+ let map := sectionPoly + sectionPoly + (X + 2) ^ 5 + (X + 4) ^ 12 + 1 + X + right
274
+ let native := X + map + X + left + (map + 2) ^ 4
275
+ let nativeSection := canonicalSectionPolynomial (s + 1) native
276
+ let full := (nativeSection + Polynomial.C (allocatedAffineResetFactorExponent s)) ^
277
+ allocatedAffineResetFactorExponent s + (native + 2) ^ 1 + nativeSection
278
+ let reset := ((full + 2) ^ 11 + full + Polynomial.C (allocatedAffineResetLiftExponent s)) ^
279
+ allocatedAffineResetLiftExponent s
280
+ X + X + map + native + reset +
281
+ (native + Polynomial.C (allocatedAffineResetCompareExponent s)) ^
282
+ allocatedAffineResetCompareExponent s + left + Polynomial.C (s + 2)
283
+
284
+ theorem allocatedAffineCanonicalBudgetPolynomial_eval (s : ℕ) {B : ℝ} (hB : 0 ≤ B) :
285
+ (allocatedAffineCanonicalBudgetPolynomial s).eval₂ (Nat.castRingHom ℝ) B =
286
+ allocatedAffineCanonicalBudget s B B := by
287
+ simp only [allocatedAffineCanonicalBudgetPolynomial, canonicalSectionPolynomial,
288
+ allocatedAffineCanonicalBudget, allocatedAffineResetMapBudget,
289
+ allocatedAffineCanonicalNativeBudget, allocatedAffineResetNativeBudget,
290
+ affineResetNativeBudget, allocatedAffineResetRightLog, allocatedAffineResetLeftLog,
291
+ allocatedAffineResetCompareLog, allocatedAffineResetLogBudget,
292
+ ordinaryImagePointwiseBudget, allocatedAffineResetHeightLog,
293
+ markedNativeLiftInput, fullMarkedNativeInput, pointwiseFastSectionInput,
294
+ max_eq_left hB, Polynomial.eval₂_add, Polynomial.eval₂_mul,
295
+ Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C,
296
+ Polynomial.eval₂_ofNat, Polynomial.eval₂_one, Nat.coe_castRingHom,
297
+ Nat.cast_add, Nat.cast_one, Nat.cast_ofNat]
298
+
299
+ noncomputable def allocatedAffineCanonicalBackendPolynomial (s : ℕ) : Polynomial ℕ :=
300
+ let P := allocatedAffineCanonicalBudgetPolynomial s
301
+ P + 12 * (P + Polynomial.C (candidatePrimitivePhysicalBudgetExponent s 1)) ^
302
+ candidatePrimitivePhysicalBudgetExponent s 1 + 32
303
+
304
+ theorem allocatedAffineCanonicalBackendPolynomial_eval (s : ℕ) {B : ℝ} (hB : 0 ≤ B) :
305
+ (allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B =
306
+ allocatedAffineCanonicalBudget s B B +
307
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
308
+ (allocatedAffineCanonicalBudget s B B) := by
309
+ simp only [allocatedAffineCanonicalBackendPolynomial, Polynomial.eval₂_add,
310
+ Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_C,
311
+ Polynomial.eval₂_ofNat, Nat.coe_castRingHom, allocatedAffineCanonicalBudgetPolynomial_eval s hB,
312
+ finiteFreezingRecursiveParameter]
313
+ ring
314
+
315
+ private theorem power_le_recursiveParameter (C : ℕ) {p : ℝ} (hp : 0 ≤ p) :
316
+ (p + C) ^ C ≤ finiteFreezingRecursiveParameter C p := by
317
+ have hpow : 0 ≤ (p + C) ^ C := pow_nonneg (by positivity) _
318
+ unfold finiteFreezingRecursiveParameter
319
+ linarith only [hpow]
320
+
321
+ theorem allocatedAffineCanonical_cutoffCost_le_recursive (s : ℕ) {p0 pFull : ℝ}
322
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) :
323
+ candidateSideCutoffCost
324
+ (Real.exp (candidatePrimitiveFreezingCutoff s 1
325
+ (allocatedAffineCanonicalBudget s p0 pFull))) ≤
326
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
327
+ (allocatedAffineCanonicalBudget s p0 pFull) := by
328
+ have hp := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).nonnegative
329
+ exact ((candidatePrimitiveFreezingCutoff_integer_cost s 1 hp).trans
330
+ (candidatePrimitiveFreezingCutoff_add_two_le_budget s 1 hp)).trans
331
+ (power_le_recursiveParameter _ hp)
332
+
333
+ structure AllocatedAffineCanonicalBackendBounds (s : ℕ) (p0 pFull upper : ℝ) : Prop where
334
+ canonical : allocatedAffineCanonicalBudget s p0 pFull ≤ upper
335
+ recursive : finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
336
+ (allocatedAffineCanonicalBudget s p0 pFull) ≤ upper
337
+ cutoff : candidatePrimitiveFreezingCutoff s 1
338
+ (allocatedAffineCanonicalBudget s p0 pFull) ≤ upper
339
+ cutoff_cost : candidateSideCutoffCost
340
+ (Real.exp (candidatePrimitiveFreezingCutoff s 1
341
+ (allocatedAffineCanonicalBudget s p0 pFull))) ≤ upper
342
+
343
+ theorem allocatedAffineCanonicalBackendPolynomial_bounds (s : ℕ) {p0 pFull B : ℝ}
344
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) :
345
+ AllocatedAffineCanonicalBackendBounds s p0 pFull
346
+ ((allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B) := by
347
+ have hB := hp0.trans hp0B
348
+ have hp := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).nonnegative
349
+ have hd := (allocatedAffineCanonicalBudget_bounds s hB hB).nonnegative
350
+ have hdiag := allocatedAffineCanonicalBudget_le_diagonal s hp0 hFull hp0B hFullB
351
+ have hrec :
352
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
353
+ (allocatedAffineCanonicalBudget s p0 pFull) ≤
354
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
355
+ (allocatedAffineCanonicalBudget s B B) := by
356
+ unfold finiteFreezingRecursiveParameter
357
+ gcongr
358
+ have hrec0 : 0 ≤
359
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
360
+ (allocatedAffineCanonicalBudget s B B) := by
361
+ unfold finiteFreezingRecursiveParameter
362
+ positivity
363
+ have hrecUpper :
364
+ finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1)
365
+ (allocatedAffineCanonicalBudget s p0 pFull) ≤
366
+ (allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B := by
367
+ rw [allocatedAffineCanonicalBackendPolynomial_eval s hB]
368
+ linarith only [hrec, hd]
369
+ constructor
370
+ · rw [allocatedAffineCanonicalBackendPolynomial_eval s hB]
371
+ linarith only [hdiag, hrec0]
372
+ · exact hrecUpper
373
+ · exact ((candidatePrimitiveFreezingCutoff_le_budget s 1 hp).trans
374
+ (power_le_recursiveParameter _ hp)).trans hrecUpper
375
+ · exact (allocatedAffineCanonical_cutoffCost_le_recursive s hp0 hFull).trans hrecUpper
376
+
377
+ theorem exists_allocatedAffineCanonicalBackend_budget (s : ℕ) :
378
+ ∃ C : ℕ, 2 ≤ C ��� ∀ (B p0 pFull : ℝ),
379
+ 0 ≤ p0 → 0 ≤ pFull → p0 ≤ B → pFull ≤ B →
380
+ AllocatedAffineCanonicalBackendBounds s p0 pFull ((B + C) ^ C) := by
381
+ obtain ⟨C, hC, hbound⟩ :=
382
+ exists_natPolynomial_eval_budget (allocatedAffineCanonicalBackendPolynomial s)
383
+ refine ⟨C, hC, ?_⟩
384
+ intro B p0 pFull hp0 hFull hp0B hFullB
385
+ have hb := allocatedAffineCanonicalBackendPolynomial_bounds s hp0 hFull hp0B hFullB
386
+ have hpoly := hbound B (hp0.trans hp0B)
387
+ exact ⟨hb.canonical.trans hpoly, hb.recursive.trans hpoly,
388
+ hb.cutoff.trans hpoly, hb.cutoff_cost.trans hpoly⟩
389
+
390
+ noncomputable def allocatedAffineCanonicalBackendExponent (s : ℕ) : ℕ :=
391
+ (exists_allocatedAffineCanonicalBackend_budget s).choose
392
+
393
+ theorem allocatedAffineCanonicalBackendExponent_ge_two (s : ℕ) :
394
+ 2 ≤ allocatedAffineCanonicalBackendExponent s :=
395
+ (exists_allocatedAffineCanonicalBackend_budget s).choose_spec.1
396
+
397
+ theorem allocatedAffineCanonicalBackend_bounds (s : ℕ) {B p0 pFull : ℝ}
398
+ (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) :
399
+ AllocatedAffineCanonicalBackendBounds s p0 pFull
400
+ ((B + allocatedAffineCanonicalBackendExponent s) ^
401
+ allocatedAffineCanonicalBackendExponent s) :=
402
+ (exists_allocatedAffineCanonicalBackend_budget s).choose_spec.2 B p0 pFull
403
+ hp0 hFull hp0B hFullB
404
+
405
+ end Erdos3.VectorPolynomial
406
+
407
+ end
408
+
409
+ end OAI