File size: 10,860 Bytes
f1f7953
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import OAI.Analysis.IrrationalRotation.Model.CircleSamplingGraph
import OAI.Analysis.IrrationalRotation.Sampling.CircleSamplingLp
import OAI.Analysis.IrrationalRotation.Sampling.CircleCharacterDynamics
import OAI.Analysis.IrrationalRotation.Rotation.WeightedGraphMarginals
import Mathlib.MeasureTheory.Group.Arithmetic
import Mathlib.MeasureTheory.Function.L1Space.Integrable
import Mathlib.MeasureTheory.Function.LpSeminorm.TriangleInequality

namespace OAI

noncomputable section
open MeasureTheory MeasureTheory.Measure
open scoped BigOperators ENNReal

namespace Invariant233.CircleParameterData

theorem measurable_samplingDensity (p : CircleParameterData) (θ : ℝ) (j n : ℕ)
    (endpoint : Bool) : Measurable (p.samplingDensity θ j n endpoint) := by
  unfold samplingDensity
  apply Finset.measurable_prod
  intro i hi
  exact (measurable_orientedKernel endpoint (p.m j)
    (Int.fract ((n : ℝ) * p.alpha θ i))).comp (p.measurable_coordinate i)

theorem samplingDensity_nonneg (p : CircleParameterData) (θ : ℝ) (j n : ℕ)
    (endpoint : Bool) (hm : 0 < p.m j) (x : Circle) :
    0 ≤ p.samplingDensity θ j n endpoint x := by
  exact Finset.prod_nonneg fun i _ => (orientedKernel_bounds endpoint hm _ _).1

theorem samplingTranslation_measurable (θ : ℝ) (n : ℕ) :
    Measurable (samplingTranslation θ n) :=
  (continuous_id.add continuous_const).measurable

theorem samplingTranslation_measurePreserving (θ : ℝ) (n : ℕ) :
    MeasurePreserving (samplingTranslation θ n) circleMeasure circleMeasure := by
  change MeasurePreserving (fun x : Circle => x + (((n : ℝ) * θ : ℝ) : Circle))
    volume volume
  exact measurePreserving_add_right volume (((n : ℝ) * θ : ℝ) : Circle)

theorem coordinate_sub_samplingTranslation (p : CircleParameterData) (θ : ℝ)
    (i n : ℕ) (x : Circle) :
    p.coordinate i (x - (((n : ℝ) * θ : ℝ) : Circle)) =
      Int.fract (p.coordinate i x - (n : ℝ) * p.alpha θ i) := by
  have h := CircleCharacterDynamics.character_orbit_representative
    (p.q i : ℤ) (-(n : ℤ)) θ x
  simpa only [coordinate, rep, alpha, neg_zsmul, natCast_zsmul,
    ← AddCircle.coe_nsmul, nsmul_eq_mul, Int.cast_neg, Int.cast_natCast,
    neg_mul, sub_eq_add_neg] using h

theorem kernel_fract_first (m : ℕ) (z v : ℝ) :
    kernel m (Int.fract z) v = kernel m z v := by
  unfold kernel delta
  rw [Int.fract_fract]

theorem fract_sub_fract_right (z v : ℝ) :
    Int.fract (z - Int.fract v) = Int.fract (z - v) := by
  have he : z - Int.fract v = z - v + (⌊v⌋ : ℤ) := by
    rw [Int.fract]
    ring
  rw [he, Int.fract_add_intCast]

theorem samplingDensity_inverse_translation (p : CircleParameterData) (θ : ℝ)
    (j n : ℕ) (x : Circle) :
    p.samplingDensity θ j n false (x - (((n : ℝ) * θ : ℝ) : Circle)) =
      p.samplingDensity θ j n true x := by
  unfold samplingDensity
  apply Finset.prod_congr rfl
  intro i hi
  rw [p.coordinate_sub_samplingTranslation]
  simp only [orientedKernel, Bool.false_eq_true, ↓reduceIte, kernel_fract_first]
  unfold kernel delta
  rw [fract_sub_fract_right]

theorem samplingGraph_first_marginal (p : CircleParameterData) (θ : ℝ)
    (j n : ℕ) :
    (p.samplingGraph θ j n).map Prod.fst =
      circleMeasure.withDensity
        (fun x => ENNReal.ofReal (p.samplingDensity θ j n false x)) := by
  exact WeightedGraphMarginals.map_fst_graph _ (samplingTranslation_measurable θ n)

theorem samplingGraph_second_marginal (p : CircleParameterData) (θ : ℝ)
    (j n : ℕ) :
    (p.samplingGraph θ j n).map Prod.snd =
      circleMeasure.withDensity
        (fun x => ENNReal.ofReal (p.samplingDensity θ j n true x)) := by
  rw [samplingGraph, WeightedGraphMarginals.map_snd_graph _
    (samplingTranslation_measurable θ n)]
  rw [WeightedGraphMarginals.map_withDensity_inverse circleMeasure
    (samplingTranslation_measurePreserving θ n)
    (S := fun x => x - (((n : ℝ) * θ : ℝ) : Circle))
    (continuous_id.sub continuous_const).measurable
    (fun x => by simp [samplingTranslation])
    (p.measurable_samplingDensity θ j n false).ennreal_ofReal]
  congr 1
  funext x
  rw [p.samplingDensity_inverse_translation]

theorem samplingGraphAverage_first_marginal (p : CircleParameterData) (θ : ℝ)
    (j r : ℕ) (hm : 0 < p.m j) :
    (p.samplingGraphAverage θ j r).map Prod.fst =
      circleMeasure.withDensity
        (fun x => ENNReal.ofReal (p.samplingAverage θ j r false x)) := by
  rw [samplingGraphAverage, Measure.map_smul _ measurable_fst.aemeasurable,
    WeightedGraphMarginals.map_finset_sum _ _ measurable_fst]
  simp_rw [p.samplingGraph_first_marginal]
  exact (WeightedGraphMarginals.withDensity_real_finset_sum circleMeasure
    (p.samples j r) (fun n => p.samplingDensity θ j n false)
    (fun n _ => p.measurable_samplingDensity θ j n false)
    (fun n _ x => p.samplingDensity_nonneg θ j n false hm x)
    (by positivity : 0 ≤ 1 / ((p.samples j r).card : ℝ))).symm

theorem samplingGraphAverage_second_marginal (p : CircleParameterData) (θ : ℝ)
    (j r : ℕ) (hm : 0 < p.m j) :
    (p.samplingGraphAverage θ j r).map Prod.snd =
      circleMeasure.withDensity
        (fun x => ENNReal.ofReal (p.samplingAverage θ j r true x)) := by
  rw [samplingGraphAverage, Measure.map_smul _ measurable_snd.aemeasurable,
    WeightedGraphMarginals.map_finset_sum _ _ measurable_snd]
  simp_rw [p.samplingGraph_second_marginal]
  exact (WeightedGraphMarginals.withDensity_real_finset_sum circleMeasure
    (p.samples j r) (fun n => p.samplingDensity θ j n true)
    (fun n _ => p.measurable_samplingDensity θ j n true)
    (fun n _ x => p.samplingDensity_nonneg θ j n true hm x)
    (by positivity : 0 ≤ 1 / ((p.samples j r).card : ℝ))).symm

theorem samplingGraphAverage_finite (p : CircleParameterData) (θ : ℝ)
    (j r : ℕ) (hm : 0 < p.m j) : IsFiniteMeasure (p.samplingGraphAverage θ j r) := by
  let : IsFiniteMeasure circleMeasure := by unfold circleMeasure; infer_instance
  have hi : Integrable (p.samplingAverage θ j r false) circleMeasure :=
    (p.memLp_samplingAverage θ j r false hm 1).integrable le_rfl
  have hn : 0 ≤ᵐ[circleMeasure] p.samplingAverage θ j r false :=
    Filter.Eventually.of_forall fun x => (p.samplingAverage_bounds θ j r false hm x).1
  have ht := (lintegral_ofReal_ne_top_iff_integrable
    hi.aestronglyMeasurable hn).2 hi
  have : IsFiniteMeasure ((p.samplingGraphAverage θ j r).map Prod.fst) := by
    rw [p.samplingGraphAverage_first_marginal θ j r hm]
    exact isFiniteMeasure_withDensity ht
  exact Measure.isFiniteMeasure_of_map measurable_fst.aemeasurable

theorem samplingGraph_ae_graph (p : CircleParameterData) (θ : ℝ) (j n : ℕ) :
    ∀ᵐ xy ∂p.samplingGraph θ j n, xy.2 = samplingTranslation θ n xy.1 := by
  unfold samplingGraph
  have hg : Measurable (fun x => (x, samplingTranslation θ n x)) :=
    measurable_id.prodMk (samplingTranslation_measurable θ n)
  apply (ae_map_iff hg.aemeasurable ?_).2
  · exact Filter.Eventually.of_forall fun _ => rfl
  · exact (isClosed_eq continuous_snd
      (continuous_fst.add continuous_const)).measurableSet

theorem samplingGraph_ae_positive_density (p : CircleParameterData) (θ : ℝ)
    (j n : ℕ) :
    ∀ᵐ xy ∂p.samplingGraph θ j n, 0 < p.samplingDensity θ j n false xy.1 := by
  unfold samplingGraph
  have hg : Measurable (fun x => (x, samplingTranslation θ n x)) :=
    measurable_id.prodMk (samplingTranslation_measurable θ n)
  apply (ae_map_iff hg.aemeasurable
    (measurableSet_lt measurable_const
      ((p.measurable_samplingDensity θ j n false).comp measurable_fst))).2
  apply (ae_withDensity_iff (p.measurable_samplingDensity θ j n false).ennreal_ofReal).2
  exact Filter.Eventually.of_forall fun x hx =>
    ENNReal.ofReal_pos.mp (pos_iff_ne_zero.mpr hx)

theorem samplingGraphAverage_ae_graph (p : CircleParameterData) (θ : ℝ) (j r : ℕ) :
    ∀ᵐ xy ∂p.samplingGraphAverage θ j r,
      ∃ n ∈ p.samples j r, xy.2 = samplingTranslation θ n xy.1 := by
  unfold samplingGraphAverage
  apply ae_smul_measure
  apply ae_finsetSum_measure_iff.mpr
  intro n hn
  filter_upwards [p.samplingGraph_ae_graph θ j n] with xy hxy
  exact ⟨n, hn, hxy⟩

theorem samplingGraphAverage_ae_positive_density_graph (p : CircleParameterData)
    (θ : ℝ) (j r : ℕ) :
    ∀ᵐ xy ∂p.samplingGraphAverage θ j r,
      ∃ n ∈ p.samples j r, 0 < p.samplingDensity θ j n false xy.1 ∧
        xy.2 = samplingTranslation θ n xy.1 := by
  unfold samplingGraphAverage
  apply ae_smul_measure
  apply ae_finsetSum_measure_iff.mpr
  intro n hn
  filter_upwards [p.samplingGraph_ae_graph θ j n,
    p.samplingGraph_ae_positive_density θ j n] with xy hxy hpos
  exact ⟨n, hn, hpos, hxy⟩

end Invariant233.CircleParameterData

namespace Invariant233.CircleParameterLaws

open CircleParameterData

theorem samplingAverage_eLpNorm_le_two {θ : ℝ} {p : CircleParameterData}
    (hp : CircleParameterLaws θ p) (j : ℕ) (hj : 1 ≤ j) (r : ℕ)
    (hr : r < p.q (p.blockEnd (j - 1))) (endpoint : Bool) :
    eLpNorm (p.samplingAverage θ j r endpoint) 2 circleMeasure ≤ 2 := by
  let : IsProbabilityMeasure circleMeasure := by
    constructor
    change volume (Set.univ : Set Circle) = 1
    exact UnitAddCircle.measure_univ
  have he := eLpNorm_add_le
    (f := fun x => p.samplingAverage θ j r endpoint x - 1)
    (g := fun _ : Circle => (1 : ℝ)) (μ := circleMeasure)
    (by norm_num : (1 : ENNReal) ≤ 2)
  have hfun : (fun x => p.samplingAverage θ j r endpoint x - 1) +
      (fun _ : Circle => (1 : ℝ)) = p.samplingAverage θ j r endpoint := by
    funext x
    simp
  rw [hfun] at he
  have hc : eLpNorm (fun _ : Circle => (1 : ℝ)) 2 circleMeasure = 1 := by
    rw [eLpNorm_const' _ (by norm_num) (by norm_num)]
    simp
  rw [hc] at he
  have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj
  have hfrac : ENNReal.ofReal (1 / (j : ℝ)) ≤ 1 := by
    apply ENNReal.ofReal_le_one.mpr
    simpa using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) hjR
  calc
    _ ≤ eLpNorm (fun x => p.samplingAverage θ j r endpoint x - 1) 2 circleMeasure + 1 := he
    _ ≤ ENNReal.ofReal (1 / (j : ℝ)) + 1 :=
      add_le_add (hp.sampling_L2 j hj r hr endpoint).le le_rfl
    _ ≤ (1 : ENNReal) + 1 := add_le_add hfrac le_rfl
    _ = 2 := by norm_num

theorem samplingGraphAverage_ae_positive_graph {θ : ℝ} {p : CircleParameterData}
    (hp : CircleParameterLaws θ p) (j : ℕ) (hj : 1 ≤ j) (r : ℕ)
    (hr : r < p.q (p.blockEnd (j - 1))) :
    ∀ᵐ xy ∂p.samplingGraphAverage θ j r,
      ∃ n ∈ p.samples j r, 0 < n ∧ xy.2 = samplingTranslation θ n xy.1 := by
  filter_upwards [p.samplingGraphAverage_ae_graph θ j r] with xy hxy
  obtain ⟨n, hn, he⟩ := hxy
  exact ⟨n, hn, hp.samples_positive j hj r hr n hn, he⟩

end Invariant233.CircleParameterLaws

end

end OAI