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

Add lean source and binary files (part 50)

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/Estimates/SampledNativeModel.lean +585 -0
  2. lean/OAI/Combinatorics/Progressions/Estimates/SampledSliceFixedModelPartners.lean +120 -0
  3. lean/OAI/Combinatorics/Progressions/Estimates/SaturatedFlag.lean +599 -0
  4. lean/OAI/Combinatorics/Progressions/Estimates/ScalarBadSublevelRamp.lean +44 -0
  5. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeBoundaryCost.lean +77 -0
  6. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeBoundaryVolume.lean +117 -0
  7. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeCokernelCutoff.lean +132 -0
  8. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeDomain.lean +233 -0
  9. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeFaceSlab.lean +363 -0
  10. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeRootTranslation.lean +82 -0
  11. lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeWindowDomain.lean +88 -0
  12. lean/OAI/Combinatorics/Progressions/Estimates/ScalarDominatedSlack.lean +481 -0
  13. lean/OAI/Combinatorics/Progressions/Estimates/ScalarExtensionSubstitution.lean +32 -0
  14. lean/OAI/Combinatorics/Progressions/Estimates/ScalarInitialThreshold.lean +74 -0
  15. lean/OAI/Combinatorics/Progressions/Estimates/ScalarInputLogFactor.lean +26 -0
  16. lean/OAI/Combinatorics/Progressions/Estimates/ScalarWindowPartitions.lean +58 -0
  17. lean/OAI/Combinatorics/Progressions/Estimates/ScaledConditionedComparison.lean +605 -0
  18. lean/OAI/Combinatorics/Progressions/Estimates/ScaledFloorPerturbation.lean +38 -0
  19. lean/OAI/Combinatorics/Progressions/Estimates/ScaledJointFrozenSource.lean +161 -0
  20. lean/OAI/Combinatorics/Progressions/Estimates/ScaledLinearResidual.lean +48 -0
  21. lean/OAI/Combinatorics/Progressions/Estimates/ScaledSectionGram.lean +73 -0
  22. lean/OAI/Combinatorics/Progressions/Estimates/SecondDifferenceVectorEquivalence.lean +143 -0
  23. lean/OAI/Combinatorics/Progressions/Estimates/SecondaryMeshGeometry.lean +112 -0
  24. lean/OAI/Combinatorics/Progressions/Estimates/SelectedChildBound.lean +53 -0
  25. lean/OAI/Combinatorics/Progressions/Estimates/SelectedCoefficientEvaluation.lean +435 -0
  26. lean/OAI/Combinatorics/Progressions/Estimates/SelectedImageCorrections.lean +85 -0
  27. lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointLifts.lean +117 -0
  28. lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointSiteDomination.lean +91 -0
  29. lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointWeightedReferenceComparison.lean +91 -0
  30. lean/OAI/Combinatorics/Progressions/Estimates/SelectedOutputL1.lean +107 -0
  31. lean/OAI/Combinatorics/Progressions/Estimates/SelectedPhysicalReferenceCap.lean +75 -0
  32. lean/OAI/Combinatorics/Progressions/Estimates/SelectedProductEnvelope.lean +34 -0
  33. lean/OAI/Combinatorics/Progressions/Estimates/SelectedProfileTranslationL1.lean +59 -0
  34. lean/OAI/Combinatorics/Progressions/Estimates/SelectedSingletonSmoothTestQuadrature.lean +235 -0
  35. lean/OAI/Combinatorics/Progressions/Estimates/SelectedSplitUnitSource.lean +76 -0
  36. lean/OAI/Combinatorics/Progressions/Estimates/SelectedWindowIndicator.lean +224 -0
  37. lean/OAI/Combinatorics/Progressions/Estimates/SeparatedCosetBalls.lean +68 -0
  38. lean/OAI/Combinatorics/Progressions/Estimates/SeparatedInterpolationBound.lean +104 -0
  39. lean/OAI/Combinatorics/Progressions/Estimates/SeparatedLabelExtension.lean +86 -0
  40. lean/OAI/Combinatorics/Progressions/Estimates/SeparatedPositiveSum.lean +48 -0
  41. lean/OAI/Combinatorics/Progressions/Estimates/SeparatedRealSamples.lean +77 -0
  42. lean/OAI/Combinatorics/Progressions/Estimates/Separation.lean +48 -0
  43. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonDescent.lean +87 -0
  44. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonLift.lean +879 -0
  45. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonOrbit.lean +109 -0
  46. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeCorrelatedFactorization.lean +220 -0
  47. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeFrozenComparison.lean +423 -0
  48. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeLowerFactorization.lean +686 -0
  49. lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeRoundingThreshold.lean +845 -0
  50. lean/OAI/Combinatorics/Progressions/Estimates/SharedWidthPreparedChoice.lean +43 -0
lean/OAI/Combinatorics/Progressions/Estimates/SampledNativeModel.lean ADDED
@@ -0,0 +1,585 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Analysis.LocallyConvex.BalancedCoreHull
2
+ import Mathlib.Analysis.Normed.Module.Seminorm.Basic
3
+ import OAI.Combinatorics.Progressions.Fourier.WeightedTranslationTwistedCentralFrequency
4
+ import OAI.Combinatorics.Progressions.Lattices.NativeIntegerAffinePullbackHom
5
+ import OAI.Combinatorics.Progressions.Lattices.ResidueStrideRebase
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3
12
+
13
+ open scoped BigOperators
14
+
15
+ theorem detector_of_unit_detector {X : Type*} [Fintype X]
16
+ (μ : FiniteProbabilityWeights X) (S : Seminorm ℂ (X → ℂ)) (atoms : Set (X → ℂ))
17
+ {R δ β : ℝ} (hR : 0 < R)
18
+ (hdetect : ∀ g : X → ℂ, (∀ x, ‖g x‖ ≤ 1) → δ / R ≤ S g →
19
+ ∃ Q ∈ atoms, β ≤ ‖μ.correlation g Q‖)
20
+ (f : X → ℂ) (hf : ∀ x, ‖f x‖ ≤ R) (hS : δ ≤ S f) :
21
+ ∃ Q ∈ atoms, R * β ≤ ‖μ.correlation f Q‖ := by
22
+ let g : X → ℂ := (R : ℂ)⁻¹ • f
23
+ have hg (x : X) : ‖g x‖ ≤ 1 := by
24
+ change ‖(R : ℂ)⁻¹ * f x‖ ≤ 1
25
+ rw [norm_mul, norm_inv, Complex.norm_real, Real.norm_of_nonneg hR.le]
26
+ calc
27
+ R⁻¹ * ‖f x‖ ≤ R⁻¹ * R := mul_le_mul_of_nonneg_left (hf x) (inv_nonneg.mpr hR.le)
28
+ _ = 1 := inv_mul_cancel₀ hR.ne'
29
+ have hSg : δ / R ≤ S g := by
30
+ dsimp only [g]
31
+ rw [map_smul_eq_mul, norm_inv, Complex.norm_real, Real.norm_of_nonneg hR.le]
32
+ simpa only [div_eq_mul_inv, mul_comm] using
33
+ mul_le_mul_of_nonneg_left hS (inv_nonneg.mpr hR.le)
34
+ obtain ⟨Q, hQ, hcorr⟩ := hdetect g hg hSg
35
+ have heq : μ.correlation g Q = (R : ℂ)⁻¹ * μ.correlation f Q := by
36
+ simp only [FiniteProbabilityWeights.correlation, g, Pi.smul_apply, smul_eq_mul,
37
+ Finset.mul_sum]
38
+ apply Finset.sum_congr rfl
39
+ intro x _
40
+ ring
41
+ rw [heq, norm_mul, norm_inv, Complex.norm_real, Real.norm_of_nonneg hR.le] at hcorr
42
+ refine ⟨Q, hQ, ?_⟩
43
+ have h := mul_le_mul_of_nonneg_left hcorr hR.le
44
+ simpa only [← mul_assoc, mul_inv_cancel₀ hR.ne', one_mul] using h
45
+
46
+ end Erdos3
47
+
48
+ end
49
+
50
+ section
51
+
52
+ namespace Erdos3
53
+
54
+ open scoped TensorProduct BigOperators
55
+
56
+ structure NativeSampleCorrelation {σ X : Type*} (w : σ → ℕ)
57
+ (degree : ℕ) (p : ℝ) (S : Finset X) (sample : X → σ → ℤ) (f : X → ℂ) where
58
+ L : Type
59
+ [lie : LieRing L]
60
+ [algebra : LieAlgebra ℚ L]
61
+ dim : ℕ
62
+ [topology : TopologicalSpace (ℝ ⊗[ℚ] L)]
63
+ [topologicalAdd : IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
64
+ [continuousSMul : ContinuousSMul ℝ (ℝ ⊗[ℚ] L)]
65
+ [hausdorff : T2Space (ℝ ⊗[ℚ] L)]
66
+ model : RationalFilteredNilmanifold L degree dim
67
+ test : model.Niltest w
68
+ complexity : test.ComplexityLE p
69
+ correlation : Real.exp (-p) ≤ ‖𝔼 x ∈ S, f x * star (test.eval (sample x))‖
70
+
71
+ attribute [local instance] NativeSampleCorrelation.lie NativeSampleCorrelation.algebra
72
+ NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd
73
+ NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff
74
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
75
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
76
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
77
+
78
+ namespace NativeSampleCorrelation
79
+
80
+ variable {σ X : Type*} {w : σ → ℕ} {s : ℕ} {p q : ℝ}
81
+ {S : Finset X} {sample : X → σ → ℤ} {f : X → ℂ}
82
+
83
+ noncomputable def mono (V : NativeSampleCorrelation w s p S sample f) (hpq : p ≤ q) :
84
+ NativeSampleCorrelation w s q S sample f :=
85
+ { V with
86
+ complexity := V.complexity.mono hpq
87
+ correlation := (Real.exp_le_exp.mpr (neg_le_neg hpq)).trans V.correlation }
88
+
89
+ theorem exists_of_expansion {eta : (σ → ℤ) → ℂ}
90
+ (E : NativeIntegerExpansion w s p eta) (hq : 0 ≤ q)
91
+ (hcorr : Real.exp (-q) ≤ ‖𝔼 x ∈ S, f x * star (eta (sample x))‖) :
92
+ Nonempty (NativeSampleCorrelation w s (q + p) S sample f) := by
93
+ obtain ⟨i, hi⟩ := E.select_sample_correlation S sample f hcorr
94
+ exact ⟨{
95
+ L := E.L i
96
+ dim := E.dim i
97
+ model := E.model i
98
+ test := E.test i
99
+ complexity := (E.complexity i).mono (le_add_of_nonneg_left hq)
100
+ correlation := hi }⟩
101
+
102
+ end NativeSampleCorrelation
103
+
104
+ end Erdos3
105
+
106
+ end
107
+
108
+ section
109
+
110
+ namespace Erdos3
111
+
112
+ open scoped TensorProduct Pointwise BigOperators
113
+
114
+ structure NativeSampleModel {σ X : Type*} (w : σ → ℕ) (degree : ℕ) (p : ℝ)
115
+ (sample : X → σ → ℤ) (f : X → ℂ) where
116
+ L : Type
117
+ [lie : LieRing L]
118
+ [algebra : LieAlgebra ℚ L]
119
+ dim : ℕ
120
+ [topology : TopologicalSpace (ℝ ⊗[ℚ] L)]
121
+ [topologicalAdd : IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
122
+ [continuousSMul : ContinuousSMul ℝ (ℝ ⊗[ℚ] L)]
123
+ [hausdorff : T2Space (ℝ ⊗[ℚ] L)]
124
+ model : RationalFilteredNilmanifold L degree dim
125
+ test : model.Niltest w
126
+ norm : test.normBound ≤ 1
127
+ complexity : test.ComplexityLE p
128
+ eval : ∀ x, f x = test.eval (sample x)
129
+
130
+ attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra
131
+ NativeSampleModel.topology NativeSampleModel.topologicalAdd
132
+ NativeSampleModel.continuousSMul NativeSampleModel.hausdorff
133
+ NativeSampleCorrelation.lie NativeSampleCorrelation.algebra
134
+ NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd
135
+ NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff
136
+
137
+ variable {σ X : Type*} {w : σ → ℕ} {degree : ℕ} {p : ℝ}
138
+ {sample : X → σ → ℤ} {f : X → ℂ}
139
+
140
+ noncomputable def NativeSampleModel.constOne (hp : 2 ≤ p) :
141
+ NativeSampleModel w degree p sample (fun _ => 1) where
142
+ L := RationalTorus.Algebra 0
143
+ dim := 0
144
+ model := RationalTorus.trivialNilmanifold degree
145
+ test := RationalFilteredNilmanifold.Niltest.const (RationalTorus.trivialNilmanifold degree) w 1
146
+ norm := by simp [RationalFilteredNilmanifold.Niltest.const]
147
+ complexity := RationalTorus.trivialNilmanifold_const_one_complexity degree w hp
148
+ eval _ := rfl
149
+
150
+ noncomputable def NativeSampleCorrelation.ofMean {S : Finset X} (hp : 2 ≤ p)
151
+ (hmean : Real.exp (-p) ≤ ‖𝔼 x ∈ S, f x‖) :
152
+ NativeSampleCorrelation w degree p S sample f where
153
+ L := RationalTorus.Algebra 0
154
+ dim := 0
155
+ model := RationalTorus.trivialNilmanifold degree
156
+ test := RationalFilteredNilmanifold.Niltest.const (RationalTorus.trivialNilmanifold degree) w 1
157
+ complexity := RationalTorus.trivialNilmanifold_const_one_complexity degree w hp
158
+ correlation := by simpa only [RationalFilteredNilmanifold.Niltest.eval_const, star_one, mul_one] using hmean
159
+
160
+ noncomputable def NativeSampleModel.smul (F : NativeSampleModel w degree p sample f)
161
+ (c : ℂ) (hc : ‖c‖ ≤ 1) : NativeSampleModel w degree p sample (c • f) where
162
+ L := F.L
163
+ dim := F.dim
164
+ model := F.model
165
+ test := F.test.scaleComplex c
166
+ norm := (F.test.scaleComplex_norm hc).trans F.norm
167
+ complexity := F.test.scaleComplex_complexity hc F.complexity
168
+ eval x := by change c * f x = c * F.test.eval (sample x); rw [F.eval]
169
+
170
+ theorem NativeSampleModel.norm_le (F : NativeSampleModel w degree p sample f) (x : X) :
171
+ ‖f x‖ ≤ 1 := by
172
+ rw [F.eval]
173
+ exact (F.test.norm_eval_le _).trans F.norm
174
+
175
+ noncomputable def NativeSampleCorrelation.toSampleModel {S : Finset X}
176
+ (V : NativeSampleCorrelation w degree p S sample f) (hV : V.test.normBound ≤ 1) :
177
+ NativeSampleModel w degree p sample (fun x => V.test.eval (sample x)) where
178
+ L := V.L
179
+ dim := V.dim
180
+ model := V.model
181
+ test := V.test
182
+ norm := hV
183
+ complexity := V.complexity
184
+ eval _ := rfl
185
+
186
+ def twistedNativeSampleFunctions {I : Type*} (w : σ → ℕ) (degree : ℕ) (p : ℝ)
187
+ (sample : X → σ → ℤ) (twist : I → X → ℂ) : Set (X → ℂ) :=
188
+ {f | f = 0 ∨ ∃ i g, Nonempty (NativeSampleModel w degree p sample g) ∧
189
+ f = fun x => star (twist i x) * g x}
190
+
191
+ theorem twistedNativeSampleFunctions_zero {I : Type*} (twist : I → X → ℂ) :
192
+ (0 : X → ℂ) ∈ twistedNativeSampleFunctions w degree p sample twist := Or.inl rfl
193
+
194
+ theorem twistedNativeSampleFunctions_balanced {I : Type*} (twist : I → X → ℂ) :
195
+ Balanced ℂ (twistedNativeSampleFunctions w degree p sample twist) := by
196
+ rintro c hc _ ⟨f, hf, rfl⟩
197
+ rcases hf with rfl | ⟨i, g, ⟨G⟩, rfl⟩
198
+ · exact Or.inl (smul_zero c)
199
+ · refine Or.inr ⟨i, c • g, ⟨G.smul c hc⟩, ?_⟩
200
+ funext x
201
+ simp only [Pi.smul_apply, smul_eq_mul]
202
+ ring
203
+
204
+ theorem twistedNativeSampleFunctions_norm {I : Type*} (twist : I → X → ℂ)
205
+ (htwist : ∀ i x, ‖twist i x‖ ≤ 1)
206
+ (hf : f ∈ twistedNativeSampleFunctions w degree p sample twist) (x : X) : ‖f x‖ ≤ 1 := by
207
+ rcases hf with rfl | ⟨i, g, ⟨G⟩, rfl⟩
208
+ · simp
209
+ · rw [norm_mul, norm_star]
210
+ exact (mul_le_of_le_one_left (norm_nonneg _) (htwist i x)).trans (G.norm_le x)
211
+
212
+ end Erdos3
213
+
214
+ end
215
+
216
+ section
217
+
218
+ namespace Erdos3
219
+
220
+ open scoped BigOperators
221
+
222
+ attribute [local instance] NativeSampleCorrelation.lie NativeSampleCorrelation.algebra
223
+ NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd
224
+ NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff
225
+
226
+ theorem nativeCorrelation_restrict_model {A σ : Type*}
227
+ (S : Finset A) (hS : S.Nonempty)
228
+ (w : σ → ℕ) (degree : ℕ) (p : ℝ) (sample : A → σ → ℤ)
229
+ (f twist : A → ℂ)
230
+ (V : NativeSampleCorrelation w degree p S sample
231
+ (fun x => f x * twist x))
232
+ (hV : V.test.normBound ≤ 1) :
233
+ ∃ G : S → ℂ, Nonempty (NativeSampleModel w degree p (fun x => sample x.val) G) ∧
234
+ Real.exp (-p) ≤ ‖(FiniteProbabilityWeights.uniformFinset S hS).correlation (fun x => f x.val)
235
+ (fun x => star (twist x.val) * G x)‖ := by
236
+ let G : S → ℂ := fun x => V.test.eval (sample x.val)
237
+ refine ⟨G, ⟨?_⟩, ?_⟩
238
+ · exact {
239
+ L := V.L
240
+ dim := V.dim
241
+ model := V.model
242
+ test := V.test
243
+ norm := hV
244
+ complexity := V.complexity
245
+ eval := fun _ => rfl }
246
+ have hc := V.correlation
247
+ rw [← FiniteProbabilityWeights.uniformFinset_complexMean S hS
248
+ (fun x => (f x * twist x) * star (V.test.eval (sample x)))] at hc
249
+ simpa only [G, FiniteProbabilityWeights.correlation, FiniteProbabilityWeights.complexMean,
250
+ star_mul, star_star, mul_assoc, mul_left_comm, mul_comm] using hc
251
+
252
+ theorem nativeCorrelation_finite_site_model {A σ : Type*}
253
+ (S : Finset A) (hS : S.Nonempty) [Nonempty S]
254
+ (w : σ → ℕ) (degree : ℕ) (p : ℝ) (sample : A → σ → ℤ)
255
+ (g : S → ℂ) (twist : A → ℂ)
256
+ (V : NativeSampleCorrelation w degree p S sample
257
+ (fun x => finiteSiteExtension Subtype.val g x * twist x))
258
+ (hV : V.test.normBound ≤ 1) :
259
+ ∃ G : S → ℂ, Nonempty (NativeSampleModel w degree p (fun x => sample x.val) G) ∧
260
+ Real.exp (-p) ≤ ‖(FiniteProbabilityWeights.uniformFinset S hS).correlation g
261
+ (fun x => star (twist x.val) * G x)‖ := by
262
+ obtain ⟨G, hG, hc⟩ := nativeCorrelation_restrict_model S hS w degree p sample
263
+ (finiteSiteExtension Subtype.val g) twist V hV
264
+ refine ⟨G, hG, ?_⟩
265
+ simpa only [finiteSiteExtension_apply Subtype.val Subtype.val_injective] using hc
266
+
267
+ end Erdos3
268
+
269
+ end
270
+
271
+ section
272
+
273
+ namespace Erdos3
274
+
275
+ open scoped TensorProduct
276
+
277
+ theorem commonStridePoint_index_of_mem {I : Type*} [Fintype I] [DecidableEq I]
278
+ (c : I → ℤ) (m : ℕ) (len : I → ℕ) {y : I → ℤ}
279
+ (hy : y ∈ commonStrideBox c m len) :
280
+ commonStridePoint c m (commonStrideIndex c m y) = y := by
281
+ rw [commonStrideBox_eq_image] at hy
282
+ obtain ⟨x, _, rfl⟩ := Finset.mem_image.mp hy
283
+ change commonStridePoint c m (commonStrideIndex c m (commonStridePoint c m x)) =
284
+ commonStridePoint c m x
285
+ by_cases hm : m = 0
286
+ · subst m
287
+ funext i
288
+ change c i + (0 : ℤ) * _ = c i + (0 : ℤ) * x i
289
+ simp only [zero_mul, add_zero]
290
+ · rw [commonStrideIndex_point c (Nat.pos_of_ne_zero hm)]
291
+
292
+ namespace RationalFilteredNilmanifold.Niltest
293
+
294
+ variable {I L : Type*} [Fintype I] [DecidableEq I] [LieRing L] [LieAlgebra ℚ L]
295
+ [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
296
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {degree dim : ℕ}
297
+ {D : RationalFilteredNilmanifold L degree dim}
298
+
299
+ noncomputable def commonStridePullback (T : D.Niltest (fun _ : I => 1))
300
+ (c : I → ℤ) (m : ℕ) : D.Niltest (fun _ : I => 1) :=
301
+ T.affinePullback (residueStepMatrix (fun _ : I => m)) c
302
+
303
+ @[simp] theorem commonStridePullback_observable (T : D.Niltest (fun _ : I => 1))
304
+ (c : I → ℤ) (m : ℕ) :
305
+ (T.commonStridePullback c m).observable = T.observable := rfl
306
+
307
+ @[simp] theorem commonStridePullback_normBound (T : D.Niltest (fun _ : I => 1))
308
+ (c : I → ℤ) (m : ℕ) :
309
+ (T.commonStridePullback c m).normBound = T.normBound := rfl
310
+
311
+ @[simp] theorem commonStridePullback_lipBound (T : D.Niltest (fun _ : I => 1))
312
+ (c : I → ℤ) (m : ℕ) :
313
+ (T.commonStridePullback c m).lipBound = T.lipBound := rfl
314
+
315
+ @[simp] theorem commonStridePullback_complexityLE (T : D.Niltest (fun _ : I => 1))
316
+ (c : I → ℤ) (m : ℕ) (p : ℝ) :
317
+ (T.commonStridePullback c m).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl
318
+
319
+ theorem commonStridePullback_eval (T : D.Niltest (fun _ : I => 1))
320
+ (c : I → ℤ) (m : ℕ) (x : I → ℤ) :
321
+ (T.commonStridePullback c m).eval x = T.eval (commonStridePoint c m x) := by
322
+ rw [commonStridePullback, eval_affinePullback, integerAffineMap_residueStepMatrix]
323
+ rfl
324
+
325
+ theorem commonStridePullback_eval_index_of_modEq (T : D.Niltest (fun _ : I => 1))
326
+ (c : I → ℤ) (m : ℕ) (y : I → ℤ)
327
+ (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) :
328
+ (T.commonStridePullback c m).eval (commonStrideIndex c m y) = T.eval y := by
329
+ rw [commonStridePullback_eval, commonStridePoint_index_of_modEq c m y hy]
330
+
331
+ theorem commonStridePullback_eval_index_of_mem (T : D.Niltest (fun _ : I => 1))
332
+ (c : I → ℤ) (m : ℕ) (len : I → ℕ) (y : I → ℤ)
333
+ (hy : y ∈ commonStrideBox c m len) :
334
+ (T.commonStridePullback c m).eval (commonStrideIndex c m y) = T.eval y := by
335
+ rw [commonStridePullback_eval, commonStridePoint_index_of_mem c m len hy]
336
+
337
+ end RationalFilteredNilmanifold.Niltest
338
+
339
+ namespace RationalFilteredNilmanifold.Niltest
340
+
341
+ variable {I Ω : Type*} {L : Type} [Fintype I] [DecidableEq I]
342
+ [LieRing L] [LieAlgebra ℚ L]
343
+ [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
344
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {degree dim : ℕ}
345
+ {D : RationalFilteredNilmanifold L degree dim} {p : ℝ}
346
+
347
+ noncomputable def commonStrideSampleModelOfModEq (T : D.Niltest (fun _ : I => 1))
348
+ (hnorm : T.normBound ≤ 1) (hcomplexity : T.ComplexityLE p)
349
+ (c : I → ℤ) (m : ℕ) (site : Ω → I → ℤ)
350
+ (hsite : ∀ x i, site x i ≡ c i [ZMOD (m : ℤ)]) :
351
+ NativeSampleModel (fun _ : I => 1) degree p
352
+ (fun x => commonStrideIndex c m (site x)) (fun x => T.eval (site x)) where
353
+ L := L
354
+ dim := dim
355
+ model := D
356
+ test := T.commonStridePullback c m
357
+ norm := hnorm
358
+ complexity := hcomplexity
359
+ eval x := (T.commonStridePullback_eval_index_of_modEq c m (site x) (hsite x)).symm
360
+
361
+ noncomputable def commonStrideSampleModel (T : D.Niltest (fun _ : I => 1))
362
+ (hnorm : T.normBound ≤ 1) (hcomplexity : T.ComplexityLE p)
363
+ (c : I → ℤ) (m : ℕ) (len : I → ℕ) :
364
+ NativeSampleModel (fun _ : I => 1) degree p
365
+ (fun y : commonStrideBox c m len => commonStrideIndex c m y.val)
366
+ (fun y => T.eval y.val) where
367
+ L := L
368
+ dim := dim
369
+ model := D
370
+ test := T.commonStridePullback c m
371
+ norm := hnorm
372
+ complexity := hcomplexity
373
+ eval y := (T.commonStridePullback_eval_index_of_mem c m len y.val y.property).symm
374
+
375
+ noncomputable def residueSliceSampleModel (T : D.Niltest (fun _ : I => 1))
376
+ (hnorm : T.normBound ≤ 1) (hcomplexity : T.ComplexityLE p)
377
+ {N : I → ℕ} {m : ℕ} (slice : ResidueBoxSlice N m) :
378
+ NativeSampleModel (fun _ : I => 1) degree p
379
+ (fun y : slice.integerPoints =>
380
+ commonStrideIndex (fun i => (slice.start i : ℤ)) m y.val)
381
+ (fun y => T.eval y.val) where
382
+ L := L
383
+ dim := dim
384
+ model := D
385
+ test := T.commonStridePullback (fun i => (slice.start i : ℤ)) m
386
+ norm := hnorm
387
+ complexity := hcomplexity
388
+ eval y := by
389
+ apply (T.commonStridePullback_eval_index_of_mem
390
+ (fun i => (slice.start i : ℤ)) m slice.length y.val _).symm
391
+ rw [← slice.integerPoints_eq_commonStrideBox]
392
+ exact y.property
393
+
394
+ end RationalFilteredNilmanifold.Niltest
395
+
396
+ end Erdos3
397
+
398
+ end
399
+
400
+ section
401
+
402
+ namespace Erdos3.NativeSampleModel
403
+
404
+ open CircleFourier
405
+ open scoped TensorProduct BigOperators
406
+
407
+ attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra
408
+ NativeSampleModel.topology NativeSampleModel.topologicalAdd
409
+ NativeSampleModel.continuousSMul NativeSampleModel.hausdorff
410
+
411
+ variable {σ X : Type*} {w : σ → ℕ} {degree : ℕ} {p : ℝ}
412
+ {sample : X → σ → ℤ} {f : X → ℂ}
413
+
414
+ structure VerticalExpansion (native : NativeSampleModel w degree p sample f)
415
+ (q rho : ℝ) where
416
+ I : Type
417
+ [finite : Fintype I]
418
+ frequency : I → native.L →ₗ[ℚ] ℚ
419
+ component : I → native.model.Niltest w
420
+ card_le : (Fintype.card I : ℝ) ≤ Real.exp (verticalDecompositionBudget q)
421
+ height_le : ∀ i j, rationalLogHeight (frequency i (native.model.basis j)) ≤
422
+ verticalDecompositionBudget q
423
+ orbit_eq : ∀ i, (component i).orbit = native.test.orbit
424
+ norm_eq : ∀ i, (component i).normBound = native.test.normBound
425
+ lip_eq : ∀ i, (component i).lipBound = native.test.lipBound
426
+ vertical : ∀ i (z : native.model.RealGroup),
427
+ z ∈ native.model.filtration.realification.subgroup degree → ∀ x,
428
+ (component i).observable (z • x) =
429
+ character ((realifyFunctional (frequency i) z.coord : ℝ) : CircleFourier.Circle) *
430
+ (component i).observable x
431
+ integral : ∀ i, (∃ x, (component i).observable x ≠ 0) →
432
+ ∀ z : native.model.RealGroup,
433
+ z ∈ native.model.filtration.realification.subgroup degree →
434
+ z ∈ native.model.realLattice → ∃ n : ℤ, realifyFunctional (frequency i) z.coord = n
435
+ preserves_character : ∀ (z : native.model.RealGroup) (c : ℂ),
436
+ (∀ x, native.test.observable (z • x) = c * native.test.observable x) →
437
+ ∀ i x, (component i).observable (z • x) = c * (component i).observable x
438
+ observable_error : ∀ x,
439
+ ‖(∑ i, (component i).observable x) - native.test.observable x‖ ≤ rho
440
+
441
+ attribute [instance] VerticalExpansion.finite
442
+
443
+ theorem exists_verticalExpansion (native : NativeSampleModel w degree p sample f)
444
+ {q rho : ℝ} (hq : 0 ≤ q) (hpq : p ≤ q) (hrho : 0 < rho)
445
+ (hrhoq : rho⁻¹ ≤ Real.exp q) : Nonempty (native.VerticalExpansion q rho) := by
446
+ obtain ⟨I, inst, frequency, component, hcard, hheight, hcert,
447
+ hvert, hint, hpres, herr, _⟩ :=
448
+ native.test.exists_vertical_decomposition_preserving_bounds_and_characters hq
449
+ (native.complexity.mono hpq) hrho hrhoq
450
+ exact ⟨{
451
+ I := I
452
+ finite := inst
453
+ frequency := frequency
454
+ component := component
455
+ card_le := hcard
456
+ height_le := hheight
457
+ orbit_eq := fun i => (hcert i).2.1
458
+ norm_eq := fun i => (hcert i).2.2.1
459
+ lip_eq := fun i => (hcert i).2.2.2
460
+ vertical := hvert
461
+ integral := hint
462
+ preserves_character := hpres
463
+ observable_error := herr }⟩
464
+
465
+ theorem exists_verticalExpansion_exp_error (native : NativeSampleModel w degree p sample f)
466
+ {r : ℝ} (hp : 0 ≤ p) (hr : 0 ≤ r) :
467
+ Nonempty (native.VerticalExpansion (p + r) (Real.exp (-r))) := by
468
+ apply native.exists_verticalExpansion (add_nonneg hp hr) (le_add_of_nonneg_right hr)
469
+ (Real.exp_pos _)
470
+ rw [Real.exp_neg, inv_inv]
471
+ exact Real.exp_le_exp.mpr (le_add_of_nonneg_left hp)
472
+
473
+ namespace VerticalExpansion
474
+
475
+ variable {native : NativeSampleModel w degree p sample f} {q rho : ℝ}
476
+ (E : native.VerticalExpansion q rho)
477
+
478
+ theorem complexity (i : E.I) : (E.component i).ComplexityLE p := by
479
+ refine ⟨native.complexity.1, ?_⟩
480
+ rw [E.norm_eq, E.lip_eq]
481
+ exact native.complexity.2
482
+
483
+ theorem normBound_le (i : E.I) : (E.component i).normBound ≤ 1 := by
484
+ rw [E.norm_eq]
485
+ exact native.norm
486
+
487
+ theorem eval_error (x : σ → ℤ) :
488
+ ‖(∑ i, (E.component i).eval x) - native.test.eval x‖ ≤ rho := by
489
+ simpa only [RationalFilteredNilmanifold.Niltest.eval, E.orbit_eq] using
490
+ E.observable_error (QuotientGroup.mk
491
+ (native.model.filtration.realification.polynomialOrbitEval w x native.test.orbit))
492
+
493
+ theorem evalReal_error (x : σ → ℝ) :
494
+ ‖(∑ i, (E.component i).evalReal x) - native.test.evalReal x‖ ≤ rho := by
495
+ simpa only [RationalFilteredNilmanifold.Niltest.evalReal, E.orbit_eq] using
496
+ E.observable_error (QuotientGroup.mk
497
+ (native.model.filtration.realification.polynomialOrbitRealEval w x native.test.orbit))
498
+
499
+ theorem sample_error (x : X) :
500
+ ‖(∑ i, (E.component i).eval (sample x)) - f x‖ ≤ rho := by
501
+ rw [native.eval]
502
+ exact E.eval_error (sample x)
503
+
504
+ theorem norm_eval_le (i : E.I) (x : σ → ℤ) : ‖(E.component i).eval x‖ ≤ 1 :=
505
+ ((E.component i).norm_eval_le x).trans (E.normBound_le i)
506
+
507
+ theorem norm_evalReal_le (i : E.I) (x : σ → ℝ) : ‖(E.component i).evalReal x‖ ≤ 1 :=
508
+ ((E.component i).norm_evalReal_le x).trans (E.normBound_le i)
509
+
510
+ noncomputable def sampleModel (i : E.I) :
511
+ NativeSampleModel w degree p sample (fun x => (E.component i).eval (sample x)) where
512
+ L := native.L
513
+ dim := native.dim
514
+ model := native.model
515
+ test := E.component i
516
+ norm := E.normBound_le i
517
+ complexity := E.complexity i
518
+ eval _ := rfl
519
+
520
+ theorem coefficient_mass :
521
+ (∑ _i : E.I, ‖(1 : ℂ)‖) ≤ Real.exp (verticalDecompositionBudget q) := by
522
+ simpa using E.card_le
523
+
524
+ end VerticalExpansion
525
+ end Erdos3.NativeSampleModel
526
+
527
+ end
528
+
529
+ section
530
+
531
+ namespace Erdos3
532
+
533
+ open scoped BigOperators
534
+
535
+ theorem exists_sampled_native_model {Ω T X σ I : Type*}
536
+ [Fintype Ω] [Fintype T] [Nonempty T] [Fintype X]
537
+ {J : Ω → Type*} [∀ z, Nonempty (J z)]
538
+ (μ : FiniteProbabilityWeights Ω) (F : Ω → T → X)
539
+ (slices : ∀ z, J z → Finset T) (tests : ∀ z, J z → T → ℂ)
540
+ (r : FiniteProbabilityWeights X) (hr : ∀ x, 0 < r.weight x)
541
+ (w : σ → ℕ) (degree : ℕ) (complexity : ℝ) (sample : X → σ → ℤ)
542
+ (twist : I → X → ℂ) (htwist : ∀ i x, ‖twist i x‖ ≤ 1)
543
+ {K C B beta tau ε : ℝ} (hK : 0 ≤ K) (hC : 0 ≤ C)
544
+ (hB : 0 < B) (hbeta : 0 < beta) (htau : 0 < tau)
545
+ (hsize : ∀ z j, (Fintype.card T : ℝ) / (slices z j).card ≤ K)
546
+ (htests : ∀ z j t, ‖tests z j t‖ ≤ 1)
547
+ (hdetect : ∀ g : X → ℂ, (∀ x, ‖g x‖ ≤ 1) →
548
+ (tau / B ^ 2) / max 1 (K * (2 * C) / tau) ≤ sampledSliceSeminorm μ F slices tests g →
549
+ ∃ (i : I) (G : X → ℂ), Nonempty (NativeSampleModel w degree complexity sample G) ∧
550
+ beta ≤ ‖r.correlation g (fun x => star (twist i x) * G x)‖)
551
+ (hexcess : r.excessMass (μ.siteLaw F) C ≤ ε)
552
+ (b : X → ℂ) (hb : ∀ x, ‖b x‖ ≤ B) :
553
+ ∃ (n : ℕ) (_ : 0 < n) (Q : Fin n → (X → ℂ)) (c : Fin n → ℝ) (e : X → ℂ),
554
+ (∀ i, Q i ∈ twistedNativeSampleFunctions w degree complexity sample twist) ∧
555
+ b = (∑ i, c i • Q i) + e ∧
556
+ (∑ i, |c i|) ≤ 2 / beta ∧
557
+ sampledSliceSeminorm μ F slices tests e ≤ 2 * tau + 2 * K * (B + 2 / beta) * ε ∧
558
+ (n : ℝ) ≤ 1 + 4 * (K * (2 * C)) ^ 2 / (beta ^ 2 * tau ^ 2) := by
559
+ let atoms := twistedNativeSampleFunctions w degree complexity sample twist
560
+ let cap := max 1 (K * (2 * C) / tau)
561
+ have hcap : 1 ≤ cap := le_max_left _ _
562
+ have hdetector (g : X → ℂ) (hg : ∀ x, ‖g x‖ ≤ K * (2 * C) / tau)
563
+ (hlarge : tau / B ^ 2 ≤ sampledSliceSeminorm μ F slices tests g) :
564
+ ∃ Q ∈ atoms, beta ≤ ‖r.correlation g Q‖ := by
565
+ have hunit (v : X → ℂ) (hv : ∀ x, ‖v x‖ ≤ 1)
566
+ (hX : (tau / B ^ 2) / cap ≤ sampledSliceSeminorm μ F slices tests v) :
567
+ ∃ Q ∈ atoms, beta ≤ ‖r.correlation v Q‖ := by
568
+ obtain ⟨i, G, hG, hcorr⟩ := hdetect v hv hX
569
+ exact ⟨_, Or.inr ⟨i, G, hG, rfl⟩, hcorr⟩
570
+ obtain ⟨Q, hQ, hc⟩ := detector_of_unit_detector r
571
+ (sampledSliceSeminorm μ F slices tests) atoms (lt_of_lt_of_le zero_lt_one hcap)
572
+ hunit g (fun x => (hg x).trans (le_max_right _ _)) hlarge
573
+ have hscale : beta ≤ cap * beta := by
574
+ simpa only [one_mul] using mul_le_mul_of_nonneg_right hcap hbeta.le
575
+ exact ⟨Q, hQ, hscale.trans hc⟩
576
+ exact exists_sampled_slice_model μ F slices tests r hr
577
+ (twistedNativeSampleFunctions_balanced twist) ⟨0, twistedNativeSampleFunctions_zero twist⟩
578
+ (fun Q hQ x => twistedNativeSampleFunctions_norm twist htwist hQ x)
579
+ hK hC hB hbeta htau hsize htests hdetector hexcess b hb
580
+
581
+ end Erdos3
582
+
583
+ end
584
+
585
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SampledSliceFixedModelPartners.lean ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.SampledNativeModel
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+ open scoped BigOperators Classical
9
+
10
+ theorem exists_fixed_sampled_slice_model_partners
11
+ {Ω T X K : Type*} {J : Ω → Type*} {I : K → Type*}
12
+ [Fintype Ω] [Fintype T] [Nonempty T] [Fintype K]
13
+ [∀ k, Fintype (I k)] [∀ k, Nonempty (I k)]
14
+ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω)
15
+ (physical : Ω → T → X) (slices : ∀ z, J z → Finset T)
16
+ (weight : ∀ z, J z → T → ℂ) (selected : ∀ z, K → J z)
17
+ (hS : ∀ z j, (slices z j).Nonempty) {cap : ℝ}
18
+ (hsize : ∀ z j, (Fintype.card T : ℝ) / (slices z j).card ≤ cap)
19
+ (hweight : ∀ z j t, ‖weight z j t‖ ≤ 1)
20
+ (v e : K → X → ℂ) (Q : ∀ k, I k → X → ℂ) (c : ∀ k, I k → ℂ)
21
+ (hmodel : ∀ k, v k = (∑ i, c k i • Q k i) + e k)
22
+ {delta M kappa : ℝ} (hdelta : 0 < delta) (hM : 0 < M)
23
+ (hc : ∀ k, (∑ i, ‖c k i‖) ≤ M)
24
+ (hproductive : kappa ≤ outer.mass productive)
25
+ (herror : (∑ k, sampledSliceSeminorm outer physical slices weight (e k)) ≤ kappa * delta / 8)
26
+ (hscore : ∀ z ∈ productive, ∀ k,
27
+ delta ≤ ‖𝔼 t ∈ slices z (selected z k), v k (physical z t) * weight z (selected z k) t‖) :
28
+ ∃ (partner : ∀ k, I k) (retained : Finset Ω),
29
+ retained ⊆ productive ∧
30
+ (3 * kappa / 4) / (∏ k, (Fintype.card (I k) : ℝ)) ≤ outer.mass retained ∧
31
+ ∀ z ∈ retained, ∀ k, delta / (2 * M) ≤
32
+ ‖𝔼 t ∈ slices z (selected z k), Q k (partner k) (physical z t) * weight z (selected z k) t‖ := by
33
+ let W := fun z j => normalizedSliceTest (slices z j) (weight z j)
34
+ let test := fun z k => sampledTestLinearMap (physical z) (W z (selected z k))
35
+ let err := fun k z => (⨆ j, sampledSingleTestSeminorm (physical z) (W z j)) (e k)
36
+ have hW (z) (j) (t) : ‖W z j t‖ ≤ cap :=
37
+ normalizedSliceTest_norm_le _ _ (hsize z j) (hweight z j) t
38
+ have htest (z) (_hz : z ∈ productive) (k) : ‖test z k (e k)‖ ≤ err k z := by
39
+ change sampledSingleTestSeminorm (physical z) (W z (selected z k)) (e k) ≤ _
40
+ dsimp only [err]
41
+ have hb := sampledSingleTestSeminorm_bddAbove physical W hW z
42
+ rw [Seminorm.iSup_apply hb]
43
+ exact le_ciSup (Seminorm.bddAbove_range_iff.mp hb (e k)) (selected z k)
44
+ have hmean : (∑ k, outer.mean (err k)) ≤ kappa * (delta / 2) / 4 := by
45
+ change (∑ k, sampledSliceSeminorm outer physical slices weight (e k)) ≤ _
46
+ convert herror using 1; ring
47
+ have heval (z) (k) (f : X → ℂ) :
48
+ test z k f = 𝔼 t ∈ slices z (selected z k), f (physical z t) * weight z (selected z k) t :=
49
+ normalizedSliceTest_mean _ (hS z (selected z k)) _ _
50
+ obtain ⟨partner, retained, hsub, hmass, hlocal⟩ := exists_fixed_linear_model_partners
51
+ outer productive v e Q c test err hmodel hdelta hM hc
52
+ (fun _ _ => apply_nonneg _ _) htest hproductive hmean
53
+ (by intro z hz k; rw [heval]; exact hscore z hz k)
54
+ refine ⟨partner, retained, hsub, hmass, ?_⟩
55
+ intro z hz k
56
+ simpa only [heval] using hlocal z hz k
57
+
58
+ theorem exists_fixed_sampled_slice_native_partners
59
+ {Ω T X K σ Θ : Type*} {J : Ω → Type*} {I : K → Type*}
60
+ [Fintype Ω] [Fintype T] [Nonempty T] [Fintype K]
61
+ [∀ k, Fintype (I k)] [∀ k, Nonempty (I k)]
62
+ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω)
63
+ (physical : Ω → T → X) (slices : ∀ z, J z → Finset T)
64
+ (weight : ∀ z, J z → T → ℂ) (selected : ∀ z, K → J z)
65
+ (hS : ∀ z j, (slices z j).Nonempty) {cap : ℝ}
66
+ (hsize : ∀ z j, (Fintype.card T : ℝ) / (slices z j).card ≤ cap)
67
+ (hweight : ∀ z j t, ‖weight z j t‖ ≤ 1)
68
+ (v e : K → X → ℂ) (Q : ∀ k, I k → X → ℂ) (c : ∀ k, I k → ℂ)
69
+ (hmodel : ∀ k, v k = (∑ i, c k i • Q k i) + e k)
70
+ {delta M kappa : ℝ} (hdelta : 0 < delta) (hM : 0 < M)
71
+ (hc : ∀ k, (∑ i, ‖c k i‖) ≤ M)
72
+ (hproductive : kappa ≤ outer.mass productive)
73
+ (herror : (∑ k, sampledSliceSeminorm outer physical slices weight (e k)) ≤ kappa * delta / 8)
74
+ (hkappa : 0 < kappa)
75
+ (w : σ → ℕ) (degree : ℕ) (budget : ℝ) (sample : X → σ → ℤ) (twist : Θ → X → ℂ)
76
+ (hQ : ∀ k i, Q k i ∈ twistedNativeSampleFunctions w degree budget sample twist)
77
+ (hscore : ∀ z ∈ productive, ∀ k,
78
+ delta ≤ ‖𝔼 t ∈ slices z (selected z k), v k (physical z t) * weight z (selected z k) t‖) :
79
+ ∃ (fixedTwist : K → Θ) (nativeValue : K → X → ℂ)
80
+ (_native : ∀ k, NativeSampleModel w degree budget sample (nativeValue k))
81
+ (retained : Finset Ω),
82
+ retained ⊆ productive ∧ 0 < outer.mass retained ∧
83
+ (3 * kappa / 4) / (∏ k, (Fintype.card (I k) : ℝ)) ≤ outer.mass retained ∧
84
+ ∀ z ∈ retained, ∀ k, delta / (2 * M) ≤
85
+ ‖𝔼 t ∈ slices z (selected z k),
86
+ (star (twist (fixedTwist k) (physical z t)) * nativeValue k (physical z t)) *
87
+ weight z (selected z k) t‖ := by
88
+ obtain ⟨partner, retained, hsub, hmass, hlocal⟩ := exists_fixed_sampled_slice_model_partners
89
+ outer productive physical slices weight selected hS hsize hweight v e Q c hmodel
90
+ hdelta hM hc hproductive herror hscore
91
+ have hmasspos : 0 < outer.mass retained := (div_pos
92
+ (by positivity : 0 < 3 * kappa / 4)
93
+ (Finset.prod_pos (fun k _ => Nat.cast_pos.mpr Fintype.card_pos))).trans_le hmass
94
+ have hne : retained.Nonempty := Finset.nonempty_iff_ne_empty.mpr (by
95
+ intro he
96
+ simp only [he, FiniteProbabilityWeights.mass, Finset.sum_empty] at hmasspos
97
+ linarith)
98
+ obtain ⟨z₀, hz₀⟩ := hne
99
+ have hchosen (k) : ∃ (t : Θ) (g : X → ℂ),
100
+ Nonempty (NativeSampleModel w degree budget sample g) ∧
101
+ Q k (partner k) = fun x => star (twist t x) * g x := by
102
+ rcases hQ k (partner k) with hzero | hnative
103
+ · have hn := hlocal z₀ hz₀ k
104
+ rw [hzero] at hn
105
+ simp only [Pi.zero_apply, zero_mul] at hn
106
+ have hpos : 0 < delta / (2 * M) := div_pos hdelta (by positivity)
107
+ simp at hn
108
+ linarith
109
+ · exact hnative
110
+ choose fixedTwist nativeValue hnative heq using hchosen
111
+ let native := fun k => Classical.choice (hnative k)
112
+ refine ⟨fixedTwist, nativeValue, native, retained, hsub, hmasspos, hmass, ?_⟩
113
+ intro z hz k
114
+ simpa only [heq k] using hlocal z hz k
115
+
116
+ end Erdos3
117
+
118
+ end
119
+
120
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SaturatedFlag.lean ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.EuclideanDomain.Int
2
+ import Mathlib.Basic.Real.Basic
3
+ import Mathlib.LinearAlgebra.Basis.Prod
4
+ import Mathlib.LinearAlgebra.FreeModule.PID
5
+ import Mathlib.LinearAlgebra.LinearIndependent.Lemmas
6
+ import Mathlib.LinearAlgebra.Projection
7
+
8
+ namespace OAI
9
+
10
+ section
11
+
12
+ namespace Erdos3.IntegerBasisReduction.SaturatedFlag
13
+
14
+ open scoped BigOperators
15
+ open Function Set Submodule
16
+ open Module
17
+
18
+ variable {M : Type*} [AddCommGroup M]
19
+
20
+ def IsSaturated (P : Submodule ℤ M) : Prop :=
21
+ ∀ (a : ℤ) (x : M), a ≠ 0 → a • x ∈ P → x ∈ P
22
+
23
+ def IsAdaptedTo {κ : Type*} (b : Basis κ ℤ M)
24
+ (P : Submodule ℤ M) : Prop :=
25
+ ∃ s : Set κ, P = Submodule.span ℤ (b '' s)
26
+
27
+ @[simp] theorem isSaturated_bot [Module.IsTorsionFree ℤ M] :
28
+ IsSaturated (⊥ : Submodule ℤ M) := by
29
+ intro a x ha hx
30
+ rw [Submodule.mem_bot] at hx ⊢
31
+ exact (smul_eq_zero.mp hx).resolve_left ha
32
+
33
+ @[simp] theorem isSaturated_top : IsSaturated (⊤ : Submodule ℤ M) := by
34
+ intro _ _ _ _
35
+ exact Submodule.mem_top
36
+
37
+ theorem IsSaturated.comap_subtype {P O : Submodule ℤ M}
38
+ (hP : IsSaturated P) (_hPO : P ≤ O) :
39
+ IsSaturated (P.comap O.subtype) := by
40
+ intro a x ha hx
41
+ change (a • (x : M)) ∈ P at hx
42
+ change (x : M) ∈ P
43
+ exact hP a x ha hx
44
+
45
+ theorem IsSaturated.comap_subtype_of_le {P O : Submodule ℤ M}
46
+ (hP : IsSaturated P) (hPO : P ≤ O) :
47
+ IsSaturated (P.comap O.subtype) :=
48
+ hP.comap_subtype hPO
49
+
50
+ def rationalEmbed (d : ℕ) : (Fin d → ℤ) →ₗ[ℤ] (Fin d → ℚ) where
51
+ toFun x i := (x i : ℚ)
52
+ map_add' x y := by
53
+ ext i
54
+ simp
55
+ map_smul' a x := by
56
+ ext i
57
+ simp
58
+
59
+ @[simp] theorem rationalEmbed_apply {d : ℕ} (x : Fin d → ℤ) (i : Fin d) :
60
+ rationalEmbed d x i = (x i : ℚ) := rfl
61
+
62
+ theorem rationalEmbed_zsmul {d : ℕ} (a : ℤ) (x : Fin d → ℤ) :
63
+ rationalEmbed d (a • x) = (a : ℚ) • rationalEmbed d x := by
64
+ ext i
65
+ simp [rationalEmbed]
66
+
67
+ def rationalSpanLattice {d : ℕ} (S : Set (Fin d → ℤ)) :
68
+ Submodule ℤ (Fin d → ℤ) :=
69
+ ((Submodule.span ℚ (rationalEmbed d '' S)).restrictScalars ℤ).comap
70
+ (rationalEmbed d)
71
+
72
+ @[simp] theorem mem_rationalSpanLattice {d : ℕ} {S : Set (Fin d → ℤ)}
73
+ {x : Fin d → ℤ} :
74
+ x ∈ rationalSpanLattice S ↔
75
+ rationalEmbed d x ∈ Submodule.span ℚ (rationalEmbed d '' S) :=
76
+ Iff.rfl
77
+
78
+ theorem isSaturated_rationalSpanLattice {d : ℕ}
79
+ (S : Set (Fin d → ℤ)) : IsSaturated (rationalSpanLattice S) := by
80
+ intro a x ha hx
81
+ rw [mem_rationalSpanLattice] at hx ⊢
82
+ have hax : (a : ℚ) • rationalEmbed d x ∈
83
+ Submodule.span ℚ (rationalEmbed d '' S) := by
84
+ rw [← rationalEmbed_zsmul]
85
+ exact hx
86
+ have hinv := (Submodule.span ℚ (rationalEmbed d '' S)).smul_mem
87
+ (a : ℚ)⁻¹ hax
88
+ simpa [smul_smul, ha] using hinv
89
+
90
+ theorem rationalSpanLattice_mono {d : ℕ} {S T : Set (Fin d → ℤ)}
91
+ (hST : S ⊆ T) : rationalSpanLattice S ≤ rationalSpanLattice T := by
92
+ intro x hx
93
+ rw [mem_rationalSpanLattice] at hx ⊢
94
+ exact Submodule.span_mono (Set.image_mono hST) hx
95
+
96
+ def realEmbed (d : ℕ) : (Fin d → ℤ) →ₗ[ℤ] (Fin d → ℝ) where
97
+ toFun x i := (x i : ℝ)
98
+ map_add' x y := by
99
+ ext i
100
+ simp
101
+ map_smul' a x := by
102
+ ext i
103
+ simp
104
+
105
+ @[simp] theorem realEmbed_apply {d : ℕ} (x : Fin d → ℤ) (i : Fin d) :
106
+ realEmbed d x i = (x i : ℝ) := rfl
107
+
108
+ theorem realEmbed_zsmul {d : ℕ} (a : ℤ) (x : Fin d → ℤ) :
109
+ realEmbed d (a • x) = (a : ℝ) • realEmbed d x := by
110
+ ext i
111
+ simp [realEmbed]
112
+
113
+ def realPrefixLattice {d n : ℕ} (x : Fin n → (Fin d → ℤ)) (i : Fin n) :
114
+ Submodule ℤ (Fin d → ℤ) :=
115
+ ((Submodule.span ℝ (realEmbed d '' (x '' Set.Iic i))).restrictScalars ℤ).comap
116
+ (realEmbed d)
117
+
118
+ @[simp] theorem mem_realPrefixLattice {d n : ℕ}
119
+ {x : Fin n → (Fin d → ℤ)} {i : Fin n} {z : Fin d → ℤ} :
120
+ z ∈ realPrefixLattice x i ↔
121
+ realEmbed d z ∈
122
+ Submodule.span ℝ (realEmbed d '' (x '' Set.Iic i)) :=
123
+ Iff.rfl
124
+
125
+ theorem isSaturated_realPrefixLattice {d n : ℕ}
126
+ (x : Fin n → (Fin d → ℤ)) (i : Fin n) :
127
+ IsSaturated (realPrefixLattice x i) := by
128
+ intro a z ha hz
129
+ rw [mem_realPrefixLattice] at hz ⊢
130
+ have haz : (a : ℝ) • realEmbed d z ∈
131
+ Submodule.span ℝ (realEmbed d '' (x '' Set.Iic i)) := by
132
+ rw [← realEmbed_zsmul]
133
+ exact hz
134
+ have hinv :=
135
+ (Submodule.span ℝ (realEmbed d '' (x '' Set.Iic i))).smul_mem
136
+ (a : ℝ)⁻¹ haz
137
+ simpa [smul_smul, ha] using hinv
138
+
139
+ theorem monotone_realPrefixLattice {d n : ℕ}
140
+ (x : Fin n → (Fin d → ℤ)) : Monotone (realPrefixLattice x) := by
141
+ intro i j hij z hz
142
+ rw [mem_realPrefixLattice] at hz ⊢
143
+ apply Submodule.span_mono (Set.image_mono (Set.image_mono ?_)) hz
144
+ intro k hk
145
+ exact hk.trans hij
146
+
147
+ theorem self_mem_realPrefixLattice {d n : ℕ}
148
+ (x : Fin n → (Fin d → ℤ)) (i : Fin n) :
149
+ x i ∈ realPrefixLattice x i := by
150
+ rw [mem_realPrefixLattice]
151
+ apply Submodule.subset_span
152
+ exact ⟨x i, ⟨i, Set.mem_Iic.mpr le_rfl, rfl⟩, rfl⟩
153
+
154
+ section Smith
155
+
156
+ variable {ι : Type*} [Finite ι]
157
+
158
+ omit [Finite ι] in
159
+
160
+ theorem smithVector_mem_of_isSaturated (_b : Basis ι ℤ M)
161
+ (P : Submodule ℤ M) (hP : IsSaturated P) {n : ℕ}
162
+ (snf : Basis.SmithNormalForm P ι n) (i : Fin n) :
163
+ snf.bM (snf.f i) ∈ P := by
164
+ classical
165
+ have hai : snf.a i ≠ 0 := by
166
+ intro hai
167
+ apply (snf.bN.ne_zero i)
168
+ apply Subtype.ext
169
+ simp [snf.snf i, hai]
170
+ exact hP (snf.a i) (snf.bM (snf.f i)) hai <| by
171
+ simpa [snf.snf i] using (snf.bN i).property
172
+
173
+ theorem exists_isCompl_of_isSaturated (b : Basis ι ℤ M)
174
+ (P : Submodule ℤ M) (hP : IsSaturated P) :
175
+ ∃ Q : Submodule ℤ M, IsCompl P Q := by
176
+ classical
177
+ let snf := P.smithNormalForm b
178
+ let selected : Set ι := Set.range snf.2.f
179
+ let Q : Submodule ℤ M :=
180
+ Submodule.span ℤ (snf.2.bM '' selectedᶜ)
181
+ have hselected :
182
+ P = Submodule.span ℤ (snf.2.bM '' selected) := by
183
+ apply le_antisymm
184
+ · intro x hx
185
+ let xp : P := ⟨x, hx⟩
186
+ have hxp : xp ∈ Submodule.span ℤ (Set.range snf.2.bN) := by
187
+ rw [snf.2.bN.span_eq]
188
+ exact Submodule.mem_top
189
+ exact Submodule.span_induction (R := ℤ) (s := Set.range snf.2.bN)
190
+ (p := fun y _ ↦ (y : M) ∈
191
+ Submodule.span ℤ (snf.2.bM '' selected))
192
+ (fun y hy ↦ by
193
+ obtain ⟨i, rfl⟩ := hy
194
+ rw [snf.2.snf i]
195
+ apply Submodule.smul_mem
196
+ apply Submodule.subset_span
197
+ exact ⟨snf.2.f i, ⟨i, rfl⟩, rfl⟩)
198
+ (Submodule.zero_mem _)
199
+ (fun _ _ _ _ hy hz ↦ Submodule.add_mem _ hy hz)
200
+ (fun a _ _ hy ↦ Submodule.smul_mem _ a hy)
201
+ hxp
202
+ · refine Submodule.span_le.mpr ?_
203
+ rintro _ ⟨j, ⟨i, rfl⟩, rfl⟩
204
+ exact smithVector_mem_of_isSaturated b P hP snf.2 i
205
+ refine ⟨Q, ?_⟩
206
+ rw [hselected]
207
+ exact snf.2.bM.linearIndependent.isCompl_span_image
208
+ snf.2.bM.span_eq (isCompl_compl)
209
+
210
+ theorem exists_basis_extending_of_isSaturated (b : Basis ι ℤ M)
211
+ (P : Submodule ℤ M) (hP : IsSaturated P)
212
+ {κ : Type*} (bP : Basis κ ℤ P) :
213
+ ∃ (m : ℕ) (bM : Basis (κ ⊕ Fin m) ℤ M),
214
+ ∀ i, bM (Sum.inl i) = (bP i : M) := by
215
+ classical
216
+ obtain ⟨Q, hPQ⟩ := exists_isCompl_of_isSaturated b P hP
217
+ obtain ⟨m, bQ⟩ := Submodule.basisOfPid b Q
218
+ let e : (P × Q) ≃ₗ[ℤ] M := P.prodEquivOfIsCompl Q hPQ
219
+ let bM : Basis (κ ⊕ Fin m) ℤ M := (bP.prod bQ).map e
220
+ refine ⟨m, bM, ?_⟩
221
+ intro i
222
+ simp [bM, e]
223
+
224
+ theorem span_image_inl_eq_of_span_comap_eq
225
+ {P R : Submodule ℤ M} (hRP : R ≤ P)
226
+ {κ μ : Type*} (bP : Basis κ ℤ P) (bM : Basis (κ ⊕ μ) ℤ M)
227
+ (hext : ∀ i, bM (Sum.inl i) = (bP i : M)) (s : Set κ)
228
+ (hspan : R.comap P.subtype = Submodule.span ℤ (bP '' s)) :
229
+ R = Submodule.span ℤ (bM '' (Sum.inl '' s)) := by
230
+ have himage : P.subtype '' (bP '' s) = bM '' (Sum.inl '' s) := by
231
+ ext x
232
+ constructor
233
+ · rintro ⟨_, ⟨i, hi, rfl⟩, rfl⟩
234
+ exact ⟨Sum.inl i, ⟨i, hi, rfl⟩, hext i⟩
235
+ · rintro ⟨_, ⟨i, hi, rfl⟩, rfl⟩
236
+ exact ⟨bP i, ⟨i, hi, rfl⟩, (hext i).symm⟩
237
+ calc
238
+ R = (R.comap P.subtype).map P.subtype :=
239
+ (Submodule.map_comap_eq_self (by
240
+ simpa [Submodule.range_subtype] using hRP)).symm
241
+ _ = (Submodule.span ℤ (bP '' s)).map P.subtype := by rw [hspan]
242
+ _ = Submodule.span ℤ (P.subtype '' (bP '' s)) := by
243
+ rw [Submodule.map_span]
244
+ _ = Submodule.span ℤ (bM '' (Sum.inl '' s)) := by rw [himage]
245
+
246
+ theorem span_range_inl_prod_eq {P Q : Submodule ℤ M} (hPQ : IsCompl P Q)
247
+ {κ μ : Type*}
248
+ (bP : Basis κ ℤ P) (bQ : Basis μ ℤ Q) :
249
+ let bM := (bP.prod bQ).map (P.prodEquivOfIsCompl Q hPQ)
250
+ P = Submodule.span ℤ (bM '' Set.range Sum.inl) := by
251
+ classical
252
+ let bM := (bP.prod bQ).map (P.prodEquivOfIsCompl Q hPQ)
253
+ apply le_antisymm
254
+ · intro x hx
255
+ let xp : P := ⟨x, hx⟩
256
+ have hxp : xp ∈ Submodule.span ℤ (Set.range bP) := by
257
+ rw [bP.span_eq]
258
+ exact Submodule.mem_top
259
+ exact Submodule.span_induction (R := ℤ) (s := Set.range bP)
260
+ (p := fun y _ ↦ (y : M) ∈
261
+ Submodule.span ℤ (bM '' Set.range Sum.inl))
262
+ (fun y hy ↦ by
263
+ obtain ⟨i, rfl⟩ := hy
264
+ apply Submodule.subset_span
265
+ refine ⟨Sum.inl i, ⟨i, rfl⟩, ?_⟩
266
+ simp [bM])
267
+ (Submodule.zero_mem _)
268
+ (fun _ _ _ _ hy hz ↦ Submodule.add_mem _ hy hz)
269
+ (fun a _ _ hy ↦ Submodule.smul_mem _ a hy)
270
+ hxp
271
+ · refine Submodule.span_le.mpr ?_
272
+ rintro _ ⟨_, ⟨i, rfl⟩, rfl⟩
273
+ simp
274
+
275
+ theorem exists_basis_with_repr_eq_zero_iff (b : Basis ι ℤ M)
276
+ (P : Submodule ℤ M) (hP : IsSaturated P) :
277
+ ∃ (κ : Type) (_ : Fintype κ) (bM : Basis κ ℤ M) (s : Set κ),
278
+ ∀ x : M, x ∈ P ↔ ∀ j ∉ s, bM.repr x j = 0 := by
279
+ classical
280
+ obtain ⟨Q, hPQ⟩ := exists_isCompl_of_isSaturated b P hP
281
+ obtain ⟨n, bP⟩ := Submodule.basisOfPid b P
282
+ obtain ⟨m, bQ⟩ := Submodule.basisOfPid b Q
283
+ let e : (P × Q) ≃ₗ[ℤ] M := P.prodEquivOfIsCompl Q hPQ
284
+ let bM : Basis (Fin n ⊕ Fin m) ℤ M := (bP.prod bQ).map e
285
+ let s : Set (Fin n ⊕ Fin m) := Set.range Sum.inl
286
+ refine ⟨Fin n ⊕ Fin m, inferInstance, bM, s, ?_⟩
287
+ intro x
288
+ constructor
289
+ · intro hxP j hj
290
+ have hx : ((P.prodEquivOfIsCompl Q hPQ).symm x).2 = 0 :=
291
+ (P.prodEquivOfIsCompl_symm_apply_snd_eq_zero Q hPQ).mpr hxP
292
+ cases j with
293
+ | inl i => exact False.elim (hj ⟨i, rfl⟩)
294
+ | inr i =>
295
+ change bQ.repr ((e.symm x).2) i = 0
296
+ rw [hx]
297
+ simp
298
+ · intro hx
299
+ apply (P.prodEquivOfIsCompl_symm_apply_snd_eq_zero Q hPQ).mp
300
+ apply bQ.repr.injective
301
+ ext i
302
+ have hi := hx (Sum.inr i) (by simp [s])
303
+ change bQ.repr ((e.symm x).2) i = 0 at hi
304
+ simpa [e] using hi
305
+
306
+ end Smith
307
+
308
+ universe u
309
+
310
+ theorem exists_basis_with_nested_supports_of_saturated_flag (n : ℕ) :
311
+ ∀ {N : Type u} [AddCommGroup N] {ι : Type} [Finite ι],
312
+ (b₀ : Basis ι ℤ N) →
313
+ (P : Fin n → Submodule ℤ N) →
314
+ (∀ i, IsSaturated (P i)) → Antitone P →
315
+ ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ ℤ N)
316
+ (s : Fin n → Set κ), Antitone s ∧
317
+ ∀ i, P i = Submodule.span ℤ (b '' s i) := by
318
+ induction n with
319
+ | zero =>
320
+ intro N _ ι _ b₀ P _ _
321
+ classical
322
+ let := Fintype.ofFinite ι
323
+ let b : Basis (Fin (Fintype.card ι)) ℤ N :=
324
+ b₀.reindex (Fintype.equivFin ι)
325
+ let s : Fin 0 → Set (Fin (Fintype.card ι)) := Fin.elim0
326
+ exact ⟨Fin (Fintype.card ι), inferInstance, b, s,
327
+ fun i ↦ Fin.elim0 i, fun i ↦ Fin.elim0 i⟩
328
+ | succ n ih =>
329
+ intro N _ ι _ b₀ P hsat hanti
330
+ classical
331
+ let P₀ : Submodule ℤ N := P 0
332
+ obtain ⟨p, bP₀⟩ := Submodule.basisOfPid b₀ P₀
333
+ let tail : Fin n → Submodule ℤ P₀ :=
334
+ fun i ↦ (P i.succ).comap P₀.subtype
335
+ have htail_sat : ∀ i, IsSaturated (tail i) := by
336
+ intro i
337
+ apply (hsat i.succ).comap_subtype
338
+ exact hanti (Fin.zero_le i.succ)
339
+ have htail_anti : Antitone tail := by
340
+ intro i j hij
341
+ apply Submodule.comap_mono
342
+ exact hanti (by simpa using hij)
343
+ obtain ⟨κ, instκ, bP, sP, hsPanti, hbP⟩ :=
344
+ ih (N := P₀) (ι := Fin p) bP₀ tail htail_sat htail_anti
345
+ let : Fintype κ := instκ
346
+ obtain ⟨Q, hP₀Q⟩ :=
347
+ exists_isCompl_of_isSaturated b₀ P₀ (hsat 0)
348
+ obtain ⟨m, bQ⟩ := Submodule.basisOfPid b₀ Q
349
+ let e : (P₀ × Q) ≃ₗ[ℤ] N := P₀.prodEquivOfIsCompl Q hP₀Q
350
+ let b : Basis (κ ⊕ Fin m) ℤ N := (bP.prod bQ).map e
351
+ let s : Fin (n + 1) → Set (κ ⊕ Fin m) :=
352
+ fun i ↦ Fin.cases (Set.range Sum.inl)
353
+ (fun j ↦ Sum.inl '' sP j) i
354
+ refine ⟨κ ⊕ Fin m, inferInstance, b, s, ?_, ?_⟩
355
+ · intro i j hij
356
+ obtain rfl | ⟨i', rfl⟩ := i.eq_zero_or_eq_succ
357
+ · obtain rfl | ⟨j', rfl⟩ := j.eq_zero_or_eq_succ
358
+ · exact fun _ hx ↦ hx
359
+ · rintro x ⟨k, hk, rfl⟩
360
+ exact Set.mem_range.mpr ⟨k, rfl⟩
361
+ · obtain rfl | ⟨j', rfl⟩ := j.eq_zero_or_eq_succ
362
+ · exact False.elim ((not_le_of_gt (Fin.succ_pos i')) hij)
363
+ · exact Set.image_mono (hsPanti (by simpa using hij))
364
+ · intro i
365
+ refine Fin.cases ?_ (fun j ↦ ?_) i
366
+ · exact span_range_inl_prod_eq hP₀Q bP bQ
367
+ · apply span_image_inl_eq_of_span_comap_eq
368
+ (P := P₀) (R := P j.succ) (hanti (Fin.zero_le j.succ))
369
+ bP b (fun k ↦ by simp [b, e]) (sP j)
370
+ simpa [tail, P₀] using hbP j
371
+
372
+ theorem exists_basis_adapted_to_saturated_flag (n : ℕ)
373
+ {N : Type u} [AddCommGroup N] {ι : Type} [Finite ι]
374
+ (b₀ : Basis ι ℤ N) (P : Fin n → Submodule ℤ N)
375
+ (hsat : ∀ i, IsSaturated (P i)) (hanti : Antitone P) :
376
+ ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ ℤ N),
377
+ ∀ i, IsAdaptedTo b (P i) := by
378
+ obtain ⟨κ, instκ, b, s, _hsanti, hs⟩ :=
379
+ exists_basis_with_nested_supports_of_saturated_flag n b₀ P hsat hanti
380
+ exact ⟨κ, instκ, b, fun i ↦ ⟨s i, hs i⟩⟩
381
+
382
+ theorem exists_basis_with_nested_supports_of_monotone_saturated_flag
383
+ (n : ℕ) {N : Type u} [AddCommGroup N] {ι : Type} [Finite ι]
384
+ (b₀ : Basis ι ℤ N) (P : Fin n → Submodule ℤ N)
385
+ (hsat : ∀ i, IsSaturated (P i)) (hmono : Monotone P) :
386
+ ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ ℤ N)
387
+ (s : Fin n → Set κ), Monotone s ∧
388
+ ∀ i, P i = Submodule.span ℤ (b '' s i) := by
389
+ let Prev : Fin n → Submodule ℤ N := fun i ↦ P i.rev
390
+ have hPrev : Antitone Prev := by
391
+ intro i j hij
392
+ exact hmono (Fin.rev_anti hij)
393
+ obtain ⟨κ, instκ, b, t, htanti, ht⟩ :=
394
+ exists_basis_with_nested_supports_of_saturated_flag n b₀ Prev
395
+ (fun i ↦ hsat i.rev) hPrev
396
+ let s : Fin n → Set κ := fun i ↦ t i.rev
397
+ refine ⟨κ, instκ, b, s, ?_, ?_⟩
398
+ · intro i j hij
399
+ exact htanti (Fin.rev_anti hij)
400
+ · intro i
401
+ simpa [s, Prev] using ht i.rev
402
+
403
+ theorem repr_eq_zero_of_mem_span_image {N : Type*} [AddCommGroup N]
404
+ {κ : Type*} (b : Basis κ ℤ N) (s : Set κ) {x : N}
405
+ (hx : x ∈ Submodule.span ℤ (b '' s)) {j : κ} (hj : j ∉ s) :
406
+ b.repr x j = 0 := by
407
+ have hsupp := b.repr_support_subset_of_mem_span s hx
408
+ by_contra hne
409
+ exact hj (hsupp (Finsupp.mem_support_iff.mpr hne))
410
+
411
+ theorem exists_basis_with_nested_supports_rationalSpanLattice
412
+ {d n : ℕ} (S : Fin n → Set (Fin d → ℤ)) (hS : Antitone S) :
413
+ ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ ℤ (Fin d → ℤ))
414
+ (s : Fin n → Set κ), Antitone s ∧
415
+ ∀ i, rationalSpanLattice (S i) =
416
+ Submodule.span ℤ (b '' s i) := by
417
+ let P : Fin n → Submodule ℤ (Fin d → ℤ) :=
418
+ fun i ↦ rationalSpanLattice (S i)
419
+ have hPanti : Antitone P := by
420
+ intro i j hij
421
+ exact rationalSpanLattice_mono (hS hij)
422
+ simpa [P] using
423
+ (exists_basis_with_nested_supports_of_saturated_flag n
424
+ (Pi.basisFun ℤ (Fin d)) P
425
+ (fun i ↦ isSaturated_rationalSpanLattice (S i)) hPanti)
426
+
427
+ theorem exists_basis_with_nested_supports_realPrefixLattice
428
+ {d n : ℕ} (x : Fin n → (Fin d → ℤ)) :
429
+ ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ ℤ (Fin d → ℤ))
430
+ (s : Fin n → Set κ), Monotone s ∧
431
+ ∀ i, realPrefixLattice x i =
432
+ Submodule.span ℤ (b '' s i) := by
433
+ exact exists_basis_with_nested_supports_of_monotone_saturated_flag n
434
+ (Pi.basisFun ℤ (Fin d)) (realPrefixLattice x)
435
+ (isSaturated_realPrefixLattice x) (monotone_realPrefixLattice x)
436
+
437
+ theorem exists_fin_basis_with_nested_supports_realPrefixLattice
438
+ {n : ℕ} (x : Fin n → (Fin n → ℤ)) :
439
+ ∃ (b : Basis (Fin n) ℤ (Fin n → ℤ)) (s : Fin n → Set (Fin n)),
440
+ Monotone s ∧
441
+ (∀ i, realPrefixLattice x i =
442
+ Submodule.span ℤ (b '' s i)) ∧
443
+ ∀ i j, j ∉ s i → b.repr (x i) j = 0 := by
444
+ classical
445
+ obtain ⟨κ, instκ, bκ, sκ, hsmono, hs⟩ :=
446
+ exists_basis_with_nested_supports_realPrefixLattice x
447
+ let : Fintype κ := instκ
448
+ let e : κ ≃ Fin n := bκ.indexEquiv (Pi.basisFun ℤ (Fin n))
449
+ let b : Basis (Fin n) ℤ (Fin n → ℤ) := bκ.reindex e
450
+ let s : Fin n → Set (Fin n) := fun i ↦ e '' sκ i
451
+ have himage (i : Fin n) : b '' s i = bκ '' sκ i := by
452
+ ext y
453
+ constructor
454
+ · rintro ⟨_, ⟨k, hk, rfl⟩, rfl⟩
455
+ exact ⟨k, hk, by simp [b, e]⟩
456
+ · rintro ⟨k, hk, rfl⟩
457
+ exact ⟨e k, ⟨k, hk, rfl⟩, by simp [b, e]⟩
458
+ have hspan (i : Fin n) : realPrefixLattice x i =
459
+ Submodule.span ℤ (b '' s i) := by
460
+ rw [himage]
461
+ exact hs i
462
+ refine ⟨b, s, ?_, hspan, ?_⟩
463
+ · intro i j hij
464
+ exact Set.image_mono (hsmono hij)
465
+ · intro i j hj
466
+ apply repr_eq_zero_of_mem_span_image b (s i)
467
+ · rw [← hspan i]
468
+ exact self_mem_realPrefixLattice x i
469
+ · exact hj
470
+
471
+ theorem exists_prefix_adapted_basis_realPrefixLattice
472
+ {n : ℕ} (x : Fin n → (Fin n → ℤ))
473
+ (hli : LinearIndependent ℝ (fun i ↦ realEmbed n (x i))) :
474
+ ∃ b : Basis (Fin n) ℤ (Fin n → ℤ),
475
+ (∀ i, realPrefixLattice x i =
476
+ Submodule.span ℤ (b '' Set.Iic i)) ∧
477
+ (∀ i j, i < j → b.repr (x i) j = 0) ∧
478
+ ∀ i, b.repr (x i) i ≠ 0 := by
479
+ classical
480
+ obtain ⟨b, s, hsmono, hspan, hzero⟩ :=
481
+ exists_fin_basis_with_nested_supports_realPrefixLattice x
482
+ have hpivot : ∀ i : Fin n, ∃ j : Fin n,
483
+ j ∈ s i ∧ b.repr (x i) j ≠ 0 ∧
484
+ ∀ hi : 0 < i.val,
485
+ j ∉ s (⟨i.val - 1, by omega⟩ : Fin n) := by
486
+ intro i
487
+ by_cases hi : 0 < i.val
488
+ · let ip : Fin n := ⟨i.val - 1, by omega⟩
489
+ have hset : Set.Iic ip = Set.Iio i := by
490
+ ext k
491
+ simp only [Set.mem_Iic, Set.mem_Iio, Fin.le_iff_val_le_val,
492
+ Fin.lt_def, ip]
493
+ omega
494
+ have hnot : x i ∉ realPrefixLattice x ip := by
495
+ intro hmem
496
+ have him := (mem_realPrefixLattice.mp hmem)
497
+ apply hli.notMem_span_image (s := Set.Iio i) (lt_irrefl i)
498
+ simpa [Set.image_image, Function.comp_def, hset] using him
499
+ have hnotspan : x i ∉ Submodule.span ℤ (b '' s ip) := by
500
+ rw [← hspan ip]
501
+ exact hnot
502
+ have hnsub : ¬ ((b.repr (x i)).support : Set (Fin n)) ⊆ s ip := by
503
+ simpa [b.mem_span_image] using hnotspan
504
+ obtain ⟨j, hjmem, hjnot⟩ := Set.not_subset.mp hnsub
505
+ have hjne : b.repr (x i) j ≠ 0 := Finsupp.mem_support_iff.mp hjmem
506
+ have hjcur : j ∈ s i := by
507
+ by_contra hj
508
+ exact hjne (hzero i j hj)
509
+ refine ⟨j, hjcur, hjne, ?_⟩
510
+ intro _hi
511
+ simpa [ip] using hjnot
512
+ · have hxne : x i ≠ 0 := by
513
+ intro hx
514
+ apply hli.ne_zero i
515
+ simp [hx]
516
+ have hrepr : b.repr (x i) ≠ 0 := by
517
+ intro hr
518
+ apply hxne
519
+ apply b.repr.injective
520
+ simpa using hr
521
+ obtain ⟨j, hjmem⟩ := Finsupp.support_nonempty_iff.mpr hrepr
522
+ have hjne : b.repr (x i) j ≠ 0 := Finsupp.mem_support_iff.mp hjmem
523
+ have hjcur : j ∈ s i := by
524
+ by_contra hj
525
+ exact hjne (hzero i j hj)
526
+ exact ⟨j, hjcur, hjne, fun h ↦ (hi h).elim⟩
527
+ choose p hp_mem hp_ne hp_prev using hpivot
528
+ have hp_injective : Function.Injective p := by
529
+ intro i j hpij
530
+ by_contra hij
531
+ rcases lt_or_gt_of_ne hij with hijlt | hjilt
532
+ · have hjpos : 0 < j.val := lt_of_le_of_lt (Nat.zero_le _) hijlt
533
+ let jp : Fin n := ⟨j.val - 1, by omega⟩
534
+ have hijp : i ≤ jp := by
535
+ apply Fin.le_iff_val_le_val.mpr
536
+ change i.val ≤ j.val - 1
537
+ omega
538
+ have hpimem : p i ∈ s jp := hsmono hijp (hp_mem i)
539
+ have hpjnot : p j ∉ s jp := by
540
+ simpa [jp] using hp_prev j hjpos
541
+ exact hpjnot (hpij ▸ hpimem)
542
+ · have hipos : 0 < i.val := lt_of_le_of_lt (Nat.zero_le _) hjilt
543
+ let ip : Fin n := ⟨i.val - 1, by omega⟩
544
+ have hjip : j ≤ ip := by
545
+ apply Fin.le_iff_val_le_val.mpr
546
+ change j.val ≤ i.val - 1
547
+ omega
548
+ have hpjmem : p j ∈ s ip := hsmono hjip (hp_mem j)
549
+ have hpinot : p i ∉ s ip := by
550
+ simpa [ip] using hp_prev i hipos
551
+ exact hpinot (hpij.symm ▸ hpjmem)
552
+ have hp_bijective : Function.Bijective p :=
553
+ (Fintype.bijective_iff_injective_and_card p).mpr
554
+ ⟨hp_injective, rfl⟩
555
+ let ep : Fin n ≃ Fin n := Equiv.ofBijective p hp_bijective
556
+ have hs_eq (i : Fin n) : p '' Set.Iic i = s i := by
557
+ apply Set.Subset.antisymm
558
+ · rintro _ ⟨k, hk, rfl⟩
559
+ exact hsmono (Set.mem_Iic.mp hk) (hp_mem k)
560
+ · intro q hq
561
+ obtain ⟨k, rfl⟩ := hp_bijective.2 q
562
+ refine ⟨k, ?_, rfl⟩
563
+ apply Set.mem_Iic.mpr
564
+ by_contra hki
565
+ have hik : i < k := lt_of_not_ge hki
566
+ have hkpos : 0 < k.val := lt_of_le_of_lt (Nat.zero_le _) hik
567
+ let kp : Fin n := ⟨k.val - 1, by omega⟩
568
+ have hikp : i ≤ kp := by
569
+ apply Fin.le_iff_val_le_val.mpr
570
+ change i.val ≤ k.val - 1
571
+ omega
572
+ exact (hp_prev k hkpos) (hsmono hikp hq)
573
+ let b' : Basis (Fin n) ℤ (Fin n → ℤ) := b.reindex ep.symm
574
+ have hbimage (i : Fin n) : b' '' Set.Iic i = b '' s i := by
575
+ rw [← hs_eq i]
576
+ ext y
577
+ constructor
578
+ · rintro ⟨k, hk, rfl⟩
579
+ exact ⟨p k, ⟨k, hk, rfl⟩, by simp [b', ep]⟩
580
+ · rintro ⟨_, ⟨k, hk, rfl⟩, rfl⟩
581
+ exact ⟨k, hk, by simp [b', ep]⟩
582
+ have hspan' (i : Fin n) : realPrefixLattice x i =
583
+ Submodule.span ℤ (b' '' Set.Iic i) := by
584
+ rw [hbimage]
585
+ exact hspan i
586
+ refine ⟨b', hspan', ?_, ?_⟩
587
+ · intro i j hij
588
+ apply repr_eq_zero_of_mem_span_image b' (Set.Iic i)
589
+ · rw [← hspan' i]
590
+ exact self_mem_realPrefixLattice x i
591
+ · exact fun hj ↦ (not_le_of_gt hij) (Set.mem_Iic.mp hj)
592
+ · intro i
593
+ simpa [b', ep] using hp_ne i
594
+
595
+ end Erdos3.IntegerBasisReduction.SaturatedFlag
596
+
597
+ end
598
+
599
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarBadSublevelRamp.lean ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Analysis.Normed.Group.Basic
2
+ import Mathlib.Tactic
3
+ import Mathlib.Topology.MetricSpace.Lipschitz
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+ open scoped NNReal
11
+
12
+ noncomputable def scalarBadSublevelRamp (κ t : ℝ) : ℝ :=
13
+ max 0 (min 1 (2 - 2 * |t| / κ))
14
+
15
+ theorem scalarBadSublevelRamp_range (κ t : ℝ) :
16
+ scalarBadSublevelRamp κ t ∈ Set.Icc (0 : ℝ) 1 := by
17
+ exact ⟨le_max_left _ _, max_le zero_le_one (min_le_left _ _)⟩
18
+
19
+ theorem scalarBadSublevelRamp_eq_one {κ t : ℝ} (hκ : 0 < κ) (ht : |t| ≤ κ / 2) :
20
+ scalarBadSublevelRamp κ t = 1 := by
21
+ have hr : 2 * |t| / κ ≤ 1 := (div_le_one hκ).mpr (by linarith)
22
+ rw [scalarBadSublevelRamp, min_eq_left (by linarith), max_eq_right zero_le_one]
23
+
24
+ theorem scalarBadSublevelRamp_eq_zero {κ t : ℝ} (hκ : 0 < κ) (ht : κ ≤ |t|) :
25
+ scalarBadSublevelRamp κ t = 0 := by
26
+ have hr : 2 ≤ 2 * |t| / κ := (le_div_iff₀ hκ).mpr (by linarith)
27
+ rw [scalarBadSublevelRamp, min_eq_right (by linarith), max_eq_left (by linarith)]
28
+
29
+ theorem scalarBadSublevelRamp_lipschitz {κ : ℝ} (hκ : 0 < κ) :
30
+ LipschitzWith ⟨2 / κ, by positivity⟩ (scalarBadSublevelRamp κ) := by
31
+ have hraw : LipschitzWith ⟨2 / κ, by positivity⟩ (fun t : ℝ => 2 - 2 * |t| / κ) := by
32
+ apply LipschitzWith.of_dist_le_mul
33
+ intro x y
34
+ rw [Real.dist_eq, Real.dist_eq]
35
+ have he : (2 - 2 * |x| / κ) - (2 - 2 * |y| / κ) = -(2 / κ) * (|x| - |y|) := by ring
36
+ rw [he, abs_mul, abs_neg, abs_of_nonneg (by positivity : 0 ≤ 2 / κ)]
37
+ exact mul_le_mul_of_nonneg_left (abs_abs_sub_abs_le_abs_sub x y) (by positivity)
38
+ exact (hraw.const_min 1).const_max 0
39
+
40
+ end Erdos3
41
+
42
+ end
43
+
44
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeBoundaryCost.lean ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.BooleanMinorDimension
2
+ import OAI.Combinatorics.Progressions.Probability.ScalarCubeDomainDensity
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped BigOperators NNReal
11
+
12
+ noncomputable def scalarCubeLinearMap {α : Type*} [Fintype α] [DecidableEq α] (t : Finset α) :
13
+ (Option α → ℝ) →L[ℝ] ℝ :=
14
+ ∑ r : Option α, (booleanFeature r t : ℝ) • ContinuousLinearMap.proj r
15
+
16
+ theorem scalarCubeLinearMap_apply {α : Type*} [Fintype α] [DecidableEq α]
17
+ (t : Finset α) (a : Option α → ℝ) : scalarCubeLinearMap t a = scalarCubeValue a t := by
18
+ simp only [scalarCubeLinearMap, sum_apply, smul_apply,
19
+ ContinuousLinearMap.proj_apply, smul_eq_mul, scalarCubeValue]
20
+
21
+ theorem scalarCubeLinearMap_single {α : Type*} [Fintype α] [DecidableEq α]
22
+ (t : Finset α) (r : Option α) :
23
+ scalarCubeLinearMap t (Pi.single r 1) = (booleanFeature r t : ℝ) := by
24
+ rw [scalarCubeLinearMap_apply]
25
+ simp [scalarCubeValue, Pi.single_apply, mul_ite]
26
+
27
+ theorem scalarCubeLinearMap_norm_le {α : Type*} [Fintype α] [DecidableEq α] (t : Finset α) :
28
+ ‖scalarCubeLinearMap t‖ ≤ (Fintype.card α : ℝ) + 1 := by
29
+ have h := clm_norm_le_card_mul_of_basis (scalarCubeLinearMap t) zero_le_one (fun r => by
30
+ rw [scalarCubeLinearMap_single, Real.norm_eq_abs]
31
+ exact booleanFeature_abs_le_one r t)
32
+ simpa only [Fintype.card_option, Nat.cast_add, Nat.cast_one, mul_one] using h
33
+
34
+ theorem scalarCubeValue_fderiv_norm_le {α : Type*} [Fintype α] [DecidableEq α]
35
+ (t : Finset α) (a : Option α → ℝ) :
36
+ ‖fderiv ℝ (fun x => scalarCubeValue x t) a‖ ≤ (Fintype.card α : ℝ) + 1 := by
37
+ have heq : (fun x => scalarCubeValue x t) = scalarCubeLinearMap t :=
38
+ funext (fun x => (scalarCubeLinearMap_apply t x).symm)
39
+ rw [heq, ContinuousLinearMap.fderiv]
40
+ exact scalarCubeLinearMap_norm_le t
41
+
42
+ theorem scalarCubeFace_fderiv_norm_le {α : Type*} [Fintype α] [DecidableEq α]
43
+ (i : Bool × Finset α) (a : Option α → ℝ) :
44
+ ‖fderiv ℝ (scalarCubeFace i) a‖ ≤ (Fintype.card α : ℝ) + 1 := by
45
+ rcases i with ⟨b, t⟩
46
+ cases b with
47
+ | false => exact scalarCubeValue_fderiv_norm_le t a
48
+ | true =>
49
+ change ‖fderiv ℝ (fun x => 1 - scalarCubeValue x t) a‖ ≤ _
50
+ rw [fderiv_const_sub, norm_neg]
51
+ exact scalarCubeValue_fderiv_norm_le t a
52
+
53
+ theorem scalarCubeBoundaryCutoff_compact (α : Type*) [Fintype α] [DecidableEq α]
54
+ {r : ℝ} (hr : 0 < r) :
55
+ HasCompactSupport (inequalityBoundaryCutoff (fun _ : Bool × Finset α => r) scalarCubeFace) := by
56
+ apply inequalityBoundaryCutoff_compact _ (fun _ => hr) _ (fun i => (scalarCubeFace_contDiff i).continuous)
57
+ rw [positiveInequalityDomain_scalarCubeFace]
58
+ exact scalarCubeDomain_isBounded α
59
+
60
+ theorem scalarCubeBoundaryCutoff_fderiv_norm_le {α : Type*} [Fintype α] [DecidableEq α]
61
+ (A : ℝ≥0) (hLip : LipschitzWith A Real.smoothTransition) {r : ℝ} (hr : 0 < r)
62
+ (a : Option α → ℝ) :
63
+ ‖fderiv ℝ (inequalityBoundaryCutoff (fun _ : Bool × Finset α => r) scalarCubeFace) a‖ ≤
64
+ ((2 * 2 ^ Fintype.card α : ℕ) : ℝ) * ((A : ℝ) / r * ((Fintype.card α : ℝ) + 1)) := by
65
+ apply (inequalityBoundaryCutoff_fderiv_norm_le A hLip _ (fun _ => hr)
66
+ scalarCubeFace scalarCubeFace_contDiff a).trans
67
+ calc
68
+ _ ≤ ∑ _i : Bool × Finset α, (A : ℝ) / r * ((Fintype.card α : ℝ) + 1) :=
69
+ Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (scalarCubeFace_fderiv_norm_le i a)
70
+ (div_nonneg A.coe_nonneg hr.le))
71
+ _ = _ := by rw [Finset.sum_const, Finset.card_univ, scalarCubeFace_card, nsmul_eq_mul]
72
+
73
+ end Erdos3
74
+
75
+ end
76
+
77
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeBoundaryVolume.lean ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
2
+ import OAI.Combinatorics.Progressions.Estimates.FiniteFiberVolumeBound
3
+ import OAI.Combinatorics.Progressions.Geometry.ScalarCubeCoordinates
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open MeasureTheory
12
+ open scoped BigOperators
13
+
14
+ def scalarCubeFaceStrip {α : Type*} [Fintype α] [DecidableEq α]
15
+ (i : Bool × Finset α) (u : ℝ) : Set (Option α → ℝ) :=
16
+ scalarCubeDomain α ∩ {a | scalarCubeFace i a < u}
17
+
18
+ theorem scalarCubeFaceStrip_measurable {α : Type*} [Fintype α] [DecidableEq α]
19
+ (i : Bool × Finset α) (u : ℝ) : MeasurableSet (scalarCubeFaceStrip i u) :=
20
+ (scalarCubeDomain_isOpen α).measurableSet.inter
21
+ (measurableSet_lt (scalarCubeFace_contDiff i).continuous.measurable measurable_const)
22
+
23
+ theorem scalarCubeFaceStrip_volume_lt_top {α : Type*} [Fintype α] [DecidableEq α]
24
+ (i : Bool × Finset α) (u : ℝ) : volume (scalarCubeFaceStrip i u) < ⊤ :=
25
+ (measure_mono Set.inter_subset_left).trans_lt (scalarCubeDomain_volume_lt_top α)
26
+
27
+ theorem scalarCubeFaceStrip_fiber_interval {α : Type*} [Fintype α] [DecidableEq α]
28
+ (i : Bool × Finset α) (u : ℝ) (b : α → ℝ) :
29
+ ∃ lo : ℝ, {y | scalarCubeJoin (b, y) ∈ scalarCubeFaceStrip i u} ⊆ Set.Ioo lo (lo + u) := by
30
+ rcases i with ⟨side, t⟩
31
+ cases side with
32
+ | false =>
33
+ refine ⟨-(∑ k ∈ t, b k), ?_⟩
34
+ intro y hy
35
+ have hpos := (hy.1 t).1
36
+ have hupper := hy.2
37
+ change scalarCubeValue (scalarCubeJoin (b, y)) t < u at hupper
38
+ rw [scalarCubeJoin_value] at hpos hupper
39
+ exact ⟨by linarith, by linarith⟩
40
+ | true =>
41
+ refine ⟨1 - (∑ k ∈ t, b k) - u, ?_⟩
42
+ intro y hy
43
+ have hpos := (hy.1 t).2
44
+ have hlower := hy.2
45
+ change 1 - scalarCubeValue (scalarCubeJoin (b, y)) t < u at hlower
46
+ rw [scalarCubeJoin_value] at hpos hlower
47
+ exact ⟨by linarith, by linarith⟩
48
+
49
+ theorem scalarCubeFaceStrip_fiber_volume_le {α : Type*} [Fintype α] [DecidableEq α]
50
+ (i : Bool × Finset α) {u : ℝ} (hu : 0 ≤ u) (b : α → ℝ) :
51
+ volume.real {y | scalarCubeJoin (b, y) ∈ scalarCubeFaceStrip i u} ≤ u := by
52
+ obtain ⟨lo, hsub⟩ := scalarCubeFaceStrip_fiber_interval i u b
53
+ have hlen : volume.real (Set.Ioo lo (lo + u)) = u := by
54
+ rw [Real.volume_real_Ioo]
55
+ simpa only [add_sub_cancel_left] using max_eq_left hu
56
+ exact (measureReal_mono (μ := volume) hsub (by simp [Real.volume_Ioo])).trans_eq hlen
57
+
58
+ theorem scalarCubeFaceStrip_base_bound {α : Type*} [Fintype α] [DecidableEq α]
59
+ (i : Bool × Finset α) (u : ℝ) {z : (α → ℝ) × ℝ}
60
+ (hz : scalarCubeJoin z ∈ scalarCubeFaceStrip i u) : z.1 ∈ Metric.closedBall (0 : α → ℝ) 1 := by
61
+ rw [Metric.mem_closedBall, dist_zero_right]
62
+ apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
63
+ intro k
64
+ have h := (scalarCubeDomain_coordinate_abs_lt_one hz.1 (some k)).le
65
+ simpa only [scalarCubeJoin_some, Real.norm_eq_abs] using h
66
+
67
+ end Erdos3
68
+
69
+ end
70
+
71
+ section
72
+
73
+ namespace Erdos3
74
+
75
+ open MeasureTheory
76
+
77
+ theorem scalarCubeFaceStrip_volume_le {α : Type*} [Fintype α] [DecidableEq α]
78
+ (i : Bool × Finset α) {u : ℝ} (hu : 0 ≤ u) :
79
+ volume.real (scalarCubeFaceStrip i u) ≤ (2 : ℝ) ^ Fintype.card α * u := by
80
+ let s : Set ((α → ℝ) × ℝ) := scalarCubeJoin ⁻¹' scalarCubeFaceStrip i u
81
+ have hs : MeasurableSet s := (scalarCubeFaceStrip_measurable i u).preimage (scalarCubeJoin_measurable α)
82
+ have hpres := scalarCubeJoin_measurePreserving α
83
+ have hmass : volume s = volume (scalarCubeFaceStrip i u) :=
84
+ hpres.measure_preimage (scalarCubeFaceStrip_measurable i u).nullMeasurableSet
85
+ have hreal : volume.real s = volume.real (scalarCubeFaceStrip i u) :=
86
+ hpres.measureReal_preimage (scalarCubeFaceStrip_measurable i u).nullMeasurableSet
87
+ have hsfin : (volume : Measure ((α → ℝ) × ℝ)) s ≠ ⊤ := by
88
+ rw [hmass]
89
+ exact (scalarCubeFaceStrip_volume_lt_top i u).ne
90
+ have h := product_measureReal_le_of_fiber_bound
91
+ (volume : Measure (α → ℝ)) (volume : Measure ℝ) s hs hsfin
92
+ (Metric.closedBall (0 : α → ℝ) 1) measurableSet_closedBall
93
+ (isCompact_closedBall _ _).measure_ne_top
94
+ (fun z hz => scalarCubeFaceStrip_base_bound i u hz)
95
+ (scalarCubeFaceStrip_fiber_volume_le i hu)
96
+ change volume.real s ≤ _ at h
97
+ rw [hreal] at h
98
+ have hbase : volume.real (Metric.closedBall (0 : α → ℝ) 1) = (2 : ℝ) ^ Fintype.card α := by
99
+ rw [measureReal_def, Real.volume_pi_closedBall _ (by norm_num)]
100
+ simp
101
+ rw [hbase] at h
102
+ exact h
103
+
104
+ theorem scalarCubeFaceStrip_weighted_volume_le {α : Type*} [Fintype α] [DecidableEq α]
105
+ (i : Bool × Finset α) {u : ℝ} (hu : 0 ≤ u) :
106
+ (∫ _ in scalarCubeFaceStrip i u, scalarCubeDomainDensity α) ≤
107
+ scalarCubeDomainDensity α * (2 : ℝ) ^ Fintype.card α * u := by
108
+ rw [setIntegral_const, smul_eq_mul]
109
+ have h := mul_le_mul_of_nonneg_left (scalarCubeFaceStrip_volume_le i hu)
110
+ (scalarCubeDomainDensity_pos α).le
111
+ nlinarith
112
+
113
+ end Erdos3
114
+
115
+ end
116
+
117
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeCokernelCutoff.lean ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.CubeResidueSupport
2
+
3
+ namespace OAI
4
+
5
+
6
+ namespace Erdos3
7
+
8
+ open scoped Matrix
9
+
10
+ theorem integerMatrix_scaled_period {I J : Type*} [Fintype I] [Fintype J]
11
+ (A : Matrix I J ℤ) (m a : ℤ)
12
+ (hperiod : integerScalarLattice I a ≤ A.mulVecLin.range) :
13
+ integerScalarLattice I (m * a) ≤ (m • A).mulVecLin.range := by
14
+ rintro y ⟨z, rfl⟩
15
+ change (m * a) • z ∈ (m • A).mulVecLin.range
16
+ obtain ⟨u, hu⟩ := hperiod ((integerScalarLattice_mem a _).mpr ⟨z, rfl⟩)
17
+ refine ⟨u, ?_⟩
18
+ change (m • A) *ᵥ u = (m * a) • z
19
+ change A *ᵥ u = a • z at hu
20
+ rw [Matrix.smul_mulVec, hu, smul_smul]
21
+
22
+ theorem integerCokernelExponent_scaled_le {I J : Type*} [Fintype I] [Fintype J]
23
+ (A : Matrix I J ℤ) (m : ℕ) (hm : 0 < m)
24
+ (hA : 0 < integerCokernelExponent A.mulVecLin.range) :
25
+ integerCokernelExponent ((m : ℤ) • A).mulVecLin.range ≤
26
+ m * integerCokernelExponent A.mulVecLin.range := by
27
+ have hp := integerMatrix_scaled_period A (m : ℤ) (integerCokernelExponent A.mulVecLin.range : ℤ)
28
+ (integerCokernelExponent_period A.mulVecLin.range)
29
+ have hp' : integerScalarLattice I ((m * integerCokernelExponent A.mulVecLin.range : ℕ) : ℤ) ≤
30
+ ((m : ℤ) • A).mulVecLin.range := by simpa only [Nat.cast_mul] using hp
31
+ exact Nat.le_of_dvd (Nat.mul_pos hm hA)
32
+ (integerCokernelExponent_dvd_period _ _ hp')
33
+
34
+ theorem scaled_nonzeroMinor {I J : Type*} [Fintype I] [DecidableEq I]
35
+ (A : Matrix I J ℤ) (m : ℤ) (s : I → J)
36
+ (h : (((m • A).submatrix id s).det) ≠ 0) :
37
+ (A.submatrix id s).det ≠ 0 := by
38
+ intro hz
39
+ apply h
40
+ change (m • A.submatrix id s).det = 0
41
+ rw [Matrix.det_smul, hz, mul_zero]
42
+
43
+ theorem scaled_largeCokernel_implies {I J : Type*}
44
+ [Fintype I] [DecidableEq I] [Fintype J]
45
+ (A : Matrix I J ℤ) (m B : ℕ) (hm : 0 < m)
46
+ (hminor : ∃ s : I → J, (((m : ℤ) • A).submatrix id s).det ≠ 0)
47
+ (hB : m * B < integerCokernelExponent ((m : ℤ) • A).mulVecLin.range) :
48
+ (∃ s : I → J, (A.submatrix id s).det ≠ 0) ∧
49
+ B < integerCokernelExponent A.mulVecLin.range := by
50
+ obtain ⟨s, hs⟩ := hminor
51
+ have hs' := scaled_nonzeroMinor A (m : ℤ) s hs
52
+ have hpos := (integerCokernelExponent_le_det A.mulVecLin.range (A.submatrix id s) hs'
53
+ (integerColumnMinor_range_le A s)).1
54
+ have hle := integerCokernelExponent_scaled_le A m hm hpos
55
+ exact ⟨⟨s, hs'⟩, (Nat.mul_lt_mul_left hm).mp (hB.trans_le hle)⟩
56
+
57
+ end Erdos3
58
+
59
+
60
+ namespace Erdos3
61
+
62
+ def HasBoundedScalarPeriod {I : Type*} [Fintype I] (L : Submodule ℤ (I → ℤ)) (B : ℕ) : Prop :=
63
+ ∃ a : ℕ, 0 < a ∧ a ≤ B ∧ integerScalarLattice I (a : ℤ) ≤ L
64
+
65
+ theorem hasBoundedScalarPeriod_iff {I : Type*} [Fintype I]
66
+ (L : Submodule ℤ (I → ℤ)) (hL : 0 < integerCokernelExponent L) (B : ℕ) :
67
+ HasBoundedScalarPeriod L B ↔ integerCokernelExponent L ≤ B := by
68
+ constructor
69
+ · rintro ⟨a, ha, haB, hperiod⟩
70
+ exact (Nat.le_of_dvd ha (integerCokernelExponent_dvd_period L a hperiod)).trans haB
71
+ · intro hB
72
+ exact ⟨integerCokernelExponent L, hL, hB, integerCokernelExponent_period L⟩
73
+
74
+ theorem scalarCube_no_bounded_period_iff {I J : Type*}
75
+ [Fintype I] [DecidableEq I] [Fintype J] {L : ℕ}
76
+ (B : ℕ) (x : J → IntegerScalarCubeBox I L) :
77
+ ((∃ s : I → J, ((scalarCubeDifferenceMatrix x).submatrix id s).det ≠ 0) ∧
78
+ ¬ HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range B) ↔
79
+ scalarCubeLargeCokernelEvent B x := by
80
+ have hpos (h : ∃ s : I → J, ((scalarCubeDifferenceMatrix x).submatrix id s).det ≠ 0) :
81
+ 0 < integerCokernelExponent (scalarCubeDifferenceMatrix x).mulVecLin.range := by
82
+ obtain ⟨s, hs⟩ := h
83
+ exact (integerCokernelExponent_le_det _ _ hs (integerColumnMinor_range_le _ s)).1
84
+ constructor
85
+ · rintro ⟨hminor, hperiod⟩
86
+ exact ⟨hminor, Nat.lt_of_not_ge (hperiod ∘ (hasBoundedScalarPeriod_iff _ (hpos hminor) B).mpr)⟩
87
+ · rintro ⟨hminor, hB⟩
88
+ exact ⟨hminor, fun hp => (Nat.not_le_of_lt hB) ((hasBoundedScalarPeriod_iff _ (hpos hminor) B).mp hp)⟩
89
+
90
+
91
+ def stridedScalarCubeLargeCokernelEvent {I J : Type*}
92
+ [Fintype I] [DecidableEq I] [Fintype J] {L : ℕ}
93
+ (m B : ℕ) (x : J → IntegerScalarCubeBox I L) : Prop :=
94
+ (∃ s : I → J, (((m : ℤ) • scalarCubeDifferenceMatrix x).submatrix id s).det ≠ 0) ∧
95
+ B < integerCokernelExponent ((m : ℤ) • scalarCubeDifferenceMatrix x).mulVecLin.range
96
+
97
+ theorem stridedScalarCube_largeCokernel_probability_le {I J : Type*}
98
+ [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J]
99
+ (L m B : ℕ) (hL : 0 < L) (hsize : Fintype.card I + 1 ≤ L) (hm : 0 < m) (hB : 0 < B)
100
+ (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) :
101
+ (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability
102
+ (stridedScalarCubeLargeCokernelEvent m (m * B)) ≤
103
+ (integerScalarCubeDensityCap I * (1 + ((Fintype.card I).factorial : ℝ))) ^
104
+ Fintype.card J / (B : ℝ) := by
105
+ apply (FiniteProbabilityWeights.eventProbability_mono _ _ (scalarCubeLargeCokernelEvent B) ?_).trans
106
+ (scalarCube_largeCokernel_probability_le L B hL hsize hB hJ)
107
+ intro x hx
108
+ exact scaled_largeCokernel_implies (scalarCubeDifferenceMatrix x) m B hm hx.1 hx.2
109
+
110
+
111
+ theorem exists_scalarCube_cokernel_cutoff (I J : Type*)
112
+ [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J]
113
+ (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2))
114
+ (ε : ℝ) (hε : 0 < ε) :
115
+ ∃ B : ℕ, 0 < B ∧ ∀ (L m : ℕ) (hL : 0 < L), Fintype.card I + 1 ≤ L → 0 < m →
116
+ (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability
117
+ (stridedScalarCubeLargeCokernelEvent m (m * B)) ≤ ε := by
118
+ let C := (integerScalarCubeDensityCap I * (1 + ((Fintype.card I).factorial : ℝ))) ^ Fintype.card J
119
+ obtain ⟨B, hB⟩ := exists_nat_gt (max 1 (C / ε))
120
+ have hBpos : 0 < B := by
121
+ have h : (1 : ℝ) < B := (le_max_left _ _).trans_lt hB
122
+ exact_mod_cast (zero_lt_one.trans h)
123
+ have hbound : C / (B : ℝ) ≤ ε := by
124
+ apply (div_le_iff₀ (by exact_mod_cast hBpos)).mpr
125
+ have h := (div_lt_iff₀ hε).mp ((le_max_right _ _).trans_lt hB)
126
+ linarith
127
+ refine ⟨B, hBpos, fun L m hL hsize hm => ?_⟩
128
+ exact (stridedScalarCube_largeCokernel_probability_le L m B hL hsize hm hBpos hJ).trans hbound
129
+
130
+ end Erdos3
131
+
132
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeDomain.lean ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Analysis.Normed.Module.FiniteDimension
2
+ import Mathlib.Topology.MetricSpace.Bounded
3
+ import OAI.Combinatorics.Progressions.Dynamics.ProductCutoffBudget
4
+ import OAI.Combinatorics.Progressions.Estimates.SmoothHalfspaceCutoff
5
+ import OAI.Combinatorics.Progressions.Polynomial.PolynomialDeterminantDerivativeBound
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3
12
+
13
+ open scoped BigOperators ContDiff NNReal
14
+
15
+ def positiveInequalityDomain {I E : Type*} (d : I → E → ℝ) : Set E :=
16
+ {x | ∀ i, 0 < d i x}
17
+
18
+ theorem positiveInequalityDomain_isOpen {I E : Type*} [Fintype I] [TopologicalSpace E]
19
+ (d : I → E → ℝ) (hd : ∀ i, Continuous (d i)) : IsOpen (positiveInequalityDomain d) := by
20
+ have heq : positiveInequalityDomain d = ⋂ i, {x | 0 < d i x} := by
21
+ ext x
22
+ simp [positiveInequalityDomain]
23
+ rw [heq]
24
+ exact isOpen_iInter_of_finite (fun i => isOpen_lt continuous_const (hd i))
25
+
26
+ noncomputable def inequalityBoundaryCutoff {I E : Type*} [Fintype I]
27
+ (r : I → ℝ) (d : I → E → ℝ) (x : E) : ℝ :=
28
+ ∏ i, halfspaceCutoff (r i) (d i) x
29
+
30
+ theorem inequalityBoundaryCutoff_range {I E : Type*} [Fintype I]
31
+ (r : I → ℝ) (d : I → E → ℝ) (x : E) :
32
+ inequalityBoundaryCutoff r d x ∈ Set.Icc (0 : ℝ) 1 :=
33
+ product_cutoff_range _ (fun i => halfspaceCutoff_range (r i) (d i) x)
34
+
35
+ theorem inequalityBoundaryCutoff_smooth {I E : Type*} [Fintype I]
36
+ [NormedAddCommGroup E] [NormedSpace ℝ E] (r : I → ℝ) (d : I → E → ℝ)
37
+ (hd : ∀ i, ContDiff ℝ ∞ (d i)) : ContDiff ℝ ∞ (inequalityBoundaryCutoff r d) :=
38
+ contDiff_prod (fun i _ => contDiff_halfspaceCutoff (r i) (d i) (hd i))
39
+
40
+ theorem inequalityBoundaryCutoff_tsupport_subset {I E : Type*} [Fintype I]
41
+ [TopologicalSpace E] (r : I → ℝ) (hr : ∀ i, 0 < r i)
42
+ (d : I → E → ℝ) (hd : ∀ i, Continuous (d i)) :
43
+ tsupport (inequalityBoundaryCutoff r d) ⊆ {x | ∀ i, r i ≤ d i x} := by
44
+ intro x hx i
45
+ exact halfspaceCutoff_tsupport_subset (hr i) (d i) (hd i)
46
+ (product_cutoff_tsupport_subset (fun j => halfspaceCutoff (r j) (d j)) i hx)
47
+
48
+ theorem inequalityBoundaryCutoff_tsupport_domain {I E : Type*} [Fintype I]
49
+ [TopologicalSpace E] (r : I → ℝ) (hr : ∀ i, 0 < r i)
50
+ (d : I → E → ℝ) (hd : ∀ i, Continuous (d i)) :
51
+ tsupport (inequalityBoundaryCutoff r d) ⊆ positiveInequalityDomain d := by
52
+ intro x hx i
53
+ exact (hr i).trans_le (inequalityBoundaryCutoff_tsupport_subset r hr d hd hx i)
54
+
55
+ theorem inequalityBoundaryCutoff_compact {I E : Type*} [Fintype I]
56
+ [MetricSpace E] [ProperSpace E] (r : I → ℝ) (hr : ∀ i, 0 < r i)
57
+ (d : I → E → ℝ) (hd : ∀ i, Continuous (d i))
58
+ (hbounded : Bornology.IsBounded (positiveInequalityDomain d)) :
59
+ HasCompactSupport (inequalityBoundaryCutoff r d) := by
60
+ apply Metric.isCompact_of_isClosed_isBounded (isClosed_tsupport _)
61
+ exact hbounded.subset (inequalityBoundaryCutoff_tsupport_domain r hr d hd)
62
+
63
+ theorem inequalityBoundaryCutoff_eq_one {I E : Type*} [Fintype I]
64
+ (r : I → ℝ) (hr : ∀ i, 0 < r i) (d : I → E → ℝ) {x : E}
65
+ (hx : ∀ i, 2 * r i ≤ d i x) : inequalityBoundaryCutoff r d x = 1 :=
66
+ Finset.prod_eq_one (fun i _ => halfspaceCutoff_eq_one (hr i) (d i) (hx i))
67
+
68
+ theorem inequalityBoundaryCutoff_fderiv_norm_le {I E : Type*} [Fintype I]
69
+ [NormedAddCommGroup E] [NormedSpace ℝ E]
70
+ (A : ℝ≥0) (hLip : LipschitzWith A Real.smoothTransition)
71
+ (r : I → ℝ) (hr : ∀ i, 0 < r i) (d : I → E → ℝ) (hd : ∀ i, ContDiff ℝ ∞ (d i)) (x : E) :
72
+ ‖fderiv ℝ (inequalityBoundaryCutoff r d) x‖ ≤
73
+ ∑ i, ((A : ℝ) / r i) * ‖fderiv ℝ (d i) x‖ := by
74
+ apply (product_cutoff_fderiv_norm_le (fun i => halfspaceCutoff (r i) (d i)) x
75
+ (fun i => ((contDiff_halfspaceCutoff (r i) (d i) (hd i)).differentiable (by norm_num)).differentiableAt)
76
+ (fun i => halfspaceCutoff_range (r i) (d i) x)).trans
77
+ exact Finset.sum_le_sum (fun i _ => halfspaceCutoff_fderiv_norm_le A hLip (hr i) (d i)
78
+ (((hd i).differentiable (by norm_num)).differentiableAt))
79
+
80
+ end Erdos3
81
+
82
+ end
83
+
84
+ section
85
+
86
+ namespace Erdos3
87
+
88
+ open MeasureTheory
89
+ open scoped BigOperators
90
+
91
+ theorem halfspaceCutoff_measurable {E : Type*} [MeasurableSpace E]
92
+ (r : ℝ) (d : E → ℝ) (hd : Measurable d) : Measurable (halfspaceCutoff r d) :=
93
+ Real.smoothTransition.continuous.measurable.comp ((hd.div_const r).sub_const 1)
94
+
95
+ theorem halfspaceCutoff_integral_loss_le {E : Type*} [MeasurableSpace E]
96
+ (μ : Measure E) [IsFiniteMeasure μ] {r : ℝ} (hr : 0 < r)
97
+ (d : E → ℝ) (hd : Measurable d) :
98
+ (∫ x, 1 - halfspaceCutoff r d x ∂μ) ≤ μ.real {x | d x < 2 * r} := by
99
+ let s := {x | d x < 2 * r}
100
+ have hs : MeasurableSet s := measurableSet_lt hd measurable_const
101
+ have hfi := cutoff_integrable μ _ (halfspaceCutoff_measurable r d hd) (halfspaceCutoff_range r d)
102
+ calc
103
+ _ ≤ ∫ x, s.indicator (fun _ => (1 : ℝ)) x ∂μ := by
104
+ apply integral_mono ((integrable_const (1 : ℝ)).sub hfi)
105
+ ((integrable_const (1 : ℝ)).indicator hs)
106
+ intro x
107
+ change 1 - halfspaceCutoff r d x ≤ s.indicator (fun _ => (1 : ℝ)) x
108
+ by_cases hx : x ∈ s
109
+ · rw [Set.indicator_of_mem hx]
110
+ linarith [(halfspaceCutoff_range r d x).1]
111
+ · rw [Set.indicator_of_notMem hx, halfspaceCutoff_eq_one hr d (le_of_not_gt hx)]
112
+ norm_num
113
+ _ = _ := integral_indicator_one hs
114
+
115
+ theorem inequalityBoundaryCutoff_integral_loss_le {I E : Type*} [Fintype I] [MeasurableSpace E]
116
+ (μ : Measure E) [IsFiniteMeasure μ] (r : I → ℝ) (hr : ∀ i, 0 < r i)
117
+ (d : I → E → ℝ) (hd : ∀ i, Measurable (d i)) :
118
+ (∫ x, 1 - inequalityBoundaryCutoff r d x ∂μ) ≤ ∑ i, μ.real {x | d i x < 2 * r i} := by
119
+ apply (product_cutoff_integral_loss_le μ (fun i => halfspaceCutoff (r i) (d i))
120
+ (fun i => halfspaceCutoff_measurable (r i) (d i) (hd i))
121
+ (fun i => halfspaceCutoff_range (r i) (d i))).trans
122
+ exact Finset.sum_le_sum (fun i _ => halfspaceCutoff_integral_loss_le μ (hr i) (d i) (hd i))
123
+
124
+ end Erdos3
125
+
126
+ end
127
+
128
+ section
129
+
130
+ namespace Erdos3
131
+
132
+ open scoped BigOperators ContDiff
133
+
134
+ noncomputable def scalarCubeValue {α : Type*} [Fintype α] [DecidableEq α]
135
+ (a : Option α → ℝ) (t : Finset α) : ℝ :=
136
+ ∑ r : Option α, (booleanFeature r t : ℝ) * a r
137
+
138
+ theorem scalarCubeValue_empty {α : Type*} [Fintype α] [DecidableEq α]
139
+ (a : Option α → ℝ) : scalarCubeValue a ∅ = a none := by
140
+ simp [scalarCubeValue, Fintype.sum_option, booleanFeature]
141
+
142
+ theorem scalarCubeValue_singleton {α : Type*} [Fintype α] [DecidableEq α]
143
+ (a : Option α → ℝ) (i : α) : scalarCubeValue a {i} = a none + a (some i) := by
144
+ simp [scalarCubeValue, Fintype.sum_option, booleanFeature]
145
+
146
+ theorem scalarCubeValue_contDiff {α : Type*} [Fintype α] [DecidableEq α] (t : Finset α) :
147
+ ContDiff ℝ ∞ (fun a : Option α → ℝ => scalarCubeValue a t) := by
148
+ unfold scalarCubeValue
149
+ apply ContDiff.sum
150
+ intro r _
151
+ exact contDiff_const.mul (ContinuousLinearMap.proj r : (Option α → ℝ) →L[ℝ] ℝ).contDiff
152
+
153
+ def scalarCubeDomain (α : Type*) [Fintype α] [DecidableEq α] : Set (Option α → ℝ) :=
154
+ {a | ∀ t : Finset α, scalarCubeValue a t ∈ Set.Ioo (0 : ℝ) 1}
155
+
156
+ noncomputable def scalarCubeFace {α : Type*} [Fintype α] [DecidableEq α]
157
+ (i : Bool × Finset α) (a : Option α → ℝ) : ℝ :=
158
+ if i.1 then 1 - scalarCubeValue a i.2 else scalarCubeValue a i.2
159
+
160
+ theorem scalarCubeFace_contDiff {α : Type*} [Fintype α] [DecidableEq α] (i : Bool × Finset α) :
161
+ ContDiff ℝ ∞ (scalarCubeFace i) := by
162
+ rcases i with ⟨b, t⟩
163
+ cases b with
164
+ | false => exact scalarCubeValue_contDiff t
165
+ | true => exact contDiff_const.sub (scalarCubeValue_contDiff t)
166
+
167
+ theorem positiveInequalityDomain_scalarCubeFace (α : Type*) [Fintype α] [DecidableEq α] :
168
+ positiveInequalityDomain (@scalarCubeFace α _ _) = scalarCubeDomain α := by
169
+ ext a
170
+ constructor
171
+ · intro ha t
172
+ have hlo : 0 < scalarCubeValue a t := ha (false, t)
173
+ have hhi : 0 < 1 - scalarCubeValue a t := ha (true, t)
174
+ exact ⟨hlo, by linarith⟩
175
+ · intro ha i
176
+ rcases i with ⟨b, t⟩
177
+ cases b with
178
+ | false => exact (ha t).1
179
+ | true => exact sub_pos.mpr (ha t).2
180
+
181
+ theorem scalarCubeDomain_isOpen (α : Type*) [Fintype α] [DecidableEq α] :
182
+ IsOpen (scalarCubeDomain α) := by
183
+ rw [← positiveInequalityDomain_scalarCubeFace α]
184
+ exact positiveInequalityDomain_isOpen _ (fun i => (scalarCubeFace_contDiff i).continuous)
185
+
186
+ theorem scalarCubeDomain_coordinate_abs_lt_one {α : Type*} [Fintype α] [DecidableEq α]
187
+ {a : Option α → ℝ} (ha : a ∈ scalarCubeDomain α) (r : Option α) : |a r| < 1 := by
188
+ have hzero := ha ∅
189
+ rw [scalarCubeValue_empty] at hzero
190
+ cases r with
191
+ | none => exact abs_lt.mpr ⟨by linarith [hzero.1], hzero.2⟩
192
+ | some i =>
193
+ have hi := ha {i}
194
+ rw [scalarCubeValue_singleton] at hi
195
+ exact abs_lt.mpr ⟨by linarith [hzero.1, hzero.2, hi.1], by linarith [hzero.1, hi.2]⟩
196
+
197
+ theorem scalarCubeDomain_isBounded (α : Type*) [Fintype α] [DecidableEq α] :
198
+ Bornology.IsBounded (scalarCubeDomain α) := by
199
+ apply (Metric.isBounded_closedBall (x := (0 : Option α → ℝ)) (r := 1)).subset
200
+ intro a ha
201
+ rw [Metric.mem_closedBall, dist_zero_right]
202
+ apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
203
+ intro r
204
+ simpa only [Real.norm_eq_abs] using (scalarCubeDomain_coordinate_abs_lt_one ha r).le
205
+
206
+ noncomputable def scalarCubeCenter (α : Type*) : Option α → ℝ
207
+ | none => 1 / 2
208
+ | some _ => 0
209
+
210
+ theorem scalarCubeValue_center {α : Type*} [Fintype α] [DecidableEq α] (t : Finset α) :
211
+ scalarCubeValue (scalarCubeCenter α) t = 1 / 2 := by
212
+ simp [scalarCubeValue, Fintype.sum_option, scalarCubeCenter, booleanFeature]
213
+
214
+ theorem scalarCubeDomain_nonempty (α : Type*) [Fintype α] [DecidableEq α] :
215
+ (scalarCubeDomain α).Nonempty := by
216
+ refine ⟨scalarCubeCenter α, ?_⟩
217
+ intro t
218
+ rw [scalarCubeValue_center]
219
+ norm_num
220
+
221
+ theorem scalarCubeFace_card (α : Type*) [Fintype α] :
222
+ Fintype.card (Bool × Finset α) = 2 * 2 ^ Fintype.card α := by simp
223
+
224
+ theorem booleanAffinePolynomial_eval_scalarCubeValue {B F α : Type*}
225
+ [Fintype α] [DecidableEq α] (a : BlockParameter B F α → ℝ) (b : B) (v : F) (t : Finset α) :
226
+ MvPolynomial.eval a (booleanAffinePolynomial b v t) = scalarCubeValue (fun r => a (b, v, r)) t :=
227
+ booleanAffinePolynomial_eval a b v t
228
+
229
+ end Erdos3
230
+
231
+ end
232
+
233
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeFaceSlab.lean ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.NormalizedRestrictionTransport
2
+ import OAI.Combinatorics.Progressions.Probability.ScalarCubeBoundaryMass
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open MeasureTheory
11
+
12
+ def closedScalarCubeDomain (α : Type*) [Fintype α] [DecidableEq α] : Set (Option α → ℝ) :=
13
+ {a | ∀ t : Finset α, scalarCubeValue a t ∈ Set.Icc (0 : ℝ) 1}
14
+
15
+ theorem scalarCubeDomain_subset_closed (α : Type*) [Fintype α] [DecidableEq α] :
16
+ scalarCubeDomain α ⊆ closedScalarCubeDomain α :=
17
+ fun _ ha t => ⟨(ha t).1.le, (ha t).2.le⟩
18
+
19
+ theorem closedScalarCubeDomain_isClosed (α : Type*) [Fintype α] [DecidableEq α] :
20
+ IsClosed (closedScalarCubeDomain α) := by
21
+ have heq : closedScalarCubeDomain α = ⋂ t : Finset α, {a | scalarCubeValue a t ∈ Set.Icc (0 : ℝ) 1} := by
22
+ ext a
23
+ simp [closedScalarCubeDomain]
24
+ rw [heq]
25
+ exact isClosed_iInter (fun t => isClosed_Icc.preimage (scalarCubeValue_contDiff t).continuous)
26
+
27
+ theorem closedScalarCubeDomain_iff_faces {α : Type*} [Fintype α] [DecidableEq α]
28
+ (a : Option α → ℝ) : a ∈ closedScalarCubeDomain α ↔ ∀ i, 0 ≤ scalarCubeFace i a := by
29
+ constructor
30
+ · intro ha i
31
+ rcases i with ⟨side, t⟩
32
+ cases side with
33
+ | false => exact (ha t).1
34
+ | true => exact sub_nonneg.mpr (ha t).2
35
+ · intro ha t
36
+ have hlo : 0 ≤ scalarCubeValue a t := ha (false, t)
37
+ have hhi : 0 ≤ 1 - scalarCubeValue a t := ha (true, t)
38
+ exact ⟨hlo, by linarith⟩
39
+
40
+ theorem closedScalarCubeDomain_coordinate_abs_le_one {α : Type*} [Fintype α] [DecidableEq α]
41
+ {a : Option α → ℝ} (ha : a ∈ closedScalarCubeDomain α) (r : Option α) : |a r| ≤ 1 := by
42
+ have hzero := ha ∅
43
+ rw [scalarCubeValue_empty] at hzero
44
+ cases r with
45
+ | none => exact abs_le.mpr ⟨by linarith [hzero.1], hzero.2⟩
46
+ | some i =>
47
+ have hi := ha {i}
48
+ rw [scalarCubeValue_singleton] at hi
49
+ exact abs_le.mpr ⟨by linarith [hzero.2, hi.1], by linarith [hzero.1, hi.2]⟩
50
+
51
+ theorem closedScalarCubeDomain_compact (α : Type*) [Fintype α] [DecidableEq α] :
52
+ IsCompact (closedScalarCubeDomain α) := by
53
+ apply Metric.isCompact_of_isClosed_isBounded (closedScalarCubeDomain_isClosed α)
54
+ apply (Metric.isBounded_closedBall (x := (0 : Option α → ℝ)) (r := 1)).subset
55
+ intro a ha
56
+ rw [Metric.mem_closedBall, dist_zero_right]
57
+ apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
58
+ intro r
59
+ simpa only [Real.norm_eq_abs] using closedScalarCubeDomain_coordinate_abs_le_one ha r
60
+
61
+ end Erdos3
62
+
63
+ end
64
+
65
+ section
66
+
67
+ namespace Erdos3
68
+
69
+ open MeasureTheory
70
+ open scoped BigOperators
71
+
72
+ theorem closedScalarCubeFace_zero_volume {α : Type*} [Fintype α] [DecidableEq α]
73
+ (i : Bool × Finset α) :
74
+ volume (closedScalarCubeDomain α ∩ {a | scalarCubeFace i a = 0}) = 0 := by
75
+ let Z := closedScalarCubeDomain α ∩ {a | scalarCubeFace i a = 0}
76
+ have hZm : MeasurableSet Z := (closedScalarCubeDomain_isClosed α).measurableSet.inter
77
+ (measurableSet_eq_fun (scalarCubeFace_contDiff i).continuous.measurable measurable_const)
78
+ have hZfin : volume Z ≠ ⊤ := ne_of_lt ((measure_mono Set.inter_subset_left).trans_lt
79
+ (closedScalarCubeDomain_compact α).measure_lt_top)
80
+ let s : Set ((α → ℝ) × ℝ) := scalarCubeJoin ⁻¹' Z
81
+ have hs : MeasurableSet s := hZm.preimage (scalarCubeJoin_measurable α)
82
+ have hm := (scalarCubeJoin_measurePreserving α).measure_preimage hZm.nullMeasurableSet
83
+ have hmr := (scalarCubeJoin_measurePreserving α).measureReal_preimage hZm.nullMeasurableSet
84
+ have hsfin : (volume : Measure ((α → ℝ) × ℝ)) s ≠ ⊤ := by
85
+ change volume (scalarCubeJoin ⁻¹' Z) ≠ ⊤
86
+ rw [hm]
87
+ exact hZfin
88
+ have hbase : ∀ z ∈ s, z.1 ∈ Metric.closedBall (0 : α → ℝ) 1 := by
89
+ intro z hz
90
+ rw [Metric.mem_closedBall, dist_zero_right]
91
+ apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
92
+ intro k
93
+ have h := closedScalarCubeDomain_coordinate_abs_le_one hz.1 (some k)
94
+ simpa only [Real.norm_eq_abs, scalarCubeJoin_some] using h
95
+ have hbound : ∀ b : α → ℝ, volume.real {y | (b, y) ∈ s} ≤ 0 := by
96
+ intro b
97
+ let c : ℝ := if i.1 then 1 - ∑ k ∈ i.2, b k else -(∑ k ∈ i.2, b k)
98
+ have hsub : {y | (b, y) ∈ s} ⊆ {c} := by
99
+ intro y hy
100
+ have heq : scalarCubeFace i (scalarCubeJoin (b, y)) = 0 := hy.2
101
+ rw [scalarCubeJoin_face] at heq
102
+ apply Set.mem_singleton_iff.mpr
103
+ dsimp [c]
104
+ split_ifs at heq ⊢ <;> linarith
105
+ have h := measureReal_mono (μ := volume) hsub (by simp)
106
+ simpa [measureReal_def] using h
107
+ have h := product_measureReal_le_of_fiber_bound
108
+ (volume : Measure (α → ℝ)) (volume : Measure ℝ) s hs hsfin
109
+ (Metric.closedBall (0 : α → ℝ) 1) measurableSet_closedBall
110
+ (isCompact_closedBall _ _).measure_ne_top hbase hbound
111
+ change volume.real s ≤ _ at h
112
+ rw [hmr, mul_zero] at h
113
+ exact (measureReal_eq_zero_iff hZfin).mp (le_antisymm h measureReal_nonneg)
114
+
115
+ theorem closedScalarCubeDomain_boundary_null (α : Type*) [Fintype α] [DecidableEq α] :
116
+ volume (closedScalarCubeDomain α \ scalarCubeDomain α) = 0 := by
117
+ have hsub : closedScalarCubeDomain α \ scalarCubeDomain α ⊆
118
+ ⋃ i : Bool × Finset α, closedScalarCubeDomain α ∩ {a | scalarCubeFace i a = 0} := by
119
+ intro a ha
120
+ have hn : ¬ ∀ i, 0 < scalarCubeFace i a := by
121
+ intro hp
122
+ apply ha.2
123
+ rw [← positiveInequalityDomain_scalarCubeFace α]
124
+ exact hp
125
+ obtain ⟨i, hi⟩ := not_forall.mp hn
126
+ have hz : scalarCubeFace i a = 0 := le_antisymm (le_of_not_gt hi)
127
+ ((closedScalarCubeDomain_iff_faces a).mp ha.1 i)
128
+ exact Set.mem_iUnion.mpr ⟨i, ha.1, hz⟩
129
+ exact measure_mono_null hsub (measure_iUnion_null closedScalarCubeFace_zero_volume)
130
+
131
+ theorem scalarCubeDomain_ae_closed (α : Type*) [Fintype α] [DecidableEq α] :
132
+ scalarCubeDomain α =ᵐ[volume] closedScalarCubeDomain α := by
133
+ apply ae_eq_set.mpr
134
+ constructor
135
+ · have he : scalarCubeDomain α \ closedScalarCubeDomain α = ∅ := by
136
+ apply Set.eq_empty_iff_forall_notMem.mpr
137
+ intro a ha
138
+ exact ha.2 (scalarCubeDomain_subset_closed α ha.1)
139
+ rw [he, measure_empty]
140
+ · exact closedScalarCubeDomain_boundary_null α
141
+
142
+ noncomputable def closedScalarCubeMeasure (α : Type*) [Fintype α] [DecidableEq α] :
143
+ Measure (Option α → ℝ) :=
144
+ (volume (closedScalarCubeDomain α))⁻¹ • volume.restrict (closedScalarCubeDomain α)
145
+
146
+ theorem closedScalarCubeMeasure_eq (α : Type*) [Fintype α] [DecidableEq α] :
147
+ closedScalarCubeMeasure α = scalarCubeMeasure α := by
148
+ have hvol := measure_congr (scalarCubeDomain_ae_closed α)
149
+ have hrestrict := Measure.restrict_congr_set (scalarCubeDomain_ae_closed α)
150
+ simp only [closedScalarCubeMeasure, scalarCubeMeasure, ← hvol, ← hrestrict]
151
+
152
+ instance closedScalarCubeMeasure_probability (α : Type*) [Fintype α] [DecidableEq α] :
153
+ IsProbabilityMeasure (closedScalarCubeMeasure α) := by
154
+ rw [closedScalarCubeMeasure_eq]
155
+ infer_instance
156
+
157
+ end Erdos3
158
+
159
+ end
160
+
161
+ section
162
+
163
+ namespace Erdos3
164
+
165
+ open MeasureTheory
166
+ open scoped Classical
167
+
168
+ def halfOpenScalarCubeDomain (I : Type*) [Fintype I] [DecidableEq I] : Set (Option I → ℝ) :=
169
+ {x | ∀ t : Finset I, scalarCubeValue x t ∈ Set.Ico (0 : ℝ) 1}
170
+
171
+ theorem halfOpenScalarCubeDomain_measurable (I : Type*) [Fintype I] [DecidableEq I] :
172
+ MeasurableSet (halfOpenScalarCubeDomain I) := by
173
+ have he : halfOpenScalarCubeDomain I = ⋂ t : Finset I,
174
+ (fun x => scalarCubeValue x t) ⁻¹' Set.Ico (0 : ℝ) 1 := by
175
+ ext x
176
+ simp only [halfOpenScalarCubeDomain, Set.mem_ofPred_eq, Set.mem_iInter, Set.mem_preimage]
177
+ rw [he]
178
+ exact MeasurableSet.iInter (fun (t : Finset I) =>
179
+ measurableSet_Ico.preimage (scalarCubeValue_contDiff t).continuous.measurable)
180
+
181
+ theorem scalarCubeDomain_subset_halfOpen (I : Type*) [Fintype I] [DecidableEq I] :
182
+ scalarCubeDomain I ⊆ halfOpenScalarCubeDomain I :=
183
+ fun _ hx t => ⟨(hx t).1.le, (hx t).2⟩
184
+
185
+ theorem halfOpenScalarCubeDomain_subset_closed (I : Type*) [Fintype I] [DecidableEq I] :
186
+ halfOpenScalarCubeDomain I ⊆ closedScalarCubeDomain I :=
187
+ fun _ hx t => ⟨(hx t).1, (hx t).2.le⟩
188
+
189
+ theorem halfOpenScalarCubeDomain_norm_le {I : Type*} [Fintype I] [DecidableEq I]
190
+ {x : Option I → ℝ} (hx : x ∈ halfOpenScalarCubeDomain I) : ‖x‖ ≤ 1 := by
191
+ apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
192
+ intro i
193
+ exact closedScalarCubeDomain_coordinate_abs_le_one (halfOpenScalarCubeDomain_subset_closed I hx) i
194
+
195
+ theorem halfOpenScalarCubeDomain_ae (I : Type*) [Fintype I] [DecidableEq I] :
196
+ halfOpenScalarCubeDomain I =ᵐ[volume] scalarCubeDomain I := by
197
+ filter_upwards [scalarCubeDomain_ae_closed I] with x hx
198
+ apply propext
199
+ have hx' : x ∈ scalarCubeDomain I ↔ x ∈ closedScalarCubeDomain I := iff_of_eq hx
200
+ constructor
201
+ · intro h
202
+ exact hx'.mpr (halfOpenScalarCubeDomain_subset_closed I h)
203
+ · exact fun h => scalarCubeDomain_subset_halfOpen I h
204
+
205
+ noncomputable def scalarCubeIndicator (I : Type*) [Fintype I] [DecidableEq I]
206
+ (x : Option I → ℝ) : ℝ := if x ∈ halfOpenScalarCubeDomain I then 1 else 0
207
+
208
+ theorem scalarCubeIndicator_range (I : Type*) [Fintype I] [DecidableEq I]
209
+ (x : Option I → ℝ) : 0 ≤ scalarCubeIndicator I x ∧ scalarCubeIndicator I x ≤ 1 := by
210
+ unfold scalarCubeIndicator
211
+ split_ifs <;> norm_num
212
+
213
+ theorem scalarCubeIndicator_zero_outside (I : Type*) [Fintype I] [DecidableEq I]
214
+ (x : Option I → ℝ) (hx : 1 < ‖x‖) : scalarCubeIndicator I x = 0 := by
215
+ apply ite_eq_right
216
+ exact fun h => (not_lt_of_ge (halfOpenScalarCubeDomain_norm_le h)) hx
217
+
218
+ theorem scalarCubeIndicator_integrable (I : Type*) [Fintype I] [DecidableEq I] :
219
+ Integrable (scalarCubeIndicator I) := by
220
+ change Integrable ((halfOpenScalarCubeDomain I).indicator (fun _ => (1 : ℝ)))
221
+ exact (integrableOn_const ((measure_mono (halfOpenScalarCubeDomain_subset_closed I)).trans_lt
222
+ (closedScalarCubeDomain_compact I).measure_lt_top).ne).integrable_indicator
223
+ (halfOpenScalarCubeDomain_measurable I)
224
+
225
+ theorem scalarCubeIndicator_integral (I : Type*) [Fintype I] [DecidableEq I] :
226
+ (∫ x, scalarCubeIndicator I x) = volume.real (scalarCubeDomain I) := by
227
+ have he : scalarCubeIndicator I =ᵐ[volume] (scalarCubeDomain I).indicator (fun _ => (1 : ℝ)) := by
228
+ filter_upwards [halfOpenScalarCubeDomain_ae I] with x hx
229
+ have hx' : (x ∈ halfOpenScalarCubeDomain I) = (x ∈ scalarCubeDomain I) := hx
230
+ change (if x ∈ halfOpenScalarCubeDomain I then 1 else 0) =
231
+ if x ∈ scalarCubeDomain I then 1 else 0
232
+ rw [hx']
233
+ rw [integral_congr_ae he]
234
+ exact integral_indicator_one (scalarCubeDomain_isOpen I).measurableSet
235
+
236
+ end Erdos3
237
+
238
+ end
239
+
240
+ section
241
+
242
+ namespace Erdos3
243
+
244
+ open MeasureTheory
245
+ open scoped BigOperators
246
+
247
+ theorem scalarCubeValue_smul {α : Type*} [Fintype α] [DecidableEq α]
248
+ (T : ℝ) (a : Option α → ℝ) (vertex : Finset α) :
249
+ scalarCubeValue (T • a) vertex = T * scalarCubeValue a vertex := by
250
+ simp only [scalarCubeValue, Pi.smul_apply, smul_eq_mul, Finset.mul_sum]
251
+ apply Finset.sum_congr rfl
252
+ intro r _
253
+ ring
254
+
255
+ def scaledScalarCubeDomain (α : Type*) [Fintype α] [DecidableEq α] (T : ℝ) :
256
+ Set (Option α → ℝ) :=
257
+ {a | ∀ vertex : Finset α, scalarCubeValue a vertex ∈ Set.Ioo (0 : ℝ) T}
258
+
259
+ theorem scaledScalarCubeDomain_smul_iff {α : Type*} [Fintype α] [DecidableEq α]
260
+ {T : ℝ} (hT : 0 < T) (a : Option α → ℝ) :
261
+ T • a ∈ scaledScalarCubeDomain α T ↔ a ∈ scalarCubeDomain α := by
262
+ change (∀ vertex, 0 < scalarCubeValue (T • a) vertex ∧ scalarCubeValue (T • a) vertex < T) ↔ _
263
+ simp only [scalarCubeValue_smul, mul_pos_iff_of_pos_left hT,
264
+ mul_lt_iff_lt_one_right hT]
265
+ rfl
266
+
267
+ theorem scaledScalarCubeDomain_eq_image {α : Type*} [Fintype α] [DecidableEq α]
268
+ {T : ℝ} (hT : 0 < T) :
269
+ scaledScalarCubeDomain α T = (T • ·) '' scalarCubeDomain α := by
270
+ ext a
271
+ constructor
272
+ · intro ha
273
+ refine ⟨T⁻¹ • a, ?_, smul_inv_smul₀ hT.ne' a⟩
274
+ apply (scaledScalarCubeDomain_smul_iff hT _).mp
275
+ simpa only [smul_inv_smul₀ hT.ne'] using ha
276
+ · rintro ⟨a, ha, rfl⟩
277
+ exact (scaledScalarCubeDomain_smul_iff hT a).mpr ha
278
+
279
+ theorem scaledScalarCubeDomain_isOpen (α : Type*) [Fintype α] [DecidableEq α]
280
+ (T : ℝ) : IsOpen (scaledScalarCubeDomain α T) := by
281
+ have he : scaledScalarCubeDomain α T =
282
+ ⋂ vertex : Finset α, (scalarCubeValue · vertex) ⁻¹' Set.Ioo (0 : ℝ) T := by
283
+ ext a
284
+ simp [scaledScalarCubeDomain]
285
+ rw [he]
286
+ exact isOpen_iInter_of_finite (fun vertex =>
287
+ isOpen_Ioo.preimage (scalarCubeValue_contDiff vertex).continuous)
288
+
289
+ end Erdos3
290
+
291
+ end
292
+
293
+ section
294
+
295
+ namespace Erdos3
296
+
297
+ open MeasureTheory
298
+ open scoped BigOperators
299
+
300
+ def scalarCubeFaceSlab {I : Type*} [Fintype I] [DecidableEq I]
301
+ (i : Bool × Finset I) (u : ℝ) : Set (Option I → ℝ) :=
302
+ Metric.closedBall 0 2 ∩ {x | |scalarCubeFace i x| ≤ u}
303
+
304
+ theorem scalarCubeFaceSlab_measurable {I : Type*} [Fintype I] [DecidableEq I]
305
+ (i : Bool × Finset I) (u : ℝ) : MeasurableSet (scalarCubeFaceSlab i u) :=
306
+ measurableSet_closedBall.inter (measurableSet_le
307
+ (scalarCubeFace_contDiff i).continuous.abs.measurable measurable_const)
308
+
309
+ theorem scalarCubeFaceSlab_finite {I : Type*} [Fintype I] [DecidableEq I]
310
+ (i : Bool × Finset I) (u : ℝ) : volume (scalarCubeFaceSlab i u) ≠ ⊤ :=
311
+ ne_of_lt ((measure_mono Set.inter_subset_left).trans_lt (isCompact_closedBall _ _).measure_lt_top)
312
+
313
+ theorem scalarCubeFaceSlab_fiber_bound {I : Type*} [Fintype I] [DecidableEq I]
314
+ (i : Bool × Finset I) {u : ℝ} (hu : 0 ≤ u) (b : I → ℝ) :
315
+ volume.real {y | scalarCubeJoin (b, y) ∈ scalarCubeFaceSlab i u} ≤ 2*u := by
316
+ let c : ℝ := if i.1 then 1 - ∑ k ∈ i.2, b k else -(∑ k ∈ i.2, b k)
317
+ have hsub : {y | scalarCubeJoin (b, y) ∈ scalarCubeFaceSlab i u} ⊆ Set.Icc (c-u) (c+u) := by
318
+ intro y hy
319
+ have hraw : |scalarCubeFace i (scalarCubeJoin (b,y))| ≤ u := hy.2
320
+ have h := abs_le.mp hraw
321
+ rw [scalarCubeJoin_face] at h
322
+ dsimp only [c]
323
+ split_ifs at h ⊢ <;> constructor <;> linarith
324
+ have hv : volume.real (Set.Icc (c-u) (c+u)) = 2*u := by
325
+ rw [Real.volume_real_Icc]
326
+ simp only [show c+u-(c-u) = 2*u by ring, max_eq_left (by positivity : 0 ≤ 2*u)]
327
+ exact (measureReal_mono (μ := volume) hsub (by simp [Real.volume_Icc])).trans_eq hv
328
+
329
+ theorem scalarCubeFaceSlab_volume_le {I : Type*} [Fintype I] [DecidableEq I]
330
+ (i : Bool × Finset I) {u : ℝ} (hu : 0 ≤ u) :
331
+ volume.real (scalarCubeFaceSlab i u) ≤ (4 : ℝ)^Fintype.card I * (2*u) := by
332
+ let s := scalarCubeJoin ⁻¹' scalarCubeFaceSlab i u
333
+ have hs : MeasurableSet s := (scalarCubeFaceSlab_measurable i u).preimage (scalarCubeJoin_measurable I)
334
+ have hm := (scalarCubeJoin_measurePreserving I).measure_preimage (scalarCubeFaceSlab_measurable i u).nullMeasurableSet
335
+ have hmr := (scalarCubeJoin_measurePreserving I).measureReal_preimage (scalarCubeFaceSlab_measurable i u).nullMeasurableSet
336
+ have hfin : (volume : Measure ((I → ℝ) × ℝ)) s ≠ ⊤ := by
337
+ change volume (scalarCubeJoin ⁻¹' scalarCubeFaceSlab i u) ≠ ⊤
338
+ rw [hm]
339
+ exact scalarCubeFaceSlab_finite i u
340
+ have hb : ∀ z ∈ s, z.1 ∈ Metric.closedBall (0 : I → ℝ) 2 := by
341
+ intro z hz
342
+ rw [Metric.mem_closedBall, dist_zero_right]
343
+ apply (pi_norm_le_iff_of_nonneg (by norm_num)).mpr
344
+ intro k
345
+ have hh : ‖scalarCubeJoin z‖ ≤ 2 := by
346
+ simpa only [Metric.mem_closedBall, dist_zero_right] using hz.1
347
+ exact (norm_le_pi_norm (scalarCubeJoin z) (some k)).trans hh
348
+ have h := product_measureReal_le_of_fiber_bound
349
+ (volume : Measure (I → ℝ)) (volume : Measure ℝ) s hs hfin
350
+ (Metric.closedBall (0 : I → ℝ) 2) measurableSet_closedBall (isCompact_closedBall _ _).measure_ne_top
351
+ hb (scalarCubeFaceSlab_fiber_bound i hu)
352
+ change volume.real s ≤ _ at h
353
+ rw [hmr] at h
354
+ have hbase : volume.real (Metric.closedBall (0 : I → ℝ) 2) = (4 : ℝ)^Fintype.card I := by
355
+ rw [measureReal_def, Real.volume_pi_closedBall _ (by norm_num)]
356
+ norm_num
357
+ rwa [hbase] at h
358
+
359
+ end Erdos3
360
+
361
+ end
362
+
363
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeRootTranslation.lean ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.CubeResidueSupport
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ def shiftScalarCube {I : Type*} (c : ℤ) (x : Option I → ℤ) : Option I → ℤ
10
+ | none => c + x none
11
+ | some i => x (some i)
12
+
13
+ def shiftScalarCubeResidues {I : Type*} (c : ℤ) (m : Option I → ℕ)
14
+ (r : ∀ i, ZMod (m i)) : ∀ i, ZMod (m i)
15
+ | none => r none - (c : ZMod (m none))
16
+ | some i => r (some i)
17
+
18
+ theorem shiftScalarCube_value {I : Type*} [Fintype I]
19
+ (c : ℤ) (x : Option I → ℤ) (t : Finset I) :
20
+ integerScalarCubeValue (shiftScalarCube c x) t = c + integerScalarCubeValue x t := by
21
+ simp only [integerScalarCubeValue, shiftScalarCube, add_assoc]
22
+
23
+ theorem shiftScalarCube_residues_iff {I : Type*} (c : ℤ) (m : Option I → ℕ)
24
+ (r : ∀ i, ZMod (m i)) (x : Option I → ℤ) :
25
+ (∀ i, ((shiftScalarCube c x i : ℤ) : ZMod (m i)) = r i) ↔
26
+ ∀ i, ((x i : ℤ) : ZMod (m i)) = shiftScalarCubeResidues c m r i := by
27
+ constructor
28
+ · intro h i
29
+ cases i with
30
+ | none => simpa [shiftScalarCube, shiftScalarCubeResidues, eq_sub_iff_add_eq, add_comm] using h none
31
+ | some i => exact h (some i)
32
+ · intro h i
33
+ cases i with
34
+ | none => simpa [shiftScalarCube, shiftScalarCubeResidues, eq_sub_iff_add_eq, add_comm] using h none
35
+ | some i => exact h (some i)
36
+
37
+ def supportedCubeCoordinates {q : ℕ} (p : (Fin q → ℤ) × ℤ) : Option (Fin q) → ℤ
38
+ | none => p.2
39
+ | some i => p.1 i
40
+
41
+ def supportedIntervalTranslateEquiv (q K : ℕ) (c : ℤ) :
42
+ SupportedCube q (Set.Ico (0 : ℤ) (K : ℤ)) ≃
43
+ SupportedCube q (Set.Ico c (c + K)) where
44
+ toFun p := ⟨(p.val.1, c + p.val.2), fun ω => by
45
+ have h := p.property ω
46
+ change 0 ≤ p.val.2 + cubeShift p.val.1 ω ∧ p.val.2 + cubeShift p.val.1 ω < K at h
47
+ change c ≤ c + p.val.2 + cubeShift p.val.1 ω ∧
48
+ c + p.val.2 + cubeShift p.val.1 ω < c + K
49
+ constructor <;> omega⟩
50
+ invFun p := ⟨(p.val.1, p.val.2 - c), fun ω => by
51
+ have h := p.property ω
52
+ change c ≤ p.val.2 + cubeShift p.val.1 ω ∧ p.val.2 + cubeShift p.val.1 ω < c + K at h
53
+ change 0 ≤ p.val.2 - c + cubeShift p.val.1 ω ∧
54
+ p.val.2 - c + cubeShift p.val.1 ω < K
55
+ constructor <;> omega⟩
56
+ left_inv p := by
57
+ apply Subtype.ext
58
+ apply Prod.ext
59
+ · rfl
60
+ · simp
61
+ right_inv p := by
62
+ apply Subtype.ext
63
+ apply Prod.ext
64
+ · rfl
65
+ · simp
66
+
67
+ noncomputable def shiftedScalarCubeEquiv (q K : ℕ) (c : ℤ) :
68
+ ↥(integerScalarCubeSet (Fin q) K) ≃ SupportedCube q (Set.Ico c (c + K)) :=
69
+ (integerScalarCubeEquiv q K).trans (supportedIntervalTranslateEquiv q K c)
70
+
71
+ theorem shiftedScalarCubeEquiv_coordinates (q K : ℕ) (c : ℤ)
72
+ (x : ↥(integerScalarCubeSet (Fin q) K)) :
73
+ supportedCubeCoordinates (shiftedScalarCubeEquiv q K c x).val =
74
+ shiftScalarCube c (fun i => (x.val i : ℤ)) := by
75
+ funext i
76
+ cases i <;> rfl
77
+
78
+ end Erdos3
79
+
80
+ end
81
+
82
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarCubeWindowDomain.lean ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.CubeResidueSupport
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem integerScalarCube_mono {I : Type*} [Fintype I] {K L : ℕ}
10
+ (hKL : K ≤ L) {x : Option I → ℤ} (hx : IntegerScalarCube K x) : IntegerScalarCube L x := by
11
+ intro t
12
+ exact ⟨(hx t).1, (hx t).2.trans_le (by exact_mod_cast hKL)⟩
13
+
14
+ def integerScalarCubeBoxEmbed (I : Type*) (K L : ℕ) (hKL : K ≤ L)
15
+ (x : IntegerScalarCubeBox I K) : IntegerScalarCubeBox I L := fun i =>
16
+ ⟨(x i : ℤ), Finset.mem_Ico.mpr (by
17
+ have hi := Finset.mem_Ico.mp (x i).property
18
+ constructor <;> omega)⟩
19
+
20
+ noncomputable def scalarCubeWindowResidueSet (I : Type*) [Fintype I]
21
+ (L K : ℕ) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) :
22
+ Finset (IntegerScalarCubeBox I L) := by
23
+ classical
24
+ exact Finset.univ.filter (fun x => IntegerScalarCube K (fun i => (x i : ℤ)) ∧
25
+ ∀ i, ((x i : ℤ) : ZMod (m i)) = r i)
26
+
27
+ theorem mem_scalarCubeWindowResidueSet {I : Type*} [Fintype I]
28
+ (L K : ℕ) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (x : IntegerScalarCubeBox I L) :
29
+ x ∈ scalarCubeWindowResidueSet I L K m r ↔
30
+ IntegerScalarCube K (fun i => (x i : ℤ)) ∧ ∀ i, ((x i : ℤ) : ZMod (m i)) = r i := by
31
+ classical
32
+ simp only [scalarCubeWindowResidueSet, Finset.mem_filter, Finset.mem_univ, true_and]
33
+
34
+ theorem scalarCubeWindowResidueSet_subset {I : Type*} [Fintype I]
35
+ (L K : ℕ) (hKL : K ≤ L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) :
36
+ scalarCubeWindowResidueSet I L K m r ⊆ integerScalarCubeSet I L := by
37
+ intro x hx
38
+ exact (mem_integerScalarCubeSet L x).mpr
39
+ (integerScalarCube_mono hKL ((mem_scalarCubeWindowResidueSet L K m r x).mp hx).1)
40
+
41
+ noncomputable def scalarCubeWindowResidueEquiv (I : Type*) [Fintype I] [DecidableEq I]
42
+ (L K : ℕ) (hKL : K ≤ L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) :
43
+ ↥((integerScalarCubeSet I K) ∩ scalarCubeResidueSet I K m r) ≃
44
+ ↥(scalarCubeWindowResidueSet I L K m r) where
45
+ toFun x := by
46
+ have hx := Finset.mem_inter.mp x.property
47
+ exact ⟨integerScalarCubeBoxEmbed I K L hKL x.val,
48
+ (mem_scalarCubeWindowResidueSet L K m r _).mpr
49
+ ⟨(mem_integerScalarCubeSet K x.val).mp hx.1,
50
+ (mem_scalarCubeResidueSet K m r x.val).mp hx.2⟩⟩
51
+ invFun y := by
52
+ have hy := (mem_scalarCubeWindowResidueSet L K m r y.val).mp y.property
53
+ let x : IntegerScalarCubeBox I K := fun i =>
54
+ ⟨(y.val i : ℤ), Finset.mem_Ico.mpr
55
+ ⟨(integerScalarCube_coordinates hy.1 i).1.le, (integerScalarCube_coordinates hy.1 i).2⟩⟩
56
+ exact ⟨x, Finset.mem_inter.mpr ⟨(mem_integerScalarCubeSet K x).mpr hy.1,
57
+ (mem_scalarCubeResidueSet K m r x).mpr hy.2⟩⟩
58
+ left_inv x := by
59
+ apply Subtype.ext
60
+ funext i
61
+ apply Subtype.ext
62
+ rfl
63
+ right_inv y := by
64
+ apply Subtype.ext
65
+ funext i
66
+ apply Subtype.ext
67
+ rfl
68
+
69
+ theorem scalarCubeWindowResidueSet_card (I : Type*) [Fintype I] [DecidableEq I]
70
+ (L K : ℕ) (hKL : K ≤ L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) :
71
+ (scalarCubeWindowResidueSet I L K m r).card =
72
+ ((integerScalarCubeSet I K) ∩ scalarCubeResidueSet I K m r).card := by
73
+ simpa only [Fintype.card_coe] using
74
+ (Fintype.card_congr (scalarCubeWindowResidueEquiv I L K hKL m r)).symm
75
+
76
+ theorem scalarCubeWindowResidueSet_card_lower (I : Type*) [Fintype I] [DecidableEq I]
77
+ (L K M H : ℕ) (hKL : K ≤ L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i))
78
+ (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hH : 0 < H)
79
+ (hbudget : (Fintype.card I + 1) * (M * H) ≤ K) :
80
+ H ^ (Fintype.card I + 1) ≤ (scalarCubeWindowResidueSet I L K m r).card := by
81
+ rw [scalarCubeWindowResidueSet_card I L K hKL m r]
82
+ exact scalarCubeResidueSet_card_lower I K M H m r hm hmM hH hbudget
83
+
84
+ end Erdos3
85
+
86
+ end
87
+
88
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarDominatedSlack.lean ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Analysis.SpecialFunctions.Exp
2
+ import Mathlib.Data.Set.Card
3
+ import OAI.Combinatorics.Progressions.Geometry.ProductSectionSupport
4
+ import OAI.Combinatorics.Progressions.Probability.FiniteExcessMassCap
5
+ import OAI.Combinatorics.Progressions.Probability.IntervalDivisorProbability
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3
12
+
13
+ open scoped BigOperators
14
+
15
+ namespace FiniteProbabilityWeights
16
+
17
+ theorem mean_comm {X Y : Type*} [Fintype X] [Fintype Y]
18
+ (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) (F : X → Y → ℝ) :
19
+ p.mean (fun x => q.mean (F x)) = q.mean (fun y => p.mean (fun x => F x y)) := by
20
+ unfold mean
21
+ simp_rw [Finset.mul_sum]
22
+ rw [Finset.sum_comm]
23
+ apply Finset.sum_congr rfl
24
+ intro y _
25
+ apply Finset.sum_congr rfl
26
+ intro x _
27
+ ring
28
+
29
+ theorem mean_sum {X J : Type*} [Fintype X] (p : FiniteProbabilityWeights X)
30
+ (s : Finset J) (F : J → X → ℝ) :
31
+ p.mean (fun x => ∑ j ∈ s, F j x) = ∑ j ∈ s, p.mean (F j) := by
32
+ unfold mean
33
+ simp_rw [Finset.mul_sum]
34
+ exact Finset.sum_comm
35
+
36
+ theorem mean_sub {X : Type*} [Fintype X] (p : FiniteProbabilityWeights X) (f g : X → ℝ) :
37
+ p.mean (fun x => f x - g x) = p.mean f - p.mean g := by
38
+ simp only [mean, mul_sub, Finset.sum_sub_distrib]
39
+
40
+ theorem mean_mul_const {X : Type*} [Fintype X] (p : FiniteProbabilityWeights X)
41
+ (f : X → ℝ) (c : ℝ) : p.mean (fun x => f x * c) = p.mean f * c := by
42
+ simp only [mean, ← mul_assoc, Finset.sum_mul]
43
+
44
+ end FiniteProbabilityWeights
45
+
46
+ variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*}
47
+ [∀ i, Fintype (X i)]
48
+
49
+ theorem productMean_coordinateSwap (μ : ∀ i, FiniteProbabilityWeights (X i))
50
+ (S : Finset I) (F : (∀ i, X i) → (∀ i, X i) → ℝ) :
51
+ (FiniteProbabilityWeights.pi μ).mean (fun x => (FiniteProbabilityWeights.pi μ).mean
52
+ (fun y => F (productCoordinateMix S x y) (productCoordinateMix S y x))) =
53
+ (FiniteProbabilityWeights.pi μ).mean (fun x => (FiniteProbabilityWeights.pi μ).mean (F x)) := by
54
+ let p := FiniteProbabilityWeights.pi μ
55
+ have h : (∑ z : (∀ i, X i) × (∀ i, X i), p.weight z.1 * p.weight z.2 *
56
+ F (productCoordinateMix S z.1 z.2) (productCoordinateMix S z.2 z.1)) =
57
+ ∑ z : (∀ i, X i) × (∀ i, X i), p.weight z.1 * p.weight z.2 * F z.1 z.2 := by
58
+ apply Fintype.sum_equiv (productCoordinateSwap (X := X) S)
59
+ intro z
60
+ change _ = p.weight (productCoordinateMix S z.1 z.2) *
61
+ p.weight (productCoordinateMix S z.2 z.1) * _
62
+ rw [productCoordinateMix_weight]
63
+ rfl
64
+ simpa only [FiniteProbabilityWeights.mean, Fintype.sum_prod_type,
65
+ Finset.mul_sum, mul_assoc] using h
66
+
67
+ theorem productMean_coordinateMix (μ : ∀ i, FiniteProbabilityWeights (X i))
68
+ (S : Finset I) (f : (∀ i, X i) → ℝ) :
69
+ (FiniteProbabilityWeights.pi μ).mean (fun x => (FiniteProbabilityWeights.pi μ).mean
70
+ (fun y => f (productCoordinateMix S x y))) = (FiniteProbabilityWeights.pi μ).mean f := by
71
+ have h := productMean_coordinateSwap μ S (fun x _ => f x)
72
+ simpa only [FiniteProbabilityWeights.mean_const] using h
73
+
74
+ end Erdos3
75
+
76
+ end
77
+
78
+ section
79
+
80
+ namespace Erdos3.FiniteProbabilityWeights
81
+
82
+ open scoped BigOperators Classical
83
+
84
+ theorem exists_code_fiber_mass {Ω I : Type*} [Fintype Ω] [Fintype I] [Nonempty I]
85
+ (p : FiniteProbabilityWeights Ω) (Q : Finset Ω) (code : Ω → I) :
86
+ ∃ i, p.mass Q / Fintype.card I ≤ p.mass (Q.filter (fun x => code x = i)) := by
87
+ have hsum : (∑ i, p.mass (Q.filter (fun x => code x = i))) = p.mass Q := by
88
+ simp only [mass, Finset.sum_filter]
89
+ rw [Finset.sum_comm]
90
+ simp
91
+ have hmean : (𝔼 i, p.mass (Q.filter (fun x => code x = i))) = p.mass Q / Fintype.card I := by
92
+ rw [Fintype.expect_eq_sum_div_card, hsum]
93
+ obtain ⟨i, _, hi⟩ := Finset.exists_le_of_le_expect Finset.univ_nonempty hmean.ge
94
+ exact ⟨i, hi⟩
95
+
96
+ end Erdos3.FiniteProbabilityWeights
97
+
98
+ end
99
+
100
+ section
101
+
102
+ namespace Erdos3.FiniteProbabilityWeights
103
+
104
+ open scoped BigOperators Classical
105
+
106
+ theorem retain_simultaneous_mean_error {Ω J : Type*} [Fintype Ω] [Fintype J]
107
+ (p : FiniteProbabilityWeights Ω) (productive : Finset Ω) (err : J → Ω → ℝ)
108
+ (herr : ∀ j a, 0 ≤ err j a) {tau : ℝ} (htau : 0 < tau) :
109
+ ∃ retained : Finset Ω, retained ⊆ productive ∧
110
+ p.mass productive - (∑ j, p.mean (err j)) / tau ≤ p.mass retained ∧
111
+ ∀ a ∈ retained, ∀ j, err j a ≤ tau := by
112
+ let retained := productive.filter (fun a => ∀ j, err j a ≤ tau)
113
+ have hpoint (a : Ω) :
114
+ tau * ((if a ∈ productive then (1 : ℝ) else 0) -
115
+ (if a ∈ retained then 1 else 0)) ≤ ∑ j, err j a := by
116
+ by_cases ha : a ∈ productive
117
+ · by_cases hg : ∀ j, err j a ≤ tau
118
+ · have hret : a ∈ retained := Finset.mem_filter.mpr ⟨ha, hg⟩
119
+ simp only [ha, hret, ite_true, sub_self, mul_zero]
120
+ exact Finset.sum_nonneg (fun j _ => herr j a)
121
+ · have hret : a ∉ retained := by simpa only [retained, Finset.mem_filter, ha, true_and] using hg
122
+ simp only [ha, hret, ite_true, ite_false, sub_zero, mul_one]
123
+ push Not at hg
124
+ obtain ⟨j, hj⟩ := hg
125
+ exact hj.le.trans (Finset.single_le_sum (fun i _ => herr i a) (Finset.mem_univ j))
126
+ · have hret : a ∉ retained := fun h => ha (Finset.mem_filter.mp h).1
127
+ simp only [ha, hret, ite_false, sub_self, mul_zero]
128
+ exact Finset.sum_nonneg (fun j _ => herr j a)
129
+ have h := p.mean_mono hpoint
130
+ rw [p.mean_const_mul, p.mean_sub, p.mean_indicator, p.mean_indicator, p.mean_sum] at h
131
+ have hdiv : p.mass productive - p.mass retained ≤ (∑ j, p.mean (err j)) / tau :=
132
+ (le_div_iff₀ htau).mpr (by simpa only [mul_comm] using h)
133
+ refine ⟨retained, Finset.filter_subset _ _, by linarith, ?_⟩
134
+ intro a ha
135
+ exact (Finset.mem_filter.mp ha).2
136
+
137
+ theorem retain_simultaneous_small_mean_error {Ω J : Type*} [Fintype Ω] [Fintype J]
138
+ (p : FiniteProbabilityWeights Ω) (productive : Finset Ω) (err : J → Ω → ℝ)
139
+ (herr : ∀ j a, 0 ≤ err j a) {tau kappa : ℝ} (htau : 0 < tau)
140
+ (hproductive : kappa ≤ p.mass productive)
141
+ (hmean : (∑ j, p.mean (err j)) ≤ kappa * tau / 4) :
142
+ ∃ retained : Finset Ω, retained ⊆ productive ∧
143
+ 3 * kappa / 4 ≤ p.mass retained ∧ ∀ a ∈ retained, ∀ j, err j a ≤ tau := by
144
+ obtain ⟨retained, hsub, hmass, hgood⟩ := p.retain_simultaneous_mean_error productive err herr htau
145
+ have hdiv : (∑ j, p.mean (err j)) / tau ≤ kappa / 4 :=
146
+ (div_le_iff₀ htau).mpr (by nlinarith)
147
+ exact ⟨retained, hsub, by linarith, hgood⟩
148
+
149
+ end Erdos3.FiniteProbabilityWeights
150
+
151
+ end
152
+
153
+ section
154
+
155
+ namespace Erdos3
156
+
157
+ theorem exists_weighted_exponential_constant_fiber {Ω β : Type*} [Fintype Ω]
158
+ (outer : FiniteProbabilityWeights Ω) (S : Finset Ω) (hS : 0 < outer.mass S)
159
+ (f : Ω → β) (A : Set β) (hA : A.Finite) (hf : ∀ x ∈ S, f x ∈ A)
160
+ {C : ℝ} (hcount : (A.ncard : ℝ) ≤ Real.exp C) :
161
+ ∃ y ∈ A, ∃ T : Finset Ω, T ⊆ S ∧ T.Nonempty ∧ (∀ x ∈ T, f x = y) ∧
162
+ Real.exp (-C) * outer.mass S ≤ outer.mass T := by
163
+ classical
164
+ have hSne : S.Nonempty := by
165
+ apply Finset.nonempty_iff_ne_empty.mpr
166
+ intro he
167
+ simp only [he, FiniteProbabilityWeights.mass, Finset.sum_empty, lt_self_iff_false] at hS
168
+ obtain ⟨x₀, hx₀⟩ := hSne
169
+ let : Fintype A := hA.fintype
170
+ let default : A := ⟨f x₀, hf x₀ hx₀⟩
171
+ let : Nonempty A := ⟨default⟩
172
+ let code : Ω → A := fun x => if hx : x ∈ S then ⟨f x, hf x hx⟩ else default
173
+ obtain ⟨y, hy⟩ := outer.exists_code_fiber_mass S code
174
+ let T := S.filter (fun x => code x = y)
175
+ have hcard : (Fintype.card A : ℝ) ≤ Real.exp C := by
176
+ simpa only [Set.fintypeCard_eq_ncard] using hcount
177
+ have hcardpos : (0 : ℝ) < Fintype.card A := by exact_mod_cast Fintype.card_pos
178
+ have hmass : Real.exp (-C) * outer.mass S ≤ outer.mass T := by
179
+ calc
180
+ _ = outer.mass S / Real.exp C := by
181
+ rw [Real.exp_neg, div_eq_mul_inv, mul_comm]
182
+ _ ≤ outer.mass S / Fintype.card A :=
183
+ div_le_div_of_nonneg_left hS.le hcardpos hcard
184
+ _ ≤ outer.mass T := by
185
+ convert hy using 1
186
+ apply congrArg outer.mass
187
+ ext x
188
+ simp only [T, Finset.mem_filter]
189
+ have hTpos : 0 < outer.mass T := (mul_pos (Real.exp_pos _) hS).trans_le hmass
190
+ have hTne : T.Nonempty := by
191
+ apply Finset.nonempty_iff_ne_empty.mpr
192
+ intro he
193
+ simp only [he, FiniteProbabilityWeights.mass, Finset.sum_empty, lt_self_iff_false] at hTpos
194
+ refine ⟨y.val, y.property, T, Finset.filter_subset _ _, hTne, ?_, hmass⟩
195
+ intro x hx
196
+ have hxS : x ∈ S := (Finset.mem_filter.mp hx).1
197
+ have he := congrArg Subtype.val (Finset.mem_filter.mp hx).2
198
+ simpa only [code, dite_eq_left hxS] using he
199
+
200
+ end Erdos3
201
+
202
+ end
203
+
204
+ section
205
+
206
+ namespace Erdos3
207
+
208
+ open scoped BigOperators Classical
209
+
210
+ theorem exists_linear_model_partner {V I : Type*}
211
+ [AddCommGroup V] [Module ℂ V] [Fintype I]
212
+ (test : V →ₗ[ℂ] ℂ) (v e : V) (Q : I → V) (c : I → ℂ)
213
+ (hmodel : v = (∑ i, c i • Q i) + e) {delta M : ℝ}
214
+ (hdelta : 0 < delta) (hM : 0 < M) (hc : (∑ i, ‖c i‖) ≤ M)
215
+ (herr : ‖test e‖ ≤ delta / 2) (hscore : delta ≤ ‖test v‖) :
216
+ ∃ i, delta / (2 * M) ≤ ‖test (Q i)‖ := by
217
+ have hid : test v = (∑ i, c i * test (Q i)) + test e := by
218
+ rw [hmodel, map_add, map_sum]
219
+ simp only [map_smul, smul_eq_mul]
220
+ have hsum : delta / 2 ≤ ‖∑ i, c i * test (Q i)‖ := by
221
+ have ht := norm_add_le (∑ i, c i * test (Q i)) (test e)
222
+ rw [← hid] at ht
223
+ linarith
224
+ obtain ⟨i, hi⟩ := exists_large_weighted_term c (fun i => test (Q i))
225
+ (by positivity : 0 < delta / 2) hM hc hsum
226
+ refine ⟨i, ?_⟩
227
+ convert hi using 1; ring
228
+
229
+ theorem exists_fixed_linear_model_partners {Ω K V : Type*} {I : K → Type*}
230
+ [Fintype Ω] [Fintype K] [∀ k, Fintype (I k)] [∀ k, Nonempty (I k)]
231
+ [AddCommGroup V] [Module ℂ V]
232
+ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω)
233
+ (v e : K → V) (Q : ∀ k, I k → V) (c : ∀ k, I k → ℂ)
234
+ (test : Ω → K → V →ₗ[ℂ] ℂ) (err : K → Ω → ℝ)
235
+ (hmodel : ∀ k, v k = (∑ i, c k i • Q k i) + e k)
236
+ {delta M kappa : ℝ} (hdelta : 0 < delta) (hM : 0 < M)
237
+ (hc : ∀ k, (∑ i, ‖c k i‖) ≤ M)
238
+ (herr : ∀ k a, 0 ≤ err k a)
239
+ (htest : ∀ a ∈ productive, ∀ k, ‖test a k (e k)‖ ≤ err k a)
240
+ (hproductive : kappa ≤ outer.mass productive)
241
+ (hmean : (∑ k, outer.mean (err k)) ≤ kappa * (delta / 2) / 4)
242
+ (hscore : ∀ a ∈ productive, ∀ k, delta ≤ ‖test a k (v k)‖) :
243
+ ∃ (partner : ∀ k, I k) (retained : Finset Ω),
244
+ retained ⊆ productive ∧
245
+ (3 * kappa / 4) / (∏ k, (Fintype.card (I k) : ℝ)) ≤ outer.mass retained ∧
246
+ ∀ a ∈ retained, ∀ k, delta / (2 * M) ≤ ‖test a k (Q k (partner k))‖ := by
247
+ obtain ⟨good, hgood, hmass, herrors⟩ := outer.retain_simultaneous_small_mean_error
248
+ productive err herr (by positivity : 0 < delta / 2) hproductive hmean
249
+ have hex (a : Ω) (ha : a ∈ good) (k : K) :
250
+ ∃ i, delta / (2 * M) ≤ ‖test a k (Q k i)‖ :=
251
+ exists_linear_model_partner (test a k) (v k) (e k) (Q k) (c k) (hmodel k)
252
+ hdelta hM (hc k) ((htest a (hgood ha) k).trans (herrors a ha k)) (hscore a (hgood ha) k)
253
+ let choice : Ω → ∀ k, I k := fun a k =>
254
+ if ha : a ∈ good then Classical.choose (hex a ha k) else Classical.choice inferInstance
255
+ have hchoice (a : Ω) (ha : a ∈ good) (k : K) :
256
+ delta / (2 * M) ≤ ‖test a k (Q k (choice a k))‖ := by
257
+ dsimp only [choice]
258
+ rw [dite_eq_left ha]
259
+ exact Classical.choose_spec (hex a ha k)
260
+ obtain ⟨partner, hpartner⟩ := outer.exists_code_fiber_mass good choice
261
+ let retained := good.filter (fun a => choice a = partner)
262
+ have hretained : retained ⊆ good := Finset.filter_subset _ _
263
+ refine ⟨partner, retained, fun a ha => hgood (hretained ha), ?_, ?_⟩
264
+ · have hcard : (Fintype.card (∀ k, I k) : ℝ) = ∏ k, (Fintype.card (I k) : ℝ) := by simp
265
+ rw [hcard] at hpartner
266
+ have h := (div_le_div_of_nonneg_right hmass (by positivity : 0 ≤ ∏ k, (Fintype.card (I k) : ℝ))).trans hpartner
267
+ convert h using 1; try rfl
268
+ congr 1
269
+ ext a
270
+ simp only [retained, Finset.mem_filter]
271
+ · intro a ha k
272
+ have he := (Finset.mem_filter.mp ha).2
273
+ rw [← he]
274
+ exact hchoice a (hretained ha) k
275
+
276
+ end Erdos3
277
+
278
+ end
279
+
280
+ section
281
+
282
+ namespace Erdos3
283
+
284
+ open scoped Classical
285
+
286
+ theorem fixedParameter_observed_tail_of_tests
287
+ {X T A : Type*} [Fintype X] [Fintype T]
288
+ (source : FiniteProbabilityWeights X) (parameter : FiniteProbabilityWeights T)
289
+ (observe : X → A) (value : T → A → ℝ) {gap bound : ℝ} (hgap : 0 < gap)
290
+ (htest : ∀ w : A → ℝ, (∀ x, 0 ≤ w (observe x) ∧ w (observe x) ≤ 1) →
291
+ (parameter.prod source).mean (fun tx => w (observe tx.2) * value tx.1 (observe tx.2)) ≤ gap * bound) :
292
+ source.eventProbability (fun x => gap < parameter.mean (fun t => value t (observe x))) ≤ bound := by
293
+ let w : A → ℝ := fun z => if gap < parameter.mean (fun t => value t z) then 1 else 0
294
+ have hw (x) : 0 ≤ w (observe x) ∧ w (observe x) ≤ 1 := by
295
+ dsimp only [w]
296
+ split_ifs <;> norm_num
297
+ have hup := htest w hw
298
+ rw [FiniteProbabilityWeights.mean_prod, FiniteProbabilityWeights.mean_comm] at hup
299
+ simp only [FiniteProbabilityWeights.mean_const_mul] at hup
300
+ have hlow : gap * source.eventProbability
301
+ (fun x => gap < parameter.mean (fun t => value t (observe x))) ≤
302
+ source.mean (fun x => w (observe x) * parameter.mean (fun t => value t (observe x))) := by
303
+ rw [FiniteProbabilityWeights.eventProbability, ← source.mean_const_mul]
304
+ apply source.mean_mono
305
+ intro x
306
+ dsimp only [w]
307
+ split_ifs with hx
308
+ · simpa only [mul_one, one_mul] using hx.le
309
+ · simp only [mul_zero, zero_mul, le_refl]
310
+ exact (mul_le_mul_iff_right₀ hgap).mp (hlow.trans hup)
311
+
312
+ theorem fixedParameter_observed_tail_exp
313
+ {X T A : Type*} [Fintype X] [Fintype T]
314
+ (source : FiniteProbabilityWeights X) (parameter : FiniteProbabilityWeights T)
315
+ (observe : X → A) (value : T → A → ℝ) (p dominationLog : ℝ)
316
+ (htest : ∀ w : A → ℝ, (∀ x, 0 ≤ w (observe x) ∧ w (observe x) ≤ 1) →
317
+ (parameter.prod source).mean (fun tx => w (observe tx.2) * value tx.1 (observe tx.2)) ≤
318
+ Real.exp (-(2 * p + dominationLog)) / 2) :
319
+ source.eventProbability (fun x => Real.exp (-p) < parameter.mean (fun t => value t (observe x))) ≤
320
+ Real.exp (-(p + dominationLog)) := by
321
+ apply fixedParameter_observed_tail_of_tests source parameter observe value (Real.exp_pos (-p))
322
+ intro w hw
323
+ apply (htest w hw).trans
324
+ rw [← Real.exp_add]
325
+ have he : -p + -(p + dominationLog) = -(2 * p + dominationLog) := by ring
326
+ rw [he]
327
+ linarith [Real.exp_pos (-(2 * p + dominationLog))]
328
+
329
+ theorem fixedParameter_observed_tail_dominated
330
+ {X T A : Type*} [Fintype X] [Fintype T]
331
+ (source outer : FiniteProbabilityWeights X) (parameter : FiniteProbabilityWeights T)
332
+ (observe : X → A) (value : T → A → ℝ) (p dominationLog : ℝ)
333
+ (hdom : ∀ x, outer.weight x ≤ Real.exp dominationLog * source.weight x)
334
+ (htest : ∀ w : A → ℝ, (∀ x, 0 ≤ w (observe x) ∧ w (observe x) ≤ 1) →
335
+ (parameter.prod source).mean (fun tx => w (observe tx.2) * value tx.1 (observe tx.2)) ≤
336
+ Real.exp (-(2 * p + dominationLog)) / 2) :
337
+ outer.eventProbability (fun x => Real.exp (-p) < parameter.mean (fun t => value t (observe x))) ≤
338
+ Real.exp (-p) := by
339
+ have ht := fixedParameter_observed_tail_exp source parameter observe value p dominationLog htest
340
+ calc
341
+ _ ≤ Real.exp dominationLog * source.eventProbability
342
+ (fun x => Real.exp (-p) < parameter.mean (fun t => value t (observe x))) :=
343
+ outer.eventProbability_le_of_weight_le source _ hdom _
344
+ _ ≤ Real.exp dominationLog * Real.exp (-(p + dominationLog)) :=
345
+ mul_le_mul_of_nonneg_left ht (Real.exp_nonneg _)
346
+ _ = _ := by rw [← Real.exp_add]; congr 1; ring
347
+
348
+ end Erdos3
349
+
350
+ end
351
+
352
+ section
353
+
354
+ namespace Erdos3.FiniteProbabilityWeights
355
+
356
+ open scoped BigOperators Classical
357
+
358
+ theorem uniform_injective_mean_le {B X : Type*}
359
+ [Fintype B] [Nonempty B] [Fintype X] [Nonempty X]
360
+ (F : B → X) (hF : Function.Injective F) (φ : X → ℝ) (hφ : ∀ x, 0 ≤ φ x) :
361
+ (uniform B).mean (fun b => φ (F b)) ≤
362
+ ((Fintype.card X : ℝ) / Fintype.card B) * (uniform X).mean φ := by
363
+ have hsum : (∑ b, φ (F b)) ≤ ∑ x, φ x :=
364
+ Finset.sum_le_sum_of_injOn F hF.injOn (Finset.subset_univ _)
365
+ (fun _ _ => le_rfl) (fun x _ _ => hφ x)
366
+ rw [uniform_mean, uniform_mean, Fintype.expect_eq_sum_div_card,
367
+ Fintype.expect_eq_sum_div_card]
368
+ have hX : (Fintype.card X : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero
369
+ calc
370
+ _ ≤ (∑ x, φ x) / Fintype.card B := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg _)
371
+ _ = _ := by field_simp
372
+
373
+ theorem uniform_base_reweight_test_le {B Ω X : Type*}
374
+ [Fintype B] [Nonempty B] [Fintype Ω] [Fintype X] [Nonempty X]
375
+ (q : FiniteProbabilityWeights Ω) (D : B × Ω → ℝ) (hD : ∀ z, 0 ≤ D z)
376
+ (hZ : 0 < ((uniform B).prod q).mean D)
377
+ (F : B × Ω → X) (hF : ∀ z, Function.Injective (fun b => F (b, z)))
378
+ (φ : X → ℝ) (hφ : ∀ x, 0 ≤ φ x)
379
+ {M ε a : ℝ} (hM : 0 ≤ M) (ha : 0 < a)
380
+ (hlower : a ≤ ((uniform B).prod q).mean D)
381
+ (hlocal : ∀ b, q.mean (fun z => D (b, z) * φ (F (b, z))) ≤
382
+ M * q.mean (fun z => φ (F (b, z))) + ε) :
383
+ (((uniform B).prod q).reweightPositive D hD hZ).mean (fun z => φ (F z)) ≤
384
+ ((M * ((Fintype.card X : ℝ) / Fintype.card B)) * (uniform X).mean φ + ε) / a := by
385
+ have href : ((uniform B).prod q).mean (fun z => φ (F z)) ≤
386
+ ((Fintype.card X : ℝ) / Fintype.card B) * (uniform X).mean φ := by
387
+ rw [mean_prod, mean_comm]
388
+ exact (q.mean_mono (fun z => uniform_injective_mean_le _ (hF z) φ hφ)).trans_eq
389
+ (q.mean_const _)
390
+ have hraw : ((uniform B).prod q).mean (fun z => D z * φ (F z)) ≤
391
+ M * ((uniform B).prod q).mean (fun z => φ (F z)) + ε := by
392
+ rw [mean_prod, mean_prod]
393
+ exact ((uniform B).mean_mono hlocal).trans_eq (by rw [mean_add, mean_const_mul, mean_const])
394
+ have hnorm := ((uniform B).prod q).reweightPositive_test_le D hD hZ
395
+ (fun z => φ (F z)) (fun z => hφ (F z)) ha hlower hraw
396
+ apply hnorm.trans
397
+ apply div_le_div_of_nonneg_right _ ha.le
398
+ calc
399
+ _ ≤ M * (((Fintype.card X : ℝ) / Fintype.card B) * (uniform X).mean φ) + ε := by
400
+ gcongr
401
+ _ = _ := by ring
402
+
403
+ theorem siteLaw_excessMass_le_of_test_bound {Ω T X : Type*}
404
+ [Fintype Ω] [Fintype T] [Nonempty T] [Fintype X]
405
+ (p : FiniteProbabilityWeights Ω) (r : FiniteProbabilityWeights X) (F : Ω → T → X)
406
+ {C ε : ℝ}
407
+ (htest : ∀ (φ : X → ℝ), (∀ x, φ x ∈ Set.Icc (0 : ℝ) 1) →
408
+ ∀ t, p.mean (fun z => φ (F z t)) ≤ C * r.mean φ + ε) :
409
+ r.excessMass (p.siteLaw F) C ≤ ε := by
410
+ apply excessMass_le_of_mass_le
411
+ intro A
412
+ let φ : X → ℝ := fun x => if x ∈ A then 1 else 0
413
+ have hφ : ∀ x, φ x ∈ Set.Icc (0 : ℝ) 1 := by intro x; dsimp only [φ]; split_ifs <;> norm_num
414
+ have hmean : (p.siteLaw F).mean φ ≤ C * r.mean φ + ε := by
415
+ rw [siteLaw_mean]
416
+ simp_rw [← uniform_mean]
417
+ rw [mean_comm]
418
+ exact ((uniform T).mean_mono (htest φ hφ)).trans_eq ((uniform T).mean_const _)
419
+ have hfilter : Finset.univ.filter (fun x => x ∈ A) = A := by ext x; simp
420
+ simpa only [mean, φ, mul_ite, mul_one, mul_zero, ← Finset.sum_filter, hfilter,
421
+ mass] using hmean
422
+
423
+ end Erdos3.FiniteProbabilityWeights
424
+
425
+ end
426
+
427
+ section
428
+
429
+ namespace Erdos3
430
+
431
+ theorem fixedParameter_scalar_tail_mono_slack {X T : Type*} [Fintype X] [Fintype T]
432
+ (outer : FiniteProbabilityWeights X) (parameter : FiniteProbabilityWeights T)
433
+ (h g : X → T → ℝ) {level small large gap bound : ℝ}
434
+ (hg : ∀ x t, 0 ≤ g x t) (hlevel : 0 ≤ level) (hslack : small ≤ large)
435
+ (hbound : outer.eventProbability (fun x => gap < parameter.mean
436
+ (fun t => h x t - (1 + small) * level * g x t)) ≤ bound) :
437
+ outer.eventProbability (fun x => gap < parameter.mean
438
+ (fun t => h x t - (1 + large) * level * g x t)) ≤ bound := by
439
+ apply (outer.eventProbability_mono _ _ ?_).trans hbound
440
+ intro x hx
441
+ apply hx.trans_le
442
+ apply parameter.mean_mono
443
+ intro t
444
+ have hs := mul_le_mul_of_nonneg_right hslack (mul_nonneg hlevel (hg x t))
445
+ nlinarith
446
+
447
+ end Erdos3
448
+
449
+ end
450
+
451
+ section
452
+
453
+ namespace Erdos3
454
+
455
+ theorem fixedParameter_scalar_tail_dominated_slack {X T : Type*} [Fintype X] [Fintype T]
456
+ (reference outer : FiniteProbabilityWeights X) (parameter : FiniteProbabilityWeights T)
457
+ (h g : X → T → ℝ) {p level small large : ℝ} (hp : 0 ≤ p)
458
+ (hdom : ∀ x, outer.weight x ≤ Real.exp p * reference.weight x)
459
+ (hg : ∀ x t, 0 ≤ g x t) (hlevel : 0 ≤ level) (hslack : small ≤ large)
460
+ (hbound : reference.eventProbability (fun x => Real.exp (-(2 * p)) < parameter.mean
461
+ (fun t => h x t - (1 + small) * level * g x t)) ≤ Real.exp (-(2 * p))) :
462
+ outer.eventProbability (fun x => Real.exp (-p) < parameter.mean
463
+ (fun t => h x t - (1 + large) * level * g x t)) ≤ Real.exp (-p) := by
464
+ have hlarge := fixedParameter_scalar_tail_mono_slack reference parameter h g hg hlevel hslack hbound
465
+ have hgap : Real.exp (-(2 * p)) ≤ Real.exp (-p) := Real.exp_le_exp.mpr (by linarith)
466
+ have hreference : reference.eventProbability (fun x => Real.exp (-p) < parameter.mean
467
+ (fun t => h x t - (1 + large) * level * g x t)) ≤ Real.exp (-(2 * p)) :=
468
+ (reference.eventProbability_mono _ _ (fun _ hx => hgap.trans_lt hx)).trans hlarge
469
+ calc
470
+ _ ≤ Real.exp p * reference.eventProbability (fun x => Real.exp (-p) < parameter.mean
471
+ (fun t => h x t - (1 + large) * level * g x t)) :=
472
+ outer.eventProbability_le_of_weight_le reference (Real.exp p) hdom _
473
+ _ ≤ Real.exp p * Real.exp (-(2 * p)) :=
474
+ mul_le_mul_of_nonneg_left hreference (Real.exp_pos p).le
475
+ _ = Real.exp (-p) := by rw [← Real.exp_add]; congr 1; ring
476
+
477
+ end Erdos3
478
+
479
+ end
480
+
481
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarExtensionSubstitution.lean ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Polynomial.RealPolynomialEvaluationMass
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MvPolynomial
10
+ open scoped BigOperators Classical
11
+
12
+ theorem aeval_polynomial_totalDegree_le {I J R S : Type*} [CommRing R] [CommRing S]
13
+ [Algebra R S] (P : MvPolynomial I R) (f : I → MvPolynomial J S) {d e : ℕ}
14
+ (hP : P.totalDegree ≤ d) (hf : ∀ i, (f i).totalDegree ≤ e) :
15
+ (aeval f P).totalDegree ≤ d * e := by
16
+ rw [aeval_def, eval₂_eq]
17
+ apply totalDegree_finsetSum_le
18
+ intro a ha
19
+ apply (totalDegree_mul _ _).trans
20
+ simp only [MvPolynomial.algebraMap_apply, totalDegree_C, zero_add]
21
+ calc
22
+ _ ≤ ∑ i ∈ a.support, (f i ^ a i).totalDegree := totalDegree_finsetProd _ _
23
+ _ ≤ ∑ i ∈ a.support, a i * e := Finset.sum_le_sum (fun i _ =>
24
+ (totalDegree_pow _ _).trans (Nat.mul_le_mul_left _ (hf i)))
25
+ _ = (a.sum fun _ n => n) * e := by rw [← Finset.sum_mul]; rfl
26
+ _ ≤ d * e := Nat.mul_le_mul_right _ ((le_totalDegree ha).trans hP)
27
+
28
+ end Erdos3
29
+
30
+ end
31
+
32
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarInitialThreshold.lean ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.OriginalParameterReferenceBudget
2
+ import OAI.Combinatorics.Progressions.Polynomial.ScalarInitialPolynomialBudget
3
+ import OAI.Combinatorics.Progressions.Polynomial.ScalarThresholdPolynomial
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ noncomputable def scalarInitialThreshold (E m n d : ℕ) (epsilon p P0 : ℝ) : ℝ :=
12
+ let Z := replacementCommonInputLog m n d P0
13
+ let G := 2 * physicalPairCoefficientLog n d Z + 2
14
+ let U := scalarInitialReferenceInput m n d p P0
15
+ let pref := affineReferenceInput epsilon U
16
+ let common := affineCommonReferenceBudget E epsilon U
17
+ let b := adaptiveAffineCutoff ⌈(pref + 2) ^ E⌉₊ m n epsilon p
18
+ (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z
19
+ scalarCombinedLogThreshold n d b p P0 Z G ((pref + 2) ^ E)
20
+ (scalarTransferCellLog common b p Z U)
21
+ (scalarMeshLog G (P0 + 1) (scalarTransferAccuracyLog b p Z))
22
+
23
+ theorem exists_scalarInitialThreshold_power (E d A : ℕ) (hE : 2 ≤ E)
24
+ {epsilon : ℝ} (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) :
25
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ (m n : ℕ) (p : ℝ), 2 ≤ p →
26
+ (m : ℝ) ≤ (d + 1 : ℝ) * p → (n : ℝ) ≤ p →
27
+ epsilon⁻¹ ≤ Real.exp ((A : ℝ) * (p + 1)) →
28
+ scalarInitialThreshold E m n d epsilon p ((A : ℝ) * (p + 1)) ≤ (p + 2) ^ C := by
29
+ obtain ⟨C0, _, hUbound⟩ := exists_scalarInitialReferenceInput_power_bound d A
30
+ obtain ⟨C1, hC1, hthreshold⟩ := exists_scalarCombinedLogThreshold_common_power
31
+ let q := ((C0 + 4) * (affineReferencePower epsilon + 1) + 1) * E + 1
32
+ refine ⟨(q + 2) * C1, by nlinarith [Nat.zero_le q], ?_⟩
33
+ intro m n p hp hm hn heps
34
+ let P0 := (A : ℝ) * (p + 1)
35
+ let Z := replacementCommonInputLog m n d P0
36
+ let G := 2 * physicalPairCoefficientLog n d Z + 2
37
+ let U := scalarInitialReferenceInput m n d p P0
38
+ let pref := affineReferenceInput epsilon U
39
+ let common := affineCommonReferenceBudget E epsilon U
40
+ let b := adaptiveAffineCutoff ⌈(pref + 2) ^ E⌉₊ m n epsilon p
41
+ (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z
42
+ have hp0 : 0 ≤ p := by linarith
43
+ have hP0 : 0 ≤ P0 := by dsimp only [P0]; positivity
44
+ have hZ : 0 ≤ Z := (replacementCommonInputLog_bounds m n d hP0).1
45
+ obtain ⟨hU, hZU, hGU, hP0U, hmU, hnU, hdU, hTU, hpU⟩ := scalarInitialReferenceInput_bounds m n d hp0 hP0
46
+ have hGU' : G ≤ U := by linarith
47
+ have hepsU : epsilon⁻¹ ≤ Real.exp U := heps.trans (Real.exp_le_exp.mpr hP0U)
48
+ have hbase : 0 < scalarTransferBaseAccuracy (3 * p) := Real.exp_pos _
49
+ have hbaseInv : (scalarTransferBaseAccuracy (3 * p))⁻¹ ≤ Real.exp U := by
50
+ simp only [scalarTransferBaseAccuracy, Real.exp_neg, inv_inv]
51
+ apply Real.exp_le_exp.mpr
52
+ unfold scalarTransferTail at hTU
53
+ linarith
54
+ have hT : 0 ≤ scalarTransferTail (3 * p) := by unfold scalarTransferTail; positivity
55
+ have hb := (adaptiveAffineCutoff_reference_bounds hE hepsilon hepsilon1 hU hp0 hT hZ hZ
56
+ hpU hTU hZU hZU hmU hnU hepsU hbase hbaseInv).2
57
+ have hc := affineCommonReferenceBudget_bounds hE epsilon hU
58
+ have hcost : (pref + 2) ^ E ≤ common := by
59
+ have hpref : 0 ≤ pref + 2 := by linarith [(affineReferenceInput_bounds epsilon hU).1]
60
+ change (pref + 2) ^ E ≤ 2 * (pref + 2) ^ E
61
+ nlinarith [pow_nonneg hpref E]
62
+ have hthresholdCommon := hthreshold n d b p P0 Z G U common ((pref + 2) ^ E) hc.1 hZ
63
+ (hpU.trans hc.2.1) (hP0U.trans hc.2.1) (hZU.trans hc.2.1) (hGU'.trans hc.2.1) hc.2.1
64
+ (hnU.trans hc.2.1) (hdU.trans hc.2.1) hcost hb
65
+ have hUoriginal : U ≤ (p + 2) ^ C0 := hUbound m n p hp0 hm hn
66
+ have hcommonOriginal : common ≤ (p + 2) ^ q :=
67
+ affineCommonReferenceBudget_le_original_power E epsilon hp hU hUoriginal
68
+ exact polynomial_budget_comp hp0 hc.1 q C1 hcommonOriginal hthresholdCommon
69
+
70
+ end Erdos3
71
+
72
+ end
73
+
74
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarInputLogFactor.lean ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.InitialBudgetJointReplacement
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem exists_scalarInputLogFactor (ell : ℕ) (epsilon : ℝ) :
10
+ ∃ A0 : ℕ, 10 ≤ A0 ∧ epsilon⁻¹ ≤ Real.exp (A0 : ℝ) ∧
11
+ (ell : ℝ) ≤ Real.exp (A0 : ℝ) ∧
12
+ (probabilityProfileLipschitz : ℝ) ≤ Real.exp (A0 : ℝ) := by
13
+ let B : ℝ := max 10 (max epsilon⁻¹ (max (ell : ℝ) (probabilityProfileLipschitz : ℝ)))
14
+ obtain ⟨A0, hA0⟩ := exists_nat_ge B
15
+ have h10 : (10 : ℝ) ≤ A0 := (le_max_left _ _).trans hA0
16
+ have hexp : (A0 : ℝ) ≤ Real.exp (A0 : ℝ) := by linarith [Real.add_one_le_exp (A0 : ℝ)]
17
+ refine ⟨A0, by exact_mod_cast h10, ?_, ?_, ?_⟩
18
+ · exact ((le_max_left _ _).trans ((le_max_right _ _).trans hA0)).trans hexp
19
+ · exact ((le_max_left _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans hA0))).trans hexp
20
+ · exact ((le_max_right _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans hA0))).trans hexp
21
+
22
+ end Erdos3
23
+
24
+ end
25
+
26
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScalarWindowPartitions.lean ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.Order.Floor.Ring
2
+ import OAI.Combinatorics.Progressions.Geometry.PhysicalBoxPartition
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ noncomputable def scalarWindowLength (N : ℕ) (S : ℝ) : ℕ :=
11
+ min N ⌊S / 4⌋₊
12
+
13
+ theorem scalarWindowLength_bounds {N : ℕ} {S K : ℝ}
14
+ (hN : 0 < N) (hS : 4 ≤ S) (hK : 0 ≤ K) (hratio : S ≤ K * N) :
15
+ 0 < scalarWindowLength N S ∧ scalarWindowLength N S ≤ N ∧
16
+ 2 * (scalarWindowLength N S : ℝ) ≤ S / 2 ∧
17
+ S ≤ (K + 8) * scalarWindowLength N S := by
18
+ have hfloor : 1 ≤ ⌊S / 4⌋₊ := (Nat.le_floor_iff (by positivity : 0 ≤ S / 4)).mpr (by norm_num; linarith)
19
+ have hfloorle : (⌊S / 4⌋₊ : ℝ) ≤ S / 4 := Nat.floor_le (by positivity)
20
+ have hgap : S / 4 < (⌊S / 4⌋₊ : ℝ) + 1 := Nat.lt_floor_add_one (S / 4)
21
+ have hpositive : 0 < scalarWindowLength N S := lt_min hN (by omega)
22
+ have hsmall : scalarWindowLength N S ≤ ⌊S / 4⌋₊ := min_le_right _ _
23
+ have hsmallreal : (scalarWindowLength N S : ℝ) ≤ (⌊S / 4⌋₊ : ℝ) := by exact_mod_cast hsmall
24
+ refine ⟨hpositive, min_le_left _ _, by linarith, ?_⟩
25
+ by_cases hNF : N ≤ ⌊S / 4⌋₊
26
+ · rw [scalarWindowLength, min_eq_left hNF]
27
+ nlinarith [Nat.cast_nonneg (α := ℝ) N]
28
+ · rw [scalarWindowLength, min_eq_right (le_of_not_ge hNF)]
29
+ have hfloorreal : (1 : ℝ) ≤ ⌊S / 4⌋₊ := by exact_mod_cast hfloor
30
+ nlinarith [mul_nonneg hK (Nat.cast_nonneg (α := ℝ) ⌊S / 4⌋₊)]
31
+
32
+ theorem exists_scalarWindowPartitions {I : Type*} (N : I → ℕ) (S : I → ℝ) (K : ℝ)
33
+ (hN : ∀ i, 0 < N i) (hS : ∀ i, 4 ≤ S i) (hK : 0 ≤ K)
34
+ (hratio : ∀ i, S i ≤ K * N i) :
35
+ ∃ P : ∀ i, FiniteProgressionPartition (N i),
36
+ (∀ i c, (P i).step c = 1) ∧ (∀ i c, 0 < (P i).length c) ∧
37
+ (∀ i c, ((P i).length c : ℝ) ≤ S i / 2) ∧
38
+ (∀ i c, S i ≤ (K + 8) * (P i).length c) := by
39
+ let H := fun i => scalarWindowLength (N i) (S i)
40
+ have hbounds i := scalarWindowLength_bounds (hN i) (hS i) hK (hratio i)
41
+ let P := comparableBoxPartitions N H (fun i => (hbounds i).1) (fun i => (hbounds i).2.1)
42
+ have hlength i c := comparableBoxPartitions_length N H (fun i => (hbounds i).1)
43
+ (fun i => (hbounds i).2.1) i c
44
+ refine ⟨P, comparableBoxPartitions_step _ _ _ _, ?_, ?_, ?_⟩
45
+ · intro i c
46
+ exact (hbounds i).1.trans_le (hlength i c).1
47
+ · intro i c
48
+ have hlen : ((P i).length c : ℝ) < 2 * H i := by exact_mod_cast (hlength i c).2
49
+ exact hlen.le.trans (hbounds i).2.2.1
50
+ · intro i c
51
+ exact (hbounds i).2.2.2.trans (mul_le_mul_of_nonneg_left
52
+ (by exact_mod_cast (hlength i c).1) (by linarith))
53
+
54
+ end Erdos3
55
+
56
+ end
57
+
58
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScaledConditionedComparison.lean ADDED
@@ -0,0 +1,605 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.DependentShellBudget
2
+ import OAI.Combinatorics.Progressions.Estimates.ObservedUnitTruncation
3
+ import OAI.Combinatorics.Progressions.Linear.KernelCoreComparison
4
+ import OAI.Combinatorics.Progressions.Linear.ProductEmbeddingANOVA
5
+
6
+ namespace OAI
7
+
8
+ section
9
+
10
+ namespace Erdos3
11
+
12
+ open scoped BigOperators
13
+
14
+ variable {ι : Type*} [Fintype ι] [DecidableEq ι]
15
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
16
+
17
+ theorem productANOVA_sum (μ : ∀ i, FiniteProbabilityWeights (X i))
18
+ {α : Type*} (s : Finset α) (f : α → (∀ i, X i) → ℝ) (S : Finset ι) (x : ∀ i, X i) :
19
+ productANOVA μ S (fun y => ∑ a ∈ s, f a y) x = ∑ a ∈ s, productANOVA μ S (f a) x := by
20
+ simp only [productANOVA, productConditionalMean, FiniteProbabilityWeights.mean_sum, Finset.mul_sum]
21
+ rw [Finset.sum_comm]
22
+
23
+ theorem productANOVATruncation_sum (μ : ∀ i, FiniteProbabilityWeights (X i))
24
+ {α : Type*} (s : Finset α) (f : α → (∀ i, X i) → ℝ) (D : Finset (Finset ι)) (x : ∀ i, X i) :
25
+ productANOVATruncation μ D (fun y => ∑ a ∈ s, f a y) x =
26
+ ∑ a ∈ s, productANOVATruncation μ D (f a) x := by
27
+ simp only [productANOVATruncation, productANOVA_sum]
28
+ rw [Finset.sum_comm]
29
+
30
+ theorem productANOVATruncation_smul (μ : ∀ i, FiniteProbabilityWeights (X i))
31
+ (D : Finset (Finset ι)) (a : ℝ) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) :
32
+ productANOVATruncation μ D (fun y => a * f y) x = a * productANOVATruncation μ D f x := by
33
+ simp only [productANOVATruncation, productANOVA_smul, Finset.mul_sum]
34
+
35
+ variable {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
36
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
37
+
38
+ theorem productCouplingPairing_smul (a b : ℝ) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
39
+ productCouplingPairing c (fun x => a * w x) (fun y => b * f y) = a * b * productCouplingPairing c w f := by
40
+ unfold productCouplingPairing
41
+ rw [← FiniteProbabilityWeights.mean_const_mul]
42
+ congr 1
43
+ funext z
44
+ ring
45
+
46
+ theorem productCouplingPairing_truncation_smul (D : Finset (Finset ι)) (a b : ℝ)
47
+ (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
48
+ productCouplingPairing c (productANOVATruncation μ D (fun x => a * w x))
49
+ (productANOVATruncation ν D (fun y => b * f y)) =
50
+ a * b * productCouplingPairing c (productANOVATruncation μ D w) (productANOVATruncation ν D f) := by
51
+ simp only [show productANOVATruncation μ D (fun x => a * w x) =
52
+ (fun x => a * productANOVATruncation μ D w x) from funext (productANOVATruncation_smul μ D a w),
53
+ show productANOVATruncation ν D (fun y => b * f y) =
54
+ (fun y => b * productANOVATruncation ν D f y) from funext (productANOVATruncation_smul ν D b f),
55
+ productCouplingPairing_smul]
56
+
57
+ end Erdos3
58
+
59
+ end
60
+
61
+ section
62
+
63
+ namespace Erdos3
64
+
65
+ theorem normalized_pairing_error_scale {P u v q m s E : ℝ} (hm : 0 < m) (hs : 0 < s)
66
+ (h : |m⁻¹ * s⁻¹ * P - q * ((m⁻¹ * u) * (s⁻¹ * v))| ≤ E) :
67
+ |P - q * (u * v)| ≤ m * s * E := by
68
+ calc
69
+ _ = |(m * s) * (m⁻¹ * s⁻¹ * P - q * ((m⁻¹ * u) * (s⁻¹ * v)))| := by
70
+ congr 1
71
+ field_simp
72
+ _ = m * s * |m⁻¹ * s⁻¹ * P - q * ((m⁻¹ * u) * (s⁻¹ * v))| := by
73
+ rw [abs_mul, abs_of_nonneg (mul_nonneg hm.le hs.le)]
74
+ _ ≤ _ := mul_le_mul_of_nonneg_left h (mul_nonneg hm.le hs.le)
75
+
76
+ variable {ι : Type*} [Fintype ι] [DecidableEq ι]
77
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
78
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
79
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
80
+
81
+ noncomputable def productAtomTruncatedPairing (D : Finset (Finset ι)) (I : Finset ι)
82
+ (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : ℝ :=
83
+ productCouplingPairing c (productANOVATruncation μ D (fun z => productFiberIndicator I x z * w z))
84
+ (productANOVATruncation ν D (fun z => productFiberIndicator I y z * f z))
85
+
86
+ theorem productAtomTruncatedPairing_smul (D : Finset (Finset ι)) (I : Finset ι)
87
+ (x : ∀ i, X i) (y : ∀ i, Y i) (a b : ℝ) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
88
+ productAtomTruncatedPairing c D I x y (fun z => a * w z) (fun z => b * f z) =
89
+ a * b * productAtomTruncatedPairing c D I x y w f := by
90
+ have hw : (fun z => productFiberIndicator I x z * (a * w z)) =
91
+ (fun z => a * (productFiberIndicator I x z * w z)) := by funext z; ring
92
+ have hf : (fun z => productFiberIndicator I y z * (b * f z)) =
93
+ (fun z => b * (productFiberIndicator I y z * f z)) := by funext z; ring
94
+ unfold productAtomTruncatedPairing
95
+ rw [hw, hf, productCouplingPairing_truncation_smul]
96
+
97
+ end Erdos3
98
+
99
+ end
100
+
101
+ section
102
+
103
+ namespace Erdos3
104
+
105
+ open scoped BigOperators
106
+
107
+ variable {ι : Type*} [Fintype ι] [DecidableEq ι]
108
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
109
+
110
+ theorem productANOVA_add (μ : ∀ i, FiniteProbabilityWeights (X i)) (S : Finset ι)
111
+ (f g : (∀ i, X i) → ℝ) (x : ∀ i, X i) :
112
+ productANOVA μ S (fun y => f y + g y) x = productANOVA μ S f x + productANOVA μ S g x := by
113
+ simp only [productANOVA, productConditionalMean, FiniteProbabilityWeights.mean_add,
114
+ mul_add, Finset.sum_add_distrib]
115
+
116
+ theorem productANOVATruncation_add (μ : ∀ i, FiniteProbabilityWeights (X i)) (D : Finset (Finset ι))
117
+ (f g : (∀ i, X i) → ℝ) (x : ∀ i, X i) :
118
+ productANOVATruncation μ D (fun y => f y + g y) x =
119
+ productANOVATruncation μ D f x + productANOVATruncation μ D g x := by
120
+ simp only [productANOVATruncation, productANOVA_add, Finset.sum_add_distrib]
121
+
122
+ variable {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
123
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
124
+
125
+ noncomputable def productTruncatedPairing (D : Finset (Finset ι))
126
+ (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : ℝ :=
127
+ productCouplingPairing c (productANOVATruncation μ D w) (productANOVATruncation ν D f)
128
+
129
+ theorem productTruncatedPairing_add_left (D : Finset (Finset ι))
130
+ (u w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
131
+ productTruncatedPairing c D (fun x => u x + w x) f =
132
+ productTruncatedPairing c D u f + productTruncatedPairing c D w f := by
133
+ simp only [productTruncatedPairing, productCouplingPairing, productANOVATruncation_add,
134
+ add_mul, FiniteProbabilityWeights.mean_add]
135
+
136
+ theorem productTruncatedPairing_add_right (D : Finset (Finset ι))
137
+ (w : (∀ i, X i) → ℝ) (f g : (∀ i, Y i) → ℝ) :
138
+ productTruncatedPairing c D w (fun x => f x + g x) =
139
+ productTruncatedPairing c D w f + productTruncatedPairing c D w g := by
140
+ simp only [productTruncatedPairing, productCouplingPairing, productANOVATruncation_add,
141
+ mul_add, FiniteProbabilityWeights.mean_add]
142
+
143
+ theorem productTruncatedPairing_smul (D : Finset (Finset ι)) (a b : ℝ)
144
+ (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
145
+ productTruncatedPairing c D (fun x => a * w x) (fun y => b * f y) =
146
+ a * b * productTruncatedPairing c D w f := productCouplingPairing_truncation_smul c D a b w f
147
+
148
+ theorem productTruncatedPairing_sub_smul_right (D : Finset (Finset ι)) (a : ℝ)
149
+ (w : (∀ i, X i) → ℝ) (f g : (∀ i, Y i) → ℝ) :
150
+ productTruncatedPairing c D w (fun y => f y - a * g y) =
151
+ productTruncatedPairing c D w f - a * productTruncatedPairing c D w g := by
152
+ have he : (fun y => f y - a * g y) = (fun y => f y + (-a) * g y) := by funext y; ring
153
+ have hs := productTruncatedPairing_smul c D 1 (-a) w g
154
+ simp only [one_mul] at hs
155
+ rw [he, productTruncatedPairing_add_right, hs]
156
+ ring
157
+
158
+ theorem productTruncatedPairing_sum_right {α : Type*} (s : Finset α) (D : Finset (Finset ι))
159
+ (w : (∀ i, X i) → ℝ) (f : α → (∀ i, Y i) → ℝ) :
160
+ productTruncatedPairing c D w (fun y => ∑ a ∈ s, f a y) =
161
+ ∑ a ∈ s, productTruncatedPairing c D w (f a) := by
162
+ simp only [productTruncatedPairing, productCouplingPairing, productANOVATruncation_sum,
163
+ Finset.mul_sum, FiniteProbabilityWeights.mean_sum]
164
+
165
+ theorem productAtomTruncatedPairing_sub_smul_right (D : Finset (Finset ι)) (I : Finset ι)
166
+ (x : ∀ i, X i) (y : ∀ i, Y i) (a : ℝ) (w : (∀ i, X i) → ℝ) (f g : (∀ i, Y i) → ℝ) :
167
+ productAtomTruncatedPairing c D I x y w (fun z => f z - a * g z) =
168
+ productAtomTruncatedPairing c D I x y w f - a * productAtomTruncatedPairing c D I x y w g := by
169
+ have he : (fun z => productFiberIndicator I y z * (f z - a * g z)) =
170
+ (fun z => productFiberIndicator I y z * f z - a * (productFiberIndicator I y z * g z)) := by
171
+ funext z
172
+ ring
173
+ change productTruncatedPairing c D (fun z => productFiberIndicator I x z * w z) _ = _
174
+ rw [he, productTruncatedPairing_sub_smul_right]
175
+ rfl
176
+
177
+ end Erdos3
178
+
179
+ end
180
+
181
+ section
182
+
183
+ namespace Erdos3
184
+
185
+ open scoped BigOperators Classical
186
+
187
+ variable {ι : Type*} [Fintype ι] [DecidableEq ι]
188
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
189
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
190
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
191
+
192
+ theorem productTruncatedPairing_atom_sum_right (D : Finset (Finset ι)) (I : Finset ι)
193
+ (x : ∀ i, X i) (baseY : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) :
194
+ (∑ a : ∀ i : I, Y i, productAtomTruncatedPairing c D I x (productSubtypePoint I a baseY) w f) =
195
+ productTruncatedPairing c D (fun z => productFiberIndicator I x z * w z) f := by
196
+ change (∑ a : ∀ i : I, Y i, productTruncatedPairing c D
197
+ (fun z => productFiberIndicator I x z * w z)
198
+ (fun z => productFiberIndicator I (productSubtypePoint I a baseY) z * f z)) = _
199
+ rw [← productTruncatedPairing_sum_right]
200
+ congr 1
201
+ funext z
202
+ exact productFiberIndicator_partition I baseY f z
203
+
204
+ variable {Ω : Type*} [Fintype Ω] [∀ i, DecidableEq (X i)]
205
+
206
+ omit c in
207
+ theorem ProductCylinder.indicator_density_cut (d : ProductCylinder X)
208
+ (μ : ∀ i, FiniteProbabilityWeights (X i)) (base : ∀ i, X i)
209
+ (p : FiniteProbabilityWeights Ω) (F : Ω → ∀ i, X i) (w : Ω → ℝ) :
210
+ (fun z => productFiberIndicator d.1 (d.assignment base) z * observedProductDensity μ p F (d.cut F w) z) =
211
+ observedProductDensity μ p F (d.cut F w) := by
212
+ funext z
213
+ by_cases hz : d.Contains z
214
+ · have hi := (d.contains_iff base z).mp hz
215
+ have he : productFiberIndicator d.1 (d.assignment base) z = 1 := by
216
+ unfold productFiberIndicator
217
+ exact ite_eq_left hi
218
+ rw [he, one_mul]
219
+ · simp only [d.density_cut, ite_eq_right hz, mul_zero]
220
+
221
+ theorem ProductCylinder.truncated_pairing_atoms (d : ProductCylinder X)
222
+ (D : Finset (Finset ι)) (base : ∀ i, X i) (baseY : ∀ i, Y i)
223
+ (p : FiniteProbabilityWeights Ω) (F : Ω → ∀ i, X i) (w : Ω → ℝ) (f : (∀ i, Y i) → ℝ) :
224
+ productTruncatedPairing c D (observedProductDensity μ p F (d.cut F w)) f =
225
+ ∑ a : ∀ i : d.1, Y i, productAtomTruncatedPairing c D d.1 (d.assignment base)
226
+ (productSubtypePoint d.1 a baseY) (observedProductDensity μ p F (d.cut F w)) f := by
227
+ rw [productTruncatedPairing_atom_sum_right, d.indicator_density_cut μ base p F w]
228
+
229
+ end Erdos3
230
+
231
+ end
232
+
233
+ section
234
+
235
+ namespace Erdos3
236
+
237
+ variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] [DecidableEq ι]
238
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
239
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
240
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
241
+
242
+ theorem observedProductDensity_residual_difference
243
+ (p : FiniteProbabilityWeights Ω) (F : Ω → ∀ i, X i)
244
+ (hμ : ∀ i x, 0 < (μ i).weight x) (base : ∀ i, X i) (v : Ω → ℝ)
245
+ {η τ H G a : ℝ} (ha : 0 ≤ a) (hv : ∀ z, 0 ≤ v z ∧ v z ≤ 1) (hη : 0 ≤ η)
246
+ (hmass : p.mean v ≤ τ) (D : Finset (Finset ι)) {b : ℕ} (hcard : ∀ S ∈ D, S.card ≤ b)
247
+ (hclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η (2 * b))
248
+ (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ)
249
+ (h g : (∀ i, Y i) → ℝ)
250
+ (hh : Real.sqrt (productANOVAEnergy ν D h) ≤ H)
251
+ (hg : Real.sqrt (productANOVAEnergy ν D g) ≤ G) :
252
+ |productTruncatedPairing c D (observedProductDensity μ p F v) (fun y => h y - a * g y)| ≤
253
+ Real.sqrt (3 * τ) * (H + a * G) := by
254
+ have hH := observedProductDensity_small_mass_pairing c p F hμ base v hv hη hmass D hcard hclose herr h hh
255
+ have hG := observedProductDensity_small_mass_pairing c p F hμ base v hv hη hmass D hcard hclose herr g hg
256
+ rw [productTruncatedPairing_sub_smul_right, sub_eq_add_neg]
257
+ calc
258
+ _ ≤ |productTruncatedPairing c D (observedProductDensity μ p F v) h| +
259
+ |-(a * productTruncatedPairing c D (observedProductDensity μ p F v) g)| := abs_add_le _ _
260
+ _ = |productTruncatedPairing c D (observedProductDensity μ p F v) h| +
261
+ a * |productTruncatedPairing c D (observedProductDensity μ p F v) g| := by
262
+ rw [abs_neg, abs_mul, abs_of_nonneg ha]
263
+ _ ≤ Real.sqrt (3 * τ) * H + a * (Real.sqrt (3 * τ) * G) :=
264
+ add_le_add hH (mul_le_mul_of_nonneg_left hG ha)
265
+ _ = _ := by ring
266
+
267
+ end Erdos3
268
+
269
+ end
270
+
271
+ section
272
+
273
+ namespace Erdos3
274
+
275
+ open scoped BigOperators Classical
276
+
277
+ variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] [DecidableEq ι]
278
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] [∀ i, DecidableEq (X i)]
279
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
280
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
281
+
282
+ theorem CylinderRemovalChain.retained_pairing_sum_le
283
+ {base : ∀ i, X i} {p : FiniteProbabilityWeights Ω} {F : Ω → ∀ i, X i}
284
+ {K τ : ℝ} {j r : ℕ} {w v : Ω → ℝ} {cs : List (ProductCylinder X)}
285
+ (hchain : CylinderRemovalChain μ base p F K τ j r w v cs)
286
+ (hμ : ∀ i x, 0 < (μ i).weight x) (D : Finset (Finset ι)) (baseY : ∀ i, Y i)
287
+ (hw : ∀ z, w z ≤ 1) (hv : ∀ z, 0 ≤ v z) {C : ℝ} (hC : 0 ≤ C)
288
+ (E : (d : ProductCylinder X) → (Ω → ℝ) → (∀ i : d.1, Y i) → ℝ)
289
+ (f : (∀ i, Y i) → ℝ)
290
+ (hret : ∀ cf ∈ cs.zip (removedCylinderWeights F w cs), ∀ a : ∀ i : cf.1.1, Y i,
291
+ productAtomTruncatedPairing c D cf.1.1 (cf.1.assignment base)
292
+ (productSubtypePoint cf.1.1 a baseY) (observedProductDensity μ p F cf.2) f ≤
293
+ C * (productCouplingAtomMass c cf.1.1 (cf.1.assignment base) (productSubtypePoint cf.1.1 a baseY) *
294
+ cf.1.mass μ base (observedProductDensity μ p F cf.2)) + E cf.1 cf.2 a) :
295
+ ((cs.zip (removedCylinderWeights F w cs)).map
296
+ (fun cf => ∑ a : ∀ i : cf.1.1, Y i, productAtomTruncatedPairing c D cf.1.1 (cf.1.assignment base)
297
+ (productSubtypePoint cf.1.1 a baseY) (observedProductDensity μ p F cf.2) f)).sum ≤
298
+ C + ((cs.zip (removedCylinderWeights F w cs)).map
299
+ (fun cf => ∑ a : ∀ i : cf.1.1, Y i, E cf.1 cf.2 a)).sum := by
300
+ apply list_weighted_error_sum_le _ _
301
+ (fun cf => ∑ a : ∀ i : cf.1.1, Y i,
302
+ productCouplingAtomMass c cf.1.1 (cf.1.assignment base) (productSubtypePoint cf.1.1 a baseY) *
303
+ cf.1.mass μ base (observedProductDensity μ p F cf.2)) _ hC
304
+ · exact CylinderRemovalChain.joint_mass_sum_le_one c hchain hμ baseY hw hv
305
+ · intro cf hcf
306
+ have hs := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset (∀ i : cf.1.1, Y i))) => hret cf hcf a)
307
+ simpa only [Finset.sum_add_distrib, ← Finset.mul_sum] using hs
308
+
309
+ end Erdos3
310
+
311
+ end
312
+
313
+ section
314
+
315
+ namespace Erdos3
316
+
317
+ open scoped BigOperators
318
+
319
+ variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
320
+ {X Y : I → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
321
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
322
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i)) (e : J ↪ I)
323
+ (baseX : ∀ i, X i) (baseY : ∀ i, Y i)
324
+
325
+ include baseX baseY
326
+
327
+ theorem productCouplingPairing_embedding (f : (∀ j, X (e j)) → ℝ) (g : (∀ j, Y (e j)) → ℝ) :
328
+ productCouplingPairing c (fun x => f (fun j => x (e j))) (fun y => g (fun j => y (e j))) =
329
+ productCouplingPairing (fun j => c (e j)) f g := by
330
+ exact productMean_pullback (fun i => (c i).law) e e.injective (fun i => (baseX i, baseY i))
331
+ (fun z => f (fun j => (z j).1) * g (fun j => (z j).2))
332
+
333
+ theorem productTruncatedPairing_embedding (D : Finset (Finset J))
334
+ (f : (∀ j, X (e j)) → ℝ) (g : (∀ j, Y (e j)) → ℝ) :
335
+ productTruncatedPairing c (D.map (Finset.mapEmbedding e).toEmbedding)
336
+ (fun x => f (fun j => x (e j))) (fun y => g (fun j => y (e j))) =
337
+ productTruncatedPairing (fun j => c (e j)) D f g := by
338
+ have hleft : productANOVATruncation μ (D.map (Finset.mapEmbedding e).toEmbedding)
339
+ (fun x => f (fun j => x (e j))) =
340
+ (fun x => productANOVATruncation (fun j => μ (e j)) D f (fun j => x (e j))) :=
341
+ funext (productANOVATruncation_embedding μ e baseX D f)
342
+ have hright : productANOVATruncation ν (D.map (Finset.mapEmbedding e).toEmbedding)
343
+ (fun y => g (fun j => y (e j))) =
344
+ (fun y => productANOVATruncation (fun j => ν (e j)) D g (fun j => y (e j))) :=
345
+ funext (productANOVATruncation_embedding ν e baseY D g)
346
+ unfold productTruncatedPairing
347
+ rw [hleft, hright]
348
+ exact productCouplingPairing_embedding c e baseX baseY _ _
349
+
350
+ end Erdos3
351
+
352
+ end
353
+
354
+ section
355
+
356
+ namespace Erdos3
357
+
358
+ open scoped BigOperators Classical
359
+
360
+ variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] [DecidableEq ι]
361
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] [∀ i, DecidableEq (X i)]
362
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
363
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
364
+
365
+ theorem CylinderRemovalChain.truncated_pairing_decomposition
366
+ {base : ∀ i, X i} {p : FiniteProbabilityWeights Ω} {F : Ω → ∀ i, X i}
367
+ {K τ : ℝ} {j r : ℕ} {w v : Ω → ℝ} {cs : List (ProductCylinder X)}
368
+ (hchain : CylinderRemovalChain μ base p F K τ j r w v cs)
369
+ (D : Finset (Finset ι)) (baseY : ∀ i, Y i) (f : (∀ i, Y i) → ℝ) :
370
+ productTruncatedPairing c D (observedProductDensity μ p F w) f =
371
+ ((cs.zip (removedCylinderWeights F w cs)).map
372
+ (fun cf => ∑ a : ∀ i : cf.1.1, Y i,
373
+ productAtomTruncatedPairing c D cf.1.1 (cf.1.assignment base)
374
+ (productSubtypePoint cf.1.1 a baseY) (observedProductDensity μ p F cf.2) f)).sum +
375
+ productTruncatedPairing c D (observedProductDensity μ p F v) f := by
376
+ induction hchain with
377
+ | nil => simp only [removedCylinderWeights, List.zip_nil_left, List.map_nil, List.sum_nil, zero_add]
378
+ | @cons w v cs d hsize hmass hbounded rest ih =>
379
+ have he : observedProductDensity μ p F w =
380
+ (fun z => observedProductDensity μ p F (d.cut F w) z + observedProductDensity μ p F (d.erase F w) z) := by
381
+ funext z
382
+ have h := observedProductDensity_add μ p F (d.cut F w) (d.erase F w) z
383
+ rw [show (fun z => d.cut F w z + d.erase F w z) = w from funext (d.cut_add_erase F w)] at h
384
+ exact h
385
+ rw [he, productTruncatedPairing_add_left, d.truncated_pairing_atoms c D base baseY p F w f, ih]
386
+ simp only [removedCylinderWeights, List.zip_cons_cons, List.map_cons, List.sum_cons, add_assoc]
387
+
388
+ end Erdos3
389
+
390
+ end
391
+
392
+ section
393
+
394
+ namespace Erdos3
395
+
396
+ open scoped BigOperators Classical
397
+
398
+ variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] [DecidableEq ι]
399
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] [∀ i, DecidableEq (X i)]
400
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
401
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
402
+
403
+ theorem CylinderRemovalChain.total_pairing_le
404
+ {base : ∀ i, X i} {p : FiniteProbabilityWeights Ω} {F : Ω → ∀ i, X i}
405
+ {K τ : ℝ} {j r : ℕ} {w v : Ω → ℝ} {cs : List (ProductCylinder X)}
406
+ (hchain : CylinderRemovalChain μ base p F K τ j r w v cs)
407
+ (hμ : ∀ i x, 0 < (μ i).weight x) (D : Finset (Finset ι)) (baseY : ∀ i, Y i)
408
+ (hw : ∀ z, w z ≤ 1) (hv : ∀ z, 0 ≤ v z ∧ v z ≤ 1) (hmass : p.mean v ≤ τ)
409
+ {η C H G a : ℝ} (hη : 0 ≤ η) (hC : 0 ≤ C) (ha : 0 ≤ a)
410
+ {b : ℕ} (hcard : ∀ S ∈ D, S.card ≤ b)
411
+ (hclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η (2 * b))
412
+ (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ)
413
+ (h g : (∀ i, Y i) → ℝ)
414
+ (hh : Real.sqrt (productANOVAEnergy ν D h) ≤ H)
415
+ (hg : Real.sqrt (productANOVAEnergy ν D g) ≤ G)
416
+ (E : (d : ProductCylinder X) → (Ω → ℝ) → (∀ i : d.1, Y i) → ℝ)
417
+ (hret : ∀ cf ∈ cs.zip (removedCylinderWeights F w cs), ∀ z : ∀ i : cf.1.1, Y i,
418
+ productAtomTruncatedPairing c D cf.1.1 (cf.1.assignment base)
419
+ (productSubtypePoint cf.1.1 z baseY) (observedProductDensity μ p F cf.2) (fun y => h y - a * g y) ≤
420
+ C * (productCouplingAtomMass c cf.1.1 (cf.1.assignment base) (productSubtypePoint cf.1.1 z baseY) *
421
+ cf.1.mass μ base (observedProductDensity μ p F cf.2)) + E cf.1 cf.2 z) :
422
+ productTruncatedPairing c D (observedProductDensity μ p F w) (fun y => h y - a * g y) ≤
423
+ C + ((cs.zip (removedCylinderWeights F w cs)).map
424
+ (fun cf => ∑ z : ∀ i : cf.1.1, Y i, E cf.1 cf.2 z)).sum +
425
+ Real.sqrt (3 * τ) * (H + a * G) := by
426
+ have hretained := CylinderRemovalChain.retained_pairing_sum_le c hchain hμ D baseY hw
427
+ (fun z => (hv z).1) hC E (fun y => h y - a * g y) hret
428
+ have hresidual := observedProductDensity_residual_difference c p F hμ base v ha hv hη hmass
429
+ D hcard hclose herr h g hh hg
430
+ rw [CylinderRemovalChain.truncated_pairing_decomposition c hchain D baseY]
431
+ exact add_le_add hretained ((le_abs_self _).trans hresidual)
432
+
433
+ end Erdos3
434
+
435
+ end
436
+
437
+ section
438
+
439
+ namespace Erdos3
440
+
441
+ open scoped BigOperators Classical
442
+
443
+ variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] [DecidableEq ι]
444
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] [∀ i, DecidableEq (X i)]
445
+ {μ : ∀ i, FiniteProbabilityWeights (X i)} {ν : ∀ i, FiniteProbabilityWeights (Y i)}
446
+ (c : ∀ i, FiniteProbabilityCoupling (μ i) (ν i))
447
+
448
+ theorem CylinderRemovalChain.total_pairing_with_shell_budget
449
+ {base : ∀ i, X i} {p : FiniteProbabilityWeights Ω} {F : Ω → ∀ i, X i}
450
+ {K τ : ℝ} {j r : ℕ} {w v : Ω → ℝ} {cs : List (ProductCylinder X)}
451
+ (hchain : CylinderRemovalChain μ base p F K τ j r w v cs)
452
+ (hμ : ∀ i x, 0 < (μ i).weight x) (D : Finset (Finset ι)) (baseY : ∀ i, Y i)
453
+ (hw : ∀ z, w z ≤ 1) (hv : ∀ z, 0 ≤ v z ∧ v z ≤ 1) (hmass : p.mean v ≤ τ)
454
+ {η C H G a κ ε P : ℝ} (hη : 0 ≤ η) (hC : 0 ≤ C) (ha : 0 ≤ a)
455
+ (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hε : 0 < ε)
456
+ {b : ℕ} (hcard : ∀ S ∈ D, S.card ≤ b)
457
+ (hclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η (2 * b))
458
+ (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ)
459
+ (h g : (∀ i, Y i) → ℝ)
460
+ (hh : Real.sqrt (productANOVAEnergy ν D h) ≤ H)
461
+ (hg : Real.sqrt (productANOVAEnergy ν D g) ≤ G)
462
+ (B : (d : ProductCylinder X) → (Ω → ℝ) → (∀ i : d.1, Y i) → ℝ)
463
+ (hB : ∀ cf ∈ cs.zip (removedCylinderWeights F w cs), ∀ z, 0 ≤ B cf.1 cf.2 z)
464
+ (hbudget : ((cs.zip (removedCylinderWeights F w cs)).map
465
+ (fun cf => ∑ z : ∀ i : cf.1.1, Y i, B cf.1 cf.2 z)).sum ≤ Real.exp P)
466
+ (hb : j + CyclicCrootSisask.spectralIterations ε P ≤ b)
467
+ (hret : ∀ cf ∈ cs.zip (removedCylinderWeights F w cs), ∀ z : ∀ i : cf.1.1, Y i,
468
+ productAtomTruncatedPairing c D cf.1.1 (cf.1.assignment base)
469
+ (productSubtypePoint cf.1.1 z baseY) (observedProductDensity μ p F cf.2) (fun y => h y - a * g y) ≤
470
+ C * (productCouplingAtomMass c cf.1.1 (cf.1.assignment base) (productSubtypePoint cf.1.1 z baseY) *
471
+ cf.1.mass μ base (observedProductDensity μ p F cf.2)) +
472
+ κ ^ (b - cf.1.1.card) * B cf.1 cf.2 z) :
473
+ productTruncatedPairing c D (observedProductDensity μ p F w) (fun y => h y - a * g y) ≤
474
+ C + ε / 16 + Real.sqrt (3 * τ) * (H + a * G) := by
475
+ let E := fun (d : ProductCylinder X) (f : Ω → ℝ) (z : ∀ i : d.1, Y i) =>
476
+ κ ^ (b - d.1.card) * B d f z
477
+ have ht := CylinderRemovalChain.total_pairing_le c hchain hμ D baseY hw hv hmass
478
+ hη hC ha hcard hclose herr h g hh hg E hret
479
+ have hs := list_dependent_shell_sum_after_cutoff (cs.zip (removedCylinderWeights F w cs))
480
+ (fun cf => ∀ i : cf.1.1, Y i) (fun cf => cf.1.1.card)
481
+ (fun cf z => E cf.1 cf.2 z) (fun cf z => B cf.1 cf.2 z)
482
+ hε hκ0 hκhalf (fun cf hcf => (hchain.removed_size_mass cf hcf).1)
483
+ hB (fun _ _ _ => le_rfl) hbudget hb
484
+ linarith
485
+
486
+ end Erdos3
487
+
488
+ end
489
+
490
+ section
491
+
492
+ namespace Erdos3
493
+
494
+ open scoped BigOperators
495
+
496
+ theorem weighted_pairing_error_compose {P Q R m E F : ℝ} (hm : 0 ≤ m)
497
+ (hP : |P - m * Q| ≤ E) (hQ : |Q - R| ≤ F) : |P - m * R| ≤ E + m * F := by
498
+ calc
499
+ _ = |(P - m * Q) + m * (Q - R)| := by congr 1; ring
500
+ _ ≤ |P - m * Q| + |m * (Q - R)| := abs_add_le _ _
501
+ _ = |P - m * Q| + m * |Q - R| := by rw [abs_mul, abs_of_nonneg hm]
502
+ _ ≤ _ := add_le_add hP (mul_le_mul_of_nonneg_left hQ hm)
503
+
504
+ theorem productKernel_conditioned_mean_comparison {ι : Type*} [Fintype ι] [DecidableEq ι]
505
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
506
+ (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i))
507
+ (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i)
508
+ (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 →
509
+ (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2))
510
+ (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f)
511
+ (I : Finset ι) {r b : ℕ} (hIb : I.card ≤ b) (hr : r ≤ b - I.card)
512
+ {κ A B M N : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ I, C i ≤ κ ^ 2)
513
+ (hsmall : κ * A ^ 2 * B ^ 2 ≤ 1 / 2)
514
+ (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ)
515
+ (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k)
516
+ (productSectionAverage μ I I x w)) ≤ A ^ (2 * k))
517
+ (hf : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k)
518
+ (productSectionAverage ν I I y f)) ≤ B ^ (2 * k))
519
+ (hM : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b) (productSectionAverage μ I I x w)) ≤ M)
520
+ (hN : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) (productSectionAverage ν I I y f)) ≤ N) :
521
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)
522
+ |productCouplingPairing c
523
+ (productANOVATruncation μ (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I x z * w z))
524
+ (productANOVATruncation ν (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I y z * f z)) -
525
+ productCouplingAtomMass c I x y *
526
+ ((FiniteProbabilityWeights.pi μ).mean (productSectionAverage μ I I x w) *
527
+ (FiniteProbabilityWeights.pi ν).mean (productSectionAverage ν I I y f))| ≤
528
+ (2 : ℝ) ^ I.card * (κ ^ (b - I.card) * M * N) +
529
+ productCouplingAtomMass c I x y * (2 * (κ * A ^ 2 * B ^ 2) + κ ^ r * M * N) := by
530
+ dsimp only
531
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)
532
+ have hsub : lowDegreeCoordinateSets ι (b - I.card) ⊆ lowDegreeCoordinateSets ι b := by
533
+ intro S hS
534
+ exact (mem_lowDegreeCoordinateSets ι b S).mpr
535
+ (((mem_lowDegreeCoordinateSets ι (b - I.card) S).mp hS).trans (Nat.sub_le b I.card))
536
+ have hcore := productKernel_core_comparison μ ν K C hC hbound hK Iᶜ hr hκ0 hκ1
537
+ (fun i hi => hcap i (Finset.mem_compl.mp hi)) hsmall
538
+ (productSectionAverage μ I I x w) (productSectionAverage ν I I y f) hw hf
539
+ ((Real.sqrt_le_sqrt (productANOVAEnergy_mono μ hsub _)).trans hM)
540
+ ((Real.sqrt_le_sqrt (productANOVAEnergy_mono ν hsub _)).trans hN)
541
+ have hshell := productKernel_conditioning_shell_of_truncated μ ν K C hC hbound hK I b hIb
542
+ hκ0 hκ1 hcap x y w f hM hN
543
+ exact weighted_pairing_error_compose (productCouplingAtomMass_nonneg c I x y) hshell hcore
544
+
545
+ end Erdos3
546
+
547
+ end
548
+
549
+ section
550
+
551
+ namespace Erdos3
552
+
553
+ open scoped BigOperators
554
+
555
+ theorem productKernel_scaled_conditioned_mean_comparison {ι : Type*} [Fintype ι] [DecidableEq ι]
556
+ {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)]
557
+ (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i))
558
+ (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i)
559
+ (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 →
560
+ (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2))
561
+ (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f)
562
+ (I : Finset ι) {r b : ℕ} (hIb : I.card ≤ b) (hr : r ≤ b - I.card)
563
+ {κ A B M N m s : ℝ} (hm : 0 < m) (hs : 0 < s)
564
+ (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ I, C i ≤ κ ^ 2)
565
+ (hsmall : κ * A ^ 2 * B ^ 2 ≤ 1 / 2)
566
+ (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ)
567
+ (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k)
568
+ (fun z => m⁻¹ * productSectionAverage μ I I x w z)) ≤ A ^ (2 * k))
569
+ (hf : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k)
570
+ (fun z => s⁻¹ * productSectionAverage ν I I y f z)) ≤ B ^ (2 * k))
571
+ (hM : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b)
572
+ (fun z => m⁻¹ * productSectionAverage μ I I x w z)) ≤ M)
573
+ (hN : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b)
574
+ (fun z => s⁻¹ * productSectionAverage ν I I y f z)) ≤ N) :
575
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)
576
+ |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι b) I x y w f -
577
+ productCouplingAtomMass c I x y *
578
+ (productConditionalMean μ I w x * productConditionalMean ν I f y)| ≤
579
+ m * s * ((2 : ℝ) ^ I.card * (κ ^ (b - I.card) * M * N) +
580
+ productCouplingAtomMass c I x y * (2 * (κ * A ^ 2 * B ^ 2) + κ ^ r * M * N)) := by
581
+ dsimp only
582
+ let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)
583
+ have hw_eq : productSectionAverage μ I I x (fun z => m⁻¹ * w z) =
584
+ (fun z => m⁻¹ * productSectionAverage μ I I x w z) :=
585
+ funext (productSectionAverage_smul μ I I x m⁻¹ w)
586
+ have hf_eq : productSectionAverage ν I I y (fun z => s⁻¹ * f z) =
587
+ (fun z => s⁻¹ * productSectionAverage ν I I y f z) :=
588
+ funext (productSectionAverage_smul ν I I y s⁻¹ f)
589
+ have h := productKernel_conditioned_mean_comparison μ ν K C hC hbound hK I hIb hr
590
+ hκ0 hκ1 hcap hsmall x y (fun z => m⁻¹ * w z) (fun z => s⁻¹ * f z)
591
+ (by simpa only [hw_eq] using hw) (by simpa only [hf_eq] using hf)
592
+ (by simpa only [hw_eq] using hM) (by simpa only [hf_eq] using hN)
593
+ change |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι b) I x y
594
+ (fun z => m⁻¹ * w z) (fun z => s⁻¹ * f z) - productCouplingAtomMass c I x y *
595
+ ((FiniteProbabilityWeights.pi μ).mean (productSectionAverage μ I I x (fun z => m⁻¹ * w z)) *
596
+ (FiniteProbabilityWeights.pi ν).mean (productSectionAverage ν I I y (fun z => s⁻¹ * f z)))| ≤ _ at h
597
+ rw [productAtomTruncatedPairing_smul, productSectionAverage_self_mean, productSectionAverage_self_mean,
598
+ productConditionalMean_smul, productConditionalMean_smul] at h
599
+ exact normalized_pairing_error_scale hm hs h
600
+
601
+ end Erdos3
602
+
603
+ end
604
+
605
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScaledFloorPerturbation.lean ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.Order.Floor.Ring
2
+ import Mathlib.Tactic
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ theorem scaled_floor_perturbation {s a ε : ℝ} (hs : 0 < s)
11
+ (z : ℤ) (hz : |(z : ℝ)| ≤ ε * s) :
12
+ |((⌊s * a⌋ + z : ℤ) : ℝ) / s - a| ≤ ε + 1 / s := by
13
+ have hround : |(⌊s * a⌋ : ℝ) - s * a| ≤ 1 := by
14
+ apply abs_le.mpr
15
+ constructor <;> linarith [Int.floor_le (s * a), Int.lt_floor_add_one (s * a)]
16
+ have hsum : |((⌊s * a⌋ + z : ℤ) : ℝ) - s * a| ≤ 1 + ε * s := by
17
+ rw [Int.cast_add, show (⌊s * a⌋ : ℝ) + z - s * a =
18
+ ((⌊s * a⌋ : ℝ) - s * a) + z by ring]
19
+ exact (abs_add_le _ _).trans (add_le_add hround hz)
20
+ have heq : ((⌊s * a⌋ + z : ℤ) : ℝ) / s - a =
21
+ (((⌊s * a⌋ + z : ℤ) : ℝ) - s * a) / s := by
22
+ field_simp
23
+ rw [heq, abs_div, abs_of_pos hs]
24
+ calc
25
+ _ ≤ (1 + ε * s) / s := div_le_div_of_nonneg_right hsum hs.le
26
+ _ = ε + 1 / s := by field_simp; ring
27
+
28
+ theorem scaled_floor_perturbation_le_twice {s a ε : ℝ} (hs : 0 < s)
29
+ (hscale : 1 / s ≤ ε) (z : ℤ) (hz : |(z : ℝ)| ≤ ε * s) :
30
+ |((⌊s * a⌋ + z : ℤ) : ℝ) / s - a| ≤ 2 * ε := by
31
+ have h := scaled_floor_perturbation (a := a) hs z hz
32
+ linarith
33
+
34
+ end Erdos3
35
+
36
+ end
37
+
38
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScaledJointFrozenSource.lean ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Measure.Prod
2
+ import OAI.Combinatorics.Progressions.Probability.SlicedRemainderDensityFamily
3
+ import OAI.Combinatorics.Progressions.Sampling.CanonicalRawSampler
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open MeasureTheory
12
+
13
+ def jointCubeScale {D α : Type*} {B : D → Type*} (h : D → ℕ)
14
+ (T : PrincipalTupleIndex B h → ℝ) (x : JointBlockParameter B h α → ℝ)
15
+ (j : JointBlockParameter B h α) : ℝ :=
16
+ T ⟨j.1, j.2.1, j.2.2.1⟩ * x j
17
+
18
+ theorem jointCubeScale_measurable {D α : Type*} {B : D → Type*} (h : D → ℕ)
19
+ (T : PrincipalTupleIndex B h → ℝ) : Measurable (jointCubeScale (α := α) h T) :=
20
+ Measurable.of_eval (fun coordinate => measurable_const.mul (measurable_pi_apply coordinate))
21
+
22
+ noncomputable def jointCubeScaleHomeomorph {D α : Type*} {B : D → Type*} (h : D → ℕ)
23
+ (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, T i ≠ 0) :
24
+ (JointBlockParameter B h α → ℝ) ≃ₜ (JointBlockParameter B h α → ℝ) :=
25
+ Homeomorph.piCongrRight (fun j =>
26
+ Homeomorph.smulOfNeZero (α := ℝ) (T ⟨j.1, j.2.1, j.2.2.1⟩) (hT _))
27
+
28
+ theorem jointCubeScaleHomeomorph_apply {D α : Type*} {B : D → Type*} (h : D → ℕ)
29
+ (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, T i ≠ 0)
30
+ (x : JointBlockParameter B h α → ℝ) :
31
+ jointCubeScaleHomeomorph h T hT x = jointCubeScale h T x := rfl
32
+
33
+ noncomputable def scaledJointCubeSource {D α : Type*} [Fintype D] [Fintype α]
34
+ [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ)
35
+ (T : PrincipalTupleIndex B h → ℝ) : Measure (JointBlockParameter B h α → ℝ) :=
36
+ sigmaAxisMeasure (fun d => scaledBlockCubeMeasure (fun i : B d × Fin (h d) => T ⟨d, i⟩))
37
+
38
+ theorem scaledJointCubeSource_eq_map {D α : Type*} [Fintype D] [Fintype α]
39
+ [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ)
40
+ (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, 0 < T i) :
41
+ scaledJointCubeSource (α := α) h T =
42
+ (jointBooleanSource h).map (jointCubeScale h T) := by
43
+ change _ = (jointBooleanSource h).map
44
+ (sigmaAxisSampler (fun d => blockCubeScale (α := α) (fun i : B d × Fin (h d) => T ⟨d, i⟩)))
45
+ rw [jointBooleanSource, sigmaAxisSampler_image_law _ _
46
+ (fun d => blockCubeScale_measurable (fun i : B d × Fin (h d) => T ⟨d, i⟩))]
47
+ unfold scaledJointCubeSource
48
+ congr 1
49
+ funext d
50
+ exact scaledBlockCubeMeasure_eq_map _ (fun i => hT ⟨d, i⟩)
51
+
52
+ theorem scaledJointCubeSource_probability {D α : Type*} [Fintype D] [Fintype α]
53
+ [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ)
54
+ (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, 0 < T i) :
55
+ IsProbabilityMeasure (scaledJointCubeSource (α := α) h T) := by
56
+ rw [scaledJointCubeSource_eq_map h T hT]
57
+ infer_instance
58
+
59
+ theorem scaledJointCubeSource_integral {D α : Type*} [Fintype D] [Fintype α]
60
+ [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ)
61
+ (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, 0 < T i)
62
+ (f : (JointBlockParameter B h α → ℝ) → ℝ) :
63
+ (∫ x, f x ∂scaledJointCubeSource h T) =
64
+ ∫ x, f (jointCubeScale h T x) ∂jointBooleanSource h := by
65
+ rw [scaledJointCubeSource_eq_map h T hT]
66
+ exact (jointCubeScaleHomeomorph h T (fun i => (hT i).ne')).toMeasurableEquiv.measurableEmbedding.integral_map f
67
+
68
+ end Erdos3
69
+
70
+ end
71
+
72
+ section
73
+
74
+ namespace Erdos3
75
+
76
+ open scoped BigOperators
77
+
78
+ noncomputable def rawCanonicalCubeTuple {D G Z α : Type*} [Fintype α] [DecidableEq α]
79
+ {B : D → Type*} {h : D → ℕ} (extra : G → Option α → Z)
80
+ (scale : SamplerTupleIndex G B h → ℝ) (z : Z → ℝ)
81
+ (x : JointBlockParameter B h α → ℝ) (vertex : Finset α) : SamplerTupleIndex G B h → ℝ
82
+ | .inl g => scale (.inl g) * ∑ r : Option α, (booleanFeature r vertex : ℝ) * z (extra g r)
83
+ | .inr ⟨d, b, v⟩ => scalarCubeValue (fun r => x ⟨d, b, v, r⟩) vertex
84
+
85
+ theorem rawCanonicalCubeTuple_rescale {D G Z α : Type*} [Fintype α] [DecidableEq α]
86
+ {B : D → Type*} {h : D → ℕ} (extra : G → Option α → Z)
87
+ (scale : SamplerTupleIndex G B h → ℝ) (z : Z → ℝ)
88
+ (x : JointBlockParameter B h α → ℝ) (vertex : Finset α) (k : SamplerTupleIndex G B h) :
89
+ rawCanonicalCubeTuple extra scale z (jointCubeScale h (fun i => scale (.inr i)) x) vertex k =
90
+ scale k * normalizedCubeTuple (canonicalTupleInput extra) z x vertex k := by
91
+ cases k with
92
+ | inl g => rfl
93
+ | inr i =>
94
+ rcases i with ⟨d, b, v⟩
95
+ exact scalarCubeValue_smul (scale (.inr ⟨d, b, v⟩)) (fun r => x ⟨d, b, v, r⟩) vertex
96
+
97
+ noncomputable def rawCanonicalJet {D G Z α : Type*} [Fintype α] [DecidableEq α]
98
+ {B O L : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ) (c : ∀ d, B d → ℝ)
99
+ (sets : ∀ d, O d → Finset α) (terms : ∀ d, Finset (L d)) (weight : ∀ d, L d → ℝ)
100
+ (exponent : ∀ d, L d → SamplerTupleIndex G B h →₀ ℕ)
101
+ (coefficientIndex : ∀ d, L d → Z) (extra : G → Option α → Z)
102
+ (Q : D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) (constant : D → ℝ)
103
+ (t : ℝ) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) : (Σ d, O d) → ℝ :=
104
+ rawProductArrayJet h sets terms exponent (fun d b v => .inr ⟨d, b, v⟩)
105
+ (scaledPrincipalCoefficient h Q scale (fun d b v => .inr ⟨d, b, v⟩) c)
106
+ (scaledTailCoefficient Q scale weight exponent coefficientIndex t z)
107
+ (fun d => Q d * constant d) Q (rawCanonicalCubeTuple extra scale z x)
108
+
109
+ theorem rawCanonicalJet_rescale {D G Z α : Type*} [Fintype α] [DecidableEq α]
110
+ {B O L : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ) (c : ∀ d, B d → ℝ)
111
+ (sets : ∀ d, O d → Finset α) (terms : ∀ d, Finset (L d)) (weight : ∀ d, L d → ℝ)
112
+ (exponent : ∀ d, L d → SamplerTupleIndex G B h →₀ ℕ)
113
+ (coefficientIndex : ∀ d, L d → Z) (extra : G → Option α → Z)
114
+ (Q : D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) (constant : D → ℝ)
115
+ (t : ℝ) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) :
116
+ rawCanonicalJet h c sets terms weight exponent coefficientIndex extra Q scale constant t z
117
+ (jointCubeScale h (fun i => scale (.inr i)) x) =
118
+ canonicalScaledProductArrayJet h c sets terms weight exponent coefficientIndex extra
119
+ Q scale constant t z x := by
120
+ unfold rawCanonicalJet canonicalScaledProductArrayJet scaledProductArrayJet
121
+ have he : rawCanonicalCubeTuple extra scale z (jointCubeScale h (fun i => scale (.inr i)) x) =
122
+ fun vertex k => scale k * normalizedCubeTuple (canonicalTupleInput extra) z x vertex k := by
123
+ funext vertex k
124
+ exact rawCanonicalCubeTuple_rescale extra scale z x vertex k
125
+ rw [he]
126
+
127
+ end Erdos3
128
+
129
+ end
130
+
131
+ section
132
+
133
+ namespace Erdos3
134
+
135
+ open MeasureTheory
136
+
137
+ theorem scaledJointCubeSource_prod {Ω D α : Type*} [MeasurableSpace Ω]
138
+ [Fintype D] [Fintype α] [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)]
139
+ (h : D → ℕ) (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, 0 < T i)
140
+ (μ : Measure Ω) [SFinite μ] :
141
+ μ.prod (scaledJointCubeSource (α := α) h T) =
142
+ (μ.prod (jointBooleanSource h)).map (Prod.map id (jointCubeScale h T)) := by
143
+ rw [scaledJointCubeSource_eq_map h T hT]
144
+ simpa only [Measure.map_id] using
145
+ Measure.map_prod_map μ (jointBooleanSource h) measurable_id (jointCubeScale_measurable h T)
146
+
147
+ theorem scaledJointCubeSource_prod_integral {Ω D α : Type*} [MeasurableSpace Ω]
148
+ [Fintype D] [Fintype α] [DecidableEq α] {B : D → Type*} [∀ d, Fintype (B d)]
149
+ (h : D → ℕ) (T : PrincipalTupleIndex B h → ℝ) (hT : ∀ i, 0 < T i)
150
+ (μ : Measure Ω) [SFinite μ] (f : Ω × (JointBlockParameter B h α → ℝ) → ℝ) :
151
+ (∫ p, f p ∂μ.prod (scaledJointCubeSource h T)) =
152
+ ∫ p, f (p.1, jointCubeScale h T p.2) ∂μ.prod (jointBooleanSource h) := by
153
+ rw [scaledJointCubeSource_prod h T hT]
154
+ exact ((MeasurableEquiv.refl Ω).prodCongr
155
+ (jointCubeScaleHomeomorph h T (fun i => (hT i).ne')).toMeasurableEquiv).measurableEmbedding.integral_map f
156
+
157
+ end Erdos3
158
+
159
+ end
160
+
161
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScaledLinearResidual.lean ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.Module.LinearMap.Basic
2
+ import Mathlib.Tactic
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ variable {V W : Type*} [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W]
11
+
12
+ noncomputable def scaledLinearResidual (E : V →ₗ[ℝ] W) (T : W →ₗ[ℝ] V) (q : ℝ) :
13
+ V →ₗ[ℝ] V := q • LinearMap.id - T.comp E
14
+
15
+ theorem scaledLinearResidual_apply (E : V →ₗ[ℝ] W) (T : W →ₗ[ℝ] V) (q : ℝ) (x : V) :
16
+ scaledLinearResidual E T q x = q • x - T (E x) := rfl
17
+
18
+ theorem scaledLinearResidual_evaluation (E : V →ₗ[ℝ] W) (T : W →ₗ[ℝ] V) (q : ℝ)
19
+ (hT : ∀ x, E (T (E x)) = q • E x) (x : V) :
20
+ E (scaledLinearResidual E T q x) = 0 := by
21
+ rw [scaledLinearResidual_apply, map_sub, map_smul, hT, sub_self]
22
+
23
+ theorem scaledLinearResidual_on_kernel (E : V →ₗ[ℝ] W) (T : W →ₗ[ℝ] V) (q : ℝ)
24
+ (x : V) (hx : E x = 0) : scaledLinearResidual E T q x = q • x := by
25
+ rw [scaledLinearResidual_apply, hx, map_zero, sub_zero]
26
+
27
+ theorem scaledLinearResidual_factor_iff (E : V →ₗ[ℝ] W) (T : W →ₗ[ℝ] V)
28
+ {q : ℝ} (hq : q ≠ 0) (hT : ∀ x, E (T (E x)) = q • E x) (L : V →ₗ[ℝ] ℝ) :
29
+ L.comp (scaledLinearResidual E T q) = 0 ↔ ∃ M : W →ₗ[ℝ] ℝ, L = M.comp E := by
30
+ constructor
31
+ · intro h
32
+ refine ⟨q⁻¹ • L.comp T, ?_⟩
33
+ ext x
34
+ have hx := DFunLike.congr_fun h x
35
+ simp only [LinearMap.comp_apply, scaledLinearResidual_apply, map_sub, map_smul,
36
+ smul_eq_mul, LinearMap.zero_apply, sub_eq_zero] at hx
37
+ simp only [LinearMap.comp_apply, LinearMap.smul_apply, smul_eq_mul]
38
+ rw [← hx, ← mul_assoc, inv_mul_cancel₀ hq, one_mul]
39
+ · rintro ⟨M, rfl⟩
40
+ ext x
41
+ simp only [LinearMap.comp_apply, scaledLinearResidual_evaluation E T q hT,
42
+ map_zero, LinearMap.zero_apply]
43
+
44
+ end Erdos3
45
+
46
+ end
47
+
48
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/ScaledSectionGram.lean ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.EuclideanDerivativeLattice
2
+ import OAI.Combinatorics.Progressions.Linear.GramBasisChange
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open Module
11
+
12
+ theorem gram_det_injective_map_basis
13
+ {ι V E : Type*} [Fintype ι] [DecidableEq ι] [AddCommGroup V] [Module ℝ V]
14
+ [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
15
+ (f : V →ₗ[ℝ] E) (hf : Function.Injective f) (b₀ b₁ : Basis ι ℝ V) :
16
+ (Matrix.gram ℝ (fun i => f (b₁ i))).det =
17
+ (b₀.det b₁) ^ 2 * (Matrix.gram ℝ (fun i => f (b₀ i))).det := by
18
+ let e := LinearEquiv.ofInjective f hf
19
+ have h := gram_det_basis_change (b₀.map e) (fun i => e (b₁ i))
20
+ have hd : (b₀.map e).det (fun i => e (b₁ i)) = b₀.det b₁ := by
21
+ rw [Basis.det_map]
22
+ apply congrArg b₀.det
23
+ funext i
24
+ exact e.symm_apply_apply (b₁ i)
25
+ have h₀ : Matrix.gram ℝ (b₀.map e) = Matrix.gram ℝ (fun i => f (b₀ i)) := by
26
+ ext i j
27
+ simp only [Matrix.gram_apply, Basis.map_apply]
28
+ rfl
29
+ have h₁ : Matrix.gram ℝ (fun i => e (b₁ i)) = Matrix.gram ℝ (fun i => f (b₁ i)) := by
30
+ ext i j
31
+ rfl
32
+ rw [hd, h₀, h₁] at h
33
+ exact h
34
+
35
+ end Erdos3
36
+
37
+ end
38
+
39
+ section
40
+
41
+ namespace Erdos3
42
+
43
+ open Module
44
+
45
+ theorem coordinateScaleEquiv_basis_det {ι : Type*} [Fintype ι] [DecidableEq ι]
46
+ (T : ι → ℝ) (hT : ∀ i, T i ≠ 0) :
47
+ (Pi.basisFun ℝ ι).det ((Pi.basisFun ℝ ι).map (coordinateScaleEquiv T hT)) = ∏ i, T i := by
48
+ rw [Pi.basisFun_det_apply]
49
+ have he : Matrix.of ((Pi.basisFun ℝ ι).map (coordinateScaleEquiv T hT)) = Matrix.diagonal T := by
50
+ ext i j
51
+ by_cases hij : i = j <;>
52
+ simp [Basis.map_apply, coordinateScaleEquiv_apply, Pi.basisFun_apply, hij]
53
+ rw [he, Matrix.det_diagonal]
54
+
55
+ theorem scaled_section_gram_sqrt {ι E : Type*} [Fintype ι] [DecidableEq ι]
56
+ [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
57
+ (L : (ι → ℝ) →ₗ[ℝ] E) (hL : Function.Injective L)
58
+ (T : ι → ℝ) (hT : ∀ i, 0 < T i) :
59
+ Real.sqrt (Matrix.gram ℝ (fun i => L (coordinateScaleEquiv T (fun j => (hT j).ne')
60
+ (Pi.basisFun ℝ ι i)))).det =
61
+ (∏ i, T i) * Real.sqrt (Matrix.gram ℝ (fun i => L (Pi.basisFun ℝ ι i))).det := by
62
+ have h := gram_det_injective_map_basis L hL (Pi.basisFun ℝ ι)
63
+ ((Pi.basisFun ℝ ι).map (coordinateScaleEquiv T (fun j => (hT j).ne')))
64
+ rw [coordinateScaleEquiv_basis_det] at h
65
+ have he := congrArg Real.sqrt h
66
+ rw [Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq (Finset.prod_nonneg (fun i _ => (hT i).le))] at he
67
+ simpa only [Basis.map_apply] using he
68
+
69
+ end Erdos3
70
+
71
+ end
72
+
73
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SecondDifferenceVectorEquivalence.lean ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.MultidegreeIntegerTranslation
2
+ import OAI.Combinatorics.Progressions.Lattices.NativeIntegerHalving
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped BigOperators
11
+
12
+ def mixedSecondDifferenceInput (j : Fin 4) (x : Fin 4 → ℤ) : Fin 2 → ℤ :=
13
+ correlationInput (x 0) (x 1 + ![0, x 2, x 3, x 2 + x 3] j)
14
+
15
+ namespace NativeMultidegreeNilcharacter
16
+
17
+ noncomputable def mixedSecondDifferenceWithShift {s : ℕ} {p : ℝ}
18
+ (M : NativeMultidegreeNilcharacter (mixedCorrelationDegree s) p)
19
+ (c : Fin 4 → ℤ)
20
+ (a : (Fin M.outputDim × Fin M.outputDim) × (Fin M.outputDim × Fin M.outputDim))
21
+ (x : Fin 4 → ℤ) : ℂ :=
22
+ (M.eval a.1.1 (mixedSecondDifferenceInput 0 x + ![0, c 0]) *
23
+ star (M.eval a.1.2 (mixedSecondDifferenceInput 1 x + ![0, c 1]))) *
24
+ star (M.eval a.2.1 (mixedSecondDifferenceInput 2 x + ![0, c 2]) *
25
+ star (M.eval a.2.2 (mixedSecondDifferenceInput 3 x + ![0, c 3])))
26
+
27
+ theorem mixedSecondDifferenceWithShift_unit {s : ℕ} {p : ℝ}
28
+ (M : NativeMultidegreeNilcharacter (mixedCorrelationDegree s) p)
29
+ (c : Fin 4 → ℤ) (x : Fin 4 → ℤ) :
30
+ ∑ a, ‖M.mixedSecondDifferenceWithShift c a x‖ ^ 2 = 1 := by
31
+ simp only [mixedSecondDifferenceWithShift, Fintype.sum_prod_type, norm_mul, norm_star,
32
+ mul_pow, ← Finset.mul_sum, M.unit_eval, mul_one]
33
+
34
+ theorem exists_mixed_second_difference_translation (s : ℕ) :
35
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ}
36
+ (M : NativeMultidegreeNilcharacter (mixedCorrelationDegree s) p) (c : Fin 4 → ℤ),
37
+ NativeIntegerVectorEquivalence s ((p + C) ^ C)
38
+ (M.mixedSecondDifferenceWithShift c) (M.mixedSecondDifferenceWithShift 0) := by
39
+ obtain ⟨A, _, htranslate⟩ := exists_multidegree_integer_translation s
40
+ obtain ⟨B, _, htensor⟩ := NativeIntegerVectorEquivalence.exists_tensor_budget
41
+ let X : Polynomial ℕ := Polynomial.X
42
+ let U := (X + Polynomial.C A) ^ A
43
+ let V := (U + Polynomial.C B) ^ B
44
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((V + Polynomial.C B) ^ B)
45
+ refine ⟨C, hC, ?_⟩
46
+ intro p M c
47
+ have hp : 0 ≤ p := (Nat.cast_nonneg M.dim).trans M.complexity.1.1
48
+ let u := (p + A) ^ A
49
+ let v := (u + B) ^ B
50
+ have hu : 0 ≤ u := by dsimp [u]; positivity
51
+ have hv : 0 ≤ v := by dsimp [v]; positivity
52
+ have hcost : (v + B) ^ B ≤ (p + C) ^ C := by
53
+ simpa [X, U, V, u, v, Polynomial.eval₂_pow] using hbudget p hp
54
+ have hdegree : (∑ i, mixedCorrelationDegree s i) = s + 1 := by
55
+ rw [Fin.sum_univ_two]
56
+ change 1 + s = s + 1
57
+ omega
58
+ let F (j : Fin 4) : Fin 2 → ((Fin 4 → ℤ) →+ ℤ) := fun i =>
59
+ { toFun := fun x => mixedSecondDifferenceInput j x i
60
+ map_zero' := by fin_cases j <;> fin_cases i <;> rfl
61
+ map_add' := by
62
+ intro x y
63
+ fin_cases i
64
+ · rfl
65
+ · change (x + y) 1 + ![0, (x + y) 2, (x + y) 3, (x + y) 2 + (x + y) 3] j =
66
+ (x 1 + ![0, x 2, x 3, x 2 + x 3] j) +
67
+ (y 1 + ![0, y 2, y 3, y 2 + y 3] j)
68
+ fin_cases j <;> dsimp <;> ring }
69
+ have hzero : (![0, 0] : Fin 2 → ℤ) = 0 := by ext i; fin_cases i <;> rfl
70
+ have E (j : Fin 4) : NativeIntegerVectorEquivalence s u
71
+ (fun i x => M.eval i (mixedSecondDifferenceInput j x + ![0, c j]))
72
+ (fun i x => M.eval i (mixedSecondDifferenceInput j x + ![0, 0])) := by
73
+ have T := (htranslate (mixedCorrelationDegree s) hdegree M ![0, c j] 0).linearPullbackHom (F j)
74
+ change NativeIntegerVectorEquivalence s u
75
+ (fun i x => M.eval i (mixedSecondDifferenceInput j x + ![0, c j]))
76
+ (fun i x => M.eval i (mixedSecondDifferenceInput j x + 0)) at T
77
+ simpa only [hzero] using T
78
+ have E₀ := htensor hu (E 0) (E 1).conjugate
79
+ have E₁ := htensor hu (E 2) (E 3).conjugate
80
+ exact (htensor hv E₀ E₁.conjugate).mono hcost
81
+
82
+ end NativeMultidegreeNilcharacter
83
+
84
+ end Erdos3
85
+
86
+ end
87
+
88
+ section
89
+
90
+ namespace Erdos3
91
+
92
+ def mixedSecondDifferenceHom (j : Fin 4) (i : Fin 2) : ((Fin 4 → ℤ) →+ ℤ) where
93
+ toFun x := mixedSecondDifferenceInput j x i
94
+ map_zero' := by fin_cases j <;> fin_cases i <;> rfl
95
+ map_add' x y := by
96
+ fin_cases i
97
+ · rfl
98
+ · change (x + y) 1 + ![0, (x + y) 2, (x + y) 3, (x + y) 2 + (x + y) 3] j =
99
+ (x 1 + ![0, x 2, x 3, x 2 + x 3] j) + (y 1 + ![0, y 2, y 3, y 2 + y 3] j)
100
+ fin_cases j <;> dsimp <;> ring
101
+
102
+ noncomputable def mixedSecondDifferenceVector {I : Type*} (f : I → (Fin 2 → ℤ) → ℂ)
103
+ (a : (I × I) × (I × I)) (x : Fin 4 → ℤ) : ℂ :=
104
+ (f a.1.1 (mixedSecondDifferenceInput 0 x) * star (f a.1.2 (mixedSecondDifferenceInput 1 x))) *
105
+ star (f a.2.1 (mixedSecondDifferenceInput 2 x) * star (f a.2.2 (mixedSecondDifferenceInput 3 x)))
106
+
107
+ theorem NativeMultidegreeNilcharacter.mixedSecondDifferenceWithShift_zero {s : ℕ} {p : ℝ}
108
+ (M : NativeMultidegreeNilcharacter (mixedCorrelationDegree s) p) :
109
+ M.mixedSecondDifferenceWithShift 0 = mixedSecondDifferenceVector M.eval := by
110
+ have hzero : (![0, 0] : Fin 2 → ℤ) = 0 := by ext i; fin_cases i <;> rfl
111
+ funext a x
112
+ simp only [NativeMultidegreeNilcharacter.mixedSecondDifferenceWithShift,
113
+ mixedSecondDifferenceVector, Pi.zero_apply, hzero, add_zero]
114
+
115
+ theorem NativeIntegerVectorEquivalence.exists_second_difference_budget :
116
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ {I J : Type*} [Fintype I] [Fintype J] {s : ℕ} {p : ℝ}
117
+ {f : I → (Fin 2 → ℤ) → ℂ} {g : J → (Fin 2 → ℤ) → ℂ},
118
+ 0 ≤ p → NativeIntegerVectorEquivalence s p f g →
119
+ NativeIntegerVectorEquivalence s ((p + C) ^ C)
120
+ (mixedSecondDifferenceVector f) (mixedSecondDifferenceVector g) := by
121
+ obtain ⟨A, _, htensor⟩ := NativeIntegerVectorEquivalence.exists_tensor_budget
122
+ let X : Polynomial ℕ := Polynomial.X
123
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget
124
+ (((X + Polynomial.C A) ^ A + Polynomial.C A) ^ A)
125
+ refine ⟨C, hC, ?_⟩
126
+ intro I J _ _ s p f g hp E
127
+ let q := (p + A) ^ A
128
+ have hq : 0 ≤ q := by dsimp [q]; positivity
129
+ have H (j : Fin 4) : NativeIntegerVectorEquivalence s p
130
+ (fun i x => f i (mixedSecondDifferenceInput j x))
131
+ (fun i x => g i (mixedSecondDifferenceInput j x)) :=
132
+ E.linearPullbackHom (mixedSecondDifferenceHom j)
133
+ have H₀ := htensor hp (H 0) (H 1).conjugate
134
+ have H₁ := htensor hp (H 2) (H 3).conjugate
135
+ have hcost : (q + A) ^ A ≤ (p + C) ^ C := by
136
+ simpa [X, q, Polynomial.eval₂_pow] using hbudget p hp
137
+ exact (htensor hq H₀ H₁.conjugate).mono hcost
138
+
139
+ end Erdos3
140
+
141
+ end
142
+
143
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SecondaryMeshGeometry.lean ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.ResidualErrorAllocation
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def secondaryBoundaryMargin (boundary beta : ℝ) : ℝ := replacementAccuracy boundary beta
10
+
11
+ noncomputable def secondaryMeshDelta (boundary movement beta : ℝ) : ℝ :=
12
+ replacementAccuracy movement (secondaryBoundaryMargin boundary beta)
13
+
14
+ theorem secondaryMeshAllocation_spec {boundary movement beta : ℝ}
15
+ (hboundary : 0 ≤ boundary) (hmovement : 0 ≤ movement) (hbeta : 0 < beta) :
16
+ 0 < secondaryBoundaryMargin boundary beta ∧ secondaryBoundaryMargin boundary beta ≤ 1 ∧
17
+ boundary * secondaryBoundaryMargin boundary beta ≤ beta ∧
18
+ 0 < secondaryMeshDelta boundary movement beta ∧ secondaryMeshDelta boundary movement beta ≤ 1 ∧
19
+ secondaryMeshDelta boundary movement beta * movement ≤ secondaryBoundaryMargin boundary beta := by
20
+ have hm := replacementAccuracy_spec hboundary hbeta
21
+ have hd := replacementAccuracy_spec hmovement hm.1
22
+ exact ⟨hm.1, hm.2.1, hm.2.2, hd.1, hd.2.1, (mul_comm _ _).trans_le hd.2.2⟩
23
+
24
+ theorem secondaryMeshAllocation_inverse_bounds {boundary movement beta P : ℝ}
25
+ (hboundary : 0 ≤ boundary) (hmovement : 0 ≤ movement) (hbeta : 0 < beta) (hP : 0 ≤ P)
26
+ (hboundaryP : boundary ≤ Real.exp P) (hmovementP : movement ≤ Real.exp P)
27
+ (hbetaP : beta⁻¹ ≤ Real.exp P) :
28
+ (secondaryBoundaryMargin boundary beta)⁻¹ ≤ Real.exp (2 * P + 2) ∧
29
+ (secondaryMeshDelta boundary movement beta)⁻¹ ≤ Real.exp (4 * P + 6) := by
30
+ have hm := replacementAccuracy_inverse_le_exp hboundary hbeta hP hboundaryP hbetaP
31
+ refine ⟨hm, ?_⟩
32
+ have hmargin := (replacementAccuracy_spec hboundary hbeta).1
33
+ have hmovement' : movement ≤ Real.exp (2 * P + 2) :=
34
+ hmovementP.trans (Real.exp_le_exp.mpr (by linarith))
35
+ have hd := replacementAccuracy_inverse_le_exp hmovement hmargin (by linarith : 0 ≤ 2 * P + 2)
36
+ hmovement' hm
37
+ exact hd.trans_eq (by congr 1; ring)
38
+
39
+ theorem secondaryMeshAllocation_size_bounds {boundary movement beta P H scale : ℝ}
40
+ (hboundary : 0 ≤ boundary) (hmovement : 0 ≤ movement) (hbeta : 0 < beta) (hP : 0 ≤ P)
41
+ (hboundaryP : boundary ≤ Real.exp P) (hmovementP : movement ≤ Real.exp P)
42
+ (hbetaP : beta⁻¹ ≤ Real.exp P) (hH : Real.exp (2 * P + 2) ≤ H)
43
+ (hscale : 4 * Real.exp (4 * P + 6) ≤ scale) :
44
+ 1 ≤ secondaryBoundaryMargin boundary beta * H ∧
45
+ 4 ≤ secondaryMeshDelta boundary movement beta * scale := by
46
+ have hs := secondaryMeshAllocation_spec hboundary hmovement hbeta
47
+ have hi := secondaryMeshAllocation_inverse_bounds hboundary hmovement hbeta hP hboundaryP hmovementP hbetaP
48
+ constructor
49
+ · have h := mul_le_mul_of_nonneg_left (hi.1.trans hH) hs.1.le
50
+ simpa only [mul_inv_cancel₀ hs.1.ne'] using h
51
+ · have hdiv : 4 / secondaryMeshDelta boundary movement beta ≤ scale := by
52
+ calc
53
+ _ = 4 * (secondaryMeshDelta boundary movement beta)⁻¹ := div_eq_mul_inv _ _
54
+ _ ≤ 4 * Real.exp (4 * P + 6) := mul_le_mul_of_nonneg_left hi.2 (by norm_num)
55
+ _ ≤ scale := hscale
56
+ simpa only [mul_comm] using (div_le_iff₀ hs.2.2.2.1).mp hdiv
57
+
58
+ end Erdos3
59
+
60
+ end
61
+
62
+ section
63
+
64
+ namespace Erdos3
65
+
66
+ noncomputable def secondaryMovementBudget (movement sourceRatio parameterRatio : ℝ) : ℝ :=
67
+ movement + sourceRatio + parameterRatio
68
+
69
+ theorem secondaryMesh_geometry {boundary movement sourceRatio parameterRatio beta : ℝ}
70
+ (hb : 0 ≤ boundary) (hm : 0 ≤ movement) (hs : 0 ≤ sourceRatio) (hp : 0 ≤ parameterRatio)
71
+ (hbeta : 0 < beta) :
72
+ let M := secondaryMovementBudget movement sourceRatio parameterRatio
73
+ let margin := secondaryBoundaryMargin boundary beta
74
+ let delta := secondaryMeshDelta boundary M beta
75
+ 0 < margin ∧ margin ≤ 1 ∧ boundary * margin ≤ beta ∧
76
+ 0 < delta ∧ delta ≤ 1 ∧ delta * movement ≤ margin ∧
77
+ delta * sourceRatio ≤ 1 ∧ delta * parameterRatio ≤ 1 := by
78
+ intro M margin delta
79
+ have hM : 0 ≤ M := by dsimp only [M, secondaryMovementBudget]; positivity
80
+ have h := secondaryMeshAllocation_spec hb hM hbeta
81
+ change 0 < margin ∧ margin ≤ 1 ∧ boundary * margin ≤ beta ∧
82
+ 0 < delta ∧ delta ≤ 1 ∧ delta * M ≤ margin at h
83
+ have hmM : movement ≤ M := by dsimp only [M, secondaryMovementBudget]; linarith
84
+ have hsM : sourceRatio ≤ M := by dsimp only [M, secondaryMovementBudget]; linarith
85
+ have hpM : parameterRatio ≤ M := by dsimp only [M, secondaryMovementBudget]; linarith
86
+ exact ⟨h.1, h.2.1, h.2.2.1, h.2.2.2.1, h.2.2.2.2.1,
87
+ (mul_le_mul_of_nonneg_left hmM h.2.2.2.1.le).trans h.2.2.2.2.2,
88
+ ((mul_le_mul_of_nonneg_left hsM h.2.2.2.1.le).trans h.2.2.2.2.2).trans h.2.1,
89
+ ((mul_le_mul_of_nonneg_left hpM h.2.2.2.1.le).trans h.2.2.2.2.2).trans h.2.1⟩
90
+
91
+ theorem secondaryMovementBudget_le_exp {movement sourceRatio parameterRatio P : ℝ}
92
+ (hm : movement ≤ Real.exp P) (hs : sourceRatio ≤ Real.exp P)
93
+ (hp : parameterRatio ≤ Real.exp P) :
94
+ secondaryMovementBudget movement sourceRatio parameterRatio ≤ Real.exp (P + 3) := by
95
+ have hthree : (3 : ℝ) ≤ Real.exp 3 := by linarith [Real.add_one_le_exp (3 : ℝ)]
96
+ rw [Real.exp_add]
97
+ have h := mul_le_mul_of_nonneg_left hthree (Real.exp_nonneg P)
98
+ unfold secondaryMovementBudget
99
+ linarith
100
+
101
+ theorem normalizedMesh_upper_of_ratio {delta scale ratio : ℝ} (N : ℕ)
102
+ (hdelta : 0 ≤ delta) (hbudget : delta * ratio ≤ 1)
103
+ (hscale : scale ≤ ratio * (N : ℝ)) : delta * scale ≤ 2 * (N : ℝ) := by
104
+ have h := mul_le_mul_of_nonneg_left hscale hdelta
105
+ have h' := mul_le_mul_of_nonneg_right hbudget (Nat.cast_nonneg N)
106
+ nlinarith
107
+
108
+ end Erdos3
109
+
110
+ end
111
+
112
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedChildBound.lean ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.FiniteCellRefinement
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.CellRefinement
8
+
9
+ open scoped BigOperators
10
+
11
+ variable {G : Type*} [AddCommGroup G] [DecidableEq G]
12
+
13
+ theorem active_center_integral_le
14
+ (Z : Finset (G × G)) (L S : Finset G) (a f g : G → ℝ) (origin : G)
15
+ (shape : G × G → Finset G) (active : G × G → Bool) {T : ℝ}
16
+ (hf : ∀ r, 0 ≤ f r ∧ f r ≤ 1) (hg : ∀ r, 0 ≤ g r ∧ g r ≤ 1)
17
+ (hchild : ∀ z ∈ Z, active z = true → CellBilinearBound (shape z) a T) :
18
+ (𝔼 z ∈ Z, if active z = true then
19
+ centerChildIntegral L S (fun r => a (origin + r)) f g z (shape z) else 0) ≤
20
+ T * (𝔼 z ∈ Z, if active z = true then centerChildPotential L S f g z (shape z) else 0) := by
21
+ calc
22
+ _ ≤ 𝔼 z ∈ Z, T * (if active z = true then centerChildPotential L S f g z (shape z) else 0) := by
23
+ apply Finset.expect_le_expect
24
+ intro z hz
25
+ by_cases ha : active z = true
26
+ · simpa only [ite_eq_left ha] using
27
+ centerChildIntegral_le_of_cellBilinearBound L S (shape z) a f g origin z (hchild z hz ha) hf hg
28
+ · simp only [ite_eq_right ha, mul_zero, le_refl]
29
+ _ = _ := (Finset.mul_expect _ _ T).symm
30
+
31
+ theorem parent_bound_of_selected_children
32
+ (Z : Finset (G × G)) (L S : Finset G) (a f g : G → ℝ) (origin : G)
33
+ (shape : G × G → Finset G) (active : G × G → Bool)
34
+ {parent T rho Phi error : ℝ} (hT : 0 ≤ T)
35
+ (hf : ∀ r, 0 ≤ f r ∧ f r ≤ 1) (hg : ∀ r, 0 ≤ g r ∧ g r ≤ 1)
36
+ (hchild : ∀ z ∈ Z, active z = true → CellBilinearBound (shape z) a T)
37
+ (hpotential : (𝔼 z ∈ Z, if active z = true then centerChildPotential L S f g z (shape z) else 0) ≤
38
+ rho * Phi)
39
+ (hparent : parent ≤ (𝔼 z ∈ Z, if active z = true then
40
+ centerChildIntegral L S (fun r => a (origin + r)) f g z (shape z) else 0) + error) :
41
+ parent ≤ T * rho * Phi + error := by
42
+ have hsum := active_center_integral_le Z L S a f g origin shape active hf hg hchild
43
+ calc
44
+ _ ≤ T * (𝔼 z ∈ Z, if active z = true then centerChildPotential L S f g z (shape z) else 0) + error :=
45
+ hparent.trans (add_le_add hsum le_rfl)
46
+ _ ≤ T * (rho * Phi) + error := add_le_add (mul_le_mul_of_nonneg_left hpotential hT) le_rfl
47
+ _ = _ := by rw [mul_assoc]
48
+
49
+ end Erdos3.CellRefinement
50
+
51
+ end
52
+
53
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedCoefficientEvaluation.lean ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Data.Matrix.ColumnRowPartitioned
2
+ import OAI.Combinatorics.Progressions.Estimates.SplitSmoothProductProfile
3
+ import OAI.Combinatorics.Progressions.Geometry.SpatialPivotNormalization
4
+ import OAI.Combinatorics.Progressions.Probability.PivotDensityCap
5
+
6
+ namespace OAI
7
+
8
+ section
9
+
10
+ namespace Erdos3
11
+
12
+ open MeasureTheory
13
+
14
+ variable {I J N : Type*} [Fintype I] [Fintype J] [Fintype N]
15
+
16
+ noncomputable def splitFreeColumns (B : (J → ℝ) →L[ℝ] (I → ℝ))
17
+ (C : (N → ℝ) →L[ℝ] (I → ℝ)) : (J ⊕ N → ℝ) →L[ℝ] (I → ℝ) :=
18
+ B.comp (ContinuousLinearMap.pi fun j => ContinuousLinearMap.proj (.inl j)) +
19
+ C.comp (ContinuousLinearMap.pi fun n => ContinuousLinearMap.proj (.inr n))
20
+
21
+ omit [Fintype I] [Fintype J] [Fintype N] in
22
+ theorem splitFreeColumns_apply (B : (J → ℝ) →L[ℝ] (I → ℝ))
23
+ (C : (N → ℝ) →L[ℝ] (I → ℝ)) (y : J ⊕ N → ℝ) :
24
+ splitFreeColumns B C y = B (fun j => y (.inl j)) + C (fun n => y (.inr n)) := rfl
25
+
26
+ noncomputable def splitFreeProfile (f : (J → ℝ) × (I → ℝ) → ℝ)
27
+ (g : (N → ℝ) → ℝ) (p : (J ⊕ N → ℝ) × (I → ℝ)) : ℝ :=
28
+ f ((fun j => p.1 (.inl j)), p.2) * g (fun n => p.1 (.inr n))
29
+
30
+ omit [Fintype I] [Fintype J] [Fintype N] in
31
+ theorem splitFreeProfile_continuous {f : (J → ℝ) × (I → ℝ) → ℝ}
32
+ {g : (N → ℝ) → ℝ} (hf : Continuous f) (hg : Continuous g) :
33
+ Continuous (splitFreeProfile f g) := by
34
+ unfold splitFreeProfile
35
+ fun_prop
36
+
37
+ omit [Fintype I] [Fintype J] [Fintype N] in
38
+ theorem splitFreeProfile_nonneg {f : (J → ℝ) × (I → ℝ) → ℝ}
39
+ {g : (N → ℝ) → ℝ} (hf : ∀ p, 0 ≤ f p) (hg : ∀ n, 0 ≤ g n) (p) :
40
+ 0 ≤ splitFreeProfile f g p := mul_nonneg (hf _) (hg _)
41
+
42
+ theorem splitFreeProfile_zero_outside {f : (J → ℝ) × (I → ℝ) → ℝ}
43
+ {g : (N → ℝ) → ℝ} {R S : ℝ}
44
+ (hf : ∀ p, R < ‖p‖ → f p = 0) (hg : ∀ n, S < ‖n‖ → g n = 0)
45
+ (p : (J ⊕ N → ℝ) × (I → ℝ)) (hp : max R S < ‖p‖) :
46
+ splitFreeProfile f g p = 0 := by
47
+ let y : J → ℝ := fun j => p.1 (.inl j)
48
+ let n : N → ℝ := fun n => p.1 (.inr n)
49
+ by_cases hy : R < ‖(y, p.2)‖
50
+ · exact mul_eq_zero_of_left (hf _ hy) _
51
+ · have hn : S < ‖n‖ := by
52
+ by_contra! hn
53
+ have hy' : ‖(y, p.2)‖ ≤ R := le_of_not_gt hy
54
+ have hnorm : ‖p‖ ≤ max R S := by
55
+ rw [Prod.norm_def]
56
+ apply max_le
57
+ · rw [← splitCoordinates_norm p.1, Prod.norm_def]
58
+ exact max_le ((norm_fst_le (y, p.2)).trans (hy'.trans (le_max_left _ _)))
59
+ (hn.trans (le_max_right _ _))
60
+ · exact (norm_snd_le (y, p.2)).trans (hy'.trans (le_max_left _ _))
61
+ exact (not_le_of_gt hp) hnorm
62
+ exact mul_eq_zero_of_right _ (hg _ hn)
63
+
64
+ theorem splitFreeProfile_slice_integrable (A : (I → ℝ) ≃L[ℝ] (I → ℝ))
65
+ (B : (J → ℝ) →L[ℝ] (I → ℝ)) (C : (N → ℝ) →L[ℝ] (I → ℝ))
66
+ {f : (J → ℝ) × (I → ℝ) → ℝ} {g : (N → ℝ) → ℝ}
67
+ (hf : Continuous f) (hg : Continuous g) {R S : ℝ}
68
+ (hfs : ∀ p, R < ‖p‖ → f p = 0) (hgs : ∀ n, S < ‖n‖ → g n = 0)
69
+ (v : I → ℝ) :
70
+ Integrable (fun p : (J → ℝ) × (N → ℝ) =>
71
+ f (p.1, A.symm (v - (B p.1 + C p.2))) * g p.2) := by
72
+ have hc : Continuous (fun p : (J → ℝ) × (N → ℝ) =>
73
+ f (p.1, A.symm (v - (B p.1 + C p.2))) * g p.2) := by fun_prop
74
+ apply hc.integrable_of_hasCompactSupport
75
+ apply HasCompactSupport.of_support_subset_isCompact
76
+ (isCompact_closedBall (0 : (J → ℝ) × (N → ℝ)) (max R S))
77
+ intro p hp
78
+ rw [Metric.mem_closedBall, dist_zero_right]
79
+ by_contra! h
80
+ apply hp
81
+ have heq : ‖Sum.elim p.1 p.2‖ = ‖p‖ := (splitCoordinates_norm (Sum.elim p.1 p.2)).symm
82
+ have hz := splitFreeProfile_zero_outside hfs hgs
83
+ (Sum.elim p.1 p.2, A.symm (v - (B p.1 + C p.2)))
84
+ (h.trans_le (heq ▸ norm_fst_le
85
+ (Sum.elim p.1 p.2, A.symm (v - (B p.1 + C p.2)))))
86
+ exact hz
87
+
88
+ end Erdos3
89
+
90
+ end
91
+
92
+ section
93
+
94
+ namespace Erdos3
95
+
96
+ open scoped Matrix
97
+
98
+ variable {I J N : Type*} [Fintype I] [DecidableEq I]
99
+ [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N]
100
+
101
+ theorem normalizedIntegerColumns_entry (B : Matrix I J ℤ) (T : J → ℝ) (P : I → ℝ)
102
+ (i : I) (j : J) : normalizedIntegerColumns B T P i j = (P i)⁻¹ * B i j * T j := by
103
+ simp [normalizedIntegerColumns, Matrix.diagonal_mul, Matrix.mul_diagonal]
104
+
105
+ theorem normalizedIntegerColumns_fromCols (B : Matrix I J ℤ) (C : Matrix I N ℤ)
106
+ (T : J → ℝ) (Q : N → ℝ) (P : I → ℝ) :
107
+ normalizedIntegerColumns (Matrix.fromCols B C) (Sum.elim T Q) P =
108
+ Matrix.fromCols (normalizedIntegerColumns B T P) (normalizedIntegerColumns C Q P) := by
109
+ ext i k
110
+ cases k <;> simp [normalizedIntegerColumns_entry]
111
+
112
+ omit [DecidableEq I] [DecidableEq J] [DecidableEq N] in
113
+ theorem matrixSupCLM_fromCols (B : Matrix I J ℝ) (C : Matrix I N ℝ) :
114
+ matrixSupCLM (Matrix.fromCols B C) = splitFreeColumns (matrixSupCLM B) (matrixSupCLM C) := by
115
+ apply ContinuousLinearMap.ext
116
+ intro y
117
+ rw [matrixSupCLM_apply, splitFreeColumns_apply, matrixSupCLM_apply, matrixSupCLM_apply]
118
+ exact Matrix.fromCols_mulVec B C y
119
+
120
+ theorem normalizedIntegerColumns_split (B : Matrix I J ℤ) (C : Matrix I N ℤ)
121
+ (T : J → ℝ) (Q : N → ℝ) (P : I → ℝ) :
122
+ matrixSupCLM (normalizedIntegerColumns (Matrix.fromCols B C) (Sum.elim T Q) P) =
123
+ splitFreeColumns (matrixSupCLM (normalizedIntegerColumns B T P))
124
+ (matrixSupCLM (normalizedIntegerColumns C Q P)) := by
125
+ rw [normalizedIntegerColumns_fromCols, matrixSupCLM_fromCols]
126
+
127
+ end Erdos3
128
+
129
+ end
130
+
131
+ section
132
+
133
+ namespace Erdos3
134
+
135
+ open scoped NNReal
136
+
137
+ variable {I J N : Type*} [Fintype I] [Fintype J] [Fintype N]
138
+
139
+ theorem splitFreeCoordinates_norm_le (p : (J ⊕ N → ℝ) × (I → ℝ)) :
140
+ ‖((fun j => p.1 (.inl j)), p.2)‖ ≤ ‖p‖ ∧
141
+ ‖fun n => p.1 (.inr n)‖ ≤ ‖p‖ := by
142
+ have hleft : ‖fun j => p.1 (.inl j)‖ ≤ ‖p.1‖ :=
143
+ (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr fun j => norm_le_pi_norm p.1 (.inl j)
144
+ have hright : ‖fun n => p.1 (.inr n)‖ ≤ ‖p.1‖ :=
145
+ (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr fun n => norm_le_pi_norm p.1 (.inr n)
146
+ refine ⟨?_, hright.trans (norm_fst_le p)⟩
147
+ rw [Prod.norm_def]
148
+ exact max_le (hleft.trans (norm_fst_le p)) (norm_snd_le p)
149
+
150
+ theorem splitFreeProfile_lipschitz {f : (J → ℝ) × (I → ℝ) → ℝ}
151
+ {g : (N → ℝ) → ℝ} {Kf Kg Hf Hg : ℝ≥0}
152
+ (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g)
153
+ (hfcap : ∀ p, ‖f p‖ ≤ Hf) (hgcap : ∀ n, ‖g n‖ ≤ Hg) :
154
+ LipschitzWith (Hf * Kg + Hg * Kf) (splitFreeProfile f g) := by
155
+ let F := fun p : (J ⊕ N → ℝ) × (I → ℝ) => f ((fun j => p.1 (.inl j)), p.2)
156
+ let G := fun p : (J ⊕ N → ℝ) × (I → ℝ) => g (fun n => p.1 (.inr n))
157
+ have hkernel : LipschitzWith 1 (fun p : (J ⊕ N → ℝ) × (I → ℝ) =>
158
+ ((fun j => p.1 (.inl j)), p.2)) := by
159
+ apply LipschitzWith.of_dist_le_mul
160
+ intro p q
161
+ rw [NNReal.coe_one, one_mul, dist_eq_norm, dist_eq_norm]
162
+ exact (splitFreeCoordinates_norm_le (p - q)).1
163
+ have hnonkernel : LipschitzWith 1 (fun p : (J ⊕ N → ℝ) × (I → ℝ) =>
164
+ fun n => p.1 (.inr n)) := by
165
+ apply LipschitzWith.of_dist_le_mul
166
+ intro p q
167
+ rw [NNReal.coe_one, one_mul, dist_eq_norm, dist_eq_norm]
168
+ exact (splitFreeCoordinates_norm_le (p - q)).2
169
+ have hF : LipschitzWith Kf F := by simpa only [mul_one, Function.comp_def] using hf.comp hkernel
170
+ have hG : LipschitzWith Kg G := by simpa only [mul_one, Function.comp_def] using hg.comp hnonkernel
171
+ apply LipschitzWith.of_dist_le_mul
172
+ intro p q
173
+ change dist (F p * G p) (F q * G q) ≤ _
174
+ rw [dist_eq_norm]
175
+ have heq : F p * G p - F q * G q = F p * (G p - G q) + (F p - F q) * G q := by ring
176
+ rw [heq]
177
+ calc
178
+ _ ≤ ‖F p * (G p - G q)‖ + ‖(F p - F q) * G q‖ := norm_add_le _ _
179
+ _ = ‖F p‖ * ‖G p - G q‖ + ‖F p - F q‖ * ‖G q‖ := by rw [norm_mul, norm_mul]
180
+ _ ≤ Hf * (Kg * dist p q) + (Kf * dist p q) * Hg := by
181
+ apply add_le_add
182
+ · exact mul_le_mul (hfcap _) (by simpa only [dist_eq_norm] using hG.dist_le_mul p q)
183
+ (norm_nonneg _) Hf.coe_nonneg
184
+ · exact mul_le_mul (by simpa only [dist_eq_norm] using hF.dist_le_mul p q) (hgcap _)
185
+ (norm_nonneg _) (mul_nonneg Kf.coe_nonneg dist_nonneg)
186
+ _ = _ := by push_cast; ring
187
+
188
+ end Erdos3
189
+
190
+ end
191
+
192
+ section
193
+
194
+ namespace Erdos3
195
+
196
+ theorem normalizedIntegerColumns_entry_div {I J : Type*}
197
+ [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
198
+ (A : Matrix I J ℤ) (T : J → ℝ) (P : I → ℝ) (i : I) (j : J) :
199
+ normalizedIntegerColumns A T P i j = (A i j : ℝ) * T j / P i := by
200
+ rw [normalizedIntegerColumns_entry]
201
+ simp only [div_eq_mul_inv]
202
+ ring
203
+
204
+ theorem normalizedIntegerColumns_entry_bound {I J : Type*}
205
+ [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
206
+ (A : Matrix I J ℤ) (T : J → ℝ) {H C : ℝ}
207
+ (hH : 0 < H) (hT : ∀ j, 0 ≤ T j) (hA : ∀ i j, |(A i j : ℝ)| * T j ≤ C * H) :
208
+ ∀ i j, |normalizedIntegerColumns A T (fun _ => H) i j| ≤ C := by
209
+ intro i j
210
+ rw [normalizedIntegerColumns_entry_div, abs_div, abs_mul, abs_of_nonneg (hT j), abs_of_pos hH]
211
+ exact (div_le_iff₀ hH).mpr (hA i j)
212
+
213
+ theorem normalizedIntegerColumns_norm_bound {I J : Type*}
214
+ [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
215
+ (A : Matrix I J ℤ) (T : J → ℝ) {H C : ℝ}
216
+ (hH : 0 < H) (hC : 0 ≤ C) (hT : ∀ j, 0 ≤ T j)
217
+ (hA : ∀ i j, |(A i j : ℝ)| * T j ≤ C * H) :
218
+ ‖matrixSupCLM (normalizedIntegerColumns A T (fun _ => H))‖ ≤ Fintype.card J * C :=
219
+ matrixSupCLM_norm_le _ hC (normalizedIntegerColumns_entry_bound A T hH hT hA)
220
+
221
+ theorem normalizedIntegerColumns_displacement {I J : Type*}
222
+ [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
223
+ (A : Matrix I J ℤ) (T : J → ℝ) {H C R : ℝ}
224
+ (hH : 0 < H) (hC : 0 ≤ C) (_hR : 0 ≤ R) (hT : ∀ j, 0 ≤ T j)
225
+ (hA : ∀ i j, |(A i j : ℝ)| * T j ≤ C * H)
226
+ (g : (J → ℝ) → ℝ) (hg : ∀ x, R < ‖x‖ → g x = 0) :
227
+ ∀ x, g x ≠ 0 → ‖matrixSupCLM (normalizedIntegerColumns A T (fun _ => H)) x‖ ≤
228
+ Fintype.card J * C * R := by
229
+ intro x hx
230
+ have hnorm : ‖x‖ ≤ R := le_of_not_gt (fun h => hx (hg x h))
231
+ exact (ContinuousLinearMap.le_opNorm _ x).trans
232
+ (mul_le_mul (normalizedIntegerColumns_norm_bound A T hH hC hT hA) hnorm
233
+ (norm_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hC))
234
+
235
+ end Erdos3
236
+
237
+ end
238
+
239
+ section
240
+
241
+ namespace Erdos3
242
+
243
+ open MeasureTheory
244
+ open scoped NNReal ContDiff BigOperators
245
+
246
+ noncomputable def smoothSplitProfile (J I : Type*) [Fintype J] [Fintype I]
247
+ (p : (J → ℝ) × (I → ℝ)) : ℝ :=
248
+ smoothProductProfile J p.1 * smoothProductProfile I p.2
249
+
250
+ theorem smoothSplitProfile_join (J I : Type*) [Fintype J] [Fintype I]
251
+ (p : (J → ℝ) × (I → ℝ)) :
252
+ smoothSplitProfile J I p = smoothProductProfile (J ⊕ I) (Sum.elim p.1 p.2) :=
253
+ (smoothProductProfile_sum J I p.1 p.2).symm
254
+
255
+ theorem smoothSplitProfile_contDiff (J I : Type*) [Fintype J] [Fintype I] :
256
+ ContDiff ℝ ∞ (smoothSplitProfile J I) :=
257
+ ((smoothProductProfile_contDiff J).comp contDiff_fst).mul
258
+ ((smoothProductProfile_contDiff I).comp contDiff_snd)
259
+
260
+ theorem smoothSplitProfile_range (J I : Type*) [Fintype J] [Fintype I]
261
+ (p : (J → ℝ) × (I → ℝ)) :
262
+ 0 ≤ smoothSplitProfile J I p ∧ smoothSplitProfile J I p ≤ 1 := by
263
+ rw [smoothSplitProfile_join]
264
+ exact smoothProductProfile_range _ _
265
+
266
+ theorem smoothSplitProfile_norm_le (J I : Type*) [Fintype J] [Fintype I]
267
+ (p : (J → ℝ) × (I → ℝ)) : ‖smoothSplitProfile J I p‖ ≤ 1 := by
268
+ rw [smoothSplitProfile_join]
269
+ exact smoothProductProfile_norm_le _ _
270
+
271
+ theorem sumElim_norm {J I : Type*} [Fintype J] [Fintype I]
272
+ (p : (J → ℝ) × (I → ℝ)) : ‖Sum.elim p.1 p.2‖ = ‖p‖ :=
273
+ (splitCoordinates_norm (Sum.elim p.1 p.2)).symm
274
+
275
+ theorem smoothSplitProfile_zero_outside (J I : Type*) [Fintype J] [Fintype I]
276
+ (p : (J → ℝ) × (I → ℝ)) (hp : 1 < ‖p‖) : smoothSplitProfile J I p = 0 := by
277
+ rw [smoothSplitProfile_join]
278
+ exact smoothProductProfile_zero_outside _ _ (by rwa [sumElim_norm])
279
+
280
+ theorem smoothSplitProfile_integral (J I : Type*) [Fintype J] [Fintype I] :
281
+ (∫ p, smoothSplitProfile J I p) = 1 := by
282
+ change (∫ p : (J → ℝ) × (I → ℝ), smoothProductProfile J p.1 * smoothProductProfile I p.2
283
+ ∂(volume.prod volume)) = 1
284
+ rw [integral_prod_mul, smoothProductProfile_integral, smoothProductProfile_integral, one_mul]
285
+
286
+ theorem smoothSplitProfile_lipschitz (J I : Type*) [Fintype J] [Fintype I] :
287
+ LipschitzWith ((Fintype.card J + Fintype.card I) * probabilityProfileLipschitz)
288
+ (smoothSplitProfile J I) := by
289
+ have hj : LipschitzWith 1 (fun p : (J → ℝ) × (I → ℝ) => Sum.elim p.1 p.2) := by
290
+ apply LipschitzWith.of_dist_le_mul
291
+ intro p q
292
+ rw [NNReal.coe_one, one_mul, dist_eq_norm, dist_eq_norm]
293
+ have he : Sum.elim p.1 p.2 - Sum.elim q.1 q.2 = Sum.elim (p-q).1 (p-q).2 := by
294
+ funext k
295
+ cases k <;> rfl
296
+ rw [he, sumElim_norm]
297
+ have h := (smoothProductProfile_lipschitz (J ⊕ I)).comp hj
298
+ simpa only [mul_one, Fintype.card_sum, Nat.cast_add, Function.comp_def,
299
+ ← smoothSplitProfile_join] using h
300
+
301
+ theorem splitFreeProfile_smooth (J I N : Type*) [Fintype J] [Fintype I] [Fintype N] :
302
+ splitFreeProfile (smoothSplitProfile J I) (smoothProductProfile N) =
303
+ smoothSplitProfile (J ⊕ N) I := by
304
+ funext p
305
+ have h := smoothProductProfile_sum J N (fun j => p.1 (.inl j)) (fun n => p.1 (.inr n))
306
+ have he : Sum.elim (fun j => p.1 (.inl j)) (fun n => p.1 (.inr n)) = p.1 := by
307
+ funext k
308
+ cases k <;> rfl
309
+ rw [he] at h
310
+ simp only [splitFreeProfile, smoothSplitProfile, h]
311
+ ring
312
+
313
+ end Erdos3
314
+
315
+ end
316
+
317
+ section
318
+
319
+ namespace Erdos3
320
+
321
+ open MeasureTheory
322
+ open scoped NNReal
323
+
324
+ noncomputable def selectedFreeFirstEquiv {I J : Type*} [Fintype I] (s : I ↪ J) :
325
+ UnselectedColumn s ⊕ I ≃ J :=
326
+ (Equiv.sumComm _ _).trans (selectedColumnEquiv s)
327
+
328
+ noncomputable def selectedCoefficientEquiv {I J : Type*} [Fintype I]
329
+ (s : I ↪ J) (R : Type*) : (UnselectedColumn s → R) × (I → R) ≃ (J → R) :=
330
+ (Equiv.sumPiEquivProdPi (fun _ : UnselectedColumn s ⊕ I => R)).symm.trans
331
+ (Equiv.arrowCongr (selectedFreeFirstEquiv s) (Equiv.refl R))
332
+
333
+ theorem selectedCoefficientEquiv_apply {I J R : Type*} [Fintype I]
334
+ (s : I ↪ J) (p : (UnselectedColumn s → R) × (I → R)) (j : J) :
335
+ selectedCoefficientEquiv s R p j =
336
+ Sum.elim p.1 p.2 ((selectedFreeFirstEquiv s).symm j) := rfl
337
+
338
+ theorem selectedCoefficientEquiv_norm {I J : Type*} [Fintype I] [Fintype J]
339
+ (s : I ↪ J) (p : (UnselectedColumn s → ℝ) × (I → ℝ)) :
340
+ ‖selectedCoefficientEquiv s ℝ p‖ = ‖p‖ := by
341
+ change ‖(Sum.elim p.1 p.2) ∘ (selectedFreeFirstEquiv s).symm‖ = _
342
+ exact ((selectedFreeFirstEquiv s).symm.surjective.pi_norm_comp (Sum.elim p.1 p.2)).trans
343
+ (sumElim_norm p)
344
+
345
+ theorem selectedCoefficientEquiv_lipschitz {I J : Type*} [Fintype I] [Fintype J]
346
+ (s : I ↪ J) : LipschitzWith 1 (selectedCoefficientEquiv s ℝ) := by
347
+ apply LipschitzWith.of_dist_le_mul
348
+ intro p q
349
+ rw [NNReal.coe_one, one_mul, dist_eq_norm, dist_eq_norm]
350
+ have he : selectedCoefficientEquiv s ℝ p - selectedCoefficientEquiv s ℝ q =
351
+ selectedCoefficientEquiv s ℝ (p - q) := by
352
+ funext j
353
+ simp only [Pi.sub_apply, selectedCoefficientEquiv_apply]
354
+ cases (selectedFreeFirstEquiv s).symm j <;> rfl
355
+ rw [he, selectedCoefficientEquiv_norm]
356
+
357
+ noncomputable def selectedCoefficientProfile {I J : Type*} [Fintype I]
358
+ (s : I ↪ J) (f : (J → ℝ) → ℝ) : (UnselectedColumn s → ℝ) × (I → ℝ) → ℝ :=
359
+ f ∘ selectedCoefficientEquiv s ℝ
360
+
361
+ theorem selectedCoefficientProfile_nonneg {I J : Type*} [Fintype I]
362
+ (s : I ↪ J) {f : (J → ℝ) → ℝ} (hf : ∀ x, 0 ≤ f x) :
363
+ ∀ p, 0 ≤ selectedCoefficientProfile s f p := fun p => hf (selectedCoefficientEquiv s ℝ p)
364
+
365
+ theorem selectedCoefficientProfile_norm_le {I J : Type*} [Fintype I]
366
+ (s : I ↪ J) {f : (J → ℝ) → ℝ} {H : ℝ} (hf : ∀ x, ‖f x‖ ≤ H) :
367
+ ∀ p, ‖selectedCoefficientProfile s f p‖ ≤ H := fun p => hf (selectedCoefficientEquiv s ℝ p)
368
+
369
+ theorem selectedCoefficientProfile_lipschitz {I J : Type*} [Fintype I] [Fintype J]
370
+ (s : I ↪ J) {f : (J → ℝ) → ℝ} {K : ℝ≥0} (hf : LipschitzWith K f) :
371
+ LipschitzWith K (selectedCoefficientProfile s f) := by
372
+ simpa only [mul_one, selectedCoefficientProfile] using hf.comp (selectedCoefficientEquiv_lipschitz s)
373
+
374
+ theorem selectedCoefficientProfile_zero_outside {I J : Type*} [Fintype I] [Fintype J]
375
+ (s : I ↪ J) {f : (J → ℝ) → ℝ} {R : ℝ}
376
+ (hf : ∀ x, R < ‖x‖ → f x = 0) :
377
+ ∀ p, R < ‖p‖ → selectedCoefficientProfile s f p = 0 := by
378
+ intro p hp
379
+ exact hf _ (by rwa [selectedCoefficientEquiv_norm])
380
+
381
+ theorem selectedCoefficientProfile_integral {I J : Type*} [Fintype I] [Fintype J]
382
+ (s : I ↪ J) (f : (J → ℝ) → ℝ) :
383
+ (∫ p, selectedCoefficientProfile s f p) = ∫ x, f x := by
384
+ let e := selectedFreeFirstEquiv s
385
+ have hsum := (volume_measurePreserving_sumPiEquivProdPi_symm
386
+ (fun _ : UnselectedColumn s ⊕ I => ℝ)).integral_comp
387
+ (MeasurableEquiv.sumPiEquivProdPi (fun _ : UnselectedColumn s ⊕ I => ℝ)).symm.measurableEmbedding
388
+ (fun z => f (z ∘ e.symm))
389
+ have hpi := (volume_measurePreserving_piCongrLeft (fun _ : J => ℝ) e).integral_comp
390
+ (MeasurableEquiv.piCongrLeft (fun _ : J => ℝ) e).measurableEmbedding f
391
+ apply hsum.trans
392
+ simpa only [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft, Equiv.piCongrLeft',
393
+ Equiv.coe_fn_symm_mk, eq_rec_constant, Function.comp_def] using hpi
394
+
395
+ end Erdos3
396
+
397
+ end
398
+
399
+ section
400
+
401
+ namespace Erdos3
402
+
403
+ variable {I J R : Type*} [Fintype I] (s : I ↪ J)
404
+
405
+ theorem selectedCoefficientEquiv_on_selected
406
+ (p : (UnselectedColumn s → R) × (I → R)) (i : I) :
407
+ selectedCoefficientEquiv s R p (s i) = p.2 i := by
408
+ have h : selectedFreeFirstEquiv s (Sum.inr i) = s i := rfl
409
+ rw [← h, selectedCoefficientEquiv_apply, Equiv.symm_apply_apply]
410
+ rfl
411
+
412
+ theorem selectedCoefficientEquiv_on_unselected
413
+ (p : (UnselectedColumn s → R) × (I → R)) (i : UnselectedColumn s) :
414
+ selectedCoefficientEquiv s R p i.val = p.1 i := by
415
+ have h : selectedFreeFirstEquiv s (Sum.inl i) = i.val := rfl
416
+ rw [← h, selectedCoefficientEquiv_apply, Equiv.symm_apply_apply]
417
+ rfl
418
+
419
+ theorem selectedCoefficientEquiv_eq_of_coordinates
420
+ (f : J → R) (p : (UnselectedColumn s → R) × (I → R))
421
+ (hfree : ∀ i : UnselectedColumn s, f i.val = p.1 i)
422
+ (hselected : ∀ i, f (s i) = p.2 i) :
423
+ f = selectedCoefficientEquiv s R p := by
424
+ classical
425
+ funext j
426
+ by_cases hj : j ∈ Set.range s
427
+ · obtain ⟨i, rfl⟩ := hj
428
+ exact (hselected i).trans (selectedCoefficientEquiv_on_selected s p i).symm
429
+ · exact (hfree ⟨j, hj⟩).trans (selectedCoefficientEquiv_on_unselected s p ⟨j, hj⟩).symm
430
+
431
+ end Erdos3
432
+
433
+ end
434
+
435
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedImageCorrections.lean ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Linear.RationalTaggedSpanProjection
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped Matrix NNReal
10
+
11
+ theorem exists_selected_image_corrections
12
+ {η ι κ σ : Type*} [Fintype η] [Fintype ι] [Fintype κ]
13
+ (A : Matrix η κ ℚ) (ρ : ι → η) {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l)
14
+ (hA : ∀ i j, RationalHeightLE (A i j) H)
15
+ {p : ℝ} (hp : 0 ≤ p) (hη : (Fintype.card η : ℝ) ≤ p)
16
+ (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p)
17
+ (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p)
18
+ (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget p) ≤ T i) :
19
+ ∃ (S : Matrix κ ι ℚ) (m : ℕ), 0 < m ∧
20
+ (m : ℝ) ≤ Real.exp ((p + 2) ^ 3 + (p + 2) ^ 36) ∧
21
+ ∀ (α : σ →₀ ℕ), α ≠ 0 → ∀ (a b : ι → ℝ) (x : η → ℝ),
22
+ x ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) →
23
+ ‖a‖ ≤ Real.exp p / monomialScale T α → b ∈ realDenominatorGrid l →
24
+ (∀ i, x (ρ i) = a i + b i) →
25
+ let e := (fun i j => (A i j : ℝ)) *ᵥ ((fun i j => (S i j : ℝ)) *ᵥ a)
26
+ let q := (fun i j => (A i j : ℝ)) *ᵥ ((fun i j => (S i j : ℝ)) *ᵥ b)
27
+ e ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) ∧
28
+ q ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) ∧
29
+ (∀ i, e (ρ i) = a i) ∧ (∀ i, q (ρ i) = b i) ∧
30
+ ‖e‖ ≤ Real.exp ((p + 2) ^ 3 + (p + 2) ^ 18 + p) / monomialScale T α ∧
31
+ q ∈ realDenominatorGrid m ∧
32
+ x - e - q ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) ∧
33
+ ∀ i, (x - e - q) (ρ i) = 0 := by
34
+ let C : Matrix ι κ ℚ := fun i j => A (ρ i) j
35
+ obtain ⟨S, m, hm, hmp, hsolve⟩ := exists_controlled_linear_splitting C hH hl
36
+ (fun i j => hA (ρ i) j) hp hι hκ hHp hlp T hT
37
+ have hHp' : (H : ℝ) ≤ Real.exp ((p + 2) ^ 1) :=
38
+ hHp.trans (Real.exp_le_exp.mpr (by simp))
39
+ have hden : (matrixDenominator A : ℝ) ≤ Real.exp ((p + 2) ^ 3) :=
40
+ matrixDenominator_le_exp_power A hp 1 hη hκ
41
+ (fun i j => (Nat.cast_le.mpr (hA i j).2).trans hHp')
42
+ have hfac : ((Fintype.card κ : ℝ) + 1) * (H + 1) ≤ Real.exp ((p + 2) ^ 3) := by
43
+ apply le_trans _ (matrix_weighted_factor_le_exp_power (Fintype.card κ) hp hκ 1 (by decide))
44
+ exact mul_le_mul_of_nonneg_left (add_le_add hHp' le_rfl) (by positivity)
45
+ have hnorm (y : κ → ℝ) :
46
+ ‖(fun i j => (A i j : ℝ)) *ᵥ y‖ ≤ Real.exp ((p + 2) ^ 3) * ‖y‖ :=
47
+ (norm_matrix_mulVec_le _ (H : ℝ≥0) (fun i j => (hA i j).abs_real_le) y).trans
48
+ (mul_le_mul_of_nonneg_right hfac (norm_nonneg y))
49
+ refine ⟨S, matrixDenominator A * m, Nat.mul_pos (matrixDenominator_pos A) hm, ?_, ?_⟩
50
+ · rw [Nat.cast_mul]
51
+ exact (mul_le_mul hden hmp (Nat.cast_nonneg _) (Real.exp_pos _).le).trans_eq
52
+ (Real.exp_add _ _).symm
53
+ · intro α hα a b x hx ha hb hselect e q
54
+ obtain ⟨z, hz⟩ := hx
55
+ have hC : (fun i j => (C i j : ℝ)) *ᵥ z = a + b := by
56
+ funext i
57
+ exact (congrFun hz (ρ i)).trans (hselect i)
58
+ obtain ⟨hSa, hSb, hslow, hgrid, _⟩ := hsolve α hα a b z ha hb hC
59
+ have he : e ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) :=
60
+ ⟨(fun i j => (S i j : ℝ)) *ᵥ a, rfl⟩
61
+ have hq : q ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) :=
62
+ ⟨(fun i j => (S i j : ℝ)) *ᵥ b, rfl⟩
63
+ have heq (i : ι) : e (ρ i) = a i := congrFun hSa i
64
+ have hqq (i : ι) : q (ρ i) = b i := congrFun hSb i
65
+ refine ⟨he, hq, heq, hqq, ?_, real_matrix_denominator_grid A m _ hgrid,
66
+ Submodule.sub_mem _ (Submodule.sub_mem _ ⟨z, hz⟩ he) hq, ?_⟩
67
+ · calc
68
+ ‖e‖ ≤ Real.exp ((p + 2) ^ 3) * ‖(fun i j => (S i j : ℝ)) *ᵥ a‖ := hnorm _
69
+ _ ≤ Real.exp ((p + 2) ^ 3) *
70
+ (Real.exp ((p + 2) ^ 18 + p) / monomialScale T α) :=
71
+ mul_le_mul_of_nonneg_left hslow (Real.exp_pos _).le
72
+ _ = _ := by
73
+ rw [← mul_div_assoc, ← Real.exp_add]
74
+ congr 2
75
+ ring
76
+ · intro i
77
+ change x (ρ i) - e (ρ i) - q (ρ i) = 0
78
+ rw [hselect i, heq i, hqq i]
79
+ ring
80
+
81
+ end Erdos3
82
+
83
+ end
84
+
85
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointLifts.lean ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.SelectedCenteredJointSupport
2
+ import OAI.Combinatorics.Progressions.Lattices.RoundedAffineLifts
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3.VectorPolynomial
9
+
10
+ open Module Submodule
11
+
12
+ variable {m : ℕ} {G V : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)]
13
+ variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)]
14
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
15
+ variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
16
+ variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j)))
17
+ variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j)))
18
+ variable (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (L₀ : ℕ)
19
+
20
+ theorem translatedSelectedPhysicalDensity_lifts
21
+ (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j)
22
+ (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖)
23
+ (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4)
24
+ (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ))
25
+ (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j))
26
+ (hm : ∀ j d, coefficients (p j) d ∈ U j)
27
+ (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) (c : ∀ j, U j)
28
+ (hc : center = -(QuotientAddGroup.mk' (coefficientIntegerLattice U)
29
+ (constantCoefficientArray U (fun s => c s.1))))
30
+ (z : Option (LayerSamplerVariables G I n B) × V → ℤ)
31
+ (hz : translatedSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ center p hm z ≠ 0) :
32
+ HasQuarterAffinePolynomialLifts p (fun j => (c j).val) (fun k v => (z (k,v) : ℝ))
33
+ (layerSamplerBox B U b (selectedLayerSamplerScale B U b R σ hR hσ L₀)) := by
34
+ apply allocatedAffineDensity_quarter_lifts B U b hb o hR hσ
35
+ (selectedLayerSamplerScale B U b R σ hR hσ L₀) p hm c hσ1 C hC hchart hsmall hp
36
+ change selectedCoefficientDensity B U b hb o R σ hR hσ L₀
37
+ (centeredAffineCoefficientTorus U p hm c (fun k v => (z (k,v) : ℝ))) ≠ 0
38
+ rw [centeredAffineCoefficientTorus_eq_subtractive, ← hc]
39
+ exact hz
40
+
41
+ end Erdos3.VectorPolynomial
42
+
43
+ end
44
+
45
+ section
46
+
47
+ namespace Erdos3.VectorPolynomial
48
+
49
+ open Module Submodule BooleanCubeKernel
50
+ open scoped BigOperators
51
+
52
+ variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X]
53
+ variable {I : Fin m → Type*} [∀ j, Fintype (I j)]
54
+ variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)]
55
+ variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ))
56
+ variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ)
57
+ variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j)))
58
+ variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j)))
59
+ variable (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (L₀ : ℕ)
60
+ variable (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j)
61
+
62
+ noncomputable def jointSelectedPhysicalDensity
63
+ (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) (a : X → ℤ) :
64
+ (Option (LayerSamplerVariables G I n B) × X → ℤ) → ℝ :=
65
+ translatedSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ (coefficientConstantCenter U center)
66
+ (fun j => translate (fun i => (a i : ℝ)) (p j))
67
+ (fun j => coefficients_translate_mem (U j) (fun i => (a i : ℝ)) (p j) (hm j))
68
+
69
+ variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))]
70
+
71
+ omit [Fintype X] in
72
+ theorem jointSelectedPhysicalDensity_nonneg
73
+ (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) (a : X → ℤ)
74
+ (z : Option (LayerSamplerVariables G I n B) × X → ℤ) :
75
+ 0 ≤ jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center a z :=
76
+ translatedSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ _ _ _ _
77
+
78
+ theorem exists_selectedJointFiniteLaw_lifts
79
+ (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j)
80
+ (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖)
81
+ (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4)
82
+ (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j))
83
+ (A : Finset (X → ℤ)) (hA : A.Nonempty)
84
+ (modulus : X → ℕ) (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X modulus))
85
+ (W : Option (LayerSamplerVariables G I n B) × X → ℝ) (hW : ∀ z, 0 < W z)
86
+ (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T W z)
87
+ (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U)
88
+ (hD : 0 < selectedJointDensityMass A modulus T W
89
+ (jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center)) :
90
+ ∃ c : ∀ j, U j, coefficientConstantCenter U center =
91
+ -(QuotientAddGroup.mk' (coefficientIntegerLattice U)
92
+ (constantCoefficientArray U (fun s => c s.1))) ∧
93
+ ∀ z : A × rectangularWeightIndices 0 W 1,
94
+ 0 < (selectedJointFiniteLaw A hA modulus T W hW hZ
95
+ (jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center)
96
+ (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ p hm center) hD).weight z →
97
+ HasQuarterAffinePolynomialLifts p (fun j => (c j).val)
98
+ (fun k i => (jointIntegerFrame (z.1.val,z.2.val) k i : ℝ))
99
+ (layerSamplerBox B U b (selectedLayerSamplerScale B U b R σ hR hσ L₀)) := by
100
+ obtain ⟨c, hc⟩ := exists_subtractive_constant_center U center
101
+ refine ⟨c, hc, ?_⟩
102
+ intro z hz
103
+ have hd := (selectedJointFiniteLaw_support A hA modulus T W hW hZ
104
+ (jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center)
105
+ (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ p hm center) hD z hz).2
106
+ apply HasQuarterAffinePolynomialLifts.joint_frame z.1.val z.2.val
107
+ exact translatedSelectedPhysicalDensity_lifts B U b hb o R σ hR hσ L₀ hσ1 C hC hchart hsmall
108
+ (fun j => translate (fun i => (z.1.val i : ℝ)) (p j))
109
+ (fun j => degreeLE_translate (1 : X → ℕ) (fun _ => by norm_num) _ (p j) (hp j))
110
+ (fun j => coefficients_translate_mem (U j) (fun i => (z.1.val i : ℝ)) (p j) (hm j))
111
+ (coefficientConstantCenter U center) c hc z.2.val hd.ne'
112
+
113
+ end Erdos3.VectorPolynomial
114
+
115
+ end
116
+
117
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointSiteDomination.lean ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Probability.PositiveDensityNormalization
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open BooleanCubeKernel
10
+ open scoped BigOperators Classical
11
+
12
+ theorem selectedJointFiniteLaw_site_excess
13
+ {K I X T : Type*} [Fintype K] [Fintype I]
14
+ [Fintype X] [Nonempty X] [Fintype T] [Nonempty T]
15
+ (A : Finset (I → ℤ)) (hA : A.Nonempty)
16
+ (modulus : I → ℕ) (cells : Finset (ColumnResiduePattern (Option K) I modulus))
17
+ (W : Option K × I → ℝ) (hW : ∀ z, 0 < W z)
18
+ (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus cells W z)
19
+ (D : (I → ℤ) → (Option K × I → ℤ) → ℝ) (hD : ∀ a z, 0 ≤ D a z)
20
+ (htotal : 0 < selectedJointDensityMass A modulus cells W D)
21
+ (hlower : 1 / 2 ≤ selectedJointDensityMass A modulus cells W D)
22
+ (e : X → I → ℝ) (he : Function.Injective e)
23
+ (root : T → K → ℤ)
24
+ (F : (A × rectangularWeightIndices 0 W 1) → T → X)
25
+ (hF : ∀ z t, e (F z t) = (fun i => (z.1.val i : ℝ)) + physicalAffineSite (root t) z.2.val)
26
+ (hcard : (Fintype.card X : ℝ) / A.card ≤ 2)
27
+ {M ε : ℝ} (hM : 0 ≤ M)
28
+ (hlocal : ∀ (a : I → ℤ) (t : T) (φ : (I → ℝ) → ℝ),
29
+ (∀ u, φ u ∈ Set.Icc (0 : ℝ) 1) →
30
+ (∑' z, (selectedResidueSmoothPMF modulus cells W hW hZ z).toReal *
31
+ (φ ((fun i => (a i : ℝ)) + physicalAffineSite (root t) z) * D a z)) ≤
32
+ M * (∑' z, (selectedResidueSmoothPMF modulus cells W hW hZ z).toReal *
33
+ φ ((fun i => (a i : ℝ)) + physicalAffineSite (root t) z)) + ε) :
34
+ (FiniteProbabilityWeights.uniform X).excessMass
35
+ ((selectedJointFiniteLaw A hA modulus cells W hW hZ D hD htotal).siteLaw F)
36
+ (4 * M) ≤ 2 * ε := by
37
+ let : Nonempty A := hA.to_subtype
38
+ let q := selectedResidueFiniteLaw modulus cells W hW hZ
39
+ apply FiniteProbabilityWeights.siteLaw_excessMass_le_of_test_bound
40
+ intro φ hφ t
41
+ let ψ : (I → ℝ) → ℝ := fun u => φ (Function.invFun e u)
42
+ have hψ (u) : ψ u ∈ Set.Icc (0 : ℝ) 1 := hφ _
43
+ have hvalue (z : A × rectangularWeightIndices 0 W 1) :
44
+ ψ ((fun i => (z.1.val i : ℝ)) + physicalAffineSite (root t) z.2.val) = φ (F z t) := by
45
+ rw [← hF z t]
46
+ exact congrArg φ (Function.leftInverse_invFun he (F z t))
47
+ have hinj (z : rectangularWeightIndices 0 W 1) :
48
+ Function.Injective (fun a : A => F (a, z) t) := by
49
+ intro a b hab
50
+ have hc := congrArg e hab
51
+ rw [hF, hF] at hc
52
+ have hd := add_right_cancel hc
53
+ apply Subtype.ext
54
+ funext i
55
+ exact_mod_cast congrFun hd i
56
+ have hlocal' (a : A) :
57
+ q.mean (fun z => D a.val z.val * φ (F (a, z) t)) ≤
58
+ M * q.mean (fun z => φ (F (a, z) t)) + ε := by
59
+ have h := hlocal a.val t ψ hψ
60
+ rw [← selectedResidueFiniteLaw_mean, ← selectedResidueFiniteLaw_mean] at h
61
+ have hv (z : rectangularWeightIndices 0 W 1) :
62
+ ψ ((fun i => (a.val i : ℝ)) + physicalAffineSite (root t) z.val) = φ (F (a, z) t) :=
63
+ hvalue (a, z)
64
+ simpa only [hv, mul_comm] using h
65
+ have hz : 0 < ((FiniteProbabilityWeights.uniform A).prod q).mean
66
+ (fun z => D z.1.val z.2.val) := by
67
+ change 0 < (selectedJointReference A hA modulus cells W hW hZ).mean _
68
+ rw [selectedJointReference_densityMass]
69
+ exact htotal
70
+ have hl : 1 / 2 ≤ ((FiniteProbabilityWeights.uniform A).prod q).mean
71
+ (fun z => D z.1.val z.2.val) := by
72
+ change 1 / 2 ≤ (selectedJointReference A hA modulus cells W hW hZ).mean _
73
+ rw [selectedJointReference_densityMass]
74
+ exact hlower
75
+ have h := FiniteProbabilityWeights.uniform_base_reweight_test_le q
76
+ (fun z => D z.1.val z.2.val) (fun z => hD z.1.val z.2.val) hz
77
+ (fun z => F z t) hinj φ (fun x => (hφ x).1) hM (by norm_num : (0 : ℝ) < 1 / 2)
78
+ hl hlocal'
79
+ change (selectedJointFiniteLaw A hA modulus cells W hW hZ D hD htotal).mean
80
+ (fun z => φ (F z t)) ≤ _ at h
81
+ apply h.trans
82
+ have hn := (FiniteProbabilityWeights.uniform X).mean_nonneg (fun x => (hφ x).1)
83
+ have hr : (Fintype.card X : ℝ) / Fintype.card A ≤ 2 := by simpa using hcard
84
+ have hm := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hr hM) hn
85
+ nlinarith
86
+
87
+ end Erdos3
88
+
89
+ end
90
+
91
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedJointWeightedReferenceComparison.lean ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Probability.PositiveDensityNormalization
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped BigOperators
10
+
11
+ theorem selectedJointFiniteLaw_weighted_reference_comparison
12
+ {B K I : Type*} [Fintype K] [Fintype I]
13
+ (A : Finset B) (hA : A.Nonempty)
14
+ (modulus : I → ℕ) (T : Finset (ColumnResiduePattern K I modulus))
15
+ (V : K × I → ℝ) (hV : ∀ z, 0 < V z)
16
+ (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z)
17
+ (D : B → (K × I → ℤ) → ℝ) (hD0 : ∀ a z, 0 ≤ D a z)
18
+ (hD : 0 < selectedJointDensityMass A modulus T V D)
19
+ (f : B → (K × I → ℤ) → ℂ) (hf : ∀ a z, ‖f a z‖ ≤ 1)
20
+ {ε η : ℝ}
21
+ (hmass : ∀ a, |selectedResidueDensityMass modulus T V (D a) - 1| ≤ η)
22
+ (htest : ∀ a,
23
+ ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) *
24
+ (f a z * (D a z : ℂ))) -
25
+ ∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * f a z‖ ≤ ε) :
26
+ ‖(selectedJointFiniteLaw A hA modulus T V hV hZ D hD0 hD).complexMean
27
+ (fun z => f z.1.val z.2.val) -
28
+ (selectedJointReference A hA modulus T V hV hZ).complexMean
29
+ (fun z => f z.1.val z.2.val)‖ ≤ η + ε := by
30
+ let p := FiniteProbabilityWeights.uniformFinset A hA
31
+ let q := selectedResidueFiniteLaw modulus T V hV hZ
32
+ let test (z : A × rectangularWeightIndices 0 V 1) := f z.1.val z.2.val
33
+ let density (z : A × rectangularWeightIndices 0 V 1) := D z.1.val z.2.val
34
+ have hraw := p.norm_complexMean_sub_le
35
+ (fun a => q.complexMean (fun z => (D a.val z.val : ℂ) * f a.val z.val))
36
+ (fun a => q.complexMean (fun z => f a.val z.val)) (fun _ => ε) (by
37
+ intro a _
38
+ change ‖(selectedResidueFiniteLaw modulus T V hV hZ).complexMean
39
+ (fun z => (D a.val z.val : ℂ) * f a.val z.val) -
40
+ (selectedResidueFiniteLaw modulus T V hV hZ).complexMean
41
+ (fun z => f a.val z.val)‖ ≤ ε
42
+ rw [selectedResidueFiniteLaw_complexMean modulus T V hV hZ
43
+ (fun z => (D a.val z : ℂ) * f a.val z),
44
+ selectedResidueFiniteLaw_complexMean modulus T V hV hZ (f a.val)]
45
+ simpa only [mul_comm (D a.val _ : ℂ)] using htest a.val)
46
+ rw [p.mean_const] at hraw
47
+ have hraw' : ‖(p.prod q).complexMean (fun z => (density z : ℂ) * test z) -
48
+ (p.prod q).complexMean test‖ ≤ ε := by
49
+ simpa only [FiniteProbabilityWeights.complexMean_prod, density, test] using hraw
50
+ have hglobal : 0 < (selectedJointReference A hA modulus T V hV hZ).mean density := by
51
+ rw [selectedJointReference_densityMass]
52
+ exact hD
53
+ have hnorm := (selectedJointReference A hA modulus T V hV hZ).normalizedDensityTest_remove_normalization
54
+ density (fun z => hD0 z.1.val z.2.val) hglobal test (fun z => hf z.1.val z.2.val)
55
+ rw [selectedJointReference_densityMass] at hnorm
56
+ have hnorm' := hnorm.trans (selectedJointDensityMass_close A hA modulus T V D hmass)
57
+ rw [selectedJointFiniteLaw_complexMean]
58
+ exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hnorm' hraw')
59
+
60
+ theorem selectedJointFiniteLaw_weighted_reference_real_comparison
61
+ {B K I : Type*} [Fintype K] [Fintype I]
62
+ (A : Finset B) (hA : A.Nonempty)
63
+ (modulus : I → ℕ) (T : Finset (ColumnResiduePattern K I modulus))
64
+ (V : K × I → ℝ) (hV : ∀ z, 0 < V z)
65
+ (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z)
66
+ (D : B → (K × I → ℤ) → ℝ) (hD0 : ∀ a z, 0 ≤ D a z)
67
+ (hD : 0 < selectedJointDensityMass A modulus T V D)
68
+ (f : B → (K × I → ℤ) → ℝ) (hf : ∀ a z, |f a z| ≤ 1)
69
+ {ε η : ℝ}
70
+ (hmass : ∀ a, |selectedResidueDensityMass modulus T V (D a) - 1| ≤ η)
71
+ (htest : ∀ a,
72
+ |(∑' z, (selectedResidueSmoothPMF modulus T V hV hZ z).toReal * (f a z * D a z)) -
73
+ ∑' z, (selectedResidueSmoothPMF modulus T V hV hZ z).toReal * f a z| ≤ ε) :
74
+ |(selectedJointFiniteLaw A hA modulus T V hV hZ D hD0 hD).mean
75
+ (fun z => f z.1.val z.2.val) -
76
+ (selectedJointReference A hA modulus T V hV hZ).mean
77
+ (fun z => f z.1.val z.2.val)| ≤ η + ε := by
78
+ have h := selectedJointFiniteLaw_weighted_reference_comparison A hA modulus T V hV hZ
79
+ D hD0 hD (fun a z => (f a z : ℂ))
80
+ (fun a z => by simpa only [Complex.norm_real, Real.norm_eq_abs] using hf a z)
81
+ hmass (fun a => by
82
+ simpa only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub,
83
+ Complex.norm_real, Real.norm_eq_abs] using htest a)
84
+ simpa only [FiniteProbabilityWeights.complexMean_ofReal, ← Complex.ofReal_sub,
85
+ Complex.norm_real, Real.norm_eq_abs] using h
86
+
87
+ end Erdos3
88
+
89
+ end
90
+
91
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedOutputL1.lean ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Integral.Prod
2
+ import OAI.Combinatorics.Progressions.Geometry.ContinuousOutputBox
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 NNReal
13
+
14
+ noncomputable def selectedOutputSlice {I J : Type*} [Fintype J]
15
+ (s : J ↪ I) (f : (I → ℝ) → ℝ) (x : UnselectedColumn s → ℝ) (y : J → ℝ) : ℝ :=
16
+ f (selectedCoefficientEquiv s ℝ (x, y))
17
+
18
+ theorem selectedOutputSlice_lipschitz {I J : Type*} [Fintype I] [Fintype J]
19
+ (s : J ↪ I) {f : (I → ℝ) → ℝ} {K : ℝ≥0} (hf : LipschitzWith K f)
20
+ (x : UnselectedColumn s → ℝ) : LipschitzWith K (selectedOutputSlice s f x) := by
21
+ change LipschitzWith K (selectedCoefficientProfile s f ∘ Prod.mk x)
22
+ simpa only [mul_one] using
23
+ (selectedCoefficientProfile_lipschitz s hf).comp (LipschitzWith.prodMk_left x)
24
+
25
+ theorem selectedOutputSlice_support_right {I J : Type*} [Fintype I] [Fintype J]
26
+ (s : J ↪ I) {f : (I → ℝ) → ℝ} {R : ℝ} (hf : ∀ v, R < ‖v‖ → f v = 0)
27
+ (x : UnselectedColumn s → ℝ) (y : J → ℝ) (hy : R < ‖y‖) :
28
+ selectedOutputSlice s f x y = 0 := by
29
+ apply hf
30
+ rw [selectedCoefficientEquiv_norm]
31
+ exact hy.trans_le (norm_snd_le (x, y))
32
+
33
+ theorem selectedOutputSlice_support_left {I J : Type*} [Fintype I] [Fintype J]
34
+ (s : J ↪ I) {f : (I → ℝ) → ℝ} {R : ℝ} (hf : ∀ v, R < ‖v‖ → f v = 0)
35
+ (x : UnselectedColumn s → ℝ) (y : J → ℝ) (hx : R < ‖x‖) :
36
+ selectedOutputSlice s f x y = 0 := by
37
+ apply hf
38
+ rw [selectedCoefficientEquiv_norm]
39
+ exact hx.trans_le (norm_fst_le (x, y))
40
+
41
+ noncomputable def retainedSelectedOutputEquiv {W I J : Type*} [MeasurableSpace W]
42
+ [Fintype I] [Fintype J] (s : J ↪ I) :
43
+ (W × (UnselectedColumn s → ℝ)) × (J → ℝ) ≃ᵐ W × (I → ℝ) :=
44
+ MeasurableEquiv.prodAssoc.trans ((MeasurableEquiv.refl W).prodCongr (selectedCoefficientMeasurableEquiv s))
45
+
46
+ theorem retainedSelectedOutputEquiv_preserving {W I J : Type*} [MeasurableSpace W]
47
+ [Fintype I] [Fintype J] (s : J ↪ I) (μ : Measure W) [SFinite μ] :
48
+ MeasurePreserving (retainedSelectedOutputEquiv (W := W) s)
49
+ ((μ.prod volume).prod volume) (μ.prod volume) :=
50
+ ((MeasurePreserving.id μ).prod (selectedCoefficientMeasurableEquiv_preserving s)).comp
51
+ (measurePreserving_prodAssoc μ volume volume)
52
+
53
+ theorem retainedSelectedOutput_integrable {W I J : Type*} [MeasurableSpace W]
54
+ [Fintype I] [Fintype J] (s : J ↪ I) (μ : Measure W) [SFinite μ]
55
+ {f : W × (I → ℝ) → ℝ} (hf : Integrable f (μ.prod volume)) :
56
+ Integrable (fun p : (W × (UnselectedColumn s → ℝ)) × (J → ℝ) =>
57
+ f (p.1.1, selectedCoefficientEquiv s ℝ (p.1.2, p.2))) ((μ.prod volume).prod volume) :=
58
+ (retainedSelectedOutputEquiv_preserving s μ).integrable_comp_of_integrable hf
59
+
60
+ theorem retainedSelectedOutput_integral {W I J : Type*} [MeasurableSpace W]
61
+ [Fintype I] [Fintype J] (s : J ↪ I) (μ : Measure W) [SFinite μ] (f : W × (I → ℝ) → ℝ) :
62
+ (∫ p : (W × (UnselectedColumn s → ℝ)) × (J → ℝ),
63
+ f (p.1.1, selectedCoefficientEquiv s ℝ (p.1.2, p.2)) ∂(μ.prod volume).prod volume) =
64
+ ∫ p, f p ∂μ.prod volume :=
65
+ (retainedSelectedOutputEquiv_preserving s μ).integral_comp
66
+ (retainedSelectedOutputEquiv (W := W) s).measurableEmbedding f
67
+
68
+ end Erdos3
69
+
70
+ end
71
+
72
+ section
73
+
74
+ namespace Erdos3
75
+
76
+ open MeasureTheory
77
+ open scoped NNReal
78
+
79
+ theorem selectedOutput_restricted_l1 {W I J : Type*} [MeasurableSpace W]
80
+ [Fintype I] [Fintype J] (s : J ↪ I) (μ : Measure W) [SFinite μ]
81
+ (R : ℝ≥0) (f : W × (I → ℝ) → ℝ) (hf : Integrable f (μ.prod volume))
82
+ {ε : ℝ} (he : (∫ p, |f p| ∂μ.prod volume) ≤ ε) :
83
+ let ν := μ.prod (continuousOutputBoxMeasure (UnselectedColumn s) R)
84
+ let F := fun p : (W × (UnselectedColumn s → ℝ)) × (J → ℝ) =>
85
+ f (p.1.1, selectedCoefficientEquiv s ℝ (p.1.2, p.2))
86
+ Integrable F (ν.prod volume) ∧ (∫ p, |F p| ∂ν.prod volume) ≤ ε := by
87
+ dsimp only
88
+ have hi := retainedSelectedOutput_integrable s μ hf
89
+ have hle : (μ.prod (continuousOutputBoxMeasure (UnselectedColumn s) R)).prod volume ≤
90
+ (μ.prod (volume : Measure (UnselectedColumn s → ℝ))).prod (volume : Measure (J → ℝ)) :=
91
+ Measure.prod_mono (Measure.prod_mono le_rfl (continuousOutputBoxMeasure_le _ R)) le_rfl
92
+ refine ⟨hi.mono_measure hle, ?_⟩
93
+ have ha : Integrable (fun p : (W × (UnselectedColumn s → ℝ)) × (J → ℝ) =>
94
+ |f (p.1.1, selectedCoefficientEquiv s ℝ (p.1.2, p.2))|) ((μ.prod volume).prod volume) := by
95
+ simpa only [Real.norm_eq_abs] using hi.norm
96
+ calc
97
+ _ ≤ ∫ p : (W × (UnselectedColumn s → ℝ)) × (J → ℝ),
98
+ |f (p.1.1, selectedCoefficientEquiv s ℝ (p.1.2, p.2))| ∂(μ.prod volume).prod volume :=
99
+ integral_mono_measure hle (Filter.Eventually.of_forall (fun _ => abs_nonneg _)) ha
100
+ _ = ∫ p, |f p| ∂μ.prod volume := retainedSelectedOutput_integral s μ (fun p => |f p|)
101
+ _ ≤ ε := he
102
+
103
+ end Erdos3
104
+
105
+ end
106
+
107
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedPhysicalReferenceCap.lean ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.ResiduePhysicalCap
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.BooleanCubeKernel
8
+
9
+ open scoped BigOperators Classical
10
+
11
+ variable {K I : Type*} [Fintype K] [Fintype I]
12
+ variable (root : K → ℤ) (modulus : I → ℕ) (hmodulus : ∀ i, 0 < modulus i)
13
+ variable (T : Finset (ColumnResiduePattern (Option K) I modulus)) (hT : T.Nonempty)
14
+ variable (W : Option K × I → ℝ) (hW : ∀ z, 0 < W z)
15
+ variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T W z)
16
+ variable (hc : ∀ r : T, 0 < shiftedSmoothProductMass
17
+ (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) (residueProfileWidth modulus W))
18
+ variable (hbase : ∀ i, 8*(probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth modulus W (none,i))
19
+
20
+ include hmodulus hT hc hbase in
21
+ theorem selectedResidueSmoothPMF_physical_cap (y : I → ℝ) :
22
+ ((selectedResidueSmoothPMF modulus T W hW hZ).map (physicalAffineSite root) y).toReal ≤
23
+ ∏ i, 2*(modulus i : ℝ)/W (none,i) := by
24
+ obtain ⟨_, h⟩ := selectedResidueSmoothPMF_bound_of_cells (ε := ∏ i, 2*(modulus i : ℝ)/W (none,i))
25
+ modulus hmodulus T hT W hW hc
26
+ (fun z => if physicalAffineSite root z = y then (1 : ℂ) else 0)
27
+ (by
28
+ intro r
29
+ exact (pmf_point_indicator_norm _ (physicalAffineSite root) y).trans_le
30
+ (residueSmoothPMF_physical_cap root (columnResidueRepresentative modulus r.val)
31
+ modulus hmodulus W hW (hc r) hbase y))
32
+ exact (pmf_point_indicator_norm _ (physicalAffineSite root) y).symm.trans_le h
33
+
34
+ include hmodulus hT hc hbase in
35
+ theorem selectedResidueSmoothPMF_physical_finite_event (E : Finset (I → ℝ)) :
36
+ (∑ y ∈ E, ((selectedResidueSmoothPMF modulus T W hW hZ).map (physicalAffineSite root) y).toReal) ≤
37
+ (E.card : ℝ) * ∏ i, 2*(modulus i : ℝ)/W (none,i) := by
38
+ calc
39
+ _ ≤ ∑ _y ∈ E, ∏ i, 2*(modulus i : ℝ)/W (none,i) :=
40
+ Finset.sum_le_sum (fun y _ => selectedResidueSmoothPMF_physical_cap
41
+ root modulus hmodulus T hT W hW hZ hc hbase y)
42
+ _ = _ := by simp
43
+
44
+ end Erdos3.BooleanCubeKernel
45
+
46
+ namespace Erdos3
47
+
48
+ open scoped BigOperators
49
+
50
+ theorem spatialBaseCap_volume_bound {I : Type*} [Fintype I]
51
+ (modulus : I → ℕ) (W H : I → ℝ) (hW : ∀ i, 0 < W i) (hH : ∀ i, 0 ≤ H i)
52
+ {S ρ : ℝ} (hρ : 0 < ρ) (hS : 0 ≤ S) (hmodulus : ∀ i, (modulus i : ℝ) ≤ S)
53
+ (hwidth : ∀ i, ρ*H i ≤ W i) :
54
+ (∏ i, H i) * (∏ i, 2*(modulus i : ℝ)/W i) ≤ (2*S/ρ)^Fintype.card I := by
55
+ have hi (i : I) : H i * (2*(modulus i : ℝ)/W i) ≤ 2*S/ρ := by
56
+ have hr : H i / W i ≤ 1/ρ :=
57
+ (div_le_div_iff₀ (hW i) hρ).mpr (by simpa only [one_mul, mul_one, mul_comm] using hwidth i)
58
+ calc
59
+ _ = 2*(modulus i : ℝ)*(H i/W i) := by ring
60
+ _ ≤ 2*S*(1/ρ) :=
61
+ mul_le_mul (mul_le_mul_of_nonneg_left (hmodulus i) (by norm_num)) hr
62
+ (div_nonneg (hH i) (hW i).le) (mul_nonneg (by norm_num) hS)
63
+ _ = _ := by ring
64
+ rw [← Finset.prod_mul_distrib]
65
+ calc
66
+ _ ≤ ∏ _i : I, 2*S/ρ := Finset.prod_le_prod₀
67
+ (fun i _ => mul_nonneg (hH i)
68
+ (div_nonneg (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) (hW i).le)) (fun i _ => hi i)
69
+ _ = _ := by rw [Finset.prod_const, Finset.card_univ]
70
+
71
+ end Erdos3
72
+
73
+ end
74
+
75
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedProductEnvelope.lean ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Algebra.BigOperators.Field
2
+ import Mathlib.Data.Fintype.Card
3
+ import Mathlib.Tactic
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open scoped BigOperators
12
+
13
+ theorem selected_nonnegative_product_le {A D : Type*} [Fintype A] [Fintype D]
14
+ (f : D → ℝ) (hf : ∀ d, 0 ≤ f d) (selected : A → D)
15
+ (hselected : Function.Injective selected) :
16
+ (∏ a, f (selected a)) ≤ (1 + ∑ d, f d) ^ Fintype.card D := by
17
+ let C := 1 + ∑ d, f d
18
+ have hs : 0 ≤ ∑ d, f d := Finset.sum_nonneg (fun d _ => hf d)
19
+ have hC : 1 ≤ C := by dsimp only [C]; linarith
20
+ have hbound (a : A) : f (selected a) ≤ C := by
21
+ have h := Finset.single_le_sum (fun d _ => hf d) (Finset.mem_univ (selected a))
22
+ dsimp only [C]
23
+ linarith
24
+ calc
25
+ _ ≤ ∏ _a : A, C := Finset.prod_le_prod₀ (fun index _ => hf (selected index))
26
+ (fun index _ => hbound index)
27
+ _ = C ^ Fintype.card A := by simp only [Finset.prod_const, Finset.card_univ]
28
+ _ ≤ C ^ Fintype.card D := pow_le_pow_right₀ hC (Fintype.card_le_of_injective selected hselected)
29
+
30
+ end Erdos3
31
+
32
+ end
33
+
34
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedProfileTranslationL1.lean ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.AffineProfileTranslationL1
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+
11
+ theorem selectedCoefficientProfile_translation_l1 {I J : Type*} [Fintype I] [Fintype J]
12
+ (s : I ↪ J) (f : (J → ℝ) → ℝ) {D : ℝ} (hD : 0 ≤ D)
13
+ (hm : ∀ a b, (∫ x, |f (x + a) - f (x + b)|) ≤ D * dist a b)
14
+ (a b : (UnselectedColumn s → ℝ) × (I → ℝ)) :
15
+ (∫ p, |selectedCoefficientProfile s f (p + a) - selectedCoefficientProfile s f (p + b)|) ≤
16
+ D * dist a b := by
17
+ have hadd (u v : (UnselectedColumn s → ℝ) × (I → ℝ)) :
18
+ selectedCoefficientEquiv s ℝ (u + v) =
19
+ selectedCoefficientEquiv s ℝ u + selectedCoefficientEquiv s ℝ v := by
20
+ funext j
21
+ simp only [selectedCoefficientEquiv_apply, Pi.add_apply]
22
+ cases (selectedFreeFirstEquiv s).symm j <;> rfl
23
+ have he : (fun p => |selectedCoefficientProfile s f (p + a) -
24
+ selectedCoefficientProfile s f (p + b)|) = selectedCoefficientProfile s
25
+ (fun x => |f (x + selectedCoefficientEquiv s ℝ a) - f (x + selectedCoefficientEquiv s ℝ b)|) := by
26
+ funext p
27
+ simp only [selectedCoefficientProfile, Function.comp_apply, hadd]
28
+ rw [he, selectedCoefficientProfile_integral]
29
+ apply (hm _ _).trans
30
+ apply mul_le_mul_of_nonneg_left _ hD
31
+ simpa only [NNReal.coe_one, one_mul] using (selectedCoefficientEquiv_lipschitz s).dist_le_mul a b
32
+
33
+ theorem affineSelectedPivot_translation_l1 {I J : Type*} [Fintype I] [Fintype J]
34
+ (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ))
35
+ (B : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ))
36
+ (c w : J → ℝ) {δ : ℝ} (hδ : 0 < δ) (hw : ∀ j, δ ≤ w j) (a b : I → ℝ) :
37
+ (∫ v, |pivotOutputDensity A B (selectedCoefficientProfile s (affineProductProfile c w)) (v + a) -
38
+ pivotOutputDensity A B (selectedCoefficientProfile s (affineProductProfile c w)) (v + b)|) ≤
39
+ ((Fintype.card J * (4 * (probabilityProfileLipschitz : ℝ) / δ)) *
40
+ ‖A.symm.toContinuousLinearMap‖) * dist a b := by
41
+ have hi := selectedCoefficientProfile_integrable s
42
+ (affineProductProfile_integrable c w (fun j => hδ.trans_le (hw j)))
43
+ apply (pivotOutputDensity_translation_l1 A B _ hi a b).trans
44
+ have he := selectedCoefficientProfile_translation_l1 s (affineProductProfile c w)
45
+ (D := Fintype.card J * (4 * (probabilityProfileLipschitz : ℝ) / δ))
46
+ (by positivity) (affineProductProfile_translation_l1 c w hδ hw)
47
+ (0, A.symm a) (0, A.symm b)
48
+ apply he.trans
49
+ have hd : dist (A.symm a) (A.symm b) ≤ ‖A.symm.toContinuousLinearMap‖ * dist a b := by
50
+ rw [dist_eq_norm, ← map_sub, dist_eq_norm]
51
+ exact A.symm.toContinuousLinearMap.le_opNorm _
52
+ simp only [Prod.dist_eq, dist_self, max_eq_right dist_nonneg]
53
+ exact (mul_le_mul_of_nonneg_left hd (by positivity)).trans_eq (by ring)
54
+
55
+ end Erdos3
56
+
57
+ end
58
+
59
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedSingletonSmoothTestQuadrature.lean ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Probability.SelectedSingletonSmoothIndexLaw
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+ open scoped BigOperators NNReal
11
+
12
+ theorem normalizedRealQuadrature_error {A M T E F : ℝ}
13
+ (hM : 1 / 2 ≤ M) (hA : |A - T| ≤ E) (hm : |M - 1| ≤ F)
14
+ (hT : |T| ≤ 1) : |A / M - T| ≤ 2 * (E + F) := by
15
+ have hMp : 0 < M := by linarith
16
+ have hF : 0 ≤ F := (abs_nonneg _).trans hm
17
+ have hE : 0 ≤ E := (abs_nonneg _).trans hA
18
+ have he : A / M - T = ((A - T) + T * (1 - M)) / M := by
19
+ field_simp
20
+ ring
21
+ rw [he, abs_div, abs_of_pos hMp]
22
+ apply (div_le_iff₀ hMp).mpr
23
+ calc
24
+ _ ≤ |A - T| + |T| * |1 - M| := by
25
+ simpa only [abs_mul] using abs_add_le (A - T) (T * (1 - M))
26
+ _ ≤ E + F := by
27
+ rw [abs_sub_comm (1 : ℝ) M]
28
+ exact add_le_add hA ((mul_le_mul hT hm (abs_nonneg _) zero_le_one).trans_eq (one_mul F))
29
+ _ ≤ 2 * (E + F) * M := by nlinarith
30
+
31
+ theorem shiftedSmoothProductMass_pos_of_mesh {I : Type*} [Fintype I]
32
+ (a S : I → ℝ) (hS : ∀ i, 0 < S i)
33
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ i, 1 / S i ≤ δ)
34
+ (hsmall : (4 : ℝ) ^ Fintype.card I *
35
+ ((Fintype.card I : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) :
36
+ 0 < shiftedSmoothProductMass a S :=
37
+ (div_pos (Finset.prod_pos (fun i _ => hS i)) (by norm_num)).trans_le
38
+ (shiftedSmoothProductMass_lower a S hS hδ hδ1 hmesh hsmall)
39
+
40
+ theorem smoothProductProfile_test_lipschitz {I : Type*} [Fintype I]
41
+ (φ : (I → ℝ) → ℝ) {L : ℝ≥0} (hLip : LipschitzWith L φ)
42
+ (hφ : ∀ x, ‖φ x‖ ≤ 1) :
43
+ LipschitzWith (L + Fintype.card I * probabilityProfileLipschitz)
44
+ (fun x => smoothProductProfile I x * φ x) := by
45
+ simpa only [one_mul] using lipschitz_real_mul_of_bounds
46
+ (smoothProductProfile I) φ (Bf := 1) (Bg := 1)
47
+ (smoothProductProfile_lipschitz I) hLip
48
+ (fun x => smoothProductProfile_norm_le I x) hφ
49
+
50
+ theorem smoothProductProfile_real_test_integral_norm_le {I : Type*} [Fintype I]
51
+ (φ : (I → ℝ) → ℝ) (hφ : ∀ x, ‖φ x‖ ≤ 1) :
52
+ ‖∫ x, smoothProductProfile I x * φ x‖ ≤ 1 := by
53
+ have hi : Integrable (smoothProductProfile I) :=
54
+ (smoothProductProfile_contDiff I).continuous.integrable_of_hasCompactSupport
55
+ (smoothProductProfile_compact I)
56
+ rw [← smoothProductProfile_integral I]
57
+ apply norm_integral_le_of_norm_le hi
58
+ filter_upwards [] with x
59
+ rw [norm_mul, Real.norm_of_nonneg (smoothProductProfile_range I x).1]
60
+ exact mul_le_of_le_one_right (smoothProductProfile_range I x).1 (hφ x)
61
+
62
+ theorem shiftedSmoothProductPMF_test_quadrature {I : Type*} [Fintype I]
63
+ (a S : I → ℝ) (hS : ∀ i, 0 < S i) (hZ : 0 < shiftedSmoothProductMass a S)
64
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ i, 1 / S i ≤ δ)
65
+ (hsmall : (4 : ℝ) ^ Fintype.card I *
66
+ ((Fintype.card I : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
67
+ (φ : (I → ℝ) → ℝ) {L : ℝ≥0} (hLip : LipschitzWith L φ)
68
+ (hφ : ∀ x, ‖φ x‖ ≤ 1) :
69
+ |(∑' k, (shiftedSmoothProductPMF a S hS hZ k).toReal *
70
+ φ (rectangularLatticePoint a S k)) -
71
+ ∫ x, smoothProductProfile I x * φ x| ≤
72
+ 2 * (4 : ℝ) ^ Fintype.card I *
73
+ ((L : ℝ) + 2 * ((Fintype.card I : ℝ) * probabilityProfileLipschitz)) * δ := by
74
+ let f := fun x => smoothProductProfile I x * φ x
75
+ have hsupp (x : I → ℝ) (hx : 1 < ‖x‖) : f x = 0 := by
76
+ simp only [f, smoothProductProfile_zero_outside I x hx, zero_mul]
77
+ have he := rectangularLattice_quadrature f
78
+ (smoothProductProfile_test_lipschitz φ hLip hφ) a S hS
79
+ zero_le_one hδ hδ1 hmesh hsupp
80
+ have hm := rectangularLattice_quadrature (smoothProductProfile I)
81
+ (smoothProductProfile_lipschitz I) a S hS
82
+ zero_le_one hδ hδ1 hmesh (smoothProductProfile_zero_outside I)
83
+ simp only [NNReal.coe_add, NNReal.coe_mul, NNReal.coe_natCast,
84
+ show 2 * (1 : ℝ) + 2 = 4 by norm_num] at he hm
85
+ rw [smoothProductProfile_integral I] at hm
86
+ change |shiftedSmoothProductMass a S / (∏ i, S i) - 1| ≤ _ at hm
87
+ have hp : 0 < ∏ i, S i := Finset.prod_pos (fun i _ => hS i)
88
+ have hlo : 1 / 2 ≤ shiftedSmoothProductMass a S / (∏ i, S i) := by
89
+ apply (le_div_iff₀ hp).mpr
90
+ simpa only [div_eq_mul_inv, one_mul, mul_comm] using
91
+ shiftedSmoothProductMass_lower a S hS hδ hδ1 hmesh hsmall
92
+ have hn := normalizedRealQuadrature_error hlo he hm
93
+ (smoothProductProfile_real_test_integral_norm_le φ hφ)
94
+ have heq : (∑' k, (shiftedSmoothProductPMF a S hS hZ k).toReal *
95
+ φ (rectangularLatticePoint a S k)) =
96
+ ((∑' k, f (rectangularLatticePoint a S k)) / (∏ i, S i)) /
97
+ (shiftedSmoothProductMass a S / (∏ i, S i)) := by
98
+ simp only [shiftedSmoothProductPMF_toReal, rectangularWeight, div_mul_eq_mul_div,
99
+ ← tsum_div_const]
100
+ dsimp only [f]
101
+ field_simp
102
+ rw [heq]
103
+ exact hn.trans_eq (by ring)
104
+
105
+ end Erdos3
106
+
107
+ end
108
+
109
+ section
110
+
111
+ namespace Erdos3
112
+
113
+ open MeasureTheory
114
+ open scoped BigOperators NNReal
115
+
116
+ variable {I : Type*} [Fintype I]
117
+
118
+ theorem smoothProductProfile_complex_test_integrable
119
+ (φ : (I → ℝ) → ℂ) (hφ : Continuous φ) :
120
+ Integrable (fun x => (smoothProductProfile I x : ℂ) * φ x) := by
121
+ apply ((Complex.continuous_ofReal.comp
122
+ (smoothProductProfile_contDiff I).continuous).mul hφ).integrable_of_hasCompactSupport
123
+ apply HasCompactSupport.of_support_subset_isCompact
124
+ (isCompact_closedBall (0 : I → ℝ) 1)
125
+ intro x hx
126
+ rw [Metric.mem_closedBall, dist_zero_right]
127
+ by_contra! hn
128
+ apply hx
129
+ change (smoothProductProfile I x : ℂ) * φ x = 0
130
+ simp only [smoothProductProfile_zero_outside I x hn, Complex.ofReal_zero, zero_mul]
131
+
132
+ theorem shiftedSmoothProductPMF_complex_test_quadrature
133
+ (a S : I → ℝ) (hS : ∀ i, 0 < S i) (hZ : 0 < shiftedSmoothProductMass a S)
134
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ i, 1 / S i ≤ δ)
135
+ (hsmall : (4 : ℝ) ^ Fintype.card I *
136
+ ((Fintype.card I : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
137
+ (φ : (I → ℝ) → ℂ) {L : ℝ≥0} (hLip : LipschitzWith L φ)
138
+ (hφ : ∀ x, ‖φ x‖ ≤ 1) :
139
+ ‖(∑' k, ((shiftedSmoothProductPMF a S hS hZ k).toReal : ℂ) *
140
+ φ (rectangularLatticePoint a S k)) -
141
+ ∫ x, (smoothProductProfile I x : ℂ) * φ x‖ ≤
142
+ 4 * (4 : ℝ) ^ Fintype.card I *
143
+ ((L : ℝ) + 2 * ((Fintype.card I : ℝ) * probabilityProfileLipschitz)) * δ := by
144
+ have hreLip : LipschitzWith L (fun x => (φ x).re) := by
145
+ apply LipschitzWith.of_dist_le_mul
146
+ intro x y
147
+ rw [Real.dist_eq, ← Complex.sub_re]
148
+ exact (Complex.abs_re_le_norm _).trans
149
+ (by simpa only [dist_eq_norm] using hLip.dist_le_mul x y)
150
+ have himLip : LipschitzWith L (fun x => (φ x).im) := by
151
+ apply LipschitzWith.of_dist_le_mul
152
+ intro x y
153
+ rw [Real.dist_eq, ← Complex.sub_im]
154
+ exact (Complex.abs_im_le_norm _).trans
155
+ (by simpa only [dist_eq_norm] using hLip.dist_le_mul x y)
156
+ have hre := shiftedSmoothProductPMF_test_quadrature a S hS hZ hδ hδ1 hmesh hsmall
157
+ (fun x => (φ x).re) hreLip
158
+ (fun x => by simpa only [Real.norm_eq_abs] using
159
+ (Complex.abs_re_le_norm (φ x)).trans (hφ x))
160
+ have him := shiftedSmoothProductPMF_test_quadrature a S hS hZ hδ hδ1 hmesh hsmall
161
+ (fun x => (φ x).im) himLip
162
+ (fun x => by simpa only [Real.norm_eq_abs] using
163
+ (Complex.abs_im_le_norm (φ x)).trans (hφ x))
164
+ have hs : Summable (fun k => ((shiftedSmoothProductPMF a S hS hZ k).toReal : ℂ) *
165
+ φ (rectangularLatticePoint a S k)) :=
166
+ finite_weighted_test_summable _ (rectangularWeightIndices a S 1)
167
+ (shiftedSmoothProductPMF_toReal_zero_off a S hS hZ) _
168
+ have hi := smoothProductProfile_complex_test_integrable φ hLip.continuous
169
+ have hire : (∫ x, (smoothProductProfile I x : ℂ) * φ x).re =
170
+ ∫ x, smoothProductProfile I x * (φ x).re := by
171
+ simpa only [RCLike.re_eq_complex_re, Complex.mul_re, Complex.ofReal_re,
172
+ Complex.ofReal_im, zero_mul, sub_zero] using (integral_re hi).symm
173
+ have hiim : (∫ x, (smoothProductProfile I x : ℂ) * φ x).im =
174
+ ∫ x, smoothProductProfile I x * (φ x).im := by
175
+ simpa only [RCLike.im_eq_complex_im, Complex.mul_im, Complex.ofReal_re,
176
+ Complex.ofReal_im, zero_mul, add_zero] using (integral_im hi).symm
177
+ let C := 2 * (4 : ℝ) ^ Fintype.card I *
178
+ ((L : ℝ) + 2 * ((Fintype.card I : ℝ) * probabilityProfileLipschitz)) * δ
179
+ calc
180
+ _ ≤ |((∑' k, ((shiftedSmoothProductPMF a S hS hZ k).toReal : ℂ) *
181
+ φ (rectangularLatticePoint a S k)) -
182
+ ∫ x, (smoothProductProfile I x : ℂ) * φ x).re| +
183
+ |((∑' k, ((shiftedSmoothProductPMF a S hS hZ k).toReal : ℂ) *
184
+ φ (rectangularLatticePoint a S k)) -
185
+ ∫ x, (smoothProductProfile I x : ℂ) * φ x).im| :=
186
+ Complex.norm_le_abs_re_add_abs_im _
187
+ _ ≤ C + C := by
188
+ apply add_le_add
189
+ · simpa only [Complex.sub_re, Complex.re_tsum hs, hire, Complex.mul_re,
190
+ Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] using hre
191
+ · simpa only [Complex.sub_im, Complex.im_tsum hs, hiim, Complex.mul_im,
192
+ Complex.ofReal_re, Complex.ofReal_im, zero_mul, add_zero] using him
193
+ _ = _ := by dsimp only [C]; ring
194
+
195
+ end Erdos3
196
+
197
+ end
198
+
199
+ section
200
+
201
+ namespace Erdos3
202
+
203
+ open MeasureTheory
204
+ open scoped BigOperators NNReal Classical
205
+
206
+ variable {K X : Type*} [Fintype K] [Fintype X]
207
+
208
+ theorem selectedResidueSmoothPMF_singleton_complex_quadrature
209
+ (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x)
210
+ (r : ColumnResiduePattern K X modulus) (V : K × X → ℝ) (hV : ∀ z, 0 < V z)
211
+ (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus {r} V z)
212
+ {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1)
213
+ (hmesh : ∀ z, (modulus z.2 : ℝ) / V z ≤ δ)
214
+ (hsmall : (4 : ℝ) ^ Fintype.card (K × X) *
215
+ ((Fintype.card (K × X) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2)
216
+ (φ : (K × X → ℝ) → ℂ) {A : ℝ≥0} (hLip : LipschitzWith A φ)
217
+ (hφ : ∀ x, ‖φ x‖ ≤ 1) :
218
+ ‖(∑' z, ((selectedResidueSmoothPMF modulus {r} V hV hZ z).toReal : ℂ) *
219
+ φ (fun k => (z k : ℝ) / V k)) -
220
+ ∫ x, (smoothProductProfile (K × X) x : ℂ) * φ x‖ ≤
221
+ 4 * (4 : ℝ) ^ Fintype.card (K × X) *
222
+ ((A : ℝ) + 2 * ((Fintype.card (K × X) : ℝ) * probabilityProfileLipschitz)) * δ := by
223
+ rw [selectedResidueSmoothPMF_singleton_normalized_expectation modulus hmodulus r V hV hZ]
224
+ apply shiftedSmoothProductPMF_complex_test_quadrature _ _
225
+ (residueProfileWidth_pos modulus V hmodulus hV)
226
+ (selectedResidueSmooth_singleton_indexMass_pos modulus hmodulus r V hV hZ)
227
+ hδ hδ1 _ hsmall φ hLip hφ
228
+ intro z
229
+ simpa only [residueProfileWidth, one_div_div] using hmesh z
230
+
231
+ end Erdos3
232
+
233
+ end
234
+
235
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedSplitUnitSource.lean ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Lattices.JointAffineL1Parameter
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open MeasureTheory
10
+
11
+ noncomputable def selectedSplitMeasurableEquiv {I J N : Type*}
12
+ [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J) :
13
+ ((UnselectedColumn s ⊕ N → ℝ) × (I → ℝ)) ≃ᵐ (J ⊕ N → ℝ) :=
14
+ (splitFreeCoordinates I (UnselectedColumn s) N).trans
15
+ (((selectedCoefficientMeasurableEquiv s).prodCongr (MeasurableEquiv.refl (N → ℝ))).trans
16
+ (MeasurableEquiv.sumPiEquivProdPi (fun _ : J ⊕ N => ℝ)).symm)
17
+
18
+ theorem selectedSplitMeasurableEquiv_apply {I J N : Type*}
19
+ [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J)
20
+ (p : (UnselectedColumn s ⊕ N → ℝ) × (I → ℝ)) :
21
+ selectedSplitMeasurableEquiv s p = selectedSplitCoefficients s p := rfl
22
+
23
+ theorem selectedSplitMeasurableEquiv_symm_apply {I J N : Type*}
24
+ [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J) (r : J ⊕ N → ℝ) :
25
+ (selectedSplitMeasurableEquiv s).symm r =
26
+ (Sum.elim (fun j : UnselectedColumn s => r (.inl j.val)) (fun n => r (.inr n)),
27
+ fun i => r (.inl (s i))) := rfl
28
+
29
+ theorem measurableEquiv_inverse_law {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y]
30
+ (e : X ≃ᵐ Y) (μ : Measure X) (ν : Measure Y) (he : μ.map e = ν) :
31
+ ν.map e.symm = μ := by
32
+ rw [← he, Measure.map_map e.symm.measurable e.measurable]
33
+ simp only [Function.comp_def, MeasurableEquiv.symm_apply_apply, Measure.map_id']
34
+
35
+ theorem affineProductProfile_map_law {I Y : Type*} [Fintype I] [MeasurableSpace Y]
36
+ (c w : I → ℝ) (hw : ∀ i, 0 < w i) (F : (I → ℝ) → Y) (hF : Measurable F) :
37
+ (realDensityMeasure volume (smoothProductProfile I)).map
38
+ (fun r => F (fun i => c i+w i*r i)) =
39
+ (realDensityMeasure volume (affineProductProfile c w)).map F := by
40
+ have hm : Measurable (fun r : I → ℝ => fun i => c i+w i*r i) := by fun_prop
41
+ change Measure.map (F ∘ (fun (r : I → ℝ) i => c i+w i*r i)) _ = _
42
+ rw [← Measure.map_map hF hm, affineProductProfile_law c w hw]
43
+
44
+ theorem selectedSplit_affine_law {I J N : Type*}
45
+ [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J)
46
+ (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) :
47
+ (realDensityMeasure volume (affineSelectedJetProfile s c w)).map
48
+ (selectedSplitMeasurableEquiv s) = realDensityMeasure volume (affineProductProfile c w) := by
49
+ have hf := selectedSplitCoefficients_law s
50
+ (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))
51
+ (affineProductProfile (fun n => c (.inr n)) (fun n => w (.inr n)))
52
+ (affineProductProfile_contDiff _ _).continuous.measurable
53
+ (affineProductProfile_contDiff _ _).continuous.measurable
54
+ (affineProductProfile_integrable _ _ (fun j => hw (.inl j)))
55
+ (affineProductProfile_integrable _ _ (fun n => hw (.inr n)))
56
+ (affineProductProfile_nonneg _ _ (fun j => hw (.inl j)))
57
+ (affineProductProfile_nonneg _ _ (fun n => hw (.inr n)))
58
+ change (realDensityMeasure volume (affineSelectedJetProfile s c w)).map
59
+ (selectedSplitMeasurableEquiv s) = _ at hf
60
+ rw [← affineProductProfile_joined] at hf
61
+ exact hf
62
+
63
+ theorem selectedSplit_unit_law {I J N : Type*}
64
+ [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J)
65
+ (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) :
66
+ (realDensityMeasure volume (smoothProductProfile (J ⊕ N))).map
67
+ (fun r => (selectedSplitMeasurableEquiv s).symm (fun j => c j+w j*r j)) =
68
+ realDensityMeasure volume (affineSelectedJetProfile s c w) := by
69
+ exact (affineProductProfile_map_law c w hw _ (selectedSplitMeasurableEquiv s).symm.measurable).trans
70
+ (measurableEquiv_inverse_law (selectedSplitMeasurableEquiv s) _ _ (selectedSplit_affine_law s c w hw))
71
+
72
+ end Erdos3
73
+
74
+ end
75
+
76
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SelectedWindowIndicator.lean ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Constructions.Pi
2
+ import Mathlib.MeasureTheory.Integral.Bochner.Basic
3
+ import OAI.Combinatorics.Progressions.Probability.PMFPointMassMixture
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open scoped BigOperators Classical
12
+
13
+ theorem normalized_complex_point_error (f g : ℂ) {N ε : ℝ} (hN : 0 < N)
14
+ (he : ‖(N : ℂ) * f - g‖ ≤ ε) : ‖f - g / (N : ℂ)‖ ≤ ε / N := by
15
+ have hn : (N : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hN.ne'
16
+ have hid : f - g / (N : ℂ) = ((N : ℂ) * f - g) / (N : ℂ) := by
17
+ field_simp
18
+ rw [hid, norm_div, Complex.norm_real, Real.norm_of_nonneg hN.le]
19
+ exact div_le_div_of_nonneg_right he hN.le
20
+
21
+ theorem finite_window_normalized_l1_error {X : Type*} (W : Finset X) (f g : X → ℂ)
22
+ {N C ε : ℝ} (hN : 0 < N) (hε : 0 ≤ ε) (hcard : (W.card : ℝ) ≤ C * N)
23
+ (hzero : ∀ x ∉ W, f x = 0 ∧ g x = 0)
24
+ (he : ∀ x, ‖(N : ℂ) * f x - g x‖ ≤ ε) :
25
+ (∑' x, ‖f x - g x / (N : ℂ)‖) ≤ ε * C := by
26
+ have hz (x) (hx : x ∉ W) : ‖f x - g x / (N : ℂ)‖ = 0 := by
27
+ rw [(hzero x hx).1, (hzero x hx).2, zero_div, sub_self, norm_zero]
28
+ rw [(hasSum_sum_of_ne_finset_zero hz).tsum_eq]
29
+ calc
30
+ _ ≤ ∑ _x ∈ W, ε / N := Finset.sum_le_sum (fun x _ => normalized_complex_point_error _ _ hN (he x))
31
+ _ = (W.card : ℝ) * (ε / N) := by simp
32
+ _ ≤ (C * N) * (ε / N) := mul_le_mul_of_nonneg_right hcard (div_nonneg hε hN.le)
33
+ _ = ε * C := by field_simp
34
+
35
+ theorem finite_window_normalized_test_error {X : Type*} (W : Finset X) (f g test : X → ℂ)
36
+ {N C ε : ℝ} (hN : 0 < N) (hε : 0 ≤ ε) (hcard : (W.card : ℝ) ≤ C * N)
37
+ (hzero : ∀ x ∉ W, f x = 0 ∧ g x = 0)
38
+ (he : ∀ x, ‖(N : ℂ) * f x - g x‖ ≤ ε) (htest : ∀ x, ‖test x‖ ≤ 1) :
39
+ ‖∑' x, (f x - g x / (N : ℂ)) * test x‖ ≤ ε * C := by
40
+ have hz (x) (hx : x ∉ W) : (f x - g x / (N : ℂ)) * test x = 0 := by
41
+ rw [(hzero x hx).1, (hzero x hx).2, zero_div, sub_self, zero_mul]
42
+ have hzn (x) (hx : x ∉ W) : ‖f x - g x / (N : ℂ)‖ = 0 := by
43
+ rw [(hzero x hx).1, (hzero x hx).2, zero_div, sub_self, norm_zero]
44
+ rw [(hasSum_sum_of_ne_finset_zero hz).tsum_eq]
45
+ calc
46
+ _ ≤ ∑ x ∈ W, ‖(f x - g x / (N : ℂ)) * test x‖ := norm_sum_le _ _
47
+ _ ≤ ∑ x ∈ W, ‖f x - g x / (N : ℂ)‖ := Finset.sum_le_sum (fun x _ => by
48
+ rw [norm_mul]
49
+ exact mul_le_of_le_one_right (norm_nonneg _) (htest x))
50
+ _ = ∑' x, ‖f x - g x / (N : ℂ)‖ := (hasSum_sum_of_ne_finset_zero hzn).tsum_eq.symm
51
+ _ ≤ ε * C := finite_window_normalized_l1_error W f g hN hε hcard hzero he
52
+
53
+ end Erdos3
54
+
55
+ end
56
+
57
+ section
58
+
59
+ namespace Erdos3
60
+
61
+ open MeasureTheory
62
+ open scoped BigOperators Classical
63
+
64
+ variable {X Y : Type*} [Countable X] [DecidableEq X] [MeasurableSpace X]
65
+ [MeasurableSingletonClass X] [MeasurableSpace Y]
66
+
67
+ theorem finite_window_weighted_integrable (W : Finset X) (f : X → ℂ)
68
+ (μ : Measure Y) (z : Y → X) (w : Y → ℂ)
69
+ (hz : Measurable z) (hw : Measurable w)
70
+ (hzero : ∀ x ∉ W, f x = 0)
71
+ (hweight : Integrable (fun y => if z y ∈ W then ‖w y‖ else 0) μ) :
72
+ Integrable (fun y => w y * f (z y)) μ := by
73
+ let C : ℝ := ∑ x ∈ W, ‖f x‖
74
+ apply (hweight.mul_const C).mono'
75
+ (hw.mul ((measurable_of_countable f).comp hz)).aestronglyMeasurable
76
+ apply ae_of_all
77
+ intro y
78
+ change ‖w y * f (z y)‖ ≤ (if z y ∈ W then ‖w y‖ else 0) * C
79
+ by_cases hy : z y ∈ W
80
+ · simp only [ite_eq_left hy, norm_mul]
81
+ exact mul_le_mul_of_nonneg_left
82
+ (Finset.single_le_sum (fun x _ => norm_nonneg (f x)) hy) (norm_nonneg (w y))
83
+ · simp only [ite_eq_right hy, hzero (z y) hy, mul_zero, norm_zero, zero_mul, le_refl]
84
+
85
+ theorem finite_window_weighted_integral_error (W : Finset X) (f g : X → ℂ)
86
+ (μ : Measure Y) (z : Y → X) (w : Y → ℂ)
87
+ (hz : Measurable z) (hw : Measurable w) {N ε : ℝ} (hN : 0 < N)
88
+ (hzero : ∀ x ∉ W, f x = 0 ∧ g x = 0)
89
+ (he : ∀ x, ‖(N : ℂ) * f x - g x‖ ≤ ε)
90
+ (hweight : Integrable (fun y => if z y ∈ W then ‖w y‖ else 0) μ) :
91
+ ‖(∫ y, w y * f (z y) ∂μ) - (∫ y, w y * g (z y) ∂μ) / (N : ℂ)‖ ≤
92
+ (ε / N) * ∫ y, if z y ∈ W then ‖w y‖ else 0 ∂μ := by
93
+ have hf := finite_window_weighted_integrable W f μ z w hz hw (fun x hx => (hzero x hx).1) hweight
94
+ have hg := finite_window_weighted_integrable W g μ z w hz hw (fun x hx => (hzero x hx).2) hweight
95
+ rw [← integral_div, ← integral_sub hf (hg.div_const (N : ℂ)), ← integral_const_mul]
96
+ apply norm_integral_le_of_norm_le (hweight.const_mul (ε / N))
97
+ apply ae_of_all
98
+ intro y
99
+ by_cases hy : z y ∈ W
100
+ · simp only [ite_eq_left hy, mul_div_assoc, ← mul_sub, norm_mul]
101
+ exact (mul_le_mul_of_nonneg_left
102
+ (normalized_complex_point_error _ _ hN (he (z y))) (norm_nonneg (w y))).trans_eq
103
+ (mul_comm _ _)
104
+ · simp only [ite_eq_right hy, (hzero (z y) hy).1, (hzero (z y) hy).2,
105
+ mul_zero, zero_div, sub_self, norm_zero, le_refl]
106
+
107
+ end Erdos3
108
+
109
+ end
110
+
111
+ section
112
+
113
+ namespace Erdos3
114
+
115
+ open MeasureTheory
116
+ open scoped BigOperators Classical
117
+
118
+ variable {A : Type*} [Fintype A] {X : A → Type*}
119
+ variable (selected : A → Prop) [DecidablePred selected]
120
+
121
+ noncomputable def selectedProductExtension (p : ∀ a, X a → ℝ)
122
+ (g : (∀ a : {a // selected a}, X a.val) → ℂ) (N : ℝ) (z : ∀ a, X a) : ℂ :=
123
+ g (fun a => z a.val) / (N : ℂ) * ((∏ a : {a // ¬selected a}, p a.val (z a.val) : ℝ) : ℂ)
124
+
125
+ theorem selectedProductExtension_error (p : ∀ a, X a → ℝ)
126
+ (hp : ∀ a z, 0 ≤ p a z)
127
+ (W : ∀ a, Finset (X a))
128
+ (g : (∀ a : {a // selected a}, X a.val) → ℂ)
129
+ {N ε : ℝ} (hN : 0 < N)
130
+ (hzero : ∀ z, (∃ a, z a ∉ W a.val) →
131
+ (∏ a : {a // selected a}, p a.val (z a)) = 0 ∧ g z = 0)
132
+ (he : ∀ z, ‖(N : ℂ) * ((∏ a : {a // selected a}, p a.val (z a) : ℝ) : ℂ) - g z‖ ≤ ε)
133
+ (z : ∀ a, X a) :
134
+ ‖((∏ a, p a (z a) : ℝ) : ℂ) - selectedProductExtension selected p g N z‖ ≤
135
+ (ε / N) * ∏ a, if selected a then (W a : Set (X a)).indicator (fun _ => (1 : ℝ)) (z a)
136
+ else p a (z a) := by
137
+ have hc : 0 ≤ ∏ a : {a // ¬selected a}, p a.val (z a.val) :=
138
+ Finset.prod_nonneg (fun a _ => hp a.val _)
139
+ have hprod := Fintype.prod_subtype_mul_prod_subtype selected (fun a => p a (z a))
140
+ have hweight := Fintype.prod_subtype_mul_prod_subtype selected
141
+ (fun a => if selected a then (W a : Set (X a)).indicator (fun _ => (1 : ℝ)) (z a) else p a (z a))
142
+ simp only [Subtype.property, ite_true] at hweight
143
+ have hright (a : {a // ¬selected a}) :
144
+ (if selected a.val then (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)
145
+ else p a.val (z a.val)) = p a.val (z a.val) := ite_eq_right a.property
146
+ simp only [hright] at hweight
147
+ rw [← hprod, Complex.ofReal_mul, selectedProductExtension, ← sub_mul, norm_mul,
148
+ Complex.norm_real, Real.norm_of_nonneg hc, ← hweight]
149
+ by_cases hz : ∀ a : {a // selected a}, z a.val ∈ W a.val
150
+ · have hi : (∏ a : {a // selected a}, (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)) = 1 := by
151
+ apply Finset.prod_eq_one
152
+ intro a _
153
+ exact Set.indicator_of_mem (hz a) _
154
+ rw [hi, one_mul]
155
+ exact mul_le_mul_of_nonneg_right
156
+ (normalized_complex_point_error _ _ hN (he (fun a => z a.val))) hc
157
+ · obtain ⟨a, ha⟩ := not_forall.mp hz
158
+ obtain ⟨htrue, hg⟩ := hzero (fun a : {a // selected a} => z a.val) ⟨a, ha⟩
159
+ have hi : (∏ a : {a // selected a}, (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)) = 0 :=
160
+ Finset.prod_eq_zero (Finset.mem_univ a) (Set.indicator_of_notMem ha _)
161
+ rw [htrue, hg, Complex.ofReal_zero, zero_div, sub_zero, norm_zero, zero_mul, hi, zero_mul, mul_zero]
162
+
163
+ theorem selectedProductExtension_measurable [∀ a, MeasurableSpace (X a)]
164
+ (p : ∀ a, X a → ℝ) (hp : ∀ a, Measurable (p a))
165
+ (g : (∀ a : {a // selected a}, X a.val) → ℂ) (hg : Measurable g) (N : ℝ) :
166
+ Measurable (selectedProductExtension selected p g N) := by
167
+ have hr : Measurable (fun z : ∀ a, X a => fun a : {a // selected a} => z a.val) :=
168
+ Measurable.of_eval (fun coordinate => measurable_pi_apply coordinate.val)
169
+ have hc : Measurable (fun z : ∀ a, X a => ∏ a : {a // ¬selected a}, p a.val (z a.val)) :=
170
+ Finset.measurable_prod _ (fun a _ => (hp a.val).comp (measurable_pi_apply a.val))
171
+ exact ((hg.comp hr).div_const _).mul hc.complex_ofReal
172
+
173
+ theorem selectedWindow_volume_cancel {N ε V M : ℝ}
174
+ (hN : 0 < N) (hε : 0 ≤ ε) (hM : 0 ≤ M) {C : ℝ} (hC : C ≤ V * N) :
175
+ (ε / N) * (C * M) ≤ (ε * V) * M := by
176
+ calc
177
+ _ ≤ (ε / N) * ((V * N) * M) :=
178
+ mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hC hM) (div_nonneg hε hN.le)
179
+ _ = _ := by field_simp
180
+
181
+ end Erdos3
182
+
183
+ end
184
+
185
+ section
186
+
187
+ namespace Erdos3
188
+
189
+ open scoped BigOperators Classical
190
+
191
+ theorem selectedProductExtension_windowIndicator {A : Type*} [Fintype A] {X : A → Type*}
192
+ (selected : A → Prop) [DecidablePred selected]
193
+ (p : ∀ a, X a → ℝ) (W : ∀ a, Finset (X a)) (N : ℝ) (z : ∀ a, X a) :
194
+ selectedProductExtension selected p
195
+ (fun x => if ∀ a : {a // selected a}, x a ∈ W a.val then 1 else 0) N z =
196
+ ((∏ a, if selected a then (W a : Set (X a)).indicator (fun _ => (1 : ℝ)) (z a)
197
+ else p a (z a) : ℝ) : ℂ) / (N : ℂ) := by
198
+ have hweight := Fintype.prod_subtype_mul_prod_subtype selected
199
+ (fun a => if selected a then (W a : Set (X a)).indicator (fun _ => (1 : ℝ)) (z a) else p a (z a))
200
+ simp only [Subtype.property, ite_true] at hweight
201
+ have hright (a : {a // ¬selected a}) :
202
+ (if selected a.val then (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)
203
+ else p a.val (z a.val)) = p a.val (z a.val) := ite_eq_right a.property
204
+ simp only [hright] at hweight
205
+ rw [← hweight, Complex.ofReal_mul]
206
+ unfold selectedProductExtension
207
+ dsimp only
208
+ by_cases hz : ∀ a : {a // selected a}, z a.val ∈ W a.val
209
+ · have hi : (∏ a : {a // selected a}, (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)) = 1 := by
210
+ apply Finset.prod_eq_one
211
+ intro a _
212
+ exact Set.indicator_of_mem (hz a) _
213
+ rw [ite_eq_left hz, hi, Complex.ofReal_one]
214
+ ring
215
+ · obtain ⟨a, ha⟩ := not_forall.mp hz
216
+ have hi : (∏ a : {a // selected a}, (W a.val : Set (X a.val)).indicator (fun _ => (1 : ℝ)) (z a.val)) = 0 :=
217
+ Finset.prod_eq_zero (Finset.mem_univ a) (Set.indicator_of_notMem ha _)
218
+ simp only [ite_eq_right hz, hi, Complex.ofReal_zero, zero_div, zero_mul]
219
+
220
+ end Erdos3
221
+
222
+ end
223
+
224
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SeparatedCosetBalls.lean ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.Tactic
2
+ import OAI.Combinatorics.Progressions.Geometry.RightCosetMetricMap
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped ENNReal NNReal
11
+
12
+ variable {G : Type*} [Group G] [MetricSpace G] [IsIsometricSMul Gᵐᵒᵖ G]
13
+
14
+ theorem dist_le_dist_mul_of_separated_ball (Γ : Subgroup G) (z : G) (R : ℝ)
15
+ (hsep : ∀ γ ∈ Γ, γ ≠ 1 → 4 * R ≤ dist z (z * γ))
16
+ {x y : G} (hx : dist x z ≤ R) (hy : dist y z ≤ R) (γ : Γ) :
17
+ dist x y ≤ dist x (y * γ) := by
18
+ by_cases hγ : (γ : G) = 1
19
+ · simp only [hγ, mul_one, le_refl]
20
+ · have hs := hsep γ γ.property hγ
21
+ have hchain : dist z (z * γ) ≤ dist z x + dist x (y * γ) + dist (y * γ) (z * γ) :=
22
+ (dist_triangle z x (z * γ)).trans (by linarith [dist_triangle x (y * γ) (z * γ)])
23
+ rw [dist_mul_right] at hchain
24
+ have hxy := dist_triangle x z y
25
+ rw [dist_comm z x] at hchain
26
+ rw [dist_comm z y] at hxy
27
+ linarith
28
+
29
+ theorem rightCosetEDist_eq_edist_of_separated_ball (Γ : Subgroup G) (z : G) (R : ℝ)
30
+ (hsep : ∀ γ ∈ Γ, γ ≠ 1 → 4 * R ≤ dist z (z * γ))
31
+ {x y : G} (hx : dist x z ≤ R) (hy : dist y z ≤ R) :
32
+ rightCosetEDist Γ x y = edist x y := by
33
+ apply le_antisymm (rightCosetEDist_le Γ x y)
34
+ apply le_iInf
35
+ intro γ
36
+ simp only [edist_dist]
37
+ exact ENNReal.ofReal_le_ofReal (dist_le_dist_mul_of_separated_ball Γ z R hsep hx hy γ)
38
+
39
+ omit [IsIsometricSMul Gᵐᵒᵖ G] in
40
+ theorem separated_ball_of_lipschitz_left (Γ : Subgroup G) {δ R : ℝ} {C : ℝ≥0}
41
+ (hC : 0 < C) (hgap : ∀ γ ∈ Γ, γ ≠ 1 → δ ≤ dist 1 γ)
42
+ (hR : 4 * R * C ≤ δ) (z : G) (hleft : LipschitzWith C (fun x => z⁻¹ * x)) :
43
+ ∀ γ ∈ Γ, γ ≠ 1 → 4 * R ≤ dist z (z * γ) := by
44
+ intro γ hγ hne
45
+ have hLip : dist 1 γ ≤ (C : ℝ) * dist z (z * γ) := by
46
+ simpa only [inv_mul_cancel, inv_mul_cancel_left] using hleft.dist_le_mul z (z * γ)
47
+ have hC' : (0 : ℝ) < C := hC
48
+ have hg := hgap γ hγ hne
49
+ nlinarith
50
+
51
+ variable [IsTopologicalGroup G]
52
+
53
+ theorem quotient_dist_eq_of_separated_ball (Γ : Subgroup G) (hΓ : IsClosed (Γ : Set G))
54
+ (z : G) (R : ℝ) (hsep : ∀ γ ∈ Γ, γ ≠ 1 → 4 * R ≤ dist z (z * γ)) :
55
+ letI := rightCosetMetricSpace Γ hΓ
56
+ ∀ {x y : G}, dist x z ≤ R → dist y z ≤ R →
57
+ dist (QuotientGroup.mk x : G ⧸ Γ) (QuotientGroup.mk y) = dist x y := by
58
+ let := rightCosetMetricSpace Γ hΓ
59
+ intro x y hx hy
60
+ have h : edist (QuotientGroup.mk x : G ⧸ Γ) (QuotientGroup.mk y) = edist x y :=
61
+ rightCosetEDist_eq_edist_of_separated_ball Γ z R hsep hx hy
62
+ simpa only [edist_dist, ENNReal.toReal_ofReal dist_nonneg] using congrArg ENNReal.toReal h
63
+
64
+ end Erdos3
65
+
66
+ end
67
+
68
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SeparatedInterpolationBound.lean ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.LinearAlgebra.Lagrange
2
+ import Mathlib.Tactic
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open Polynomial
11
+ open scoped BigOperators
12
+
13
+ theorem coeff_X_sub_C_mul_abs_le (p : ℝ[X]) {M y : ℝ} (hM : 0 ≤ M)
14
+ (hp : ∀ n, |p.coeff n| ≤ M) (hy : |y| ≤ 1) (n : ℕ) :
15
+ |((X - C y) * p).coeff n| ≤ 2 * M := by
16
+ cases n with
17
+ | zero =>
18
+ simp only [mul_coeff_zero, coeff_sub, coeff_X_zero, coeff_C_zero, zero_sub, neg_mul, abs_neg,
19
+ abs_mul]
20
+ calc
21
+ |y| * |p.coeff 0| ≤ 1 * M := mul_le_mul hy (hp 0) (abs_nonneg _) zero_le_one
22
+ _ ≤ 2 * M := by linarith
23
+ | succ n =>
24
+ rw [coeff_X_sub_C_mul]
25
+ calc
26
+ |p.coeff n - y * p.coeff (n + 1)| ≤ |p.coeff n| + |y * p.coeff (n + 1)| := abs_sub _ _
27
+ _ = |p.coeff n| + |y| * |p.coeff (n + 1)| := by rw [abs_mul]
28
+ _ ≤ M + 1 * M := add_le_add (hp n) (mul_le_mul hy (hp (n + 1)) (abs_nonneg _) zero_le_one)
29
+ _ = 2 * M := by ring
30
+
31
+ theorem coeff_prod_X_sub_C_abs_le {ι : Type*} (s : Finset ι) (v : ι → ℝ)
32
+ (hv : ∀ i ∈ s, |v i| ≤ 1) (n : ℕ) :
33
+ |(∏ i ∈ s, (X - C (v i))).coeff n| ≤ (2 : ℝ) ^ s.card := by
34
+ classical
35
+ induction s using Finset.induction_on generalizing n with
36
+ | empty =>
37
+ simp only [Finset.prod_empty, Finset.card_empty, pow_zero, coeff_one]
38
+ split_ifs <;> norm_num
39
+ | @insert i s hi ih =>
40
+ rw [Finset.prod_insert hi, Finset.card_insert_of_notMem hi, pow_succ]
41
+ have hp (k : ℕ) : |(∏ j ∈ s, (X - C (v j))).coeff k| ≤ (2 : ℝ) ^ s.card := by
42
+ exact ih (fun j hj => hv j (Finset.mem_insert_of_mem hj)) k
43
+ simpa only [mul_comm] using coeff_X_sub_C_mul_abs_le (∏ j ∈ s, (X - C (v j)))
44
+ (by positivity : 0 ≤ (2 : ℝ) ^ s.card) hp (hv i (Finset.mem_insert_self i s)) n
45
+
46
+ theorem lagrange_basis_coeff_abs_le {ι : Type*} [DecidableEq ι]
47
+ (s : Finset ι) (v : ι → ℝ) (i : ι) {r : ℝ} (hr : 0 < r)
48
+ (hv : ∀ j ∈ s, |v j| ≤ 1)
49
+ (hsep : ∀ j ∈ s.erase i, r ≤ |v i - v j|) (n : ℕ) :
50
+ |(Lagrange.basis s v i).coeff n| ≤ (2 / r) ^ (s.erase i).card := by
51
+ have heq : Lagrange.basis s v i =
52
+ C (∏ j ∈ s.erase i, (v i - v j)⁻¹) * ∏ j ∈ s.erase i, (X - C (v j)) := by
53
+ simp only [Lagrange.basis, Lagrange.basisDivisor, Finset.prod_mul_distrib, map_prod]
54
+ have hprod : (∏ j ∈ s.erase i, |(v i - v j)⁻¹|) ≤ (r⁻¹) ^ (s.erase i).card := by
55
+ apply (Finset.prod_le_prod₀ (fun j _ => abs_nonneg _) (fun j hj => ?_)).trans_eq
56
+ (Finset.prod_const _)
57
+ rw [abs_inv]
58
+ simpa only [one_div] using one_div_le_one_div_of_le hr (hsep j hj)
59
+ rw [heq, coeff_C_mul, abs_mul, Finset.abs_prod]
60
+ calc
61
+ _ ≤ (r⁻¹) ^ (s.erase i).card * (2 : ℝ) ^ (s.erase i).card :=
62
+ mul_le_mul hprod (coeff_prod_X_sub_C_abs_le (s.erase i) v
63
+ (fun j hj => hv j (Finset.mem_of_mem_erase hj)) n) (abs_nonneg _) (by positivity)
64
+ _ = _ := by rw [← mul_pow]; congr 1; ring
65
+
66
+ end Erdos3
67
+
68
+ end
69
+
70
+ section
71
+
72
+ namespace Erdos3
73
+
74
+ open Polynomial
75
+ open scoped BigOperators
76
+
77
+ theorem polynomial_coeff_le_of_separated_samples (p : ℝ[X]) (t : Finset ℝ)
78
+ {r u : ℝ} (hr : 0 < r) (hu : 0 ≤ u) (hdeg : p.degree < t.card)
79
+ (ht : ∀ x ∈ t, |x| ≤ 1) (hval : ∀ x ∈ t, |p.eval x| ≤ u)
80
+ (hsep : ∀ x ∈ t, ∀ y ∈ t, x ≠ y → r ≤ |x - y|) (n : ℕ) :
81
+ |p.coeff n| ≤ (t.card : ℝ) * u * (2 / r) ^ (t.card - 1) := by
82
+ classical
83
+ have heq : p = Lagrange.interpolate t id (fun x => p.eval x) :=
84
+ Lagrange.eq_interpolate (fun _ _ _ _ h => h) hdeg
85
+ have hterm (x : ℝ) (hx : x ∈ t) :
86
+ |(C (p.eval x) * Lagrange.basis t id x).coeff n| ≤ u * (2 / r) ^ (t.card - 1) := by
87
+ rw [coeff_C_mul, abs_mul]
88
+ apply mul_le_mul (hval x hx) _ (abs_nonneg _) hu
89
+ have h := lagrange_basis_coeff_abs_le t id x hr ht
90
+ (fun y hy => hsep x hx y (Finset.mem_of_mem_erase hy) (Finset.ne_of_mem_erase hy).symm) n
91
+ simpa only [Finset.card_erase_of_mem hx] using h
92
+ calc
93
+ |p.coeff n| = |(∑ x ∈ t, C (p.eval x) * Lagrange.basis t id x).coeff n| :=
94
+ congrArg (fun q : ℝ[X] => |q.coeff n|) heq
95
+ _ = |∑ x ∈ t, (C (p.eval x) * Lagrange.basis t id x).coeff n| := by rw [finsetSum_coeff]
96
+ _ ≤ ∑ x ∈ t, |(C (p.eval x) * Lagrange.basis t id x).coeff n| := Finset.abs_sum_le_sum_abs _ _
97
+ _ ≤ ∑ _x ∈ t, u * (2 / r) ^ (t.card - 1) := Finset.sum_le_sum hterm
98
+ _ = _ := by simp only [Finset.sum_const, nsmul_eq_mul]; ring
99
+
100
+ end Erdos3
101
+
102
+ end
103
+
104
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SeparatedLabelExtension.lean ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.LipschitzExtensionAlongMap
2
+ import OAI.Combinatorics.Progressions.Lattices.CircleResiduePartition
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ open scoped NNReal
11
+
12
+ theorem exists_bounded_extension_on_separated_labels
13
+ {A Y X : Type*} [PseudoMetricSpace Y] [PseudoMetricSpace X]
14
+ (embed : A → Y) (D L B : ℝ≥0)
15
+ (hsep : ∀ a b, a ≠ b → (1 : ℝ) ≤ D * dist (embed a) (embed b))
16
+ (f : A → X → ℂ) (hf : ∀ a, LipschitzWith L (f a))
17
+ (hb : ∀ a x, ‖f a x‖ ≤ B) :
18
+ ∃ g : Y × X → ℂ, LipschitzWith (2 * max L (2 * B * D)) g ∧
19
+ (∀ a x, g (embed a, x) = f a x) ∧ ∀ z, ‖g z‖ ≤ 2 * B := by
20
+ classical
21
+ let S : Set (Y × X) := {z | z.1 ∈ Set.range embed}
22
+ let label (z : S) : A := Classical.choose z.property
23
+ have hlabel (z : S) : embed (label z) = z.val.1 := Classical.choose_spec z.property
24
+ let F : S → ℂ := fun z => f (label z) z.val.2
25
+ let K : ℝ≥0 := max L (2 * B * D)
26
+ have hLK : (L : ℝ) ≤ K := by exact_mod_cast le_max_left L (2 * B * D)
27
+ have hDK : (2 * B * D : ℝ≥0) ≤ K := le_max_right _ _
28
+ have hF : LipschitzWith K F := by
29
+ apply LipschitzWith.of_dist_le_mul
30
+ intro z w
31
+ have hY : dist z.val.1 w.val.1 ≤ dist z w := by
32
+ change dist z.val.1 w.val.1 ≤ max (dist z.val.1 w.val.1) (dist z.val.2 w.val.2)
33
+ exact le_max_left _ _
34
+ have hX : dist z.val.2 w.val.2 ≤ dist z w := by
35
+ change dist z.val.2 w.val.2 ≤ max (dist z.val.1 w.val.1) (dist z.val.2 w.val.2)
36
+ exact le_max_right _ _
37
+ by_cases h : label z = label w
38
+ · have he : dist (F z) (F w) ≤ (L : ℝ) * dist z.val.2 w.val.2 := by
39
+ simpa only [F, h] using (hf (label w)).dist_le_mul z.val.2 w.val.2
40
+ exact he.trans ((mul_le_mul_of_nonneg_left hX L.coe_nonneg).trans
41
+ (mul_le_mul_of_nonneg_right hLK dist_nonneg))
42
+ · have hs := hsep (label z) (label w) h
43
+ rw [hlabel z, hlabel w] at hs
44
+ have hs' : (1 : ℝ) ≤ D * dist z w :=
45
+ hs.trans (mul_le_mul_of_nonneg_left hY D.coe_nonneg)
46
+ have hnorm : dist (F z) (F w) ≤ 2 * (B : ℝ) := by
47
+ rw [dist_eq_norm]
48
+ exact (norm_sub_le _ _).trans ((add_le_add (hb (label z) z.val.2)
49
+ (hb (label w) w.val.2)).trans_eq (two_mul (B : ℝ)).symm)
50
+ calc
51
+ _ ≤ 2 * (B : ℝ) := hnorm
52
+ _ ≤ (2 * (B : ℝ)) * (D * dist z w) := by
53
+ simpa only [mul_one] using mul_le_mul_of_nonneg_left hs' (by positivity : 0 ≤ 2 * (B : ℝ))
54
+ _ = ((2 * B * D : ℝ≥0) : ℝ) * dist z w := by
55
+ simp only [NNReal.coe_mul, NNReal.coe_ofNat]
56
+ ring
57
+ _ ≤ (K : ℝ) * dist z w := mul_le_mul_of_nonneg_right (by exact_mod_cast hDK) dist_nonneg
58
+ obtain ⟨g, hg, heq, hgB⟩ := exists_complex_extension_from_subset S F K B hF
59
+ (fun z => hb (label z) z.val.2)
60
+ refine ⟨g, hg, ?_, hgB⟩
61
+ intro a x
62
+ let z : S := ⟨(embed a, x), ⟨a, rfl⟩⟩
63
+ have ha : label z = a := by
64
+ by_contra h
65
+ have hs := hsep (label z) a h
66
+ rw [hlabel z] at hs
67
+ change (1 : ℝ) ≤ D * dist (embed a) (embed a) at hs
68
+ simp only [dist_self, mul_zero] at hs
69
+ norm_num at hs
70
+ simpa only [F, ha, z] using heq z
71
+
72
+ theorem exists_residue_real_extension {q : ℕ} [NeZero q]
73
+ (f : ZMod q → ℝ → ℂ) (L : ℝ≥0)
74
+ (hf : ∀ r, LipschitzWith L (f r)) (hb : ∀ r x, ‖f r x‖ ≤ 1) :
75
+ ∃ g : AddCircle (1 : ℝ) × ℝ → ℂ,
76
+ LipschitzWith (2 * max L (2 * (q : ℝ≥0))) g ∧
77
+ (∀ r x, g (ZMod.toAddCircle r, x) = f r x) ∧ ∀ z, ‖g z‖ ≤ 2 := by
78
+ simpa using exists_bounded_extension_on_separated_labels
79
+ (fun r : ZMod q => ZMod.toAddCircle r) (q : ℝ≥0) L 1
80
+ (fun r s hrs => by exact_mod_cast CircleFourier.one_le_mul_dist_toAddCircle hrs) f hf hb
81
+
82
+ end Erdos3
83
+
84
+ end
85
+
86
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SeparatedPositiveSum.lean ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ open scoped NNReal
10
+
11
+ theorem separated_tsum_lipschitz {ι X : Type*} [PseudoMetricSpace X]
12
+ (f : ι → X → ℝ) {K : ℝ≥0} (hf : ∀ i, LipschitzWith K (f i))
13
+ (hpos : ∀ i x, 0 ≤ f i x)
14
+ (hsep : ∀ x i j, f i x ≠ 0 → f j x ≠ 0 → i = j) :
15
+ LipschitzWith K (fun x => ∑' i, f i x) := by
16
+ have hsingle (x : X) (i : ι) (hi : f i x ≠ 0) : (∑' j, f j x) = f i x := by
17
+ apply tsum_eq_single i
18
+ intro j hji
19
+ by_contra hj
20
+ exact hji (hsep x j i hj hi)
21
+ have hdom (x : X) (i : ι) : f i x ≤ ∑' j, f j x := by
22
+ by_cases hi : f i x = 0
23
+ · rw [hi]
24
+ exact tsum_nonneg (fun j => hpos j x)
25
+ · rw [hsingle x i hi]
26
+ have hsub (x y : X) : (∑' i, f i x) - (∑' i, f i y) ≤ K * dist x y := by
27
+ by_cases hx : ∃ i, f i x ≠ 0
28
+ · obtain ⟨i, hi⟩ := hx
29
+ rw [hsingle x i hi]
30
+ have h := (le_abs_self (f i x - f i y)).trans ((hf i).dist_le_mul x y)
31
+ linarith [hdom y i]
32
+ · have hz : ∀ i, f i x = 0 := fun i => not_ne_iff.mp (fun hi => hx ⟨i, hi⟩)
33
+ simp only [hz, tsum_zero, zero_sub]
34
+ exact le_trans (neg_nonpos.mpr (tsum_nonneg (fun i => hpos i y)))
35
+ (mul_nonneg K.coe_nonneg dist_nonneg)
36
+ apply LipschitzWith.of_dist_le_mul
37
+ intro x y
38
+ rw [Real.dist_eq, abs_le]
39
+ have hxy := hsub x y
40
+ have hyx := hsub y x
41
+ rw [dist_comm y x] at hyx
42
+ constructor <;> linarith
43
+
44
+ end Erdos3
45
+
46
+ end
47
+
48
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SeparatedRealSamples.lean ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
2
+ import Mathlib.MeasureTheory.Measure.Real
3
+ import Mathlib.Tactic
4
+
5
+ namespace OAI
6
+
7
+ section
8
+
9
+ namespace Erdos3
10
+
11
+ open MeasureTheory
12
+ open scoped BigOperators
13
+
14
+ theorem real_interval_cover_measure_le (t : Finset ℝ) {r : ℝ} (hr : 0 ≤ r) :
15
+ volume.real (⋃ y ∈ t, Set.Ioo (y - r) (y + r)) ≤ 2 * (t.card : ℝ) * r := by
16
+ apply (measureReal_biUnion_finset_le t (fun y => Set.Ioo (y - r) (y + r))).trans
17
+ have hlen (y : ℝ) : volume.real (Set.Ioo (y - r) (y + r)) = 2 * r := by
18
+ rw [Real.volume_real_Ioo_of_le (by linarith)]
19
+ ring
20
+ simp only [hlen, Finset.sum_const, nsmul_eq_mul]
21
+ ring_nf
22
+ exact le_rfl
23
+
24
+ theorem exists_separated_real_samples (s : Set ℝ) {r : ℝ} (hr : 0 < r) (n : ℕ)
25
+ (hlarge : 2 * (n : ℝ) * r < volume.real s) :
26
+ ∃ t : Finset ℝ, t.card = n ∧ (↑t : Set ℝ) ⊆ s ∧
27
+ ∀ x ∈ t, ∀ y ∈ t, x ≠ y → r ≤ |x - y| := by
28
+ classical
29
+ induction n with
30
+ | zero => exact ⟨∅, rfl, by simp, by simp⟩
31
+ | succ n ih =>
32
+ have hsmall : 2 * (n : ℝ) * r < volume.real s := by
33
+ push_cast at hlarge
34
+ nlinarith
35
+ obtain ⟨t, hcard, hts, hsep⟩ := ih hsmall
36
+ let cover := ⋃ y ∈ t, Set.Ioo (y - r) (y + r)
37
+ have hfinite : volume cover ≠ ⊤ := by
38
+ apply measure_biUnion_ne_top t.finite_toSet
39
+ intro y _
40
+ simp only [Real.volume_Ioo, ne_eq, ENNReal.ofReal_ne_top, not_false_eq_true]
41
+ have hnot : ¬s ⊆ cover := by
42
+ intro hsub
43
+ have h := (measureReal_mono hsub hfinite).trans (real_interval_cover_measure_le t hr.le)
44
+ rw [hcard] at h
45
+ linarith
46
+ obtain ⟨x, hxs, hxc⟩ := Set.not_subset.mp hnot
47
+ have hfar (y : ℝ) (hy : y ∈ t) : r ≤ |x - y| := by
48
+ by_contra! h
49
+ have hxy := abs_lt.mp h
50
+ apply hxc
51
+ exact Set.mem_iUnion.mpr ⟨y, Set.mem_iUnion.mpr ⟨hy, ⟨by linarith, by linarith⟩⟩⟩
52
+ have hxt : x ∉ t := by
53
+ intro hx
54
+ have h := hfar x hx
55
+ simp only [sub_self, abs_zero] at h
56
+ linarith
57
+ refine ⟨insert x t, by rw [Finset.card_insert_of_notMem hxt, hcard], ?_, ?_⟩
58
+ · intro y hy
59
+ rcases Finset.mem_insert.mp hy with rfl | hy
60
+ · exact hxs
61
+ · exact hts hy
62
+ · intro a ha b hb hab
63
+ rcases Finset.mem_insert.mp ha with hax | hat
64
+ · subst a
65
+ rcases Finset.mem_insert.mp hb with rfl | hbt
66
+ · exact False.elim (hab rfl)
67
+ · exact hfar b hbt
68
+ · rcases Finset.mem_insert.mp hb with hbx | hbt
69
+ · subst b
70
+ simpa only [abs_sub_comm] using hfar a hat
71
+ · exact hsep a hat b hbt hab
72
+
73
+ end Erdos3
74
+
75
+ end
76
+
77
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/Separation.lean ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Results.Basic
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem eq_zero_of_integer_mul_of_abs_lt {x D : ℝ} (hD : 0 < D)
10
+ (hgrid : ∃ z : ℤ, D * x = z) (hsmall : |x| < 1 / D) : x = 0 := by
11
+ obtain ⟨z, hz⟩ := hgrid
12
+ have hzsmall : |(z : ℝ)| < 1 := by
13
+ rw [← hz, abs_mul, abs_of_pos hD]
14
+ have h := (lt_div_iff₀ hD).mp hsmall
15
+ nlinarith
16
+ have hz0 : z = 0 := by
17
+ have h : |z| < (1 : ℤ) := by exact_mod_cast hzsmall
18
+ have hnonneg := abs_nonneg z
19
+ have habs : |z| = 0 := by omega
20
+ exact abs_eq_zero.mp habs
21
+ rw [hz0, Int.cast_zero] at hz
22
+ exact (mul_eq_zero.mp hz).resolve_left hD.ne'
23
+
24
+ theorem separate_kernel {V ι : Type*} [AddCommGroup V] [Module ℝ V]
25
+ (Q : V →ₗ[ℝ] (ι → ℝ)) (a b : V) {D : ℝ} (hD : 0 < D)
26
+ (hsum : Q (a + b) = 0)
27
+ (hgrid : ∀ i, ∃ z : ℤ, D * Q b i = z)
28
+ (hsmall : ∀ i, |Q a i| < 1 / D) : Q a = 0 ∧ Q b = 0 := by
29
+ have hcoords : ∀ i, Q a i + Q b i = 0 := by
30
+ intro i
31
+ have h := congrFun hsum i
32
+ simpa only [map_add, Pi.add_apply, Pi.zero_apply] using h
33
+ have hb : Q b = 0 := by
34
+ funext i
35
+ apply eq_zero_of_integer_mul_of_abs_lt hD (hgrid i)
36
+ have hneg : Q b i = -(Q a i) := by linarith [hcoords i]
37
+ simpa only [hneg, abs_neg] using hsmall i
38
+ refine ⟨?_, hb⟩
39
+ funext i
40
+ change Q a i = 0
41
+ have hbi : Q b i = 0 := congrFun hb i
42
+ linarith [hcoords i]
43
+
44
+ end Erdos3
45
+
46
+ end
47
+
48
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonDescent.lean ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Linear.SharedFreeComparisonKernel
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def rankUnitDescentConstant (s : ℕ) : ℕ :=
10
+ (RationalFilteredNilmanifold.UnitVerticalObservable.exists_lower_rank_family.{0, 0, 0} s).choose
11
+
12
+ end Erdos3
13
+
14
+ namespace Erdos3.NativeRankRelation.CommonData
15
+
16
+ open Module
17
+ open scoped TensorProduct BigOperators
18
+
19
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
20
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
21
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
22
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
23
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
24
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
25
+
26
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
27
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
28
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
29
+ (B : D.CoefficientBases Q)
30
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
31
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
32
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
33
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
34
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
35
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
36
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
37
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
38
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
39
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
40
+
41
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
42
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
43
+ (D' : R'.CommonData P')
44
+
45
+ theorem CoefficientBases.comparison_lower_rank_family
46
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
47
+ (hfreq : V.frequency = B.freeFrequency D) (pM : ℝ) (hpM : 0 ≤ pM) :
48
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
49
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
50
+ ∀ [TopologicalSpace (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))]
51
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))]
52
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))]
53
+ [T2Space (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))]
54
+ (J : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j))
55
+ (M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
56
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1)))) (U : M.DegreeRankStructure (r + 1)),
57
+ U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree →
58
+ U.ComplexityLE pM →
59
+ ∀ Z : M.UnitVerticalObservable (U.realSubgroup s (r + 1))
60
+ (Fin W.family.outputDim × Fin W.family.outputDim) pM,
61
+ Z.frequency = (pairDifferenceFunctional V.frequency).comp
62
+ (SubspaceFreeLift.evaluation S J
63
+ (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS).toLinearMap →
64
+ ∀ u : M.filtration.realification.PolynomialOrbit (fun _ : Unit => 1),
65
+ RationalFilteredNilmanifold.HasLowerRankUnitFamily M U Z.observable u
66
+ ((pM + rankUnitDescentConstant s) ^ rankUnitDescentConstant s) := by
67
+ intro S hS _ _ _ _ J M U hU hUc Z hZ u
68
+ have hzero := B.native_comparison_frequency_zero D E T hbQ hT V g hg D'
69
+ hTfil hfreq J M U hU Z.frequency hZ
70
+ obtain ⟨n, hn, Q', U', hQF, _, _, hU'c, hK⟩ :=
71
+ (RationalFilteredNilmanifold.UnitVerticalObservable.exists_lower_rank_family.{0, 0, 0} s).choose_spec.2
72
+ M U Z u hpM hUc hzero
73
+ refine ⟨n, hn, Q', U', hU'c, ?_⟩
74
+ let := moduleTopology ℝ (ℝ ⊗[ℚ]
75
+ (SubspaceFreeLift.Algebra S (r + 1) ⧸ U.filtration.layerIdeal s (r + 1)))
76
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ]
77
+ (SubspaceFreeLift.Algebra S (r + 1) ⧸ U.filtration.layerIdeal s (r + 1))) :=
78
+ IsModuleTopology.isTopologicalAddGroup ℝ _
79
+ let := realification_moduleTopology_t2 Q'.basis
80
+ obtain ⟨K, hKo, hKn, hKc, hKu, _, hKe⟩ := hK
81
+ exact ⟨U.rankQuotientOrbit Q' hQF u, K, hKo, hKn, hKc, hKu, hKe⟩
82
+
83
+ end Erdos3.NativeRankRelation.CommonData
84
+
85
+ end
86
+
87
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonLift.lean ADDED
@@ -0,0 +1,879 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Estimates.SharedFreeComparisonOrbit
2
+ import OAI.Combinatorics.Progressions.Linear.SharedFreeComparisonBasis
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3
9
+
10
+ theorem four_projection_petal_add_invariant
11
+ {R I E : Type*} {V : I → Type*} [CommRing R]
12
+ [∀ i, AddCommGroup (V i)] [∀ i, Module R (V i)] [AddCommGroup E]
13
+ (f : (∀ i, V i) → E) (K : ∀ i, Submodule R (Fin 4 → V i))
14
+ (hK : ∀ z : ∀ i, Fin 4 → V i, (∀ i, z i ∈ K i) → fourFunctionDifference f z = 0)
15
+ (x p : ∀ i, V i) (hx : ∀ i, x i ∈ (K i).map (LinearMap.proj 0))
16
+ (hp : ∀ i, LinearMap.single R (fun _ : Fin 4 => V i) 0 (p i) ∈ K i) :
17
+ f (x + p) = f x := by
18
+ classical
19
+ have hlift (i : I) : ∃ z ∈ K i, z 0 = x i := hx i
20
+ choose z hz hz0 using hlift
21
+ let y (i : I) := z i + LinearMap.single R (fun _ : Fin 4 => V i) 0 (p i)
22
+ have hy (i : I) : y i ∈ K i := (K i).add_mem (hz i) (hp i)
23
+ have hy0 : (fun i => y i 0) = x + p := by
24
+ funext i
25
+ simp only [y, Pi.add_apply, LinearMap.single_apply, Pi.single_eq_same, hz0]
26
+ have hy1 : (fun i => y i 1) = fun i => z i 1 := by
27
+ funext i
28
+ simp [y, LinearMap.single_apply]
29
+ have hy2 : (fun i => y i 2) = fun i => z i 2 := by
30
+ funext i
31
+ simp [y, LinearMap.single_apply]
32
+ have hy3 : (fun i => y i 3) = fun i => z i 3 := by
33
+ funext i
34
+ simp [y, LinearMap.single_apply]
35
+ have h₀ := hK z hz
36
+ have h₁ := hK y hy
37
+ rw [fourFunctionDifference, hy0, hy1, hy2, hy3] at h₁
38
+ rw [fourFunctionDifference, show (fun i => z i 0) = x from funext hz0] at h₀
39
+ simp only [sub_eq_add_neg] at h₀ h₁
40
+ exact add_right_cancel (add_right_cancel (add_right_cancel (h₁.trans h₀.symm)))
41
+
42
+ end Erdos3
43
+
44
+ end
45
+
46
+ section
47
+
48
+ namespace Erdos3
49
+
50
+ open Module
51
+ open scoped TensorProduct Matrix NNReal
52
+
53
+ theorem realifyCoordinateMap_eq_coordinates
54
+ {V ι : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι]
55
+ (φ : V →ₗ[ℚ] (ι → ℚ)) (x : ℝ ⊗[ℚ] V) :
56
+ realifyCoordinateMap φ x = realRationalCoordinateEquiv (φ.baseChange ℝ x) := by
57
+ induction x using TensorProduct.inductionOn with
58
+ | tmul a v =>
59
+ funext i
60
+ rw [realifyCoordinateMap_tmul, LinearMap.baseChange_tmul, realRationalCoordinateEquiv_tmul]
61
+ | add x y hx hy => simp only [map_add, hx, hy]
62
+
63
+ theorem exists_controlled_subspace_image_section
64
+ {μ ι κ V : Type*} [Fintype μ] [Fintype ι] [Fintype κ]
65
+ [AddCommGroup V] [Module ℚ V]
66
+ (b : Basis μ ℚ V) (U : Submodule ℚ V) (v : κ → V)
67
+ (hv : Submodule.span ℚ (Set.range v) = U) (φ : V →ₗ[ℚ] (ι → ℚ))
68
+ {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l)
69
+ (hvH : ∀ j i, RationalHeightLE (b.repr (v j) i) H)
70
+ (hφH : ∀ j i, RationalHeightLE (φ (v j) i) H)
71
+ {p : ℝ} (hp : 0 ≤ p) (hμ : (Fintype.card μ : ℝ) ≤ p)
72
+ (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p)
73
+ (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) :
74
+ ∃ (σ : (ι → ℝ) →ₗ[ℝ] (ℝ ⊗[ℚ] V)) (m : ℕ),
75
+ 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 3 + (p + 2) ^ 36) ∧
76
+ (∀ y, σ y ∈ U.baseChange ℝ) ∧
77
+ (∀ x ∈ U.baseChange ℝ,
78
+ realifyCoordinateMap φ (σ (realifyCoordinateMap φ x)) = realifyCoordinateMap φ x) ∧
79
+ (∀ y, ‖(b.baseChange ℝ).equivFun (σ y)‖ ≤
80
+ Real.exp ((p + 2) ^ 3 + (p + 2) ^ 18) * ‖y‖) ∧
81
+ ∀ y ∈ realDenominatorGrid l, (b.baseChange ℝ).equivFun (σ y) ∈ realDenominatorGrid m := by
82
+ classical
83
+ let A : Matrix ι κ ℚ := fun i j => φ (v j) i
84
+ let B : Matrix μ κ ℚ := fun i j => b.repr (v j) i
85
+ obtain ⟨S, hS, hSH⟩ := exists_bounded_rational_image_section A hH (fun i j => hφH j i)
86
+ let σ := (b.baseChange ℝ).equivFun.symm.toLinearMap.comp
87
+ ((Matrix.mulVecLin (fun i j => (B i j : ℝ))).comp
88
+ (Matrix.mulVecLin (fun i j => (S i j : ℝ))))
89
+ have hσ (y : ι → ℝ) :
90
+ σ y = realGeneratorCombination v ((fun i j => (S i j : ℝ)) *ᵥ y) := by
91
+ apply (b.baseChange ℝ).equivFun.injective
92
+ change (b.baseChange ℝ).equivFun ((b.baseChange ℝ).equivFun.symm
93
+ ((fun i j => (B i j : ℝ)) *ᵥ ((fun i j => (S i j : ℝ)) *ᵥ y))) = _
94
+ rw [LinearEquiv.apply_symm_apply, realGeneratorCombination_coordinates]
95
+ have hcoord (y : ι → ℝ) : (b.baseChange ℝ).equivFun (σ y) =
96
+ (fun i j => (B i j : ℝ)) *ᵥ ((fun i j => (S i j : ℝ)) *ᵥ y) := by
97
+ rw [hσ, realGeneratorCombination_coordinates]
98
+ have hvU (j : κ) : v j ∈ U := hv ▸ Submodule.subset_span (Set.mem_range_self j)
99
+ have hvφ : Submodule.span ℚ (Set.range (fun j => φ (v j))) = U.map φ := by
100
+ rw [← hv, Submodule.map_span, ← Set.range_comp]
101
+ rfl
102
+ have hHp' : (H : ℝ) ≤ Real.exp ((p + 2) ^ 1) :=
103
+ hHp.trans (Real.exp_le_exp.mpr (by simp))
104
+ have hBden : (matrixDenominator B : ℝ) ≤ Real.exp ((p + 2) ^ 3) :=
105
+ matrixDenominator_le_exp_power B hp 1 hμ hκ
106
+ (fun i j => (Nat.cast_le.mpr (hvH j i).2).trans hHp')
107
+ have hSden := real_image_section_denominator_bound S H l hSH hp hι hκ hHp hlp
108
+ have hfac : ((Fintype.card κ : ℝ) + 1) * (H + 1) ≤ Real.exp ((p + 2) ^ 3) := by
109
+ apply le_trans _ (matrix_weighted_factor_le_exp_power (Fintype.card κ) hp hκ 1 (by decide))
110
+ exact mul_le_mul_of_nonneg_left (add_le_add hHp' le_rfl) (by positivity)
111
+ have hBnorm (y : κ → ℝ) :
112
+ ‖(fun i j => (B i j : ℝ)) *ᵥ y‖ ≤ Real.exp ((p + 2) ^ 3) * ‖y‖ :=
113
+ (norm_matrix_mulVec_le _ (H : ℝ≥0) (fun i j => (hvH j i).abs_real_le) y).trans
114
+ (mul_le_mul_of_nonneg_right hfac (norm_nonneg y))
115
+ refine ⟨σ, matrixDenominator B * (matrixDenominator S * l),
116
+ Nat.mul_pos (matrixDenominator_pos B) (Nat.mul_pos (matrixDenominator_pos S) hl),
117
+ ?_, ?_, ?_, ?_, ?_⟩
118
+ · rw [Nat.cast_mul]
119
+ exact (mul_le_mul hBden hSden (Nat.cast_nonneg _) (Real.exp_pos _).le).trans_eq
120
+ (Real.exp_add _ _).symm
121
+ · intro y
122
+ rw [hσ]
123
+ exact realGeneratorCombination_mem U v hvU _
124
+ · intro x hx
125
+ have himg : realifyCoordinateMap φ x ∈
126
+ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) := by
127
+ rw [← realRationalCoordinateSpan_eq_image (U.map φ) (fun j => φ (v j)) hvφ,
128
+ realifyCoordinateMap_eq_coordinates]
129
+ refine ⟨φ.baseChange ℝ x, ?_, rfl⟩
130
+ rw [realification_map]
131
+ exact ⟨x, hx, rfl⟩
132
+ rw [hσ, realifyCoordinateMap_eq_coordinates, realGeneratorCombination_map_coordinates]
133
+ exact real_matrix_image_section_apply A S hS _ himg
134
+ · intro y
135
+ rw [hcoord]
136
+ calc
137
+ _ ≤ Real.exp ((p + 2) ^ 3) * ‖(fun i j => (S i j : ℝ)) *ᵥ y‖ := hBnorm _
138
+ _ ≤ Real.exp ((p + 2) ^ 3) * (Real.exp ((p + 2) ^ 18) * ‖y‖) :=
139
+ mul_le_mul_of_nonneg_left (real_image_section_norm_bound S H hSH hp hι hκ hHp y)
140
+ (Real.exp_pos _).le
141
+ _ = _ := by rw [← mul_assoc, ← Real.exp_add]
142
+ · intro y hy
143
+ rw [hcoord]
144
+ exact real_matrix_denominator_grid B _ _ (real_matrix_denominator_grid S l y hy)
145
+
146
+ end Erdos3
147
+
148
+ end
149
+
150
+ section
151
+
152
+ namespace Erdos3
153
+
154
+ open Module
155
+ open scoped TensorProduct
156
+
157
+ theorem realify_basis_coordinates
158
+ {V ι : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι]
159
+ (b : Basis ι ℚ V) (x : ℝ ⊗[ℚ] V) :
160
+ realifyCoordinateMap b.equivFun.toLinearMap x = (b.baseChange ℝ).equivFun x := by
161
+ induction x using TensorProduct.inductionOn with
162
+ | tmul a v =>
163
+ funext i
164
+ rw [realifyCoordinateMap_tmul]
165
+ change a * (b.repr v i : ℝ) = (b.baseChange ℝ).repr (a ⊗ₜ[ℚ] v) i
166
+ rw [Basis.baseChange_repr_tmul]
167
+ simp only [Rat.smul_def, mul_comm]
168
+ | add x y hx hy => simp only [map_add, hx, hy]
169
+
170
+ theorem exists_controlled_subspace_projector
171
+ {μ κ V : Type*} [Fintype μ] [Fintype κ] [AddCommGroup V] [Module ℚ V]
172
+ (b : Basis μ ℚ V) (U : Submodule ℚ V) (v : κ → V)
173
+ (hv : Submodule.span ℚ (Set.range v) = U) (l : ℕ) (hl : 0 < l)
174
+ {p : ℝ} (hp : 0 ≤ p) (hμ : (Fintype.card μ : ℝ) ≤ p)
175
+ (hκ : (Fintype.card κ : ℝ) ≤ p)
176
+ (hvH : ∀ j i, rationalLogHeight (b.repr (v j) i) ≤ p)
177
+ (hlp : (l : ℝ) ≤ Real.exp p) :
178
+ let q := p + 1
179
+ ∃ (P : (ℝ ⊗[ℚ] V) →ₗ[ℝ] (ℝ ⊗[ℚ] V)) (m : ℕ),
180
+ 0 < m ∧ (m : ℝ) ≤ Real.exp ((q + 2) ^ 3 + (q + 2) ^ 36) ∧
181
+ (∀ x, P x ∈ U.baseChange ℝ) ∧ (∀ x ∈ U.baseChange ℝ, P x = x) ∧
182
+ (∀ x, ‖(b.baseChange ℝ).equivFun (P x)‖ ≤
183
+ Real.exp ((q + 2) ^ 3 + (q + 2) ^ 18) * ‖(b.baseChange ℝ).equivFun x‖) ∧
184
+ ∀ x, (b.baseChange ℝ).equivFun x ∈ realDenominatorGrid l →
185
+ (b.baseChange ℝ).equivFun (P x) ∈ realDenominatorGrid m := by
186
+ intro q
187
+ have hpq : p ≤ q := by dsimp [q]; linarith
188
+ obtain ⟨σ, m, hm, hmp, hσU, hσfix, hσnorm, hσgrid⟩ :=
189
+ exists_controlled_subspace_image_section b U v hv b.equivFun.toLinearMap
190
+ (one_le_ceil_exp p) hl (fun j i => rationalHeightLE_ceil_exp (hvH j i))
191
+ (fun j i => rationalHeightLE_ceil_exp (hvH j i))
192
+ (hp.trans hpq) (hμ.trans hpq) (hμ.trans hpq) (hκ.trans hpq)
193
+ (ceil_exp_le_exp_add_one hp) (hlp.trans (Real.exp_le_exp.mpr hpq))
194
+ let P := σ.comp (b.baseChange ℝ).equivFun.toLinearMap
195
+ refine ⟨P, m, hm, hmp, (fun x => hσU _), ?_, (fun x => hσnorm _), ?_⟩
196
+ · intro x hx
197
+ apply (b.baseChange ℝ).equivFun.injective
198
+ change (b.baseChange ℝ).equivFun (σ ((b.baseChange ℝ).equivFun x)) = _
199
+ simpa only [realify_basis_coordinates] using hσfix x hx
200
+ · intro x hx
201
+ exact hσgrid _ hx
202
+
203
+ end Erdos3
204
+
205
+ end
206
+
207
+ section
208
+
209
+ namespace Erdos3
210
+
211
+ open Module
212
+ open scoped TensorProduct
213
+
214
+ theorem exists_logHeight_subspace_image_section
215
+ {μ ι κ V : Type*} [Fintype μ] [Fintype ι] [Fintype κ]
216
+ [AddCommGroup V] [Module ℚ V]
217
+ (b : Basis μ ℚ V) (U : Submodule ℚ V) (v : κ → V)
218
+ (hv : Submodule.span ℚ (Set.range v) = U) (φ : V →ₗ[ℚ] (ι → ℚ))
219
+ (l : ℕ) (hl : 0 < l) {p : ℝ} (hp : 0 ≤ p)
220
+ (hμ : (Fintype.card μ : ℝ) ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p)
221
+ (hκ : (Fintype.card κ : ℝ) ≤ p)
222
+ (hvH : ∀ j i, rationalLogHeight (b.repr (v j) i) ≤ p)
223
+ (hφH : ∀ i j, rationalLogHeight (φ (b i) j) ≤ p)
224
+ (hlp : (l : ℝ) ≤ Real.exp p) :
225
+ let t := (p + 2) ^ 4 + 1
226
+ ∃ (σ : (ι → ℝ) →ₗ[ℝ] (ℝ ⊗[ℚ] V)) (m : ℕ),
227
+ 0 < m ∧ (m : ℝ) ≤ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 36) ∧
228
+ (∀ y, σ y ∈ U.baseChange ℝ) ∧
229
+ (∀ x ∈ U.baseChange ℝ,
230
+ realifyCoordinateMap φ (σ (realifyCoordinateMap φ x)) = realifyCoordinateMap φ x) ∧
231
+ (∀ y, ‖(b.baseChange ℝ).equivFun (σ y)‖ ≤
232
+ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 18) * ‖y‖) ∧
233
+ ∀ y ∈ realDenominatorGrid l, (b.baseChange ℝ).equivFun (σ y) ∈ realDenominatorGrid m := by
234
+ intro t
235
+ have hp4 : p ≤ (p + 2) ^ 4 := le_power_budget hp (by decide)
236
+ have hpt : p ≤ t := hp4.trans (le_add_of_nonneg_right (by norm_num))
237
+ have ht : 0 ≤ t := hp.trans hpt
238
+ apply exists_controlled_subspace_image_section b U v hv φ
239
+ (one_le_ceil_exp ((p + 2) ^ 4)) hl _ _ ht (hμ.trans hpt) (hι.trans hpt) (hκ.trans hpt)
240
+ (ceil_exp_le_exp_add_one (by positivity)) (hlp.trans (Real.exp_le_exp.mpr hpt))
241
+ · intro j i
242
+ exact rationalHeightLE_ceil_exp ((hvH j i).trans hp4)
243
+ · intro j i
244
+ apply rationalHeightLE_ceil_exp
245
+ exact linearMap_coordinate_logHeight b (Pi.basisFun ℚ ι) φ hp hμ hφH (v j) (hvH j) i
246
+
247
+ end Erdos3
248
+
249
+ end
250
+
251
+ section
252
+
253
+ namespace Erdos3.SubspaceFreeLift
254
+
255
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
256
+ open scoped TensorProduct
257
+
258
+ theorem exists_native_pair_model (s : ℕ) :
259
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ (L I : Type*) [LieRing L] [LieAlgebra ℚ L] [Fintype I]
260
+ [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
261
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)]
262
+ [TopologicalSpace (ℝ ⊗[ℚ] (Fin 2 → L))]
263
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] (Fin 2 → L))]
264
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] (Fin 2 → L))] [T2Space (ℝ ⊗[ℚ] (Fin 2 → L))]
265
+ (r d : ℕ) (D : RationalFilteredNilmanifold L s d) (T : D.DegreeRankStructure r)
266
+ (S : Fin s → Submodule ℚ (Fin 2 → L))
267
+ (B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j))
268
+ (hS : ∀ j, S j ≤ (piRank (fun _ : Fin 2 => D) (fun _ => T)).filtration.layer (j.val + 1) 0)
269
+ (p : ℝ), 2 ≤ p → T.ComplexityLE p →
270
+ (∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => D.basis)).repr
271
+ (B j a : Fin 2 → L) i) ≤ p) →
272
+ ∀ U : D.UnitVerticalObservable (T.realSubgroup s r) I p,
273
+ let φ := evaluation S B (piRank (fun _ : Fin 2 => D) (fun _ => T)).filtration hS
274
+ ∃ E : RationalFilteredNilmanifold (Algebra S r) s (finrank ℚ (Algebra S r)),
275
+ ∃ Q : E.DegreeRankStructure r,
276
+ Q.filtration = filtration S T.filtration.rank_le_degree ∧
277
+ Q.ComplexityLE ((p + C) ^ C) ∧ IsCentralLieBasis E.basis ∧
278
+ Nonempty (FreeCoordinateFrame E.basis ((p + C) ^ C)) ∧
279
+ (∀ i j, rationalLogHeight ((pi (fun _ : Fin 2 => D)).basis.repr
280
+ (φ (E.basis j)) i) ≤ (p + C) ^ C) ∧
281
+ E.lattice ≤ (pi (fun _ : Fin 2 => D)).lattice.comap (mapOfSteps
282
+ (hL := E.filtration.lowerCentralSeries_eq_bot)
283
+ (hM := (pi (fun _ : Fin 2 => D)).filtration.lowerCentralSeries_eq_bot) φ) ∧
284
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] Algebra S r)
285
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] Algebra S r) :=
286
+ IsModuleTopology.isTopologicalAddGroup ℝ _
287
+ letI := realification_moduleTopology_t2 E.basis
288
+ ∃ V : E.UnitVerticalObservable (Q.realSubgroup s r) (I × I) ((p + C) ^ C),
289
+ V.frequency = (pairDifferenceFunctional U.frequency).comp φ.toLinearMap ∧
290
+ ∀ i x, V.observable i (QuotientGroup.mk x) =
291
+ U.pairedObservable T i (QuotientGroup.mk (realificationMap
292
+ (hnil := E.filtration.lowerCentralSeries_eq_bot)
293
+ (hM := (pi (fun _ : Fin 2 => D)).filtration.lowerCentralSeries_eq_bot) φ x))) := by
294
+ obtain ⟨a, _, hfree⟩ := exists_native_model s
295
+ let K₀ : Polynomial ℕ := (Polynomial.X + 2) ^ 2 +
296
+ (Polynomial.X + (Polynomial.X ^ 2 + Polynomial.X + 3) ^ 2 + 2)
297
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((K₀ + Polynomial.C a) ^ a)
298
+ refine ⟨C, hC, ?_⟩
299
+ intro L I _ _ _ _ _ _ _ _ _ _ _ r d D T S B hS p hp hT hB U φ
300
+ have hp₀ : 0 ≤ p := by linarith
301
+ let P := p + (p ^ 2 + p + 3) ^ 2 + 2
302
+ let K := (p + 2) ^ 2 + P
303
+ have hP : 0 ≤ P := by dsimp only [P]; positivity
304
+ have hpP : p ≤ P := by dsimp only [P]; nlinarith [sq_nonneg (p ^ 2 + p + 3)]
305
+ have hPK : P ≤ K := le_add_of_nonneg_left (sq_nonneg (p + 2))
306
+ have hGK : (p + 2) ^ 2 ≤ K := le_add_of_nonneg_right hP
307
+ have hK : 0 ≤ K := hP.trans hPK
308
+ have hbound : (K + a) ^ a ≤ (p + C) ^ C := by
309
+ simpa [K₀, K, P, Polynomial.eval₂_pow] using hbudget p hp₀
310
+ let D₂ := pi (fun _ : Fin 2 => D)
311
+ let T₂ := piRank (fun _ : Fin 2 => D) (fun _ => T)
312
+ have hT₂ : T₂.ComplexityLE K :=
313
+ (piRank_complexity (fun _ : Fin 2 => D) (fun _ => T) hp₀
314
+ (by simpa using hp) (fun _ => hT)).mono T₂ hGK
315
+ have hB₂ (j : Fin s) (k : Fin (finrank ℚ (S j))) (i) :
316
+ rationalLogHeight (D₂.basis.repr (B j k : Fin 2 → L) i) ≤ K := by
317
+ change rationalLogHeight ((productFinBasis (fun _ : Fin 2 => D)).repr _ i) ≤ K
318
+ rw [productFinBasis, Basis.repr_reindex_apply]
319
+ exact (hB j k _).trans (hpP.trans hPK)
320
+ obtain ⟨E, Q, hQ, hQc, hcentral, ⟨frame⟩, hmatrix, hlattice, hV⟩ :=
321
+ hfree (Fin 2 → L) (I × I) r _ D₂ T₂ S B hS K hK hT₂ hB₂
322
+ ((U.paired T hp hT.1).mono hPK)
323
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] Algebra S r)
324
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] Algebra S r) := IsModuleTopology.isTopologicalAddGroup ℝ _
325
+ let := realification_moduleTopology_t2 E.basis
326
+ obtain ⟨V, hfreq, hobs⟩ := hV
327
+ exact ⟨E, Q, hQ, hQc.mono Q hbound, hcentral, ⟨frame.mono hbound⟩,
328
+ (fun i j => (hmatrix i j).trans hbound), hlattice, V.mono hbound, hfreq, hobs⟩
329
+
330
+ end Erdos3.SubspaceFreeLift
331
+
332
+ end
333
+
334
+ section
335
+
336
+ namespace Erdos3.NativeRankRelation.CommonData
337
+
338
+ open Module
339
+ open scoped TensorProduct
340
+
341
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
342
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
343
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
344
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
345
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
346
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
347
+
348
+ variable {s r N : ℕ} [NeZero N] {b p q P : ℝ}
349
+ {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim}
350
+ {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P)
351
+ (e : Basis (Fin (finrank ℚ D.CoefficientFreeLieAlgebra)) ℚ D.CoefficientFreeLieAlgebra)
352
+ {Q : ℝ} (F : FreeCoordinateFrame e Q)
353
+
354
+ include F
355
+
356
+ theorem exists_coefficientFreeSpan_projector (hs : 1 ≤ s) (d : Fin s)
357
+ (l : ℕ) (hl : 0 < l) {A : ℝ} (hA : 0 ≤ A) (hQA : Q ≤ A)
358
+ (hdim : (finrank ℚ D.CoefficientFreeLieAlgebra : ℝ) ≤ A)
359
+ (hlA : (l : ℝ) ≤ Real.exp A) :
360
+ let t := A + 1
361
+ ∃ (P : (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) →ₗ[ℝ]
362
+ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)) (m : ℕ),
363
+ 0 < m ∧ (m : ℝ) ≤ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 36) ∧
364
+ (∀ x, P x ∈ (D.coefficientFreeSpan d).baseChange ℝ) ∧
365
+ (∀ x ∈ (D.coefficientFreeSpan d).baseChange ℝ, P x = x) ∧
366
+ (∀ x, ‖(e.baseChange ℝ).equivFun (P x)‖ ≤
367
+ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 18) * ‖(e.baseChange ℝ).equivFun x‖) ∧
368
+ ∀ x, (e.baseChange ℝ).equivFun x ∈ realDenominatorGrid l →
369
+ (e.baseChange ℝ).equivFun (P x) ∈ realDenominatorGrid m := by
370
+ obtain ⟨c, hc⟩ := D.exists_coefficientFreeSpan_basis e F hs d
371
+ have hcspan : Submodule.span ℚ (Set.range (fun j => (c j : D.CoefficientFreeLieAlgebra))) =
372
+ D.coefficientFreeSpan d := by
373
+ change Submodule.span ℚ (Set.range ((D.coefficientFreeSpan d).subtype ∘ c)) = _
374
+ rw [Set.range_comp, ← Submodule.map_span, c.span_eq, Submodule.map_top, Submodule.range_subtype]
375
+ apply exists_controlled_subspace_projector e (D.coefficientFreeSpan d)
376
+ (fun j => (c j : D.CoefficientFreeLieAlgebra)) hcspan l hl hA
377
+ · simpa only [Fintype.card_fin] using hdim
378
+ · have hd : (finrank ℚ (D.coefficientFreeSpan d) : ℝ) ≤
379
+ finrank ℚ D.CoefficientFreeLieAlgebra := by
380
+ exact_mod_cast Submodule.finrank_le (D.coefficientFreeSpan d)
381
+ simpa only [Fintype.card_fin] using hd.trans hdim
382
+ · exact fun j i => (hc j i).trans hQA
383
+ · exact hlA
384
+
385
+ end Erdos3.NativeRankRelation.CommonData
386
+
387
+ end
388
+
389
+ section
390
+
391
+ namespace Erdos3
392
+
393
+ noncomputable def sharedFreeCommonCorrectionBudget (s : ℕ) (q p : ℝ) : ℝ :=
394
+ let Λ := (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s
395
+ let t := (q + p + Λ) + 1
396
+ (t + 2) ^ 3 + (t + 2) ^ 36 + Λ
397
+
398
+ theorem refined_firstProjection_le_common
399
+ {R V : Type*} [CommRing R] [AddCommGroup V] [Module R V]
400
+ (C D : Submodule R V) (hDC : D ≤ C) (K : Submodule R (Fin 4 → V)) :
401
+ (fourRefinedRelation C D K).map (LinearMap.proj 0) ≤ C := by
402
+ rintro v ⟨w, hw, rfl⟩
403
+ exact ((mem_fourCommonModulo C D w).mp (fourRefinedRelation_le_common C D hDC K hw)).1 0
404
+
405
+ end Erdos3
406
+
407
+ namespace Erdos3.NativeRankRelation.CommonData
408
+
409
+ open Module VectorPolynomial CyclicCrootSisask
410
+ open scoped TensorProduct BigOperators
411
+
412
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
413
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
414
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
415
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
416
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
417
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
418
+
419
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
420
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
421
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
422
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
423
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
424
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
425
+ (F : FreeCoordinateFrame E.basis Q)
426
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
427
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
428
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
429
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
430
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
431
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
432
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
433
+
434
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
435
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
436
+ (D' : R'.CommonData P')
437
+
438
+ include F
439
+
440
+ theorem exists_shared_free_filtered_common
441
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
442
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
443
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
444
+ (hsplit : ∀ h, g h = ξ * v h)
445
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
446
+ (D.commonFreeSpan d).baseChange ℝ)
447
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
448
+ (D.dependentFreeSpan d).baseChange ℝ)
449
+ (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) :
450
+ let L := sharedFreeCommonCorrectionBudget s Q P'
451
+ ∃ (m : Fin s → ℕ) (γ e q : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra),
452
+ ∀ d, 0 < m d ∧ (m d : ℝ) ≤ Real.exp L ∧
453
+ γ d ∈ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
454
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ ∧
455
+ γ d ∈ (D.coefficientFreeSpan d).baseChange ℝ ∧
456
+ e d ∈ (D.coefficientFreeSpan d).baseChange ℝ ∧
457
+ q d ∈ (D.coefficientFreeSpan d).baseChange ℝ ∧
458
+ coefficients ξ.log (Finsupp.single () (d.val + 1)) = γ d + e d + q d ∧
459
+ ‖(E.basis.baseChange ℝ).equivFun (e d)‖ ≤ Real.exp L / (N : ℝ) ^ (d.val + 1) ∧
460
+ (E.basis.baseChange ℝ).equivFun (q d) ∈ realDenominatorGrid (m d) := by
461
+ intro L
462
+ classical
463
+ obtain ⟨l, γ, e, q, hdata⟩ :=
464
+ D.exists_shared_free_common_projection E T hbQ hT F V g hg D'
465
+ hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN
466
+ let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s
467
+ let A := Q + P' + Λ
468
+ let t := A + 1
469
+ let C := (t + 2) ^ 3 + (t + 2) ^ 18
470
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
471
+ have hΛ : 0 ≤ Λ := pow_nonneg (add_nonneg hP' (Nat.cast_nonneg _)) _
472
+ have hA : 0 ≤ A := add_nonneg (add_nonneg hQ hP') hΛ
473
+ have hQA : Q ≤ A := (le_add_of_nonneg_right hP').trans (le_add_of_nonneg_right hΛ)
474
+ have hPA : P' ≤ A := (le_add_of_nonneg_left hQ).trans (le_add_of_nonneg_right hΛ)
475
+ have hΛA : Λ ≤ A := le_add_of_nonneg_left (add_nonneg hQ hP')
476
+ have hprojectors (d : Fin s) :
477
+ ∃ (P : (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) →ₗ[ℝ]
478
+ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)) (m : ℕ),
479
+ 0 < m ∧ (m : ℝ) ≤ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 36) ∧
480
+ (∀ x, P x ∈ (D.coefficientFreeSpan d).baseChange ℝ) ∧
481
+ (∀ x ∈ (D.coefficientFreeSpan d).baseChange ℝ, P x = x) ∧
482
+ (∀ x, ‖(E.basis.baseChange ℝ).equivFun (P x)‖ ≤
483
+ Real.exp C * ‖(E.basis.baseChange ℝ).equivFun x‖) ∧
484
+ ∀ x, (E.basis.baseChange ℝ).equivFun x ∈ realDenominatorGrid (l d) →
485
+ (E.basis.baseChange ℝ).equivFun (P x) ∈ realDenominatorGrid m := by
486
+ exact D.exists_coefficientFreeSpan_projector E.basis F (by omega) d
487
+ (l d) (hdata d).1 hA hQA ((hT.1.1.trans hQP').trans hPA)
488
+ ((hdata d).2.1.trans (Real.exp_le_exp.mpr hΛA))
489
+ choose P m hm hmb hPU hPfix hPnorm hPgrid using hprojectors
490
+ have ht : 0 ≤ t := add_nonneg hA zero_le_one
491
+ have h18 : (t + 2) ^ 18 ≤ (t + 2) ^ 36 := pow_le_pow_right₀ (by linarith only [ht]) (by decide)
492
+ have hL : L = (t + 2) ^ 3 + (t + 2) ^ 36 + Λ := rfl
493
+ have hCL : C + Λ ≤ L := add_le_add (add_le_add (le_refl ((t + 2) ^ 3)) h18) (le_refl Λ)
494
+ refine ⟨m, γ, (fun d => P d (e d)), (fun d => P d (q d)), ?_⟩
495
+ intro d
496
+ obtain ⟨_hl, _hlb, hγ, heq, herr, hgrid⟩ := hdata d
497
+ have hγC : γ d ∈ (D.coefficientFreeSpan d).baseChange ℝ :=
498
+ Submodule.baseChange_mono ℝ
499
+ (refined_firstProjection_le_common _ _ (D.dependentFreeSpan_le_coefficientFreeSpan d) _) hγ
500
+ have hξC : coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
501
+ (D.coefficientFreeSpan d).baseChange ℝ :=
502
+ Submodule.baseChange_mono ℝ (D.commonFreeSpan_le_coefficientFreeSpan d) (hξ d)
503
+ have hsum : e d + q d ∈ (D.coefficientFreeSpan d).baseChange ℝ := by
504
+ have hh : e d + q d = coefficients ξ.log (Finsupp.single () (d.val + 1)) - γ d := by
505
+ rw [heq]
506
+ abel
507
+ rw [hh]
508
+ exact ((D.coefficientFreeSpan d).baseChange ℝ).sub_mem hξC hγC
509
+ have hsumfix := hPfix d (e d + q d) hsum
510
+ rw [map_add] at hsumfix
511
+ refine ⟨hm d, (hmb d).trans (Real.exp_le_exp.mpr (le_add_of_nonneg_right hΛ)),
512
+ hγ, hγC, hPU d _, hPU d _, ?_, ?_, hPgrid d _ hgrid⟩
513
+ · calc
514
+ _ = γ d + (e d + q d) := by rw [heq, add_assoc]
515
+ _ = γ d + (P d (e d) + P d (q d)) := by rw [hsumfix]
516
+ _ = _ := (add_assoc _ _ _).symm
517
+ · calc
518
+ _ ≤ Real.exp C * ‖(E.basis.baseChange ℝ).equivFun (e d)‖ := hPnorm d _
519
+ _ ≤ Real.exp C * (Real.exp Λ / (N : ℝ) ^ (d.val + 1)) :=
520
+ mul_le_mul_of_nonneg_left herr (Real.exp_pos _).le
521
+ _ = Real.exp (C + Λ) / (N : ℝ) ^ (d.val + 1) := by rw [← mul_div_assoc, ← Real.exp_add]
522
+ _ ≤ _ := div_le_div_of_nonneg_right (Real.exp_le_exp.mpr hCL) (pow_nonneg (Nat.cast_nonneg N) _)
523
+
524
+ end Erdos3.NativeRankRelation.CommonData
525
+
526
+ end
527
+
528
+ section
529
+
530
+ namespace Erdos3.NativeRankRelation.CommonData
531
+
532
+ open Module
533
+ open scoped TensorProduct
534
+
535
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
536
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
537
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
538
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
539
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
540
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
541
+
542
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
543
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
544
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
545
+ (B : D.CoefficientBases Q)
546
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
547
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
548
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
549
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
550
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
551
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
552
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
553
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
554
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
555
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
556
+
557
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
558
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
559
+ (D' : R'.CommonData P')
560
+
561
+ theorem CoefficientBases.comparison_space_top_frequency
562
+ (hfreq : V.frequency = B.freeFrequency D) (n : ℕ) (d : Fin n → Fin s)
563
+ (a : FreeMagma (Fin n)) (hd : lieTreeWeight (fun i => (d i).val + 1) a = s)
564
+ (hr : a.length = r) (z : Fin n → Fin 2 → D.CoefficientFreeLieAlgebra)
565
+ (hz : ∀ i, z i ∈ petalComparisonSpace
566
+ ((fourRefinedRelation (D.coefficientFreeSpan (d i)) (D.dependentFreeSpan (d i))
567
+ (D'.coefficientFourSpace ⟨(d i).val + 1, by omega⟩)).map (LinearMap.proj 0))
568
+ (fourPetalSpace (D.dependentFreeSpan (d i))
569
+ (fourRefinedRelation (D.coefficientFreeSpan (d i)) (D.dependentFreeSpan (d i))
570
+ (D'.coefficientFourSpace ⟨(d i).val + 1, by omega⟩)))
571
+ (D.coefficientFreeFiltration.layer ((d i).val + 1) 2)) :
572
+ pairDifferenceFunctional (B.freeFrequency D) (lieTreeEval z a) = 0 := by
573
+ have hC (j : Fin s) :
574
+ (fourRefinedRelation (D.coefficientFreeSpan j) (D.dependentFreeSpan j)
575
+ (D'.coefficientFourSpace ⟨j.val + 1, by omega⟩)).map (LinearMap.proj 0) ≤
576
+ D.coefficientFreeFiltration.layer (j.val + 1) 1 :=
577
+ (refined_firstProjection_le_common _ _ (D.dependentFreeSpan_le_coefficientFreeSpan j) _).trans
578
+ (D.coefficientFreeSpan_le_layer j)
579
+ apply petalComparisonSpace_top_tree D.coefficientFreeFiltration (fun i => (d i).val + 1)
580
+ _ _ (fun i => hC (d i))
581
+ (fun i => (fourPetalSpace_le_first _ _).trans (hC (d i))) (B.freeFrequency D) a hd hr _ z hz
582
+ intro c p hc hp
583
+ apply four_projection_petal_add_invariant
584
+ (fun x => B.freeFrequency D (lieTreeEval x a))
585
+ (fun i => fourRefinedRelation (D.coefficientFreeSpan (d i)) (D.dependentFreeSpan (d i))
586
+ (D'.coefficientFourSpace ⟨(d i).val + 1, by omega⟩))
587
+ (B.correlation_refined_four_identity D E T hbQ hT V g hg D' hfreq n d a hd hr) c p hc
588
+ exact fun i => ((mem_fourPetalSpace _ _ _).mp (hp i)).2
589
+
590
+ end Erdos3.NativeRankRelation.CommonData
591
+
592
+ end
593
+
594
+ section
595
+
596
+ namespace Erdos3.NativeRankRelation.CommonData
597
+
598
+ open Module
599
+ open scoped TensorProduct
600
+
601
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
602
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
603
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
604
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
605
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
606
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
607
+
608
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
609
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
610
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
611
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
612
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
613
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
614
+ (F : FreeCoordinateFrame E.basis Q)
615
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
616
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
617
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
618
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
619
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
620
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
621
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
622
+
623
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
624
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
625
+ (D' : R'.CommonData P')
626
+
627
+ noncomputable def comparisonCoefficientSpace (d : Fin s) :
628
+ Submodule ℚ (Fin 2 → D.CoefficientFreeLieAlgebra) :=
629
+ petalComparisonSpace
630
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
631
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0))
632
+ (fourPetalSpace (D.dependentFreeSpan d)
633
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
634
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)))
635
+ (D.coefficientFreeFiltration.layer (d.val + 1) 2)
636
+
637
+ theorem comparisonCoefficientSpace_le_layer
638
+ (hTfil : T.filtration = D.coefficientFreeFiltration) (d : Fin s) :
639
+ D.comparisonCoefficientSpace E T hbQ hT V g hg D' d ≤
640
+ (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration.layer
641
+ (d.val + 1) 0 := by
642
+ have hC : (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
643
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0) ≤
644
+ D.coefficientFreeFiltration.layer (d.val + 1) 1 :=
645
+ (refined_firstProjection_le_common _ _ (D.dependentFreeSpan_le_coefficientFreeSpan d) _).trans
646
+ (D.coefficientFreeSpan_le_layer d)
647
+ change petalComparisonSpace _ _ _ ≤
648
+ Submodule.pi Set.univ (fun _ : Fin 2 => T.filtration.layer (d.val + 1) 0)
649
+ rw [hTfil, D.coefficientFreeFiltration.rank_zero_eq_one]
650
+ exact petalComparisonSpace_le_pi _ _ _ _ hC
651
+ ((fourPetalSpace_le_first _ _).trans hC)
652
+ (D.coefficientFreeFiltration.lex_antitone (Or.inr ⟨rfl, by omega⟩))
653
+
654
+ include F in
655
+ theorem exists_comparisonCoefficientBases
656
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
657
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') :
658
+ ∃ B : ∀ d : Fin s, Basis (Fin (finrank ℚ
659
+ (D.comparisonCoefficientSpace E T hbQ hT V g hg D' d))) ℚ
660
+ (D.comparisonCoefficientSpace E T hbQ hT V g hg D' d),
661
+ ∀ d a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr
662
+ (B d a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P' := by
663
+ classical
664
+ choose B hB using fun d => D.exists_sharedFreeComparisonSpace_basis E T hbQ hT F V g hg D'
665
+ hTfil hs hP' hQP' d
666
+ exact ⟨B, hB⟩
667
+
668
+ end Erdos3.NativeRankRelation.CommonData
669
+
670
+ end
671
+
672
+ section
673
+
674
+ namespace Erdos3
675
+
676
+ noncomputable def nativePairModelConstant (s : ℕ) : ℕ :=
677
+ (SubspaceFreeLift.exists_native_pair_model.{0, 0} s).choose
678
+
679
+ noncomputable def sharedFreeComparisonModelBudget (s : ℕ) (q p : ℝ) : ℝ :=
680
+ (q + 2 + sharedFreeComparisonBasisBudget q p + nativePairModelConstant s) ^ nativePairModelConstant s
681
+
682
+ theorem sharedFreeComparisonBasisBudget_nonneg {q p : ℝ} (hq : 0 ≤ q) (hp : 0 ≤ p) :
683
+ 0 ≤ sharedFreeComparisonBasisBudget q p := by
684
+ have hA := add_nonneg hq (fourRefinementBasisBudget_nonneg
685
+ (add_nonneg hq (coefficientFourHeightBudget_nonneg hp)))
686
+ exact add_nonneg hA (preimageBasisBudget_nonneg (mul_nonneg (by norm_num) hA))
687
+
688
+ theorem exists_sharedFreeComparisonModelBudget_bound (s : ℕ) :
689
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ q p : ℝ, 0 ≤ q → q ≤ p → 0 ≤ p →
690
+ sharedFreeComparisonModelBudget s q p ≤ (p + C) ^ C := by
691
+ obtain ⟨b, _, hb⟩ := exists_sharedFreeComparisonBasisBudget_bound
692
+ let a := nativePairModelConstant s
693
+ let K : Polynomial ℕ := Polynomial.X + 2 + (Polynomial.X + Polynomial.C b) ^ b
694
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((K + Polynomial.C a) ^ a)
695
+ refine ⟨C, hC, ?_⟩
696
+ intro q p hq hqp hp
697
+ have hsmall : q + 2 + sharedFreeComparisonBasisBudget q p + a ≤
698
+ p + 2 + (p + b) ^ b + a := by linarith [hb q p hq hqp hp]
699
+ have hzero : 0 ≤ q + 2 + sharedFreeComparisonBasisBudget q p + a := by
700
+ have := sharedFreeComparisonBasisBudget_nonneg hq hp
701
+ positivity
702
+ apply (pow_le_pow_left₀ hzero hsmall a).trans
703
+ simpa [K, Polynomial.eval₂_pow] using hbudget p hp
704
+
705
+ end Erdos3
706
+
707
+ namespace Erdos3.NativeRankRelation.CommonData
708
+
709
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
710
+ open scoped TensorProduct
711
+
712
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
713
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
714
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
715
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
716
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
717
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
718
+
719
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
720
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
721
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
722
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
723
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
724
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
725
+ (F : FreeCoordinateFrame E.basis Q)
726
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
727
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
728
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
729
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
730
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
731
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
732
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
733
+
734
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
735
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
736
+ (D' : R'.CommonData P')
737
+
738
+ include F
739
+
740
+ theorem exists_native_comparison_model
741
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
742
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') :
743
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
744
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
745
+ ∃ B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j),
746
+ (∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr
747
+ (B j a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P') ∧
748
+ let φ := SubspaceFreeLift.evaluation S B (piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS
749
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S r) s
750
+ (finrank ℚ (SubspaceFreeLift.Algebra S r)),
751
+ ∃ U : M.DegreeRankStructure r,
752
+ U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
753
+ U.ComplexityLE (sharedFreeComparisonModelBudget s Q P') ∧ IsCentralLieBasis M.basis ∧
754
+ Nonempty (FreeCoordinateFrame M.basis (sharedFreeComparisonModelBudget s Q P')) ∧
755
+ (∀ i j, rationalLogHeight ((pi (fun _ : Fin 2 => E)).basis.repr
756
+ (φ (M.basis j)) i) ≤ sharedFreeComparisonModelBudget s Q P') ∧
757
+ M.lattice ≤ (pi (fun _ : Fin 2 => E)).lattice.comap (mapOfSteps
758
+ (hL := M.filtration.lowerCentralSeries_eq_bot)
759
+ (hM := (pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ) ∧
760
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r)
761
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r) :=
762
+ IsModuleTopology.isTopologicalAddGroup ℝ _
763
+ letI := realification_moduleTopology_t2 M.basis
764
+ ∃ Z : M.UnitVerticalObservable (U.realSubgroup s r)
765
+ (Fin W.family.outputDim × Fin W.family.outputDim) (sharedFreeComparisonModelBudget s Q P'),
766
+ Z.frequency = (pairDifferenceFunctional V.frequency).comp φ.toLinearMap ∧
767
+ ∀ i x, Z.observable i (QuotientGroup.mk x) =
768
+ V.pairedObservable T i (QuotientGroup.mk (realificationMap
769
+ (hnil := M.filtration.lowerCentralSeries_eq_bot)
770
+ (hM := (pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ x))) := by
771
+ intro S hS
772
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
773
+ have hH := sharedFreeComparisonBasisBudget_nonneg hQ hP'
774
+ let K := Q + 2 + sharedFreeComparisonBasisBudget Q P'
775
+ have h2 : 2 ≤ K := by dsimp only [K]; linarith
776
+ have hQK : Q ≤ K := by dsimp only [K]; linarith
777
+ have hHK : sharedFreeComparisonBasisBudget Q P' ≤ K := by dsimp only [K]; linarith
778
+ obtain ⟨B, hB⟩ := D.exists_comparisonCoefficientBases E T hbQ hT F V g hg D' hTfil hs hP' hQP'
779
+ refine ⟨B, hB, ?_⟩
780
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] (Fin 2 → D.CoefficientFreeLieAlgebra))
781
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (Fin 2 → D.CoefficientFreeLieAlgebra)) :=
782
+ IsModuleTopology.isTopologicalAddGroup ℝ _
783
+ let := realification_moduleTopology_t2 (Pi.basis (fun _ : Fin 2 => E.basis))
784
+ exact (SubspaceFreeLift.exists_native_pair_model s).choose_spec.2
785
+ D.CoefficientFreeLieAlgebra (Fin W.family.outputDim) r _ E T S B hS K h2
786
+ (hT.mono T hQK) (fun j a i => (hB j a i).trans hHK) (V.mono hQK)
787
+
788
+ end Erdos3.NativeRankRelation.CommonData
789
+
790
+ end
791
+
792
+ section
793
+
794
+ namespace Erdos3.NativeRankRelation.CommonData
795
+
796
+ open Module VectorPolynomial
797
+ open scoped TensorProduct BigOperators
798
+
799
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
800
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
801
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
802
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
803
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
804
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
805
+
806
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
807
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
808
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
809
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
810
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
811
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
812
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
813
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
814
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
815
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
816
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
817
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
818
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
819
+
820
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
821
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
822
+ (D' : R'.CommonData P')
823
+
824
+ theorem exists_native_factored_comparison_orbit
825
+ (hTfil : T.filtration = D.coefficientFreeFiltration) (hs : 1 ≤ s)
826
+ (A K U : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
827
+ (hA0 : E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 A = 1)
828
+ (hK0 : E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 K = 1)
829
+ (hU0 : E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 U = 1)
830
+ (hA : ∀ d : Fin s, coefficients A.log (Finsupp.single () (d.val + 1)) ∈
831
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
832
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
833
+ (hK : ∀ d : Fin s, coefficients K.log (Finsupp.single () (d.val + 1)) ∈
834
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ)
835
+ (hU : ∀ d : Fin s, coefficients U.log (Finsupp.single () (d.val + 1)) ∈
836
+ (fourPetalSpace (D.dependentFreeSpan d)
837
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
838
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) :
839
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
840
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
841
+ let a : Fin 2 → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1) := ![A * K * U, A]
842
+ ∀ (B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j))
843
+ (M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S r) s
844
+ (finrank ℚ (SubspaceFreeLift.Algebra S r))) (Q' : M.DegreeRankStructure r),
845
+ Q'.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree →
846
+ let φ := SubspaceFreeLift.evaluation S B
847
+ (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS
848
+ ∃ u : M.filtration.realification.PolynomialOrbit (fun _ : Unit => 1),
849
+ M.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 u = 1 ∧
850
+ (∀ j : Fin s, coefficients u.log (Finsupp.single () (j.val + 1)) ∈
851
+ (SubspaceFreeLift.generatorSpan S r j).baseChange ℝ) ∧
852
+ ∀ i x, RationalFilteredNilmanifold.productProjectionHom (fun _ : Fin 2 => E) i
853
+ (NilpotentLieBCHGroup.realificationMap (hnil := M.filtration.lowerCentralSeries_eq_bot)
854
+ (hM := (RationalFilteredNilmanifold.pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ
855
+ (M.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x u)) =
856
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (a i) := by
857
+ intro S hS a B M Q' hQ' φ
858
+ apply SubspaceFreeLift.exists_native_pair_orbit E T S B hS M Q' hQ' a
859
+ · intro i
860
+ fin_cases i
861
+ · change E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A * K * U) = 1
862
+ rw [map_mul, map_mul, hA0, hK0, hU0, mul_one, mul_one]
863
+ · exact hA0
864
+ · intro j
865
+ have h := D.paired_affine_orbit_coefficient_mem_comparison E T hbQ hT V g hg D'
866
+ hTfil hs A K U hA hK hU j
867
+ have heq : (fun i => coefficients (a i).log (Finsupp.single () (j.val + 1))) =
868
+ ![coefficients (A * K * U).log (Finsupp.single () (j.val + 1)),
869
+ coefficients A.log (Finsupp.single () (j.val + 1))] := by
870
+ funext i
871
+ fin_cases i <;> rfl
872
+ rw [heq]
873
+ exact h
874
+
875
+ end Erdos3.NativeRankRelation.CommonData
876
+
877
+ end
878
+
879
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeComparisonOrbit.lean ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Fourier.SharedFreeFactorizationFrequency
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.NativeRankRelation.CommonData
8
+
9
+ open Module VectorPolynomial
10
+ open scoped TensorProduct BigOperators
11
+
12
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
13
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
14
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
15
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
16
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
17
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
18
+
19
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
20
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
21
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
22
+ (B : D.CoefficientBases Q)
23
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
24
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
25
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
26
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
27
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
28
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
29
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
30
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
31
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
32
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
33
+
34
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
35
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
36
+ (D' : R'.CommonData P')
37
+
38
+ theorem paired_affine_orbit_coefficient_mem_comparison
39
+ (hTfil : T.filtration = D.coefficientFreeFiltration) (hs : 1 ≤ s)
40
+ (A K U : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
41
+ (hA : ∀ d : Fin s, coefficients A.log (Finsupp.single () (d.val + 1)) ∈
42
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
43
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
44
+ (hK : ∀ d : Fin s, coefficients K.log (Finsupp.single () (d.val + 1)) ∈
45
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ)
46
+ (hU : ∀ d : Fin s, coefficients U.log (Finsupp.single () (d.val + 1)) ∈
47
+ (fourPetalSpace (D.dependentFreeSpan d)
48
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
49
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ)
50
+ (d : Fin s) :
51
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 2 => D.CoefficientFreeLieAlgebra)).symm
52
+ ![coefficients (A * K * U).log (Finsupp.single () (d.val + 1)),
53
+ coefficients A.log (Finsupp.single () (d.val + 1))] ∈
54
+ (petalComparisonSpace
55
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
56
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0))
57
+ (fourPetalSpace (D.dependentFreeSpan d)
58
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
59
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)))
60
+ (D.coefficientFreeFiltration.layer (d.val + 1) 2)).baseChange ℝ := by
61
+ have h₁ := T.polynomialOrbit_mul_coefficient_sub_mem_rank_two hs
62
+ (fun _ : Unit => 1) (Finsupp.single () (d.val + 1)) A K
63
+ have h₂ := T.polynomialOrbit_mul_coefficient_sub_mem_rank_two hs
64
+ (fun _ : Unit => 1) (Finsupp.single () (d.val + 1)) (A * K) U
65
+ simp only [Finsupp.weight_single, smul_eq_mul, mul_one] at h₁ h₂
66
+ have herr : coefficients (A * K * U).log (Finsupp.single () (d.val + 1)) -
67
+ (coefficients A.log (Finsupp.single () (d.val + 1)) +
68
+ coefficients U.log (Finsupp.single () (d.val + 1))) ∈
69
+ (D.coefficientFreeFiltration.layer (d.val + 1) 2).baseChange ℝ := by
70
+ rw [← hTfil]
71
+ convert ((T.filtration.layer (d.val + 1) 2).baseChange ℝ).add_mem
72
+ (((T.filtration.layer (d.val + 1) 2).baseChange ℝ).add_mem h₂ h₁) (hK d) using 1
73
+ abel
74
+ have hp : ![coefficients (A * K * U).log (Finsupp.single () (d.val + 1)),
75
+ coefficients A.log (Finsupp.single () (d.val + 1))] ∈
76
+ petalComparisonSpace
77
+ (((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
78
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
79
+ ((fourPetalSpace (D.dependentFreeSpan d)
80
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
81
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ)
82
+ ((D.coefficientFreeFiltration.layer (d.val + 1) 2).baseChange ℝ) := by
83
+ apply (mem_petalComparisonSpace _ _ _ _).mpr
84
+ constructor
85
+ · exact Submodule.mem_sup_left (hA d)
86
+ · apply Submodule.mem_sup.mpr
87
+ refine ⟨_, hU d, _, herr, ?_⟩
88
+ change coefficients U.log (Finsupp.single () (d.val + 1)) +
89
+ (coefficients (A * K * U).log (Finsupp.single () (d.val + 1)) -
90
+ (coefficients A.log (Finsupp.single () (d.val + 1)) +
91
+ coefficients U.log (Finsupp.single () (d.val + 1)))) =
92
+ coefficients (A * K * U).log (Finsupp.single () (d.val + 1)) -
93
+ coefficients A.log (Finsupp.single () (d.val + 1))
94
+ abel
95
+ rw [← realification_petalComparisonSpace] at hp
96
+ obtain ⟨y, hy, heq⟩ := hp
97
+ have hy' : (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 2 => D.CoefficientFreeLieAlgebra)).symm
98
+ ![coefficients (A * K * U).log (Finsupp.single () (d.val + 1)),
99
+ coefficients A.log (Finsupp.single () (d.val + 1))] = y := by
100
+ rw [← heq]
101
+ exact LinearEquiv.symm_apply_apply _ _
102
+ rw [hy']
103
+ exact hy
104
+
105
+ end Erdos3.NativeRankRelation.CommonData
106
+
107
+ end
108
+
109
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeCorrelatedFactorization.lean ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.SharedFreeCorrelationBudget
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3.NativeRankRelation.CommonData
8
+
9
+ open Module VectorPolynomial RationalFilteredNilmanifold
10
+ open scoped TensorProduct BigOperators
11
+
12
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
13
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
14
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
15
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
16
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
17
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
18
+
19
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
20
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
21
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
22
+ (B₀ : D.CoefficientBases Q)
23
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
24
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
25
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
26
+ (F : FreeCoordinateFrame E.basis Q)
27
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
28
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
29
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
30
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
31
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
32
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
33
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
34
+
35
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
36
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
37
+ (D' : R'.CommonData P')
38
+
39
+ include F
40
+
41
+ theorem CoefficientBases.exists_correlated_lower_factorization
42
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
43
+ (hfreq : V.frequency = B₀.freeFrequency D)
44
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
45
+ (hf : ∀ x, ‖f x‖ ≤ 1)
46
+ (Hsource : Finset (ZMod N)) (hsource : Hsource.Nonempty)
47
+ (hsourceDense : Real.exp (-Q) * Fintype.card (ZMod N) ≤ (Hsource.card : ℝ))
48
+ (hHsource : H' ⊆ Hsource)
49
+ (hcorr : ∀ h ∈ Hsource, Nonempty (NativeVectorCorrelation (s - 1) N Q
50
+ (W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk
51
+ (E.filtration.realification.polynomialOrbitEval
52
+ (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (g h)))))))
53
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
54
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
55
+ (hsplit : ∀ h, g h = ξ * v h)
56
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
57
+ (D.commonFreeSpan d).baseChange ℝ)
58
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
59
+ (D.dependentFreeSpan d).baseChange ℝ)
60
+ (hN : Real.exp (sharedFreeCorrelationBudget s hs P') ≤ (N : ℝ)) :
61
+ let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s
62
+ let C := sharedFreeCorrelationBudget s hs P'
63
+ let Qc := C + sharedFreeComparisonBasisBudget Q P' + 2
64
+ let Lv := sharedFreePetalLiftBudget s Q P'
65
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
66
+ ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-(Λ + C)) * H'.card ≤ (J.card : ℝ) ∧
67
+ ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N)
68
+ (Γ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
69
+ (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)
70
+ (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra),
71
+ (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 Γ = 1 ∧
72
+ (∀ d : Fin s, coefficients Γ.log (Finsupp.single () (d.val + 1)) ∈
73
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
74
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ) ∧
75
+ (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
76
+ ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp Lv) ∧
77
+ (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
78
+ ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp Lv) ∧
79
+ ∃ (x : {h // h ∈ J} → Fin r₀ → ℤ)
80
+ (A K U : {h // h ∈ J} → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)),
81
+ (∀ h : {h // h ∈ J},
82
+ (∀ j, |x h j| ≤ (R₀ j : ℤ)) ∧ h.val = h₀ + η (x h) ∧
83
+ (A h).log = Γ.log + positiveUnivariate (fun d => α d + ∑ j, (x h j : ℝ) • β j d) ∧
84
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A h) = 1 ∧
85
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K h) = 1 ∧
86
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U h) = 1 ∧
87
+ ∀ d : Fin s,
88
+ coefficients (K h).log (Finsupp.single () (d.val + 1)) ∈
89
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ ∧
90
+ coefficients (U h).log (Finsupp.single () (d.val + 1)) ∈
91
+ (fourPetalSpace (D.dependentFreeSpan d)
92
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
93
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) ∧
94
+ ∃ Δ : Subgroup E.filtration.Group, Δ ≤ E.lattice ∧
95
+ (Δ.subgroupOf E.lattice).Characteristic ∧ (Δ.subgroupOf E.lattice).Normal ∧
96
+ (Δ.subgroupOf E.lattice).FiniteIndex ∧ (Δ.relIndex E.lattice : ℝ) ≤ Real.exp C ∧
97
+ ∃ (l : ℕ) (hl : 0 < l)
98
+ (hin : scaledIntegerGrid l ⊆ bchSubgroupCoordinates E.basis Δ)
99
+ (hout : bchSubgroupCoordinates E.basis Δ ⊆ denominatorGrid l),
100
+ (T.withLattice Δ l hl hin hout).ComplexityLE C ∧
101
+ ∃ V₁ : (E.withLattice Δ l hl hin hout).UnitVerticalObservable
102
+ ((T.withLattice Δ l hl hin hout).realSubgroup s (r + 1)) (Fin W.family.outputDim) C,
103
+ V₁.frequency = V.frequency ∧
104
+ (∀ h : {h // h ∈ J}, Nonempty (NativeVectorCorrelation (s - 1) N C
105
+ (W.replacedRankResidual h.val (fun i z => V₁.observable i (QuotientGroup.mk
106
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1)
107
+ (fun _ => (z.val : ℤ)) (A h * K h * U h))))))) ∧
108
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
109
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
110
+ ∃ Tm : M.DegreeRankStructure (r + 1),
111
+ Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
112
+ Tm.ComplexityLE ((Qc + nativePairModelConstant s) ^ nativePairModelConstant s) ∧
113
+ M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1)
114
+ (fun h (i : Fin W.family.outputDim × Fin W.family.outputDim) z =>
115
+ V₁.observable i.1 (QuotientGroup.mk
116
+ (E.filtration.realification.polynomialOrbitEval
117
+ (fun _ : Unit => 1) z (A h * K h * U h))) *
118
+ star (V₁.observable i.2 (QuotientGroup.mk
119
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) z (A h)))))
120
+ (nativeLowerPairModelBudget s Qc) := by
121
+ intro Λ C Qc Lv S
122
+ classical
123
+ let P₀ := sharedFreeCorrelationInput s P'
124
+ have hQ0 : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
125
+ obtain ⟨hP₀, hQP₀, hΛP₀, hdenP₀, hslowP₀, hperiodP₀⟩ :=
126
+ sharedFreeCorrelationInput_bounds s hQ0 hQP' hP'
127
+ have hP₀C : P₀ ≤ C := sharedFreeCorrelationInput_le_budget s hs hP'
128
+ have hC0 : 0 ≤ C := (show 0 ≤ P₀ by linarith).trans hP₀C
129
+ obtain ⟨D₁, _, _, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, Γ, α, β,
130
+ hrank, hproper, hm, hmb, hΓ0, hΓ, hα, hβ, x, ε, A, K, U, ρ, hdata, hperiod, _⟩ :=
131
+ B₀.exists_shared_free_lower_factorization D E T hbQ hT F V g hg D'
132
+ hTfil hfreq hs hp' hP' hQP' hpp' ξ v hsplit hξ hv
133
+ ((Real.exp_le_exp.mpr (hΛP₀.trans hP₀C)).trans hN)
134
+ obtain ⟨M₀, hM₀, hM₀b, hperiod, _⟩ := hperiod
135
+ let X := W.replaceRank E T hbQ hT V g hg Hsource hsource hsourceDense hcorr
136
+ let ε' (h : ZMod N) := if hh : h ∈ J then ε ⟨h, hh⟩ else 1
137
+ let a' (h : ZMod N) := if hh : h ∈ J then A ⟨h, hh⟩ * K ⟨h, hh⟩ * U ⟨h, hh⟩ else 1
138
+ let ρ' (h : ZMod N) := if hh : h ∈ J then ρ ⟨h, hh⟩ else 1
139
+ have hprod' (h : ZMod N) (hh : h ∈ J) : ε' h * a' h * ρ' h = X.family.orbit h := by
140
+ rcases hdata ⟨h, hh⟩ with ⟨_, _, _, _, _, _, _, _, _, _, hprod, _⟩
141
+ change ε' h * a' h * ρ' h = g h
142
+ simp only [ε', a', ρ', dite_eq_left hh]
143
+ simpa only [mul_assoc] using hprod
144
+ have hε' (h : ZMod N) (hh : h ∈ J) :
145
+ CoefficientBound (E.basis.baseChange ℝ) (fun _ : Unit => (N : ℝ))
146
+ (Real.exp ((P₀ + 2) ^ 1)) (ε' h).log := by
147
+ rcases hdata ⟨h, hh⟩ with ⟨_, _, _, _, _, _, _, _, hε, _, _, _⟩
148
+ simp only [ε', dite_eq_left hh]
149
+ exact CoefficientBound.mono _ _ (fun _ => Nat.cast_pos.mpr (NeZero.pos N)) hε hslowP₀
150
+ have hρ' (h : ZMod N) (hh : h ∈ J) : CoefficientGrid (E.basis.baseChange ℝ) m (ρ' h).log := by
151
+ rcases hdata ⟨h, hh⟩ with ⟨_, _, _, _, _, _, _, _, _, hρ, _, _⟩
152
+ simpa only [ρ', dite_eq_left hh] using hρ
153
+ have hperiod' (h : ZMod N) (hh : h ∈ J) (z z' : Unit → ℤ)
154
+ (hres : ∀ j, (M₀ : ℤ) ∣ z j - z' j) :
155
+ (QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
156
+ (fun _ : Unit => 1) z (ρ' h)) : E.Space) =
157
+ QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
158
+ (fun _ : Unit => 1) z' (ρ' h)) := by
159
+ simpa only [ρ', dite_eq_left hh] using (hperiod ⟨h, hh⟩ z z' hres).1
160
+ obtain ⟨Δ, hΔ, hchar, hnormal, hfinite, hindex, l, hl, hin, hout,
161
+ hRank, J₂, hsub, hJ₂, hdense, V₁, hfreq₁, hcorr₁⟩ :=
162
+ (exists_shared_factor_correlations s hs).choose_spec.2 X hf hP₀ hQP₀ m M₀ hm
163
+ (hmb.trans (Real.exp_le_exp.mpr hdenP₀)) hM₀
164
+ (hM₀b.trans (Real.exp_le_exp.mpr hperiodP₀)) J
165
+ (fun h hh => hHsource (hJH hh)) hJ ε' a' ρ' hprod' hε' hρ' hperiod' hN
166
+ let lift (h : {h // h ∈ J₂}) : {h // h ∈ J} := ⟨h.val, hsub h.property⟩
167
+ refine ⟨J₂, (fun h hh => hJH (hsub hh)), hJ₂, ?_, r₀, R₀, η, h₀, Γ, α, β,
168
+ hrank, hproper, hΓ0, hΓ, hα, hβ, (fun h => x (lift h)), (fun h => A (lift h)),
169
+ (fun h => K (lift h)), (fun h => U (lift h)), ?_, Δ, hΔ, hchar, hnormal, hfinite,
170
+ hindex, l, hl, hin, hout, hRank, V₁, hfreq₁, ?_, ?_⟩
171
+ · calc
172
+ _ = Real.exp (-C) * (Real.exp (-Λ) * H'.card) := by
173
+ rw [← mul_assoc, ← Real.exp_add]
174
+ congr 2
175
+ ring
176
+ _ ≤ Real.exp (-C) * J.card := mul_le_mul_of_nonneg_left hcard (Real.exp_pos _).le
177
+ _ ≤ _ := hdense
178
+ · intro h
179
+ rcases hdata (lift h) with ⟨hx, hs, hA, _, hA0, hK0, hU0, _, _, _, _, hKU⟩
180
+ exact ⟨hx, hs, hA, hA0, hK0, hU0, hKU⟩
181
+ · intro h
182
+ have hc := hcorr₁ h.val h.property
183
+ change Nonempty (NativeVectorCorrelation (s - 1) N C
184
+ (W.replacedRankResidual h.val (fun i z => V₁.observable i (QuotientGroup.mk
185
+ (E.filtration.realification.polynomialOrbitEval
186
+ (fun _ : Unit => 1) (fun _ => (z.val : ℤ)) (a' h.val)))))) at hc
187
+ have ha : a' h.val = A (lift h) * K (lift h) * U (lift h) := by
188
+ simp only [a', dite_eq_left (hsub h.property), lift]
189
+ rw [ha] at hc
190
+ exact hc
191
+ · apply B₀.exists_covered_factored_family D E T hbQ hT F V g hg D'
192
+ hTfil hfreq hs hP' hQP' Δ l hl hin hout hC0 hRank V₁ hfreq₁
193
+ (fun h => A (lift h)) (fun h => K (lift h)) (fun h => U (lift h))
194
+ · intro h
195
+ rcases hdata (lift h) with ⟨_, _, _, _, hA0, _, _, _, _, _, _, _⟩
196
+ exact hA0
197
+ · intro h
198
+ rcases hdata (lift h) with ⟨_, _, _, _, _, hK0, _, _, _, _, _, _⟩
199
+ exact hK0
200
+ · intro h
201
+ rcases hdata (lift h) with ⟨_, _, _, _, _, _, hU0, _, _, _, _, _⟩
202
+ exact hU0
203
+ · intro h d
204
+ rcases hdata (lift h) with ⟨_, _, hA, _, _, _, _, _, _, _, _, _⟩
205
+ rw [hA]
206
+ exact affine_refined_coefficient_mem D.coefficientFreeSpan D.dependentFreeSpan
207
+ (fun d : Fin s => D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)
208
+ Γ.log α β (fun j => (x (lift h) j : ℝ)) hΓ (fun d => (hα d).1) (fun j d => (hβ j d).1) d
209
+ · intro h d
210
+ rcases hdata (lift h) with ⟨_, _, _, _, _, _, _, _, _, _, _, hKU⟩
211
+ exact (hKU d).1
212
+ · intro h d
213
+ rcases hdata (lift h) with ⟨_, _, _, _, _, _, _, _, _, _, _, hKU⟩
214
+ exact (hKU d).2
215
+
216
+ end Erdos3.NativeRankRelation.CommonData
217
+
218
+ end
219
+
220
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeFrozenComparison.lean ADDED
@@ -0,0 +1,423 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.SharedFreeLowerComparisonBudget
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ noncomputable def nativeLowerPairModelBudget (s : ℕ) (p : ℝ) : ℝ :=
10
+ ((p + nativePairModelConstant s) ^ nativePairModelConstant s + rankUnitDescentConstant s) ^
11
+ rankUnitDescentConstant s
12
+
13
+ theorem exists_nativeLowerPairModelBudget_bound (s : ℕ) :
14
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p →
15
+ (p + nativePairModelConstant s) ^ nativePairModelConstant s ≤ (p + C) ^ C ∧
16
+ nativeLowerPairModelBudget s p ≤ (p + C) ^ C := by
17
+ let a := nativePairModelConstant s
18
+ let b := rankUnitDescentConstant s
19
+ let A : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a
20
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (A + (A + Polynomial.C b) ^ b)
21
+ refine ⟨C, hC, ?_⟩
22
+ intro p hp
23
+ have ha : 0 ≤ (p + a) ^ a := by positivity
24
+ have hb : 0 ≤ ((p + a) ^ a + b) ^ b := by positivity
25
+ have hsum : (p + a) ^ a + ((p + a) ^ a + b) ^ b ≤ (p + C) ^ C := by
26
+ simpa [A, Polynomial.eval₂_pow] using hbudget p hp
27
+ exact ⟨(le_add_of_nonneg_right hb).trans hsum, (le_add_of_nonneg_left ha).trans hsum⟩
28
+
29
+ end Erdos3
30
+
31
+ namespace Erdos3.SubspaceFreeLift
32
+
33
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
34
+ open scoped TensorProduct
35
+
36
+ theorem exists_uniform_lower_pair_model {L I : Type} [LieRing L] [LieAlgebra ℚ L] [Fintype I]
37
+ [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
38
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)]
39
+ {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) (T : D.DegreeRankStructure (r + 1))
40
+ (S : Fin s → Submodule ℚ (Fin 2 → L))
41
+ (B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j))
42
+ (hS : ∀ j, S j ≤ (piRank (fun _ : Fin 2 => D) (fun _ => T)).filtration.layer (j.val + 1) 0)
43
+ {p : ℝ} (hp : 2 ≤ p) (hT : T.ComplexityLE p)
44
+ (hB : ∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => D.basis)).repr
45
+ (B j a : Fin 2 → L) i) ≤ p)
46
+ (V : D.UnitVerticalObservable (T.realSubgroup s (r + 1)) I p)
47
+ (hzero : ∀ x ∈ (filtration S T.filtration.rank_le_degree).layer s (r + 1),
48
+ pairDifferenceFunctional V.frequency
49
+ (evaluation S B (piRank (fun _ : Fin 2 => D) (fun _ => T)).filtration hS x) = 0) :
50
+ let pM := (p + nativePairModelConstant s) ^ nativePairModelConstant s
51
+ let φ := evaluation S B (piRank (fun _ : Fin 2 => D) (fun _ => T)).filtration hS
52
+ ∃ M : RationalFilteredNilmanifold (Algebra S (r + 1)) s (finrank ℚ (Algebra S (r + 1))),
53
+ ∃ U : M.DegreeRankStructure (r + 1),
54
+ U.filtration = filtration S T.filtration.rank_le_degree ∧ U.ComplexityLE pM ∧
55
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] Algebra S (r + 1))
56
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] Algebra S (r + 1)) :=
57
+ IsModuleTopology.isTopologicalAddGroup ℝ _
58
+ letI := realification_moduleTopology_t2 M.basis
59
+ ∃ Z : M.UnitVerticalObservable (U.realSubgroup s (r + 1)) (I × I) pM,
60
+ (∀ i x, Z.observable i (QuotientGroup.mk x) =
61
+ V.pairedObservable T i (QuotientGroup.mk (realificationMap
62
+ (hnil := M.filtration.lowerCentralSeries_eq_bot)
63
+ (hM := (pi (fun _ : Fin 2 => D)).filtration.lowerCentralSeries_eq_bot) φ x))) ∧
64
+ M.HasUniformLowerRankUnitFamily U Z.observable (fun _ : Unit => 1)
65
+ (nativeLowerPairModelBudget s p)) := by
66
+ intro pM φ
67
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] (Fin 2 → L))
68
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (Fin 2 → L)) :=
69
+ IsModuleTopology.isTopologicalAddGroup ℝ _
70
+ let := realification_moduleTopology_t2 (Pi.basis (fun _ : Fin 2 => D.basis))
71
+ obtain ⟨M, U, hU, hUc, _, _, _, _, hZ⟩ :=
72
+ (exists_native_pair_model.{0, 0} s).choose_spec.2 L I (r + 1) d D T S B hS p hp hT hB V
73
+ refine ⟨M, U, hU, hUc, ?_⟩
74
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] Algebra S (r + 1))
75
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] Algebra S (r + 1)) :=
76
+ IsModuleTopology.isTopologicalAddGroup ℝ _
77
+ let := realification_moduleTopology_t2 M.basis
78
+ obtain ⟨Z, hfreq, hobs⟩ := hZ
79
+ refine ⟨Z, hobs, ?_⟩
80
+ have hZzero : ∀ x ∈ U.filtration.layer s (r + 1), Z.frequency x = 0 := by
81
+ intro x hx
82
+ rw [hfreq]
83
+ exact hzero x (by simpa only [hU] using hx)
84
+ exact UnitVerticalObservable.hasUniformLowerRankUnitFamily M U Z (fun _ : Unit => 1)
85
+ ((Nat.cast_nonneg _).trans hUc.1.1) hUc hZzero
86
+
87
+ end Erdos3.SubspaceFreeLift
88
+
89
+ end
90
+
91
+ section
92
+
93
+ namespace Erdos3.NativeRankRelation.CommonData
94
+
95
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
96
+ open scoped TensorProduct
97
+
98
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
99
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
100
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
101
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
102
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
103
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
104
+
105
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
106
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
107
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
108
+ (B₀ : D.CoefficientBases Q)
109
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
110
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
111
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
112
+ (F : FreeCoordinateFrame E.basis Q)
113
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
114
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
115
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
116
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
117
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
118
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
119
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
120
+
121
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
122
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
123
+ (D' : R'.CommonData P')
124
+
125
+ include F
126
+
127
+ theorem CoefficientBases.exists_covered_comparison
128
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
129
+ (hfreq : V.frequency = B₀.freeFrequency D)
130
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P')
131
+ (Λ : Subgroup E.filtration.Group) (m : ℕ) (hm : 0 < m)
132
+ (hin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates E.basis Λ)
133
+ (hout : bchSubgroupCoordinates E.basis Λ ⊆ denominatorGrid m)
134
+ {p₁ : ℝ} (hp₁ : 0 ≤ p₁) (hT₁ : (T.withLattice Λ m hm hin hout).ComplexityLE p₁)
135
+ (V₁ : (E.withLattice Λ m hm hin hout).UnitVerticalObservable
136
+ ((T.withLattice Λ m hm hin hout).realSubgroup s (r + 1)) (Fin W.family.outputDim) p₁)
137
+ (hV₁ : V₁.frequency = V.frequency) :
138
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
139
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
140
+ let q₁ := p₁ + sharedFreeComparisonBasisBudget Q P' + 2
141
+ let E₁ := E.withLattice Λ m hm hin hout
142
+ let T₁ := T.withLattice Λ m hm hin hout
143
+ let pM := (q₁ + nativePairModelConstant s) ^ nativePairModelConstant s
144
+ ∃ J : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j),
145
+ (∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr
146
+ (J j a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P') ∧
147
+ let φ := SubspaceFreeLift.evaluation S J (piRank (fun _ : Fin 2 => E₁) (fun _ => T₁)).filtration hS
148
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
149
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
150
+ ∃ U : M.DegreeRankStructure (r + 1),
151
+ U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
152
+ U.ComplexityLE pM ∧
153
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))
154
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1)) :=
155
+ IsModuleTopology.isTopologicalAddGroup ℝ _
156
+ letI := realification_moduleTopology_t2 M.basis
157
+ ∃ Z : M.UnitVerticalObservable (U.realSubgroup s (r + 1))
158
+ (Fin W.family.outputDim × Fin W.family.outputDim) pM,
159
+ (∀ i x, Z.observable i (QuotientGroup.mk x) =
160
+ V₁.pairedObservable T₁ i (QuotientGroup.mk (realificationMap
161
+ (hnil := M.filtration.lowerCentralSeries_eq_bot)
162
+ (hM := (pi (fun _ : Fin 2 => E₁)).filtration.lowerCentralSeries_eq_bot) φ x))) ∧
163
+ M.HasUniformLowerRankUnitFamily U Z.observable (fun _ : Unit => 1)
164
+ (nativeLowerPairModelBudget s q₁)) := by
165
+ intro S hS q₁ E₁ T₁ pM
166
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
167
+ have hB := sharedFreeComparisonBasisBudget_nonneg hQ hP'
168
+ have hq : 2 ≤ q₁ := by dsimp only [q₁]; linarith
169
+ have hpq : p₁ ≤ q₁ := by dsimp only [q₁]; linarith
170
+ have hBq : sharedFreeComparisonBasisBudget Q P' ≤ q₁ := by dsimp only [q₁]; linarith
171
+ obtain ⟨J, hJ⟩ := D.exists_comparisonCoefficientBases E T hbQ hT F V g hg D'
172
+ hTfil hs hP' hQP'
173
+ refine ⟨J, hJ, ?_⟩
174
+ apply SubspaceFreeLift.exists_uniform_lower_pair_model E₁ T₁ S J hS hq
175
+ (hT₁.mono T₁ hpq) (fun j a i => (hJ j a i).trans hBq) (V₁.mono hpq)
176
+ intro x hx
177
+ change pairDifferenceFunctional V₁.frequency
178
+ (SubspaceFreeLift.evaluation S J (piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS x) = 0
179
+ rw [hV₁]
180
+ exact B₀.comparison_free_top_frequency D E T hbQ hT V g hg D' hTfil hfreq J x hx
181
+
182
+ end Erdos3.NativeRankRelation.CommonData
183
+
184
+ end
185
+
186
+ section
187
+
188
+ namespace Erdos3.NativeRankRelation.CommonData
189
+
190
+ open Module VectorPolynomial RationalFilteredNilmanifold
191
+ open scoped TensorProduct
192
+
193
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
194
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
195
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
196
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
197
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
198
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
199
+
200
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
201
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
202
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
203
+ (B₀ : D.CoefficientBases Q)
204
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
205
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
206
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
207
+ (F : FreeCoordinateFrame E.basis Q)
208
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
209
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
210
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
211
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
212
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
213
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
214
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
215
+
216
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
217
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
218
+ (D' : R'.CommonData P')
219
+
220
+ include F
221
+
222
+ theorem CoefficientBases.exists_covered_factored_family {τ : Type*}
223
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
224
+ (hfreq : V.frequency = B₀.freeFrequency D)
225
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P')
226
+ (Λ : Subgroup E.filtration.Group) (m : ℕ) (hm : 0 < m)
227
+ (hin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates E.basis Λ)
228
+ (hout : bchSubgroupCoordinates E.basis Λ ⊆ denominatorGrid m)
229
+ {p₁ : ℝ} (hp₁ : 0 ≤ p₁) (hT₁ : (T.withLattice Λ m hm hin hout).ComplexityLE p₁)
230
+ (V₁ : (E.withLattice Λ m hm hin hout).UnitVerticalObservable
231
+ ((T.withLattice Λ m hm hin hout).realSubgroup s (r + 1)) (Fin W.family.outputDim) p₁)
232
+ (hV₁ : V₁.frequency = V.frequency)
233
+ (A K U : τ → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
234
+ (hA0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A t) = 1)
235
+ (hK0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K t) = 1)
236
+ (hU0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U t) = 1)
237
+ (hA : ∀ t (d : Fin s), coefficients (A t).log (Finsupp.single () (d.val + 1)) ∈
238
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
239
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
240
+ (hK : ∀ t (d : Fin s), coefficients (K t).log (Finsupp.single () (d.val + 1)) ∈
241
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ)
242
+ (hU : ∀ t (d : Fin s), coefficients (U t).log (Finsupp.single () (d.val + 1)) ∈
243
+ (fourPetalSpace (D.dependentFreeSpan d)
244
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
245
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) :
246
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
247
+ let q₁ := p₁ + sharedFreeComparisonBasisBudget Q P' + 2
248
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
249
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
250
+ ∃ Tm : M.DegreeRankStructure (r + 1),
251
+ Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
252
+ Tm.ComplexityLE ((q₁ + nativePairModelConstant s) ^ nativePairModelConstant s) ∧
253
+ M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1)
254
+ (fun t (i : Fin W.family.outputDim × Fin W.family.outputDim) x =>
255
+ V₁.observable i.1 (QuotientGroup.mk
256
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (A t * K t * U t))) *
257
+ star (V₁.observable i.2 (QuotientGroup.mk
258
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (A t)))))
259
+ (nativeLowerPairModelBudget s q₁) := by
260
+ intro S q₁
261
+ let E₁ := E.withLattice Λ m hm hin hout
262
+ let T₁ := T.withLattice Λ m hm hin hout
263
+ obtain ⟨J, _, M, Tm, hTm, hTmc, hZ⟩ :=
264
+ B₀.exists_covered_comparison D E T hbQ hT F V g hg D'
265
+ hTfil hfreq hs hP' hQP' Λ m hm hin hout hp₁ hT₁ V₁ hV₁
266
+ refine ⟨M, Tm, hTm, hTmc, ?_⟩
267
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))
268
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1)) :=
269
+ IsModuleTopology.isTopologicalAddGroup ℝ _
270
+ let := realification_moduleTopology_t2 M.basis
271
+ obtain ⟨Z, hobs, huniform⟩ := hZ
272
+ apply huniform.realizeFamily
273
+ intro t
274
+ obtain ⟨u, hu0, _, hu⟩ := D.exists_native_factored_comparison_orbit E T hbQ hT V g hg D'
275
+ hTfil (by omega) (A t) (K t) (U t) (hA0 t) (hK0 t) (hU0 t) (hA t) (hK t) (hU t)
276
+ J M Tm hTm
277
+ refine ⟨u, hu0, ?_⟩
278
+ intro i x
279
+ exact SubspaceFreeLift.native_pair_observable_eval E₁ T₁ S J
280
+ (D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil)
281
+ M Tm V₁ Z hobs ![A t * K t * U t, A t] u hu i x
282
+
283
+ end Erdos3.NativeRankRelation.CommonData
284
+
285
+ end
286
+
287
+ section
288
+
289
+ namespace Erdos3
290
+
291
+ noncomputable def sharedFreeFrozenCoverBudget (s : ℕ) (p : ℝ) : ℝ :=
292
+ (p + (RationalFilteredNilmanifold.exists_shared_frozen_unit_observable.{0, 0, 0} s 1).choose) ^
293
+ (RationalFilteredNilmanifold.exists_shared_frozen_unit_observable.{0, 0, 0} s 1).choose
294
+
295
+ end Erdos3
296
+
297
+ namespace Erdos3.NativeRankRelation.CommonData
298
+
299
+ open Module VectorPolynomial RationalFilteredNilmanifold
300
+ open scoped TensorProduct BigOperators
301
+
302
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
303
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
304
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
305
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
306
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
307
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
308
+
309
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
310
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
311
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
312
+ (B₀ : D.CoefficientBases Q)
313
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
314
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
315
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
316
+ (F : FreeCoordinateFrame E.basis Q)
317
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
318
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
319
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
320
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
321
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
322
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
323
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
324
+
325
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
326
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
327
+ (D' : R'.CommonData P')
328
+
329
+ include F
330
+
331
+ theorem CoefficientBases.exists_frozen_comparison {τ : Type}
332
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
333
+ (hfreq : V.frequency = B₀.freeFrequency D)
334
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hf : ∀ x, ‖f x‖ ≤ 1)
335
+ {pF ε : ℝ} (hpF : 0 ≤ pF) (hQF : Q ≤ pF) (hε : 0 < ε) (hεF : 1 / ε ≤ Real.exp pF)
336
+ (q₀ : ℕ) (hq₀ : 0 < q₀) (hqF : (q₀ : ℝ) ≤ Real.exp pF)
337
+ (J₀ : Finset τ) (hJ₀ : J₀.Nonempty) (a u : τ → E.RealGroup)
338
+ (ha : ∀ t ∈ J₀, ∀ i, |(E.basis.baseChange ℝ).repr (a t).coord i| ≤ Real.exp ((pF + 2) ^ 1))
339
+ (hu : ∀ t ∈ J₀, ∀ i, |(E.basis.baseChange ℝ).repr (u t).coord i| ≤ Real.exp ((pF + 2) ^ 1))
340
+ (hugrid : ∀ t ∈ J₀, (E.basis.baseChange ℝ).equivFun (u t).coord ∈ realDenominatorGrid q₀)
341
+ (A K U : τ → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
342
+ (hA0 : ∀ t ∈ J₀, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A t) = 1)
343
+ (hK0 : ∀ t ∈ J₀, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K t) = 1)
344
+ (hU0 : ∀ t ∈ J₀, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U t) = 1)
345
+ (hA : ∀ t ∈ J₀, ∀ d : Fin s, coefficients (A t).log (Finsupp.single () (d.val + 1)) ∈
346
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
347
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
348
+ (hK : ∀ t ∈ J₀, ∀ d : Fin s, coefficients (K t).log (Finsupp.single () (d.val + 1)) ∈
349
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ)
350
+ (hU : ∀ t ∈ J₀, ∀ d : Fin s, coefficients (U t).log (Finsupp.single () (d.val + 1)) ∈
351
+ (fourPetalSpace (D.dependentFreeSpan d)
352
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
353
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) :
354
+ let p₁ := sharedFreeFrozenCoverBudget s pF
355
+ let q₁ := p₁ + sharedFreeComparisonBasisBudget Q P' + 2
356
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
357
+ ∃ Λ : Subgroup E.filtration.Group, Λ ≤ E.lattice ∧
358
+ (Λ.subgroupOf E.lattice).Characteristic ∧ (Λ.subgroupOf E.lattice).Normal ∧
359
+ (Λ.subgroupOf E.lattice).FiniteIndex ∧ (Λ.relIndex E.lattice : ℝ) ≤ Real.exp p₁ ∧
360
+ ∃ (m : ℕ) (hm : 0 < m)
361
+ (hin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates E.basis Λ)
362
+ (hout : bchSubgroupCoordinates E.basis Λ ⊆ denominatorGrid m),
363
+ (T.withLattice Λ m hm hin hout).ComplexityLE p₁ ∧
364
+ ∃ J : Finset τ, J ⊆ J₀ ∧ J.Nonempty ∧ Real.exp (-p₁) * J₀.card ≤ (J.card : ℝ) ∧
365
+ ∃ V₁ : (E.withLattice Λ m hm hin hout).UnitVerticalObservable
366
+ ((T.withLattice Λ m hm hin hout).realSubgroup s (r + 1)) (Fin W.family.outputDim) p₁,
367
+ V₁.frequency = V.frequency ∧
368
+ (∀ t ∈ J, ∀ i (b c : E.RealGroup),
369
+ ‖V.observable i (QuotientGroup.mk (a t * b * u t)) -
370
+ ∑ j, (V₁.observable i (QuotientGroup.mk b) *
371
+ star (V₁.observable j (QuotientGroup.mk c))) *
372
+ V₁.observable j (QuotientGroup.mk c)‖ ≤ (V.lipBound : ℝ) * ε) ∧
373
+ (∀ t ∈ J, ∀ (h : ZMod N) (v : ZMod N → E.RealGroup) (pC : ℝ),
374
+ (V.lipBound : ℝ) * ε ≤ Real.exp (-(2 * pC)) / 2 →
375
+ Nonempty (NativeVectorCorrelation (s - 1) N pC
376
+ (W.replacedRankResidual h (fun i x => V.observable i
377
+ (QuotientGroup.mk (a t * v x * u t))))) →
378
+ Nonempty (NativeVectorCorrelation (s - 1) N (pC + 1)
379
+ (W.replacedRankResidual h (fun i x => V₁.observable i
380
+ (QuotientGroup.mk (v x)))))) ∧
381
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
382
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
383
+ ∃ Tm : M.DegreeRankStructure (r + 1),
384
+ Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
385
+ Tm.ComplexityLE ((q₁ + nativePairModelConstant s) ^ nativePairModelConstant s) ∧
386
+ M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1)
387
+ (fun (t : {t // t ∈ J}) (i : Fin W.family.outputDim × Fin W.family.outputDim) x =>
388
+ V₁.observable i.1 (QuotientGroup.mk
389
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x
390
+ (A t.val * K t.val * U t.val))) *
391
+ star (V₁.observable i.2 (QuotientGroup.mk
392
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (A t.val)))))
393
+ (nativeLowerPairModelBudget s q₁) := by
394
+ intro p₁ q₁ S
395
+ obtain ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, m, hm, hin, hout,
396
+ hT₁, J, hsub, hJ, hdense, V₁, hV₁, happ⟩ :=
397
+ (RationalFilteredNilmanifold.exists_shared_frozen_unit_observable.{0, 0, 0} s 1).choose_spec.2
398
+ E T hpF (hT.mono T hQF) hε hεF q₀ hq₀ hqF (V.mono hQF) J₀ a u hJ₀ ha hu hugrid
399
+ refine ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, m, hm, hin, hout,
400
+ hT₁, J, hsub, hJ, hdense, V₁, hV₁, ?_, ?_, ?_⟩
401
+ · intro t ht i b c
402
+ rw [← complex_unit_vector_resolution (fun j => V₁.observable j (QuotientGroup.mk c))
403
+ (V₁.unit (QuotientGroup.mk c)) (V₁.observable i (QuotientGroup.mk b))]
404
+ exact happ t ht i b
405
+ · intro t ht h v pC hsmall hcorr
406
+ obtain ⟨C⟩ := hcorr
407
+ apply C.exists_of_uniform_approx
408
+ intro ij x
409
+ exact (W.replacedRankResidual_norm_sub_le hf h _ _ ij x).trans
410
+ ((happ t ht ij.2 (v x)).trans hsmall)
411
+ · exact B₀.exists_covered_factored_family D E T hbQ hT F V g hg D'
412
+ hTfil hfreq hs hP' hQP' Λ m hm hin hout ((Nat.cast_nonneg _).trans hT₁.1.1) hT₁ V₁ hV₁
413
+ (fun t : {t // t ∈ J} => A t.val) (fun t : {t // t ∈ J} => K t.val)
414
+ (fun t : {t // t ∈ J} => U t.val)
415
+ (fun t => hA0 t.val (hsub t.property)) (fun t => hK0 t.val (hsub t.property))
416
+ (fun t => hU0 t.val (hsub t.property)) (fun t => hA t.val (hsub t.property))
417
+ (fun t => hK t.val (hsub t.property)) (fun t => hU t.val (hsub t.property))
418
+
419
+ end Erdos3.NativeRankRelation.CommonData
420
+
421
+ end
422
+
423
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeLowerFactorization.lean ADDED
@@ -0,0 +1,686 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.SharedFreeFullOrbitBudget
2
+ import OAI.Combinatorics.Progressions.Dynamics.SharedFreeLowerComparisonBudget
3
+ import OAI.Combinatorics.Progressions.Lattices.AffineRefinedCoefficients
4
+ import OAI.Combinatorics.Progressions.Polynomial.PolynomialOrbitLogSum
5
+ import OAI.Combinatorics.Progressions.Polynomial.SharedFreeCommonPolynomialCorrections
6
+
7
+ namespace OAI
8
+
9
+ section
10
+
11
+ namespace Erdos3.NativeRankRelation.CommonData
12
+
13
+ open Module VectorPolynomial CyclicCrootSisask
14
+ open scoped TensorProduct BigOperators
15
+
16
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
17
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
18
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
19
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
20
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
21
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
22
+
23
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
24
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
25
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
26
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
27
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
28
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
29
+ (F : FreeCoordinateFrame E.basis Q)
30
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
31
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
32
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
33
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
34
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
35
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
36
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
37
+
38
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
39
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
40
+ (D' : R'.CommonData P')
41
+
42
+ include F
43
+
44
+ theorem exists_shared_free_full_orbit_factorization
45
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
46
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
47
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
48
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
49
+ (hsplit : ∀ h, g h = ξ * v h)
50
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
51
+ (D.commonFreeSpan d).baseChange ℝ)
52
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
53
+ (D.dependentFreeSpan d).baseChange ℝ)
54
+ (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) :
55
+ let B := (P' + 2) ^ 3 + 2 * P'
56
+ let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s
57
+ let Lc := sharedFreeCommonCorrectionBudget s Q P'
58
+ let Lv := sharedFreePetalLiftBudget s Q P'
59
+ ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧
60
+ ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-Λ) * H'.card ≤ (J.card : ℝ) ∧
61
+ ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N)
62
+ (m : ℕ) (Γ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
63
+ (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)
64
+ (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra),
65
+ (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ 0 < m ∧ (m : ℝ) ≤ Real.exp ((s : ℝ) * (Lc + Lv)) ∧
66
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 Γ = 1 ∧
67
+ (∀ d : Fin s, coefficients Γ.log (Finsupp.single () (d.val + 1)) ∈
68
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
69
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ) ∧
70
+ (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
71
+ ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp Lv) ∧
72
+ (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
73
+ ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp Lv) ∧
74
+ ∀ h ∈ J, ∃ x : Fin r₀ → ℤ,
75
+ (∀ j, |x j| ≤ (R₀ j : ℤ)) ∧ h = h₀ + η x ∧
76
+ ∃ ε A K U ρ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1),
77
+ A.log = Γ.log + positiveUnivariate (fun d => α d + ∑ j, (x j : ℝ) • β j d) ∧
78
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ε = 1 ∧
79
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 A = 1 ∧
80
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 K = 1 ∧
81
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 U = 1 ∧
82
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ρ = 1 ∧
83
+ CoefficientBound (E.basis.baseChange ℝ) (fun _ : Unit => (N : ℝ))
84
+ (Real.exp Lc + Real.exp Lv) ε.log ∧
85
+ CoefficientGrid (E.basis.baseChange ℝ) m ρ.log ∧
86
+ ε * A * K * U * ρ = g h ∧
87
+ ∀ d : Fin s,
88
+ coefficients K.log (Finsupp.single () (d.val + 1)) ∈
89
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ ∧
90
+ coefficients U.log (Finsupp.single () (d.val + 1)) ∈
91
+ (fourPetalSpace (D.dependentFreeSpan d)
92
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
93
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ := by
94
+ intro B Λ Lc Lv
95
+ classical
96
+ obtain ⟨mc, Γ, εc, ρc, hmc, hmcb, hΓ0, hεc0, hρc0, hεc, hρc, hcommon⟩ :=
97
+ D.exists_shared_free_common_polynomial_corrections E T hbQ hT F V g hg D'
98
+ hTfil hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN
99
+ obtain ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, mv, α, β,
100
+ hrank, hproper, hmv, hmvb, hα, hβ, hfamily⟩ :=
101
+ D.exists_shared_free_affine_orbit_family E T hbQ hT F V g hg D'
102
+ hTfil hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN
103
+ let m := mc * mv
104
+ have hm : 0 < m := Nat.mul_pos hmc hmv
105
+ have hmcdiv : mc ∣ m := ⟨mv, rfl⟩
106
+ have hmvdiv : mv ∣ m := ⟨mc, Nat.mul_comm _ _⟩
107
+ have hmb : (m : ℝ) ≤ Real.exp ((s : ℝ) * (Lc + Lv)) := by
108
+ change ((mc * mv : ℕ) : ℝ) ≤ _
109
+ rw [Nat.cast_mul]
110
+ calc
111
+ _ ≤ Real.exp ((s : ℝ) * Lc) * Real.exp ((s : ℝ) * Lv) :=
112
+ mul_le_mul hmcb hmvb (Nat.cast_nonneg _) (Real.exp_pos _).le
113
+ _ = _ := by rw [← Real.exp_add]; congr 1; ring
114
+ have hρcM : CoefficientGrid (E.basis.baseChange ℝ) m ρc.log :=
115
+ fun a => realDenominatorGrid_subset_of_dvd hmc hmcdiv (hρc a)
116
+ refine ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, Γ, α, β,
117
+ hrank, hproper, hm, hmb, hΓ0, (fun d => (hcommon d).1), hα, hβ, ?_⟩
118
+ intro h hh
119
+ obtain ⟨x, hx, hspace, Av, εv, ρv, U, hAv, hAv0, hεv0, hρv0, hU0,
120
+ hεv, hρv, hdependent⟩ := hfamily h hh
121
+ let ε := εc.logSum εv
122
+ let ρ := ρc.logSum ρv
123
+ let A := Γ.logSum Av
124
+ have hε0 := εc.logSum_normalized εv hεc0 hεv0
125
+ have hρ0 := ρc.logSum_normalized ρv hρc0 hρv0
126
+ have hA0 := Γ.logSum_normalized Av hΓ0 hAv0
127
+ have hρvM : CoefficientGrid (E.basis.baseChange ℝ) m ρv.log :=
128
+ fun a => realDenominatorGrid_subset_of_dvd hmv hmvdiv (hρv a)
129
+ have hcoeff (d : Fin s) : coefficients (g h).log (Finsupp.single () (d.val + 1)) -
130
+ (coefficients ε.log (Finsupp.single () (d.val + 1)) +
131
+ coefficients A.log (Finsupp.single () (d.val + 1)) +
132
+ coefficients U.log (Finsupp.single () (d.val + 1)) +
133
+ coefficients ρ.log (Finsupp.single () (d.val + 1))) ∈
134
+ (T.filtration.layer (Finsupp.weight (fun _ : Unit => 1)
135
+ (Finsupp.single () (d.val + 1))) 2).baseChange ℝ := by
136
+ have hp := T.polynomialOrbit_mul_coefficient_sub_mem_rank_two (by omega)
137
+ (fun _ : Unit => 1) (Finsupp.single () (d.val + 1)) ξ (v h)
138
+ rw [← hsplit h, (hcommon d).2, (hdependent d).2] at hp
139
+ convert hp using 1
140
+ simp only [ε, ρ, A, NilpotentLieFiltration.PolynomialOrbit.logSum_log,
141
+ map_add, Finsupp.add_apply]
142
+ abel
143
+ obtain ⟨K, hK0, hprod, hK⟩ := T.exists_polynomialOrbit_factorization_rank_two (by omega)
144
+ (fun _ : Unit => 1) (fun d : Fin s => Finsupp.single () (d.val + 1))
145
+ (g h) ε A U ρ (hg h) hε0 hA0 hU0 hρ0 hcoeff
146
+ refine ⟨x, hx, hspace, ε, A, K, U, ρ, ?_, hε0, hA0, hK0, hU0, hρ0,
147
+ CoefficientBound.add _ _ hεc hεv, CoefficientGrid.add _ _ hρcM hρvM, hprod, ?_⟩
148
+ · exact congrArg (fun z => Γ.log + z) hAv
149
+ · intro d
150
+ exact ⟨by simpa only [Finsupp.weight_single, smul_eq_mul, mul_one] using hK d,
151
+ (hdependent d).1⟩
152
+
153
+ end Erdos3.NativeRankRelation.CommonData
154
+
155
+ end
156
+
157
+ section
158
+
159
+ namespace Erdos3.RationalFilteredNilmanifold
160
+
161
+ open VectorPolynomial
162
+ open scoped TensorProduct NNReal
163
+
164
+ theorem exists_sharedFreeFactorFreezing (s : ℕ) :
165
+ ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L]
166
+ [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)]
167
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)]
168
+ {d : ℕ} (D : RationalFilteredNilmanifold L s d) {q p : ℝ},
169
+ 0 ≤ q → q ≤ p → 0 ≤ p → D.GeometryComplexityLE q →
170
+ ∀ m : ℕ, 0 < m →
171
+ (m : ℝ) ≤ Real.exp ((s : ℝ) *
172
+ (sharedFreeCommonCorrectionBudget s q p + sharedFreePetalLiftBudget s q p)) →
173
+ ∃ M : ℕ, 0 < M ∧ (M : ℝ) ≤ Real.exp ((p + C) ^ C) ∧
174
+ (∀ ρ : D.filtration.realification.PolynomialOrbit (fun _ : Unit => 1),
175
+ CoefficientGrid (D.basis.baseChange ℝ) m ρ.log →
176
+ ∀ x y : Unit → ℤ, (∀ j, (M : ℤ) ∣ x j - y j) →
177
+ ((QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval
178
+ (fun _ : Unit => 1) x ρ) : D.Space) =
179
+ QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval
180
+ (fun _ : Unit => 1) y ρ)) ∧
181
+ ((QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval
182
+ (fun _ : Unit => 1) x ρ)⁻¹ : D.Space) =
183
+ QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval
184
+ (fun _ : Unit => 1) y ρ)⁻¹)) ∧
185
+ ∀ (Φ : D.Space → ℂ) (K : ℝ≥0), (∀ z, ‖Φ z‖ ≤ 1) →
186
+ (letI := D.metricSpace; LipschitzWith K Φ) → (K : ℝ) ≤ Real.exp q →
187
+ ∀ ε a ρ g : D.filtration.realification.PolynomialOrbit (fun _ : Unit => 1),
188
+ ε * a * ρ = g → ∀ T : ℝ, 0 < T →
189
+ CoefficientBound (D.basis.baseChange ℝ) (fun _ : Unit => T)
190
+ (Real.exp (sharedFreeCommonCorrectionBudget s q p) +
191
+ Real.exp (sharedFreePetalLiftBudget s q p)) ε.log →
192
+ CoefficientGrid (D.basis.baseChange ℝ) m ρ.log →
193
+ ∀ (x y : Unit → ℤ) (δ : ℝ), 0 ≤ δ →
194
+ (∀ j, |(x j : ℝ)| ≤ T) → (∀ j, |(y j : ℝ)| ≤ T) →
195
+ (∀ j, |(x j : ℝ) - y j| ≤ T * δ) →
196
+ (∀ j, (M : ℤ) ∣ x j - y j) →
197
+ ‖Φ (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval
198
+ (fun _ : Unit => 1) x g)) -
199
+ Φ (QuotientGroup.mk
200
+ (D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) y ε *
201
+ D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x a *
202
+ D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) y ρ))‖ ≤
203
+ Real.exp ((p + C) ^ C) * δ := by
204
+ obtain ⟨a, _, hfull⟩ := exists_sharedFreeFullOrbitBudget_bound s
205
+ obtain ⟨b, _, hperiod⟩ := exists_native_orbit_rational_period s
206
+ obtain ⟨c, _, hfreeze⟩ := exists_orbit_factor_freezing s 1
207
+ let B : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + Polynomial.X + 2
208
+ obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget
209
+ ((B + Polynomial.C b) ^ b + (B + Polynomial.C c) ^ c)
210
+ refine ⟨C, hC, ?_⟩
211
+ intro L _ _ _ _ _ _ d D q p hq hqp hp hD m hm hmb
212
+ let t := (p + a) ^ a + p + 2
213
+ have hpow : 0 ≤ (p + a) ^ a := by positivity
214
+ have ht : 0 ≤ t := by dsimp only [t]; positivity
215
+ have hqt : q ≤ t := by dsimp only [t]; linarith
216
+ have hbt : (p + a) ^ a ≤ t := by dsimp only [t]; linarith
217
+ have ht1 : (1 : ℝ) ≤ t := by dsimp only [t]; linarith
218
+ have hsum : (t + b) ^ b + (t + c) ^ c ≤ (p + C) ^ C := by
219
+ simpa [B, t, Polynomial.eval₂_pow] using hbudget p hp
220
+ have hbC : (t + b) ^ b ≤ (p + C) ^ C := by
221
+ linarith [show 0 ≤ (t + c) ^ c by positivity]
222
+ have hcC : (t + c) ^ c ≤ (p + C) ^ C := by
223
+ linarith [show 0 ≤ (t + b) ^ b by positivity]
224
+ obtain ⟨_, _, _, hden, hslow⟩ := hfull q p hq hqp hp
225
+ obtain ⟨M, hM, hMb, hsolve⟩ := hperiod D (fun _ : Unit => 1)
226
+ (fun _ => Nat.zero_lt_one) t ht (hD.mono D hqt)
227
+ (by simpa only [Fintype.card_unit, Nat.cast_one] using ht1) m hm
228
+ (hmb.trans (Real.exp_le_exp.mpr (hden.trans hbt)))
229
+ refine ⟨M, hM, hMb.trans (Real.exp_le_exp.mpr hbC), hsolve, ?_⟩
230
+ intro Φ K hΦ hLip hK ε a₀ ρ g hprod T hT hε hρ x y δ hδ hx hy hxy hres
231
+ have hε' : CoefficientBound (D.basis.baseChange ℝ) (fun _ : Unit => T)
232
+ (Real.exp ((t + 2) ^ 1)) ε.log :=
233
+ CoefficientBound.mono _ _ (fun _ => hT) hε
234
+ (hslow.trans (Real.exp_le_exp.mpr (by simpa only [pow_one] using
235
+ (hbt.trans (show t ≤ t + 2 by linarith)))))
236
+ exact (hfreeze D (fun _ : Unit => 1) (fun _ => Nat.zero_lt_one) t ht
237
+ (hD.mono D hqt) (by simpa only [Fintype.card_unit, Nat.cast_one] using ht1)
238
+ Φ K hΦ hLip (hK.trans (Real.exp_le_exp.mpr hqt)) ε a₀ ρ g hprod
239
+ (fun _ : Unit => T) (fun _ => hT) hε' x y δ hδ hx hy hxy
240
+ (hsolve ρ hρ x y hres).1).trans
241
+ (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hcC) hδ)
242
+
243
+ end Erdos3.RationalFilteredNilmanifold
244
+
245
+ namespace Erdos3
246
+
247
+ noncomputable def sharedFreeFactorFreezingConstant (s : ℕ) : ℕ :=
248
+ (RationalFilteredNilmanifold.exists_sharedFreeFactorFreezing.{0} s).choose
249
+
250
+ end Erdos3
251
+
252
+ end
253
+
254
+ section
255
+
256
+ namespace Erdos3.NativeRankRelation.CommonData
257
+
258
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
259
+ open scoped TensorProduct
260
+
261
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
262
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
263
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
264
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
265
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
266
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
267
+
268
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
269
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
270
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
271
+ (B₀ : D.CoefficientBases Q)
272
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
273
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
274
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
275
+ (F : FreeCoordinateFrame E.basis Q)
276
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
277
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
278
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
279
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
280
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
281
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
282
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
283
+
284
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
285
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
286
+ (D' : R'.CommonData P')
287
+
288
+ include F
289
+
290
+ theorem CoefficientBases.exists_invariant_native_comparison_model
291
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
292
+ (hfreq : V.frequency = B₀.freeFrequency D)
293
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') :
294
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
295
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
296
+ ∃ B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j),
297
+ (∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr
298
+ (B j a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P') ∧
299
+ let φ := SubspaceFreeLift.evaluation S B (piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS
300
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S r) s
301
+ (finrank ℚ (SubspaceFreeLift.Algebra S r)),
302
+ ∃ U : M.DegreeRankStructure r,
303
+ U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
304
+ U.ComplexityLE (sharedFreeComparisonModelBudget s Q P') ∧ IsCentralLieBasis M.basis ∧
305
+ Nonempty (FreeCoordinateFrame M.basis (sharedFreeComparisonModelBudget s Q P')) ∧
306
+ (∀ i j, rationalLogHeight ((pi (fun _ : Fin 2 => E)).basis.repr
307
+ (φ (M.basis j)) i) ≤ sharedFreeComparisonModelBudget s Q P') ∧
308
+ M.lattice ≤ (pi (fun _ : Fin 2 => E)).lattice.comap (mapOfSteps
309
+ (hL := M.filtration.lowerCentralSeries_eq_bot)
310
+ (hM := (pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ) ∧
311
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r)
312
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r) :=
313
+ IsModuleTopology.isTopologicalAddGroup ℝ _
314
+ letI := realification_moduleTopology_t2 M.basis
315
+ ∃ Z : M.UnitVerticalObservable (U.realSubgroup s r)
316
+ (Fin W.family.outputDim × Fin W.family.outputDim) (sharedFreeComparisonModelBudget s Q P'),
317
+ Z.frequency = (pairDifferenceFunctional V.frequency).comp φ.toLinearMap ∧
318
+ (∀ x ∈ U.filtration.layer s r, Z.frequency x = 0) ∧
319
+ (∀ i z, z ∈ U.realSubgroup s r → ∀ x, Z.observable i (z • x) = Z.observable i x) ∧
320
+ ∀ i x, Z.observable i (QuotientGroup.mk x) =
321
+ V.pairedObservable T i (QuotientGroup.mk (realificationMap
322
+ (hnil := M.filtration.lowerCentralSeries_eq_bot)
323
+ (hM := (pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ x))) := by
324
+ intro S hS
325
+ obtain ⟨J, hJ, M, U, hU, hUc, hcentral, hframe, hmatrix, hlattice, hZ⟩ :=
326
+ D.exists_native_comparison_model E T hbQ hT F V g hg D' hTfil hs hP' hQP'
327
+ refine ⟨J, hJ, M, U, hU, hUc, hcentral, hframe, hmatrix, hlattice, ?_⟩
328
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r)
329
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S r) :=
330
+ IsModuleTopology.isTopologicalAddGroup ℝ _
331
+ let := realification_moduleTopology_t2 M.basis
332
+ obtain ⟨Z, hfreqZ, hobs⟩ := hZ
333
+ have hzero := B₀.native_comparison_frequency_zero D E T hbQ hT V g hg D'
334
+ hTfil hfreq J M U hU Z.frequency hfreqZ
335
+ exact ⟨Z, hfreqZ, hzero,
336
+ (fun i z hz x => Z.rank_invariant_of_frequency_zero U hzero z hz i x), hobs⟩
337
+
338
+ end Erdos3.NativeRankRelation.CommonData
339
+
340
+ end
341
+
342
+ section
343
+
344
+ namespace Erdos3.NativeRankRelation.CommonData
345
+
346
+ open Module NilpotentLieBCHGroup RationalFilteredNilmanifold
347
+ open scoped TensorProduct
348
+
349
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
350
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
351
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
352
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
353
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
354
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
355
+
356
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
357
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
358
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
359
+ (B₀ : D.CoefficientBases Q)
360
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
361
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
362
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
363
+ (F : FreeCoordinateFrame E.basis Q)
364
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
365
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
366
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
367
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
368
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
369
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
370
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
371
+
372
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
373
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
374
+ (D' : R'.CommonData P')
375
+
376
+ include F
377
+
378
+ theorem CoefficientBases.exists_uniform_lower_comparison_model
379
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
380
+ (hfreq : V.frequency = B₀.freeFrequency D)
381
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') :
382
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
383
+ let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil
384
+ ∃ B : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j),
385
+ (∀ j a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr
386
+ (B j a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P') ∧
387
+ let φ := SubspaceFreeLift.evaluation S B (piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS
388
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
389
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
390
+ ∃ U : M.DegreeRankStructure (r + 1),
391
+ U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
392
+ U.ComplexityLE (sharedFreeComparisonModelBudget s Q P') ∧
393
+ (letI := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))
394
+ letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1)) :=
395
+ IsModuleTopology.isTopologicalAddGroup ℝ _
396
+ letI := realification_moduleTopology_t2 M.basis
397
+ ∃ Z : M.UnitVerticalObservable (U.realSubgroup s (r + 1))
398
+ (Fin W.family.outputDim × Fin W.family.outputDim) (sharedFreeComparisonModelBudget s Q P'),
399
+ (∀ i x, Z.observable i (QuotientGroup.mk x) =
400
+ V.pairedObservable T i (QuotientGroup.mk (realificationMap
401
+ (hnil := M.filtration.lowerCentralSeries_eq_bot)
402
+ (hM := (pi (fun _ : Fin 2 => E)).filtration.lowerCentralSeries_eq_bot) φ x))) ∧
403
+ M.HasUniformLowerRankUnitFamily U Z.observable (fun _ : Unit => 1)
404
+ (sharedFreeLowerComparisonBudget s Q P')) := by
405
+ intro S hS
406
+ obtain ⟨J, hJ, M, U, hU, hUc, _, _, _, _, hZ⟩ :=
407
+ B₀.exists_invariant_native_comparison_model D E T hbQ hT F V g hg D'
408
+ hTfil hfreq hs hP' hQP'
409
+ refine ⟨J, hJ, M, U, hU, hUc, ?_⟩
410
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))
411
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1)) :=
412
+ IsModuleTopology.isTopologicalAddGroup ℝ _
413
+ let := realification_moduleTopology_t2 M.basis
414
+ obtain ⟨Z, _, hzero, _, hobs⟩ := hZ
415
+ refine ⟨Z, hobs, ?_⟩
416
+ have hpM : 0 ≤ sharedFreeComparisonModelBudget s Q P' :=
417
+ (Nat.cast_nonneg _).trans hUc.1.1
418
+ exact UnitVerticalObservable.hasUniformLowerRankUnitFamily M U Z
419
+ (fun _ : Unit => 1) hpM hUc hzero
420
+
421
+ end Erdos3.NativeRankRelation.CommonData
422
+
423
+ end
424
+
425
+ section
426
+
427
+ namespace Erdos3.NativeRankRelation.CommonData
428
+
429
+ open Module VectorPolynomial RationalFilteredNilmanifold
430
+ open scoped TensorProduct
431
+
432
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
433
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
434
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
435
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
436
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
437
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
438
+
439
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
440
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
441
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
442
+ (B�� : D.CoefficientBases Q)
443
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
444
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
445
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
446
+ (F : FreeCoordinateFrame E.basis Q)
447
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
448
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
449
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
450
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
451
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
452
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
453
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
454
+
455
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
456
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
457
+ (D' : R'.CommonData P')
458
+
459
+ include F
460
+
461
+ theorem CoefficientBases.exists_lower_factored_family {τ : Type*}
462
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
463
+ (hfreq : V.frequency = B₀.freeFrequency D)
464
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P')
465
+ (A K U : τ → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
466
+ (hA0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A t) = 1)
467
+ (hK0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K t) = 1)
468
+ (hU0 : ∀ t, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U t) = 1)
469
+ (hA : ∀ t (d : Fin s), coefficients (A t).log (Finsupp.single () (d.val + 1)) ∈
470
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
471
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ)
472
+ (hK : ∀ t (d : Fin s), coefficients (K t).log (Finsupp.single () (d.val + 1)) ∈
473
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ)
474
+ (hU : ∀ t (d : Fin s), coefficients (U t).log (Finsupp.single () (d.val + 1)) ∈
475
+ (fourPetalSpace (D.dependentFreeSpan d)
476
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
477
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) :
478
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
479
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
480
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
481
+ ∃ Tm : M.DegreeRankStructure (r + 1),
482
+ Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
483
+ Tm.ComplexityLE (sharedFreeComparisonModelBudget s Q P') ∧
484
+ M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1)
485
+ (fun t (i : Fin W.family.outputDim × Fin W.family.outputDim) x =>
486
+ V.observable i.1 (QuotientGroup.mk
487
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (A t * K t * U t))) *
488
+ star (V.observable i.2 (QuotientGroup.mk
489
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) x (A t)))))
490
+ (sharedFreeLowerComparisonBudget s Q P') := by
491
+ intro S
492
+ obtain ⟨J, _, M, Tm, hTm, hTmc, hZ⟩ :=
493
+ B₀.exists_uniform_lower_comparison_model D E T hbQ hT F V g hg D'
494
+ hTfil hfreq hs hP' hQP'
495
+ refine ⟨M, Tm, hTm, hTmc, ?_⟩
496
+ let := moduleTopology ℝ (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1))
497
+ let : IsTopologicalAddGroup (ℝ ⊗[ℚ] SubspaceFreeLift.Algebra S (r + 1)) :=
498
+ IsModuleTopology.isTopologicalAddGroup ℝ _
499
+ let := realification_moduleTopology_t2 M.basis
500
+ obtain ⟨Z, hobs, huniform⟩ := hZ
501
+ apply huniform.realizeFamily
502
+ intro t
503
+ obtain ⟨u, hu0, _, hu⟩ := D.exists_native_factored_comparison_orbit E T hbQ hT V g hg D'
504
+ hTfil (by omega) (A t) (K t) (U t) (hA0 t) (hK0 t) (hU0 t) (hA t) (hK t) (hU t)
505
+ J M Tm hTm
506
+ refine ⟨u, hu0, ?_⟩
507
+ intro i x
508
+ exact SubspaceFreeLift.native_pair_observable_eval E T S J
509
+ (D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil)
510
+ M Tm V Z hobs ![A t * K t * U t, A t] u hu i x
511
+
512
+ end Erdos3.NativeRankRelation.CommonData
513
+
514
+ end
515
+
516
+ section
517
+
518
+ namespace Erdos3.NativeRankRelation.CommonData
519
+
520
+ open Module VectorPolynomial RationalFilteredNilmanifold
521
+ open scoped TensorProduct BigOperators
522
+
523
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
524
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
525
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
526
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
527
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
528
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
529
+
530
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
531
+ {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim}
532
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
533
+ (B₀ : D.CoefficientBases Q)
534
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
535
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
536
+ (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
537
+ (F : FreeCoordinateFrame E.basis Q)
538
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
539
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
540
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
541
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
542
+ (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q)
543
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
544
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
545
+
546
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
547
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
548
+ (D' : R'.CommonData P')
549
+
550
+ include F
551
+
552
+ theorem CoefficientBases.exists_shared_free_lower_factorization
553
+ (hTfil : T.filtration = D.coefficientFreeFiltration)
554
+ (hfreq : V.frequency = B₀.freeFrequency D)
555
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
556
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
557
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
558
+ (hsplit : ∀ h, g h = ξ * v h)
559
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
560
+ (D.commonFreeSpan d).baseChange ℝ)
561
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
562
+ (D.dependentFreeSpan d).baseChange ℝ)
563
+ (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) :
564
+ let B := (P' + 2) ^ 3 + 2 * P'
565
+ let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s
566
+ let Lc := sharedFreeCommonCorrectionBudget s Q P'
567
+ let Lv := sharedFreePetalLiftBudget s Q P'
568
+ ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧
569
+ ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-Λ) * H'.card ≤ (J.card : ℝ) ∧
570
+ ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N)
571
+ (m : ℕ) (Γ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
572
+ (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)
573
+ (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra),
574
+ (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ 0 < m ∧ (m : ℝ) ≤ Real.exp ((s : ℝ) * (Lc + Lv)) ∧
575
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 Γ = 1 ∧
576
+ (∀ d : Fin s, coefficients Γ.log (Finsupp.single () (d.val + 1)) ∈
577
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
578
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ) ∧
579
+ (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
580
+ ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp Lv) ∧
581
+ (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧
582
+ ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp Lv) ∧
583
+ ∃ (x : {h // h ∈ J} → Fin r₀ → ℤ)
584
+ (ε A K U ρ : {h // h ∈ J} →
585
+ E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)),
586
+ (∀ h : {h // h ∈ J},
587
+ (∀ j, |x h j| ≤ (R₀ j : ℤ)) ∧ h.val = h₀ + η (x h) ∧
588
+ (A h).log = Γ.log + positiveUnivariate
589
+ (fun d => α d + ∑ j, (x h j : ℝ) • β j d) ∧
590
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (ε h) = 1 ∧
591
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A h) = 1 ∧
592
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K h) = 1 ∧
593
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U h) = 1 ∧
594
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (ρ h) = 1 ∧
595
+ CoefficientBound (E.basis.baseChange ℝ) (fun _ : Unit => (N : ℝ))
596
+ (Real.exp Lc + Real.exp Lv) (ε h).log ∧
597
+ CoefficientGrid (E.basis.baseChange ℝ) m (ρ h).log ∧
598
+ ε h * A h * K h * U h * ρ h = g h.val ∧
599
+ ∀ d : Fin s,
600
+ coefficients (K h).log (Finsupp.single () (d.val + 1)) ∈
601
+ (T.filtration.layer (d.val + 1) 2).baseChange ℝ ∧
602
+ coefficients (U h).log (Finsupp.single () (d.val + 1)) ∈
603
+ (fourPetalSpace (D.dependentFreeSpan d)
604
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
605
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) ∧
606
+ (∃ M₀ : ℕ, 0 < M₀ ∧
607
+ (M₀ : ℝ) ≤ Real.exp ((P' + sharedFreeFactorFreezingConstant s) ^
608
+ sharedFreeFactorFreezingConstant s) ∧
609
+ (∀ (h : {h // h ∈ J}) (y z : Unit → ℤ),
610
+ (∀ j, (M₀ : ℤ) ∣ y j - z j) →
611
+ ((QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
612
+ (fun _ : Unit => 1) y (ρ h)) : E.Space) =
613
+ QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
614
+ (fun _ : Unit => 1) z (ρ h))) ∧
615
+ ((QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
616
+ (fun _ : Unit => 1) y (ρ h))⁻¹ : E.Space) =
617
+ QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval
618
+ (fun _ : Unit => 1) z (ρ h))⁻¹)) ∧
619
+ ∀ (h : {h // h ∈ J}) i (y z : Unit → ℤ) (δ : ℝ), 0 ≤ δ →
620
+ (∀ j, |(y j : ℝ)| ≤ N) → (∀ j, |(z j : ℝ)| ≤ N) →
621
+ (∀ j, |(y j : ℝ) - z j| ≤ (N : ℝ) * δ) →
622
+ (∀ j, (M₀ : ℤ) ∣ y j - z j) →
623
+ ‖V.observable i (QuotientGroup.mk
624
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) y (g h.val))) -
625
+ V.observable i (QuotientGroup.mk
626
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) z (ε h) *
627
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) y
628
+ (A h * K h * U h) *
629
+ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) z (ρ h)))‖ ≤
630
+ Real.exp ((P' + sharedFreeFactorFreezingConstant s) ^
631
+ sharedFreeFactorFreezingConstant s) * δ) ∧
632
+ let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D'
633
+ ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s
634
+ (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))),
635
+ ∃ Tm : M.DegreeRankStructure (r + 1),
636
+ Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧
637
+ Tm.ComplexityLE (sharedFreeComparisonModelBudget s Q P') ∧
638
+ M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1)
639
+ (fun h (i : Fin W.family.outputDim × Fin W.family.outputDim) y =>
640
+ V.observable i.1 (QuotientGroup.mk
641
+ (E.filtration.realification.polynomialOrbitEval
642
+ (fun _ : Unit => 1) y (A h * K h * U h))) *
643
+ star (V.observable i.2 (QuotientGroup.mk
644
+ (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) y (A h)))))
645
+ (sharedFreeLowerComparisonBudget s Q P') := by
646
+ intro B Λ Lc Lv
647
+ classical
648
+ obtain ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, Γ, α, β,
649
+ hrank, hproper, hm, hmb, hΓ0, hΓ, hα, hβ, hfamily⟩ :=
650
+ D.exists_shared_free_full_orbit_factorization E T hbQ hT F V g hg D'
651
+ hTfil hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN
652
+ choose x hx hspace ε A K U ρ hAl hε0 hA0 hK0 hU0 hρ0 hε hρ hprod hKU using
653
+ (fun h : {h // h ∈ J} => hfamily h.val h.property)
654
+ have hAc : ∀ (h : {h // h ∈ J}) (d : Fin s),
655
+ coefficients (A h).log (Finsupp.single () (d.val + 1)) ∈
656
+ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
657
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ := by
658
+ intro h d
659
+ rw [hAl h]
660
+ exact affine_refined_coefficient_mem D.coefficientFreeSpan D.dependentFreeSpan
661
+ (fun d : Fin s => D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)
662
+ Γ.log α β (fun j => (x h j : ℝ)) hΓ (fun d => (hα d).1) (fun j d => (hβ j d).1) d
663
+ refine ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, Γ, α, β,
664
+ hrank, hproper, hm, hmb, hΓ0, hΓ, hα, hβ, x, ε, A, K, U, ρ, ?_, ?_, ?_⟩
665
+ · intro h
666
+ exact ⟨hx h, hspace h, hAl h, hε0 h, hA0 h, hK0 h, hU0 h, hρ0 h,
667
+ hε h, hρ h, hprod h, hKU h⟩
668
+ · have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
669
+ obtain ⟨M₀, hM₀, hM₀b, hperiod, hfreeze⟩ :=
670
+ (RationalFilteredNilmanifold.exists_sharedFreeFactorFreezing.{0} s).choose_spec.2
671
+ E hQ hQP' hP' hT.1 m hm hmb
672
+ refine ⟨M₀, hM₀, hM₀b, (fun h y z hres => hperiod (ρ h) (hρ h) y z hres), ?_⟩
673
+ intro h i y z δ hδ hy hz hyz hres
674
+ exact hfreeze (V.observable i) V.lipBound (V.norm i) (V.lipschitz i) V.lip_bound
675
+ (ε h) (A h * K h * U h) (ρ h) (g h.val)
676
+ (by simpa only [mul_assoc] using hprod h) (N : ℝ)
677
+ (by exact_mod_cast NeZero.pos N) (hε h) (hρ h) y z δ hδ hy hz hyz hres
678
+ · exact B₀.exists_lower_factored_family D E T hbQ hT F V g hg D'
679
+ hTfil hfreq hs hP' hQP' A K U hA0 hK0 hU0 hAc
680
+ (fun h d => (hKU h d).1) (fun h d => (hKU h d).2)
681
+
682
+ end Erdos3.NativeRankRelation.CommonData
683
+
684
+ end
685
+
686
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedFreeRoundingThreshold.lean ADDED
@@ -0,0 +1,845 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Dynamics.SharedRefinementBudget
2
+ import OAI.Combinatorics.Progressions.Linear.RealFourBalancedDual
3
+
4
+ namespace OAI
5
+
6
+ section
7
+
8
+ namespace Erdos3.NativeRankRelation.CommonData
9
+
10
+ open Module RationalFilteredNilmanifold VectorPolynomial
11
+ open scoped TensorProduct
12
+
13
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
14
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
15
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
16
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
17
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
18
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
19
+
20
+ variable {κ : Type*} {s r N : ℕ} [NeZero N] {b p q P : ℝ}
21
+ {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim}
22
+ {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P)
23
+
24
+ theorem exists_native_full_coefficient_corrections (hs : 1 ≤ s) (hP : 0 ≤ P)
25
+ (c : Basis κ ℚ W.L) (τ : κ → ℕ)
26
+ (hG : ∀ j, W.rank.filtration.associatedDegree.layer j =
27
+ Submodule.span ℚ (c '' {i | j ≤ τ i}))
28
+ (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ D.quadruples) :
29
+ let I := R.interval ⟨t, D.subset ht⟩
30
+ let V : I.SunflowerWitness P := D.witness t ht
31
+ ∃ E Q : ∀ α : Unit →₀ ℕ,
32
+ (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ,
33
+ (∀ α j, |(W.fourRankBasis.baseChange ℝ).repr (E α).val j| ≤
34
+ Real.exp ((P + 3) ^ 2) / monomialScale (fun _ : Unit => (I.length : ℝ)) α) ∧
35
+ (∀ α, (W.fourRankBasis.baseChange ℝ).equivFun (Q α).val ∈
36
+ realDenominatorGrid V.projectedDenominator) ∧
37
+ ∀ (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s),
38
+ (fun k => coefficients
39
+ (W.orbit (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α) -
40
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) (E α).val -
41
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) (Q α).val ∈
42
+ D.realCoefficientFourSpace ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ := by
43
+ intro I V
44
+ obtain ⟨E, Q, hE, hQ, hres⟩ := D.exists_bounded_coefficient_corrections hs hP t ht
45
+ refine ⟨E, Q, hE, hQ, ?_⟩
46
+ intro α hα
47
+ let d : Fin (s + 1) := ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩
48
+ let e4 := TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)
49
+ let u := e4 (V.projectedOrbitCoefficient α).val
50
+ let β : Fin 4 → ℝ ⊗[ℚ] W.L := fun k => coefficients
51
+ (W.orbit (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α
52
+ let e := e4 (E α).val
53
+ let a := e4 (Q α).val
54
+ have hu : u - e - a ∈ D.realCoefficientFourSpace d := by
55
+ have h := (D.mem_real_coefficientFourSpace d (V.projectedOrbitCoefficient α - E α - Q α)).mpr
56
+ (hres α hα)
57
+ simpa only [Submodule.coe_sub, map_sub] using h
58
+ have hk (k : Fin 4) : (u - e - a) k - (β - e - a) k ∈
59
+ (W.rank.filtration.layer d.val 2).baseChange ℝ := by
60
+ have heq : (u - e - a) k - (β - e - a) k = u k - β k := by
61
+ simp only [Pi.sub_apply]
62
+ abel
63
+ rw [heq]
64
+ exact V.projectedOrbitCoefficient_native_log_mod_kernel hs c τ hG α k
65
+ exact (D.realCoefficientFourSpace_congr_mod_kernel d _ _ hk).mp hu
66
+
67
+ theorem native_full_scaled_correction (hs : 1 ≤ s) (hp : 0 ≤ p) (hP : 0 ≤ P)
68
+ (c : Basis κ ℚ W.L) (τ : κ → ℕ)
69
+ (hG : ∀ j, W.rank.filtration.associatedDegree.layer j =
70
+ Submodule.span ℚ (c '' {i | j ≤ τ i}))
71
+ (l : ℕ) (hdenom : ∀ t (ht : t ∈ D.quadruples), (D.witness t ht).projectedDenominator = l)
72
+ (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s)
73
+ (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ D.quadruples) :
74
+ ∃ E Q : ℝ ⊗[ℚ] (Fin 4 → W.L),
75
+ ‖(W.fourRankBasis.baseChange ℝ).equivFun E‖ ≤
76
+ Real.exp ((P + 3) ^ 2 + (s : ℝ) * p) / monomialScale (fun _ : Unit => (N : ℝ)) α ∧
77
+ (W.fourRankBasis.baseChange ℝ).equivFun Q ∈ realDenominatorGrid l ∧
78
+ (fun k => coefficients
79
+ (W.orbit (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α) -
80
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) E -
81
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) Q ∈
82
+ D.realCoefficientFourSpace ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ := by
83
+ obtain ⟨E, Q, hE, hQ, hres⟩ := D.exists_native_full_coefficient_corrections hs hP c τ hG t ht
84
+ let I := R.interval ⟨t, D.subset ht⟩
85
+ have hlength : (0 : ℝ) < I.length := by exact_mod_cast I.length_pos
86
+ have hnorm : ‖(W.fourRankBasis.baseChange ℝ).equivFun (E α).val‖ ≤
87
+ Real.exp ((P + 3) ^ 2) / monomialScale (fun _ : Unit => (I.length : ℝ)) α := by
88
+ apply (pi_norm_le_iff_of_nonneg (div_nonneg (Real.exp_pos _).le
89
+ (monomialScale_pos _ (fun _ => hlength) α).le)).mpr
90
+ exact fun j => hE α j
91
+ refine ⟨(E α).val, (Q α).val, ?_, ?_, hres α hα⟩
92
+ · have h := I.norm_bound_on_modulus hp α hα (Real.exp_pos _).le
93
+ ((W.fourRankBasis.baseChange ℝ).equivFun (E α).val) hnorm
94
+ simpa only [Real.exp_add] using h
95
+ · simpa only [hdenom t ht] using hQ α
96
+
97
+ theorem exists_uniform_native_full_scaled_corrections (hs : 1 ≤ s) (hp : 0 ≤ p) (hP : 0 ≤ P)
98
+ (c : Basis κ ℚ W.L) (τ : κ → ℕ)
99
+ (hG : ∀ j, W.rank.filtration.associatedDegree.layer j =
100
+ Submodule.span ℚ (c '' {i | j ≤ τ i})) :
101
+ let B := (P + 2) ^ 3 + 2 * P
102
+ ∃ (C : R.CommonData B) (l : ℕ), C.quadruples ⊆ D.quadruples ∧ C.spaces = D.spaces ∧
103
+ 0 < l ∧ (l : ℝ) ≤ Real.exp ((P + 2) ^ 3 + P) ∧
104
+ ∀ (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s)
105
+ (t : ZMod N × ZMod N × ZMod N), t ∈ C.quadruples →
106
+ ∃ E Q : ℝ ⊗[ℚ] (Fin 4 → W.L),
107
+ ‖(W.fourRankBasis.baseChange ℝ).equivFun E‖ ≤
108
+ Real.exp ((B + 3) ^ 2 + (s : ℝ) * p) / monomialScale (fun _ : Unit => (N : ℝ)) α ∧
109
+ (W.fourRankBasis.baseChange ℝ).equivFun Q ∈ realDenominatorGrid l ∧
110
+ (fun k => coefficients
111
+ (W.orbit (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α) -
112
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) E -
113
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) Q ∈
114
+ C.realCoefficientFourSpace ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ := by
115
+ intro B
116
+ obtain ⟨C, l, hCD, hspaces, hl, hbound, hdenom⟩ := D.exists_common_projected_denominator hP
117
+ refine ⟨C, l, hCD, hspaces, hl, hbound, ?_⟩
118
+ intro α hα t ht
119
+ exact C.native_full_scaled_correction hs hp (by positivity)
120
+ c τ hG l hdenom α hα t ht
121
+
122
+ end Erdos3.NativeRankRelation.CommonData
123
+
124
+ end
125
+
126
+ section
127
+
128
+ namespace Erdos3
129
+
130
+ open Module VectorPolynomial
131
+ open scoped TensorProduct
132
+
133
+ noncomputable def sharedLogCoefficientTuple
134
+ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s N : ℕ}
135
+ (F : NilpotentLieFiltration L s)
136
+ (ξ : F.realification.PolynomialOrbit (fun _ : Unit => 1))
137
+ (v : ZMod N → F.realification.PolynomialOrbit (fun _ : Unit => 1))
138
+ (α : Unit →₀ ℕ) (t : ZMod N × ZMod N × ZMod N) : Fin 4 → ℝ ⊗[ℚ] L :=
139
+ fun k => coefficients ξ.log α + coefficients
140
+ (v (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α
141
+
142
+ theorem sharedLogCoefficientTuple_mem_common
143
+ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s N : ℕ}
144
+ (F : NilpotentLieFiltration L s) (C D : Submodule ℚ L) (hDC : D ≤ C)
145
+ (ξ : F.realification.PolynomialOrbit (fun _ : Unit => 1))
146
+ (v : ZMod N → F.realification.PolynomialOrbit (fun _ : Unit => 1))
147
+ (α : Unit →₀ ℕ) (t : ZMod N × ZMod N × ZMod N)
148
+ (hξ : coefficients ξ.log α ∈ C.baseChange ℝ)
149
+ (hv : ∀ h, coefficients (v h).log α ∈ D.baseChange ℝ) :
150
+ sharedLogCoefficientTuple F ξ v α t ∈ fourCommonModulo (C.baseChange ℝ) (D.baseChange ℝ) := by
151
+ apply (mem_fourCommonModulo _ _ _).mpr
152
+ constructor
153
+ · intro k
154
+ exact (C.baseChange ℝ).add_mem hξ (Submodule.baseChange_mono ℝ hDC (hv _))
155
+ · intro k
156
+ change (coefficients ξ.log α + coefficients (v _).log α) -
157
+ (coefficients ξ.log α + coefficients (v _).log α) ∈ D.baseChange ℝ
158
+ rw [add_sub_add_left_eq_sub]
159
+ exact (D.baseChange ℝ).sub_mem (hv _) (hv _)
160
+
161
+ namespace NativeRankRelation.CommonData
162
+
163
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
164
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
165
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
166
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
167
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
168
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
169
+
170
+ variable {κ : Type*} {s r N : ℕ} [NeZero N] {b p q P : ℝ}
171
+ {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim}
172
+ {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P)
173
+
174
+ theorem native_shared_scaled_correction (hs : 1 ≤ s) (hp : 0 ≤ p) (hP : 0 ≤ P)
175
+ (c : Basis κ ℚ W.L) (τ : κ → ℕ)
176
+ (hG : ∀ j, W.rank.filtration.associatedDegree.layer j =
177
+ Submodule.span ℚ (c '' {i | j ≤ τ i}))
178
+ (ξ : W.model.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
179
+ (v : ZMod N → W.model.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
180
+ (horbit : ∀ h, W.orbit h = ξ * v h)
181
+ (l : ℕ) (hdenom : ∀ t (ht : t ∈ D.quadruples), (D.witness t ht).projectedDenominator = l)
182
+ (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s)
183
+ (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ D.quadruples) :
184
+ ∃ E Q : ℝ ⊗[ℚ] (Fin 4 → W.L),
185
+ ‖(W.fourRankBasis.baseChange ℝ).equivFun E‖ ≤
186
+ Real.exp ((P + 3) ^ 2 + (s : ℝ) * p) / monomialScale (fun _ : Unit => (N : ℝ)) α ∧
187
+ (W.fourRankBasis.baseChange ℝ).equivFun Q ∈ realDenominatorGrid l ∧
188
+ sharedLogCoefficientTuple W.model.filtration ξ v α t -
189
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) E -
190
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) Q ∈
191
+ D.realCoefficientFourSpace ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ := by
192
+ obtain ⟨E, Q, hE, hQ, hres⟩ := D.native_full_scaled_correction hs hp hP c τ hG
193
+ l hdenom α hα t ht
194
+ refine ⟨E, Q, hE, hQ, ?_⟩
195
+ apply (D.realCoefficientFourSpace_congr_mod_kernel _ _ _ ?_).mp hres
196
+ intro k
197
+ let a := rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)
198
+ let e := (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) E k
199
+ let z := (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) Q k
200
+ change (coefficients (W.orbit a).log α - e - z) -
201
+ (coefficients ξ.log α + coefficients (v a).log α - e - z) ∈ _
202
+ rw [horbit a]
203
+ have heq : (coefficients (ξ * v a).log α - e - z) -
204
+ (coefficients ξ.log α + coefficients (v a).log α - e - z) =
205
+ coefficients (ξ * v a).log α - (coefficients ξ.log α + coefficients (v a).log α) := by abel
206
+ rw [heq]
207
+ exact W.rank.orbit_log_mul_mod_rank_two hs c τ hG (fun _ : Unit => 1) α ξ (v a)
208
+
209
+ end NativeRankRelation.CommonData
210
+ end Erdos3
211
+
212
+ end
213
+
214
+ section
215
+
216
+ namespace Erdos3
217
+
218
+ open VectorPolynomial
219
+ open scoped TensorProduct
220
+
221
+ theorem sharedLogCoefficientTuple_annihilator_decomposition
222
+ {L J : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype J] {s N : ℕ}
223
+ (F : NilpotentLieFiltration L s) (C D : Submodule ℚ L) (hDC : D ≤ C)
224
+ (ℓ : (Fin 4 → L) →ₗ[ℚ] (J → ℚ))
225
+ (hℓ : fourBalancedDependent D ≤ LinearMap.ker ℓ)
226
+ (ξ : F.realification.PolynomialOrbit (fun _ : Unit => 1))
227
+ (v : ZMod N → F.realification.PolynomialOrbit (fun _ : Unit => 1))
228
+ (α : Unit →₀ ℕ) (t : ZMod N × ZMod N × ZMod N)
229
+ (hξ : coefficients ξ.log α ∈ C.baseChange ℝ)
230
+ (hv : ∀ h, coefficients (v h).log α ∈ D.baseChange ℝ) :
231
+ let φ := ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => L) 0)
232
+ let a := fun h => realifyCoordinateMap φ (coefficients (v h).log α)
233
+ realFourCoordinateMap ℓ (sharedLogCoefficientTuple F ξ v α t) =
234
+ realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) (coefficients ξ.log α) +
235
+ (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) -
236
+ a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) := by
237
+ intro φ a
238
+ have h := realFourCoordinateMap_shared_decomposition C D hDC ℓ hℓ
239
+ (coefficients ξ.log α) hξ
240
+ (fun k => coefficients (v (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α)
241
+ (fun k => hv _)
242
+ change realFourCoordinateMap ℓ (sharedLogCoefficientTuple F ξ v α t) =
243
+ realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) (coefficients ξ.log α) +
244
+ realifyCoordinateMap φ
245
+ (coefficients (v (rankQuadrupleParameters t 1)).log α +
246
+ coefficients (v (rankQuadrupleParameters t 2)).log α -
247
+ coefficients (v (rankQuadrupleParameters t 0)).log α -
248
+ coefficients (v (rankQuadrupleParameters t 3)).log α) at h
249
+ simpa only [map_add, map_sub] using h
250
+
251
+ end Erdos3
252
+
253
+ end
254
+
255
+ section
256
+
257
+ namespace Erdos3.NativeRankRelation.CommonData
258
+
259
+ open Module VectorPolynomial
260
+ open scoped TensorProduct
261
+
262
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
263
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
264
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
265
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
266
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
267
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
268
+
269
+ variable {s r N : ℕ} [NeZero N] {b p q P : ℝ}
270
+ {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim}
271
+ {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P)
272
+
273
+ theorem exists_uniform_shared_refinement
274
+ (hs : 2 ≤ s) (hp : 0 ≤ p) (hP : 0 ≤ P) (hbP : b ≤ P) (hpP : p ≤ P)
275
+ (U V : Fin s → Submodule ℚ W.L) (hVU : ∀ d, V d ≤ U d)
276
+ (u : ∀ d, Basis (Fin (finrank ℚ (U d))) ℚ (U d))
277
+ (v : ∀ d, Basis (Fin (finrank ℚ (V d))) ℚ (V d))
278
+ (hu : ∀ d a i, rationalLogHeight (W.model.basis.repr (u d a : W.L) i) ≤ P)
279
+ (hv : ∀ d a i, rationalLogHeight (W.model.basis.repr (v d a : W.L) i) ≤ P)
280
+ (ξ : W.model.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
281
+ (g : ZMod N → W.model.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
282
+ (horbit : ∀ h, W.orbit h = ξ * g h)
283
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ (U d).baseChange ℝ)
284
+ (hg : ∀ h (d : Fin s), coefficients (g h).log (Finsupp.single () (d.val + 1)) ∈
285
+ (V d).baseChange ℝ)
286
+ (hN : Real.exp (separationBudget (8 * sharedRefinementInputBudget s P + 1)) ≤ (N : ℝ)) :
287
+ let B := (P + 2) ^ 3 + 2 * P
288
+ let z := 8 * sharedRefinementInputBudget s P + 1
289
+ ∃ D₁ : R.CommonData B, D₁.quadruples ⊆ D.quadruples ∧ D₁.spaces = D.spaces ∧
290
+ ∀ d : Fin s, ∃ m : ℕ, 0 < m ∧
291
+ (m : ℝ) ≤ Real.exp (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) ∧
292
+ ∀ t ∈ D₁.quadruples, ∃ E Q : ℝ ⊗[ℚ] (Fin 4 → W.L),
293
+ ‖(W.fourRankBasis.baseChange ℝ).equivFun E‖ ≤
294
+ (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) /
295
+ monomialScale (fun _ : Unit => (N : ℝ)) (Finsupp.single () (d.val + 1)) ∧
296
+ (W.fourRankBasis.baseChange ℝ).equivFun Q ∈ realDenominatorGrid m ∧
297
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)).symm
298
+ (sharedLogCoefficientTuple W.model.filtration ξ g (Finsupp.single () (d.val + 1)) t) -
299
+ E - Q ∈ (fourRefinedRelation (U d) (V d)
300
+ (D.coefficientFourSpace ⟨d.val + 1, by omega⟩)).baseChange ℝ := by
301
+ intro B z
302
+ classical
303
+ let A := sharedRefinementInputBudget s P
304
+ obtain ⟨hB, hPB, hA, hPA, hHA, hEA, hLA⟩ := sharedRefinementInputBudget_bounds s hP
305
+ have hAz : A ≤ z := by dsimp only [z, A]; linarith
306
+ have hdim : (Fintype.card (Fin W.dim) : ℝ) ≤ A := by
307
+ simpa only [Fintype.card_fin] using W.complexity.1.1.trans (hbP.trans hPA)
308
+ let : FiniteDimensional ℚ W.L := W.model.basis.finiteDimensional_of_finite
309
+ obtain ⟨c, τ, _, _, hF⟩ := W.rank.filtration.associatedDegree.exists_sorted_adapted_basis
310
+ obtain ⟨D₁, l, hsub, hspaces, hl, hlbound, hdenom⟩ := D.exists_common_projected_denominator hP
311
+ refine ⟨D₁, hsub, hspaces, ?_⟩
312
+ intro d
313
+ let δ : Fin (s + 1) := ⟨d.val + 1, by omega⟩
314
+ let α : Unit →₀ ℕ := Finsupp.single () (d.val + 1)
315
+ have hα : Finsupp.weight (fun _ : Unit => 1) α = δ.val := by
316
+ simp only [α, δ, Finsupp.weight_single, smul_eq_mul, mul_one]
317
+ have hαs : Finsupp.weight (fun _ : Unit => 1) α ≤ s := by rw [hα]; exact Nat.le_of_lt_succ δ.isLt
318
+ have hα0 : α ≠ 0 := by simp [α]
319
+ obtain ⟨k, hk⟩ := D₁.exists_coefficientFour_basis hs hB (hbP.trans hPB) δ
320
+ have hlA : (l : ℝ) ≤ Real.exp A := hlbound.trans (Real.exp_le_exp.mpr hLA)
321
+ obtain ⟨m, hm, hmp, _, hsolve⟩ := exists_fourRefinedRelation_correction W.model.basis
322
+ (U d) (V d) (hVU d) (D₁.coefficientFourSpace δ) (u d) (v d) k hA hdim
323
+ (fun a i => (hu d a i).trans hPA) (fun a i => (hv d a i).trans hPA)
324
+ (fun a i => (hk a i).trans hHA) l hl hlA (fun _ : Unit => (N : ℝ)) (fun _ => hN)
325
+ refine ⟨m, hm, hmp, ?_⟩
326
+ intro t ht
327
+ obtain ⟨E₀, Q₀, hE₀, hQ₀, hres⟩ := D₁.native_shared_scaled_correction (by omega) hp hB
328
+ c τ hF ξ g horbit l hdenom α hαs t ht
329
+ have hδ : (⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hαs⟩ : Fin (s + 1)) = δ :=
330
+ Fin.ext hα
331
+ rw [hδ] at hres
332
+ let e4 := TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)
333
+ let β := sharedLogCoefficientTuple W.model.filtration ξ g α t
334
+ let x := e4.symm β
335
+ have hxK : x - E₀ - Q₀ ∈ (D₁.coefficientFourSpace δ).baseChange ℝ := by
336
+ change β - e4 E₀ - e4 Q₀ ∈ ((D₁.coefficientFourSpace δ).baseChange ℝ).map e4.toLinearMap at hres
337
+ have h := (Submodule.mem_map_equiv _).mp hres
338
+ change e4.symm (β - e4 E₀ - e4 Q₀) ∈ _ at h
339
+ rw [map_sub, map_sub, e4.symm_apply_apply, e4.symm_apply_apply] at h
340
+ exact h
341
+ have hxS : x ∈ (fourCommonModulo (U d) (V d)).baseChange ℝ := by
342
+ have h := sharedLogCoefficientTuple_mem_common W.model.filtration (U d) (V d) (hVU d)
343
+ ξ g α t (hξ d) (fun h => hg h d)
344
+ rw [← realification_fourCommonModulo] at h
345
+ exact (Submodule.mem_map_equiv _).mp h
346
+ have herror : (B + 3) ^ 2 + (s : ℝ) * p ≤ z := by
347
+ have hmul := mul_le_mul_of_nonneg_left hpP (Nat.cast_nonneg s : (0 : ℝ) ≤ s)
348
+ exact (add_le_add_right hmul _).trans (hEA.trans hAz)
349
+ have hEbound : ‖(W.fourRankBasis.baseChange ℝ).equivFun E₀‖ ≤
350
+ Real.exp z / monomialScale (fun _ : Unit => (N : ℝ)) α := by
351
+ apply hE₀.trans
352
+ apply div_le_div_of_nonneg_right (Real.exp_le_exp.mpr herror)
353
+ exact (monomialScale_pos _ (fun _ => by exact_mod_cast NeZero.pos N) α).le
354
+ obtain ⟨E, Q, hE, hQ, hmem⟩ := hsolve α hα0 x E₀ Q₀ hxK hxS hEbound hQ₀
355
+ have hK : D₁.coefficientFourSpace δ = D.coefficientFourSpace δ := by
356
+ rw [D₁.coefficientFourSpace_eq_sup, D.coefficientFourSpace_eq_sup, hspaces]
357
+ rw [hK] at hmem
358
+ exact ⟨E, Q, hE, hQ, hmem⟩
359
+
360
+ end Erdos3.NativeRankRelation.CommonData
361
+
362
+ end
363
+
364
+ section
365
+
366
+ namespace Erdos3.NativeRankRelation.CommonData
367
+
368
+ open Module
369
+ open scoped TensorProduct
370
+
371
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
372
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
373
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
374
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
375
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
376
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
377
+
378
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
379
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
380
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
381
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
382
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
383
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
384
+ (F : FreeCoordinateFrame E.basis Q)
385
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
386
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
387
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
388
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
389
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
390
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
391
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
392
+
393
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
394
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
395
+ (D' : R'.CommonData P')
396
+
397
+ include F
398
+
399
+ theorem exists_correlation_refined_basis (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P')
400
+ (d : Fin s) :
401
+ ∃ a : Basis (Fin (finrank ℚ (fourRefinedRelation (D.coefficientFreeSpan d)
402
+ (D.dependentFreeSpan d) (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)))) ℚ
403
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
404
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)),
405
+ ∀ j i, rationalLogHeight ((Pi.basis (fun _ : Fin 4 => E.basis)).repr
406
+ (a j : Fin 4 → D.CoefficientFreeLieAlgebra) i) ≤
407
+ fourRefinementBasisBudget (Q + coefficientFourHeightBudget P') := by
408
+ obtain ⟨c, hc⟩ := D.exists_coefficientFreeSpan_basis E.basis F (by omega) d
409
+ obtain ⟨b, hb⟩ := D.exists_dependentFreeSpan_basis E.basis F (by omega) d
410
+ obtain ⟨k, hk⟩ := D'.exists_coefficientFour_basis hs hP' hQP' ⟨d.val + 1, by omega⟩
411
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
412
+ have hB := coefficientFourHeightBudget_nonneg hP'
413
+ have hQA : Q ≤ Q + coefficientFourHeightBudget P' := le_add_of_nonneg_right hB
414
+ have hBA : coefficientFourHeightBudget P' ≤ Q + coefficientFourHeightBudget P' :=
415
+ le_add_of_nonneg_left hQ
416
+ apply exists_fourRefinedRelation_basis_logHeight E.basis _ _
417
+ (D.dependentFreeSpan_le_coefficientFreeSpan d) _ c b k (add_nonneg hQ hB)
418
+ (by simpa only [Fintype.card_fin] using hT.1.1.trans hQA)
419
+ (fun a i => (hc a i).trans hQA) (fun a i => (hb a i).trans hQA)
420
+ exact fun a i => (hk a i).trans hBA
421
+
422
+ theorem exists_correlation_refined_annihilator (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P')
423
+ (d : Fin s) :
424
+ ∃ m : ℕ, m ≤ 4 * finrank ℚ D.CoefficientFreeLieAlgebra ∧
425
+ ∃ ℓ : (Fin 4 → D.CoefficientFreeLieAlgebra) →ₗ[ℚ] (Fin m → ℚ),
426
+ Function.Surjective ℓ ∧ LinearMap.ker ℓ =
427
+ fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
428
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩) ∧
429
+ (∀ k i j, rationalLogHeight (ℓ (LinearMap.single ℚ
430
+ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) k (E.basis i)) j) ≤
431
+ fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P')) ∧
432
+ (∀ x ∈ D.dependentFreeSpan d, ℓ (fourDiagonalMap (R := ℚ) x) = 0) ∧
433
+ (∀ z ∈ fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
434
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩),
435
+ ℓ (fourDiagonalMap (R := ℚ) (z 0)) +
436
+ ℓ (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0
437
+ (z 0 + z 1 - z 2 - z 3)) = 0) ∧
438
+ fourPetalSpace (D.dependentFreeSpan d)
439
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
440
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)) =
441
+ D.dependentFreeSpan d ⊓ LinearMap.ker
442
+ (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) := by
443
+ obtain ⟨c, hc⟩ := D.exists_coefficientFreeSpan_basis E.basis F (by omega) d
444
+ obtain ⟨b, hb⟩ := D.exists_dependentFreeSpan_basis E.basis F (by omega) d
445
+ obtain ⟨k, hk⟩ := D'.exists_coefficientFour_basis hs hP' hQP' ⟨d.val + 1, by omega⟩
446
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
447
+ have hB := coefficientFourHeightBudget_nonneg hP'
448
+ have hQA : Q ≤ Q + coefficientFourHeightBudget P' := le_add_of_nonneg_right hB
449
+ have hBA : coefficientFourHeightBudget P' ≤ Q + coefficientFourHeightBudget P' :=
450
+ le_add_of_nonneg_left hQ
451
+ simpa only [Fintype.card_fin] using
452
+ exists_fourRefinedRelation_annihilator E.basis _ _
453
+ (D.dependentFreeSpan_le_coefficientFreeSpan d) _ c b k (add_nonneg hQ hB)
454
+ (by simpa only [Fintype.card_fin] using hT.1.1.trans hQA)
455
+ (fun a i => (hc a i).trans hQA) (fun a i => (hb a i).trans hQA)
456
+ (fun a i => (hk a i).trans hBA)
457
+
458
+ end Erdos3.NativeRankRelation.CommonData
459
+
460
+ end
461
+
462
+ section
463
+
464
+ namespace Erdos3.NativeRankRelation.CommonData
465
+
466
+ open Module VectorPolynomial
467
+ open scoped TensorProduct
468
+
469
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
470
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
471
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
472
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
473
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
474
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
475
+
476
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
477
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
478
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
479
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
480
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
481
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
482
+ (F : FreeCoordinateFrame E.basis Q)
483
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
484
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
485
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
486
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
487
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
488
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
489
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
490
+
491
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
492
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
493
+ (D' : R'.CommonData P')
494
+
495
+ include F
496
+
497
+ theorem exists_controlled_shared_free_refinement
498
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
499
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
500
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
501
+ (hsplit : ∀ h, g h = ξ * v h)
502
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
503
+ (D.commonFreeSpan d).baseChange ℝ)
504
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
505
+ (D.dependentFreeSpan d).baseChange ℝ)
506
+ (hN : Real.exp (separationBudget (8 * sharedRefinementInputBudget s P' + 1)) ≤ (N : ℝ)) :
507
+ let B := (P' + 2) ^ 3 + 2 * P'
508
+ let z := 8 * sharedRefinementInputBudget s P' + 1
509
+ ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧
510
+ ∀ d : Fin s, ∃ m : ℕ, 0 < m ∧
511
+ (m : ℝ) ≤ Real.exp (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) ∧
512
+ ∀ t ∈ D₁.quadruples, ∃ A S : ℝ ⊗[ℚ] (Fin 4 → D.CoefficientFreeLieAlgebra),
513
+ ‖((Pi.basis (fun _ : Fin 4 => E.basis)).baseChange ℝ).equivFun A‖ ≤
514
+ (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) /
515
+ monomialScale (fun _ : Unit => (N : ℝ)) (Finsupp.single () (d.val + 1)) ∧
516
+ ((Pi.basis (fun _ : Fin 4 => E.basis)).baseChange ℝ).equivFun S ∈ realDenominatorGrid m ∧
517
+ (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra)).symm
518
+ (sharedLogCoefficientTuple E.filtration ξ v (Finsupp.single () (d.val + 1)) t) - A - S ∈
519
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
520
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).baseChange ℝ := by
521
+ have hC := fun d : Fin s => D.exists_coefficientFreeSpan_basis E.basis F (by omega) d
522
+ have hD := fun d : Fin s => D.exists_dependentFreeSpan_basis E.basis F (by omega) d
523
+ choose c hc using hC
524
+ choose a ha using hD
525
+ exact D'.exists_uniform_shared_refinement hs hp' hP' hQP' hpp'
526
+ D.coefficientFreeSpan D.dependentFreeSpan D.dependentFreeSpan_le_coefficientFreeSpan c a
527
+ (fun d j i => (hc d j i).trans hQP') (fun d j i => (ha d j i).trans hQP') ξ v hsplit
528
+ (fun d => Submodule.baseChange_mono ℝ (D.commonFreeSpan_le_coefficientFreeSpan d) (hξ d)) hv hN
529
+
530
+ end Erdos3.NativeRankRelation.CommonData
531
+
532
+ end
533
+
534
+ section
535
+
536
+ namespace Erdos3.NativeRankRelation.CommonData
537
+
538
+ open Module
539
+ open scoped TensorProduct
540
+
541
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
542
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
543
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
544
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
545
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
546
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
547
+
548
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
549
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
550
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
551
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
552
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
553
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
554
+ (F : FreeCoordinateFrame E.basis Q)
555
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
556
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
557
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
558
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
559
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
560
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
561
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
562
+
563
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
564
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
565
+ (D' : R'.CommonData P')
566
+
567
+ include F
568
+
569
+ theorem exists_real_correlation_refined_equations
570
+ (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') (d : Fin s) :
571
+ ∃ m : ℕ, m ≤ 4 * finrank ℚ D.CoefficientFreeLieAlgebra ∧
572
+ ∃ ℓ : (Fin 4 → D.CoefficientFreeLieAlgebra) →ₗ[ℚ] (Fin m → ℚ),
573
+ Function.Surjective ℓ ∧ LinearMap.ker ℓ =
574
+ fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
575
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩) ∧
576
+ (∀ k i j, rationalLogHeight (ℓ (LinearMap.single ℚ
577
+ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) k (E.basis i)) j) ≤
578
+ fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P')) ∧
579
+ (∀ v : Fin 4 → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra,
580
+ v ∈ fourRefinedRelation ((D.coefficientFreeSpan d).baseChange ℝ)
581
+ ((D.dependentFreeSpan d).baseChange ℝ)
582
+ (D'.realCoefficientFourSpace ⟨d.val + 1, by omega⟩) ↔
583
+ ∀ j, realifyFunctional ((LinearMap.proj j).comp ℓ)
584
+ ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra)).symm v) = 0) ∧
585
+ (∀ v : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra,
586
+ v ∈ fourPetalSpace ((D.dependentFreeSpan d).baseChange ℝ)
587
+ (fourRefinedRelation ((D.coefficientFreeSpan d).baseChange ℝ)
588
+ ((D.dependentFreeSpan d).baseChange ℝ)
589
+ (D'.realCoefficientFourSpace ⟨d.val + 1, by omega⟩)) ↔
590
+ v ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ ∀ j, realifyFunctional
591
+ (((LinearMap.proj j).comp ℓ).comp
592
+ (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) v = 0) := by
593
+ obtain ⟨m, hm, ℓ, hsurj, hker, hheight, _, _, _⟩ :=
594
+ D.exists_correlation_refined_annihilator E T hbQ hT F V g hg D' hs hP' hQP' d
595
+ have hspace := realification_fourRefinedRelation (D.coefficientFreeSpan d)
596
+ (D.dependentFreeSpan d) (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)
597
+ change _ = fourRefinedRelation ((D.coefficientFreeSpan d).baseChange ℝ)
598
+ ((D.dependentFreeSpan d).baseChange ℝ)
599
+ (D'.realCoefficientFourSpace ⟨d.val + 1, by omega⟩) at hspace
600
+ refine ⟨m, hm, ℓ, hsurj, hker, hheight, ?_, ?_⟩
601
+ · intro v
602
+ rw [← hspace]
603
+ exact mem_real_four_annihilator_iff _ ℓ hker v
604
+ · intro v
605
+ have hpetal := realification_fourPetalSpace (D.dependentFreeSpan d)
606
+ (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
607
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))
608
+ rw [hspace] at hpetal
609
+ rw [← hpetal]
610
+ exact mem_real_petal_annihilator_iff _ _ ℓ hker v
611
+
612
+ end Erdos3.NativeRankRelation.CommonData
613
+
614
+ end
615
+
616
+ section
617
+
618
+ namespace Erdos3
619
+
620
+ noncomputable def sharedFreeEquationInputBudget (s : ℕ) (q p : ℝ) : ℝ :=
621
+ let z := 8 * sharedRefinementInputBudget s p + 1
622
+ 4 * p + (fourRefinementAnnihilatorBudget (q + coefficientFourHeightBudget p) + 1) +
623
+ (z + ((z + 2) ^ 3 + (z + 2) ^ 36))
624
+
625
+ theorem sharedFreeEquationInputBudget_bounds (s : ℕ) {q p : ℝ} (hq : 0 ≤ q) (hp : 0 ≤ p) :
626
+ let z := 8 * sharedRefinementInputBudget s p + 1
627
+ let a := fourRefinementAnnihilatorBudget (q + coefficientFourHeightBudget p)
628
+ let A := sharedFreeEquationInputBudget s q p
629
+ 0 ≤ A ∧ 4 * p ≤ A ∧ a + 1 ≤ A ∧ z + ((z + 2) ^ 3 + (z + 2) ^ 36) ≤ A := by
630
+ intro z a A
631
+ have hi := (sharedRefinementInputBudget_bounds s hp).2.2.1
632
+ have hz : 0 ≤ z := by dsimp only [z]; linarith
633
+ have ha : 0 ≤ a :=
634
+ fourRefinementAnnihilatorBudget_nonneg (add_nonneg hq (coefficientFourHeightBudget_nonneg hp))
635
+ have hZ : 0 ≤ z + ((z + 2) ^ 3 + (z + 2) ^ 36) := by positivity
636
+ have hA : A = 4 * p + (a + 1) + (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) := rfl
637
+ exact ⟨by linarith, by linarith, by linarith, by linarith⟩
638
+
639
+ namespace NativeRankRelation.CommonData
640
+
641
+ open Module VectorPolynomial
642
+ open scoped TensorProduct
643
+
644
+ attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra
645
+ NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd
646
+ NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff
647
+ NativeIntegerExpansion.lie NativeIntegerExpansion.algebra
648
+ NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd
649
+ NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff
650
+
651
+ variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ}
652
+ {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim}
653
+ {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P)
654
+ (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s
655
+ (finrank ℚ D.CoefficientFreeLieAlgebra))
656
+ (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q)
657
+ (F : FreeCoordinateFrame E.basis Q)
658
+ [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
659
+ [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
660
+ [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
661
+ [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)]
662
+ (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q)
663
+ (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
664
+ (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1)
665
+
666
+ variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ}
667
+ {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'}
668
+ (D' : R'.CommonData P')
669
+
670
+ include F
671
+
672
+ theorem exists_controlled_shared_free_equations
673
+ (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P')
674
+ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
675
+ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1))
676
+ (hsplit : ∀ h, g h = ξ * v h)
677
+ (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈
678
+ (D.commonFreeSpan d).baseChange ℝ)
679
+ (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈
680
+ (D.dependentFreeSpan d).baseChange ℝ)
681
+ (hN : Real.exp (separationBudget (8 * sharedRefinementInputBudget s P' + 1)) ≤ (N : ℝ)) :
682
+ let B := (P' + 2) ^ 3 + 2 * P'
683
+ let z := 8 * sharedRefinementInputBudget s P' + 1
684
+ let A := sharedFreeEquationInputBudget s Q P'
685
+ ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧
686
+ ∀ d : Fin s, ∃ n : ℕ, n ≤ 4 * finrank ℚ D.CoefficientFreeLieAlgebra ∧
687
+ ∃ ℓ : (Fin 4 → D.CoefficientFreeLieAlgebra) →ₗ[ℚ] (Fin n → ℚ),
688
+ Function.Surjective ℓ ∧ LinearMap.ker ℓ =
689
+ fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
690
+ (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩) ∧
691
+ (∀ k i j, rationalLogHeight (ℓ (LinearMap.single ℚ
692
+ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) k (E.basis i)) j) ≤
693
+ fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P')) ∧
694
+ ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((A + 2) ^ 4) ∧
695
+ let α := Finsupp.single () (d.val + 1)
696
+ let φ := ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)
697
+ let a := fun h => realifyCoordinateMap φ (coefficients (v h).log α)
698
+ let c := realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) (coefficients ξ.log α)
699
+ ∀ t ∈ D₁.quadruples, ∃ q ∈ realDenominatorGrid m,
700
+ ‖c + (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) -
701
+ a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) - q‖ ≤
702
+ Real.exp ((A + 2) ^ 3) *
703
+ ((Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) /
704
+ monomialScale (fun _ : Unit => (N : ℝ)) α) := by
705
+ intro B z A
706
+ classical
707
+ have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1
708
+ obtain ⟨hA, hdimA, hheightA, hdenomA⟩ := sharedFreeEquationInputBudget_bounds s hQ hP'
709
+ obtain ⟨D₁, hsub, hspaces, hcorr⟩ :=
710
+ D.exists_controlled_shared_free_refinement E T hbQ hT F V g hg D'
711
+ hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN
712
+ refine ⟨D₁, hsub, hspaces, ?_⟩
713
+ intro d
714
+ obtain ⟨n, hn, ℓ, hsurj, hker, hheight, _, _, _⟩ :=
715
+ D.exists_correlation_refined_annihilator E T hbQ hT F V g hg D' hs hP' hQP' d
716
+ obtain ⟨l, hl, hlp, hcorr⟩ := hcorr d
717
+ let e4 := Pi.basis (fun _ : Fin 4 => E.basis)
718
+ let H := ⌈Real.exp (fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P'))⌉₊
719
+ have hheightH : ∀ j i, RationalHeightLE (ℓ (e4 i) j) H := by
720
+ intro j i
721
+ apply rationalHeightLE_ceil_exp
722
+ have he : e4 i = LinearMap.single ℚ
723
+ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) i.1 (E.basis i.2) := by
724
+ simp only [e4, Pi.basis_apply, LinearMap.single_apply]
725
+ rw [he]
726
+ exact hheight i.1 i.2 j
727
+ have hdim : (4 : ℝ) * finrank ℚ D.CoefficientFreeLieAlgebra ≤ 4 * P' :=
728
+ mul_le_mul_of_nonneg_left (hT.1.1.trans hQP') (by norm_num)
729
+ have hI : (Fintype.card (Σ _ : Fin 4, Fin (finrank ℚ D.CoefficientFreeLieAlgebra)) : ℝ) ≤ A := by
730
+ simpa only [Fintype.card_sigma, Fintype.card_fin, Finset.sum_const, Finset.card_univ,
731
+ smul_eq_mul, Nat.cast_mul, Nat.cast_ofNat] using hdim.trans hdimA
732
+ have hJ : (Fintype.card (Fin n) : ℝ) ≤ A := by
733
+ have hn' := (Nat.cast_le (α := ℝ)).mpr hn
734
+ simp only [Nat.cast_mul, Nat.cast_ofNat] at hn'
735
+ simpa only [Fintype.card_fin] using hn'.trans (hdim.trans hdimA)
736
+ have hH : (H : ℝ) ≤ Real.exp A :=
737
+ (ceil_exp_le_exp_add_one (fourRefinementAnnihilatorBudget_nonneg
738
+ (add_nonneg hQ (coefficientFourHeightBudget_nonneg hP')))).trans
739
+ (Real.exp_le_exp.mpr hheightA)
740
+ have hlA : (l : ℝ) ≤ Real.exp A := hlp.trans (Real.exp_le_exp.mpr hdenomA)
741
+ obtain ⟨m, hm, hmA, _, hsolve⟩ :=
742
+ exists_real_annihilator_correction e4 ℓ hheightH hA hI hJ hH hl hlA
743
+ refine ⟨n, hn, ℓ, hsurj, hker, hheight, m, hm, hmA, ?_⟩
744
+ intro α φ a c t ht
745
+ obtain ⟨E₀, Q₀, hE₀, hQ₀, hmem⟩ := hcorr t ht
746
+ rw [← hker] at hmem
747
+ obtain ⟨q, hq, hbound⟩ := hsolve _ E₀ Q₀ _ hmem hE₀ hQ₀
748
+ refine ⟨q, hq, ?_⟩
749
+ have hbalanced : fourBalancedDependent (D.dependentFreeSpan d) ≤ LinearMap.ker ℓ := by
750
+ rw [hker]
751
+ exact fourBalancedDependent_le_refined _ _ _
752
+ have hdecomp := sharedLogCoefficientTuple_annihilator_decomposition E.filtration
753
+ (D.coefficientFreeSpan d) (D.dependentFreeSpan d)
754
+ (D.dependentFreeSpan_le_coefficientFreeSpan d) ℓ hbalanced ξ v α t
755
+ (Submodule.baseChange_mono ℝ (D.commonFreeSpan_le_coefficientFreeSpan d) (hξ d))
756
+ (fun h => hv h d)
757
+ change realFourCoordinateMap ℓ (sharedLogCoefficientTuple E.filtration ξ v α t) =
758
+ c + (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) -
759
+ a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) at hdecomp
760
+ change ‖realFourCoordinateMap ℓ (sharedLogCoefficientTuple E.filtration ξ v α t) - q‖ ≤ _ at hbound
761
+ rw [hdecomp] at hbound
762
+ exact hbound
763
+
764
+ end NativeRankRelation.CommonData
765
+ end Erdos3
766
+
767
+ end
768
+
769
+ section
770
+
771
+ namespace Erdos3
772
+
773
+ theorem sharedFree_rounding_small {A z : ℝ} (hA : 0 ≤ A) (hz : 0 ≤ z)
774
+ (hbudget : z + ((z + 2) ^ 3 + (z + 2) ^ 36) ≤ A)
775
+ (N l d : ℕ) [NeZero N] (hd : 1 ≤ d)
776
+ (hl : (l : ℝ) ≤ Real.exp ((A + 2) ^ 4))
777
+ (hN : Real.exp ((A + 2) ^ 5) ≤ (N : ℝ)) :
778
+ 2 * (l : ℝ) * (Real.exp ((A + 2) ^ 3) *
779
+ ((Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) / (N : ℝ) ^ d)) ≤ 1 := by
780
+ have hzA : z ≤ A := by
781
+ have h3 : 0 ≤ (z + 2) ^ 3 := by positivity
782
+ have h36 : 0 ≤ (z + 2) ^ 36 := by positivity
783
+ linarith
784
+ have h18 : (z + 2) ^ 18 ≤ (z + 2) ^ 36 :=
785
+ pow_le_pow_right₀ (by linarith) (by decide)
786
+ have hwA : (z + 2) ^ 3 + (z + 2) ^ 18 + z ≤ A := by linarith
787
+ have hsum : Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z) ≤
788
+ 2 * Real.exp A := by
789
+ linarith [Real.exp_le_exp.mpr hzA, Real.exp_le_exp.mpr hwA]
790
+ have hpoly : (A + 2) ^ 4 + (A + 2) ^ 3 + A + 4 ≤ (A + 2) ^ 5 := by
791
+ have hh : 0 ≤ A ^ 5 + 9 * A ^ 4 + 31 * A ^ 3 + 50 * A ^ 2 + 35 * A + 4 := by positivity
792
+ nlinarith
793
+ have hnum : 2 * (l : ℝ) * (Real.exp ((A + 2) ^ 3) *
794
+ (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z))) ≤
795
+ Real.exp ((A + 2) ^ 5) := by
796
+ calc
797
+ _ ≤ 2 * Real.exp ((A + 2) ^ 4) * (Real.exp ((A + 2) ^ 3) * (2 * Real.exp A)) := by
798
+ gcongr
799
+ _ = 4 * Real.exp ((A + 2) ^ 4 + (A + 2) ^ 3 + A) := by
800
+ simp only [Real.exp_add]
801
+ ring
802
+ _ ≤ Real.exp 4 * Real.exp ((A + 2) ^ 4 + (A + 2) ^ 3 + A) := by
803
+ apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le
804
+ linarith [Real.add_one_le_exp (4 : ℝ)]
805
+ _ = Real.exp ((A + 2) ^ 4 + (A + 2) ^ 3 + A + 4) := by
806
+ rw [← Real.exp_add]
807
+ congr 1
808
+ ring
809
+ _ ≤ _ := Real.exp_le_exp.mpr hpoly
810
+ have hN1 : (1 : ℝ) ≤ N := by exact_mod_cast NeZero.pos N
811
+ have hpower : (N : ℝ) ≤ (N : ℝ) ^ d := by
812
+ simpa only [pow_one] using pow_le_pow_right₀ hN1 hd
813
+ have hdenpos : (0 : ℝ) < (N : ℝ) ^ d := by positivity
814
+ have hquot := (div_le_one hdenpos).mpr (hnum.trans (hN.trans hpower))
815
+ simpa only [mul_div_assoc] using hquot
816
+
817
+ noncomputable def sharedFreeRecoveryThreshold (s : ℕ) (q p : ℝ) : ℝ :=
818
+ max (separationBudget (8 * sharedRefinementInputBudget s p + 1))
819
+ ((sharedFreeEquationInputBudget s q p + 2) ^ 5)
820
+
821
+ theorem sharedFreeRecoveryThreshold_spec (s : ℕ) {q p : ℝ} (hq : 0 ≤ q) (hp : 0 ≤ p)
822
+ (N : ℕ) [NeZero N] (hN : Real.exp (sharedFreeRecoveryThreshold s q p) ≤ (N : ℝ)) :
823
+ let z := 8 * sharedRefinementInputBudget s p + 1
824
+ let A := sharedFreeEquationInputBudget s q p
825
+ Real.exp (separationBudget z) ≤ (N : ℝ) ∧
826
+ ∀ (l d : ℕ), 1 ≤ d → (l : ℝ) ≤ Real.exp ((A + 2) ^ 4) →
827
+ 2 * (l : ℝ) * (Real.exp ((A + 2) ^ 3) *
828
+ ((Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) / (N : ℝ) ^ d)) ≤ 1 := by
829
+ intro z A
830
+ constructor
831
+ · exact (Real.exp_le_exp.mpr (le_max_left _ _)).trans hN
832
+ · intro l d hd hl
833
+ have hb := sharedFreeEquationInputBudget_bounds s hq hp
834
+ have hz : 0 ≤ z := by
835
+ have h := (sharedRefinementInputBudget_bounds s hp).2.2.1
836
+ dsimp only [z]
837
+ linarith
838
+ exact sharedFree_rounding_small hb.1 hz hb.2.2.2 N l d hd hl
839
+ ((Real.exp_le_exp.mpr (le_max_right _ _)).trans hN)
840
+
841
+ end Erdos3
842
+
843
+ end
844
+
845
+ end OAI
lean/OAI/Combinatorics/Progressions/Estimates/SharedWidthPreparedChoice.lean ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Combinatorics.Progressions.Geometry.SpatialNumericEnvelopeFunctoriality
2
+
3
+ namespace OAI
4
+
5
+ section
6
+
7
+ namespace Erdos3
8
+
9
+ theorem sharedWidthPreparedChoice {T : Type*} (width : T → ℝ) (Plate : ℝ)
10
+ (hpositive : ∀ t, 0 < width t)
11
+ (hreciprocal : ∀ t, (width t)⁻¹ ≤ Real.exp Plate) :
12
+ let ξ := Real.exp (-Plate)
13
+ 0 < ξ ∧ ξ⁻¹ = Real.exp Plate ∧ ∀ t, ξ ≤ width t := by
14
+ refine ⟨Real.exp_pos _, ?_, ?_⟩
15
+ · simp only [Real.exp_neg, inv_inv]
16
+ · intro t
17
+ have h := (inv_le_inv₀ (Real.exp_pos Plate) (inv_pos.mpr (hpositive t))).2
18
+ (hreciprocal t)
19
+ simpa only [Real.exp_neg, inv_inv] using h
20
+
21
+ theorem sharedWidthPreparedChoice_le_one {Plate : ℝ} (hPlate : 0 ≤ Plate) :
22
+ Real.exp (-Plate) ≤ 1 := by
23
+ exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr hPlate)
24
+
25
+ theorem sharedWidthNormalizedTuplePreparedChoice {T G N X : Type*}
26
+ [Fintype G] [Fintype N] [Fintype X]
27
+ (q M : T → ℕ) (selection : ∀ t, Fin (q t) ↪ G) (p E : T → ℝ) (Plate : ℝ)
28
+ (hreciprocal : ∀ t,
29
+ (normalizedTupleNarrowWidth X N (selection t) (M t) (p t) (E t))⁻¹ ≤
30
+ Real.exp Plate) :
31
+ let ξ := Real.exp (-Plate)
32
+ 0 < ξ ∧ ξ⁻¹ = Real.exp Plate ∧ ∀ t,
33
+ ξ ≤ normalizedTupleNarrowWidth X N (selection t) (M t) (p t) (E t) := by
34
+ exact sharedWidthPreparedChoice
35
+ (fun t => normalizedTupleNarrowWidth X N (selection t) (M t) (p t) (E t)) Plate
36
+ (fun t => normalizedTupleNarrowWidth_pos X N (selection t) (M t) (p t) (E t))
37
+ hreciprocal
38
+
39
+ end Erdos3
40
+
41
+ end
42
+
43
+ end OAI