File size: 13,223 Bytes
9b6e014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import Mathlib
import OAI.Probability.Ballisticity.Estimates.MeasurableCountableSample

namespace OAI

section
open MeasureTheory ProbabilityTheory Filter
open scoped ENNReal NNReal Topology BigOperators

namespace TailDecorrelation

section Randomization
variable {D I A J E : Type*} [MeasurableSpace D] [MeasurableSpace A]
variable [MeasurableSpace E] [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J]
variable (δ : Measure D) (σ : Measure E) (ν : Measure A)
variable [IsProbabilityMeasure δ] [IsProbabilityMeasure σ] [IsProbabilityMeasure ν]

lemma randomization_projection_preserving :
    MeasurePreserving (fun x : (D × E) × (I → A) => (x.1.1, x.2))
      ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν)))
      (δ.prod (Measure.infinitePi (fun _ : I => ν))) := by
  exact measurePreserving_fst.prod (MeasurePreserving.id _)

lemma randomized_density {f : D × (I → A) → ℝ}
    (hf : Measurable f) (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν))))
    (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) :
    Integrable (fun x : (D × E) × (I → A) => f (x.1.1, x.2))
      ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) ∧
    Integrable (fun x : (D × E) × (I → A) => entropyPlus (f (x.1.1, x.2)))
      ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) ∧
    (∫ x : (D × E) × (I → A), f (x.1.1, x.2)
      ∂(δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) =
      (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) := by
  have hp := randomization_projection_preserving δ σ ν (I := I)
  refine ⟨(hp.integrable_comp hf.aestronglyMeasurable).mpr hfi,
    (hp.integrable_comp (measurable_entropyPlus.comp hf).aestronglyMeasurable).mpr hH, ?_⟩
  have hh : AEStronglyMeasurable f
      (((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))).map
        (fun x : (D × E) × (I → A) => (x.1.1, x.2))) := by
    rw [hp.map_eq]
    exact hf.aestronglyMeasurable
  have he := integral_map hp.measurable.aemeasurable hh
  rw [hp.map_eq] at he
  exact he.symm

end Randomization
end TailDecorrelation

namespace TailDecorrelation

lemma measurableSet_eventually_nat {X : Type*} [MeasurableSpace X]
    {p : ℕ → X → Prop} (hp : ∀ n, MeasurableSet {x | p n x}) :
    MeasurableSet {x | ∀ᶠ n in atTop, p n x} := by
  simp only [eventually_atTop, Set.ofPred_exists, Set.ofPred_forall]
  exact MeasurableSet.iUnion fun n => MeasurableSet.iInter fun m =>
    MeasurableSet.iInter fun _ => hp m

section KernelTransfer
variable {D E W J : Type*} [MeasurableSpace D] [MeasurableSpace E]
variable [MeasurableSpace W] [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J]
variable (δ : Measure D) (σ : Measure E) (P : Measure W)
variable [IsProbabilityMeasure δ] [IsProbabilityMeasure σ] [IsProbabilityMeasure P]

lemma integral_comp_preserving {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y]
    {μ : Measure X} {ρ : Measure Y} {T : X → Y} (hT : MeasurePreserving T μ ρ)
    {g : Y → ℝ} (hg : Measurable g) :
    (∫ x, g (T x) ∂μ) = ∫ y, g y ∂ρ := by
  have hm : AEStronglyMeasurable g (μ.map T) := by
    rw [hT.map_eq]
    exact hg.aestronglyMeasurable
  have he := integral_map hT.measurable.aemeasurable hm
  rw [hT.map_eq] at he
  exact he.symm

lemma swap_seed_preserving :
    MeasurePreserving (fun x : (D × W) × E => ((x.1.1,x.2),x.1.2))
      ((δ.prod P).prod σ) ((δ.prod σ).prod P) := by
  exact ((measurePreserving_prodAssoc δ σ P).symm MeasurableEquiv.prodAssoc).comp
    (((MeasurePreserving.id δ).prod Measure.measurePreserving_swap).comp
      (measurePreserving_prodAssoc δ P σ))

lemma sampled_kernel_integral (κ : Kernel D J) (s : D → E → J)
    (hs : Measurable (Function.uncurry s)) (hmap : ∀ d, σ.map (s d) = κ d)
    {f : D × W → ℝ} (hf : Measurable f) {Z : J → W → ℝ}
    (hZ : ∀ a, Measurable (Z a))
    (hi : Integrable (fun x : (D × E) × W => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2)
      ((δ.prod σ).prod P)) :
    (∫ x : (D × E) × W, f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2 ∂(δ.prod σ).prod P) =
      (∫ x : D × W, f x * (∫ a, Z a x.2 ∂κ x.1) ∂δ.prod P) := by
  have hz : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ
  let G : (D × E) × W → ℝ := fun x => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2
  have hG : Measurable G :=
    (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)).mul
      (hz.comp ((hs.comp measurable_fst).prodMk measurable_snd))
  have hp := swap_seed_preserving δ σ P
  have hj : Integrable (fun x : (D × W) × E => f x.1 * Z (s x.1.1 x.2) x.1.2)
      ((δ.prod P).prod σ) := (hp.integrable_comp hG.aestronglyMeasurable).mpr hi
  rw [← integral_comp_preserving hp hG]
  change (∫ x : (D × W) × E, f x.1 * Z (s x.1.1 x.2) x.1.2 ∂(δ.prod P).prod σ) = _
  rw [integral_prod _ hj]
  apply integral_congr_ae
  apply Eventually.of_forall
  intro x
  change (∫ u, f x * Z (s x.1 u) x.2 ∂σ) = f x * (∫ a, Z a x.2 ∂κ x.1)
  rw [integral_const_mul]
  congr 1
  have he := integral_map ((hs.comp measurable_prodMk_left).aemeasurable)
    (show AEStronglyMeasurable (fun a => Z a x.2) (σ.map (s x.1)) from
      Measurable.of_discrete.aestronglyMeasurable)
  change (∫ a, Z a x.2 ∂σ.map (s x.1)) = (∫ u, Z (s x.1 u) x.2 ∂σ) at he
  rw [hmap] at he
  exact he.symm

lemma sampled_kernel_integrable (κ : Kernel D J) (s : D → E → J)
    (hs : Measurable (Function.uncurry s)) (hmap : ∀ d, σ.map (s d) = κ d)
    {f : D × W → ℝ} (hf : Measurable f) {Z : J → W → ℝ}
    (hZ : ∀ a, Measurable (Z a))
    (hi : Integrable (fun x : (D × E) × W => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2)
      ((δ.prod σ).prod P)) :
    Integrable (fun x : D × W => f x * (∫ a, Z a x.2 ∂κ x.1)) (δ.prod P) := by
  have hz : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ
  let G : (D × E) × W → ℝ := fun x => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2
  have hG : Measurable G :=
    (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)).mul
      (hz.comp ((hs.comp measurable_fst).prodMk measurable_snd))
  have hp := swap_seed_preserving δ σ P
  have hj : Integrable (fun x : (D × W) × E => f x.1 * Z (s x.1.1 x.2) x.1.2)
      ((δ.prod P).prod σ) := (hp.integrable_comp hG.aestronglyMeasurable).mpr hi
  apply hj.integral_prod_left.congr
  apply Eventually.of_forall
  intro x
  change (∫ u, f x * Z (s x.1 u) x.2 ∂σ) = f x * (∫ a, Z a x.2 ∂κ x.1)
  rw [integral_const_mul]
  congr 1
  have he := integral_map ((hs.comp measurable_prodMk_left).aemeasurable)
    (show AEStronglyMeasurable (fun a => Z a x.2) (σ.map (s x.1)) from
      Measurable.of_discrete.aestronglyMeasurable)
  change (∫ a, Z a x.2 ∂σ.map (s x.1)) = (∫ u, Z (s x.1 u) x.2 ∂σ) at he
  rw [hmap] at he
  exact he.symm

omit [IsProbabilityMeasure δ] in
lemma kernel_escape_sampled (κ : ℕ → Kernel D J) (s : ℕ → D → E → J)
    (hs : ∀ r, Measurable (Function.uncurry (s r)))
    (hmap : ∀ r d, σ.map (s r d) = κ r d)
    (good : ℕ → J → Prop)
    (hesc : ∀ᵐ d ∂δ, ∀ᶠ r in atTop, ∀ᵐ a ∂κ r d, good r a) :
    ∀ᵐ x ∂δ.prod σ, ∀ᶠ r in atTop, good r (s r x.1 x.2) := by
  have hm : ∀ r, MeasurableSet {x : D × E | good r (s r x.1 x.2)} := fun r =>
    (hs r) (Set.to_countable _).measurableSet
  apply (Measure.ae_prod_iff_ae_ae (measurableSet_eventually_nat hm)).mpr
  filter_upwards [hesc] with d hd
  obtain ⟨N,hN⟩ := eventually_atTop.mp hd
  have hforall : ∀ r : ℕ, ∀ᵐ u ∂σ, N ≤ r → good r (s r d u) := by
    intro r
    by_cases hr : N ≤ r
    · have hh := hN r hr
      rw [← hmap r d] at hh
      have htrans := (ae_map_iff (hs r |>.comp measurable_prodMk_left |>.aemeasurable)
        (Set.to_countable _).measurableSet).mp hh
      exact htrans.mono fun u hu _ => hu
    · exact Eventually.of_forall fun _ h => (hr h).elim
  filter_upwards [ae_all_iff.mpr hforall] with u hu
  exact eventually_atTop.mpr ⟨N,hu⟩

end KernelTransfer
end TailDecorrelation

namespace TailDecorrelation
section KernelCompletion
variable {D I A J : Type*} [MeasurableSpace D] [MeasurableSpace A] [Encodable I]
variable [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J]
variable [Nonempty J] [StandardBorelSpace J]
variable (δ : Measure D) (ν : Measure A) [IsProbabilityMeasure δ] [IsProbabilityMeasure ν]

omit [Encodable I] in
lemma kernel_density_integrable {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ}
    {c Q : ℝ} (hc : 0 < c)
    (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x)
    (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν))))
    (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν))))
    (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω)
    (he : ∀ a, Integrable (fun ω => Real.exp (c * Z a ω)) (Measure.infinitePi (fun _ : I => ν)))
    (heQ : ∀ a, (∫ ω, Real.exp (c * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q)
    (κ : Kernel D J) [IsMarkovKernel κ] :
    Integrable (fun x : D × (I → A) => f x * (∫ a, Z a x.2 ∂κ x.1))
      (δ.prod (Measure.infinitePi (fun _ : I => ν))) := by
  obtain ⟨s,hs,hmap⟩ := Kernel.exists_measurable_map_eq_unitInterval κ
  let σ : Measure unitInterval := volume
  let g : (D × unitInterval) × (I → A) → ℝ := fun x => f (x.1.1,x.2)
  have hg : Measurable g := hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)
  obtain ⟨_,hgH,_⟩ := randomized_density δ σ ν hf hfi hH
  have hi := integrable_density_mul_of_entropy hc hg
    (measurable_countable_sample hZ hs) (fun x => hf0 _) (fun x => hZ0 _ _) hgH
    (sampled_exponential_integrable (δ.prod σ) ν hZ he heQ hs).1
  exact sampled_kernel_integrable δ σ (Measure.infinitePi (fun _ : I => ν))
    κ s hs hmap hf hZ hi

lemma kernel_entropy_decorrelation {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ}
    {c Q C : ℝ} (hc : 0 < c) (hC : 0 ≤ C)
    (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x)
    (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν))))
    (hf1 : (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) = 1)
    (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν))))
    (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω)
    (he : ∀ a, Integrable (fun ω => Real.exp ((2 * c) * Z a ω)) (Measure.infinitePi (fun _ : I => ν)))
    (heQ : ∀ a, (∫ ω, Real.exp ((2 * c) * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q)
    (hZi : ∀ a, Integrable (Z a) (Measure.infinitePi (fun _ : I => ν)))
    (hZC : ∀ a, (∫ ω, Z a ω ∂Measure.infinitePi (fun _ : I => ν)) ≤ C)
    (N : ℕ → J → Set I) (κ : ℕ → Kernel D J) [∀ r, IsMarkovKernel (κ r)]
    (hloc : ∀ K η : ℝ, 0 < K → 0 < η → ∃ n : ℕ, ∃ F : J → (I → A) → ℝ,
      (∀ a, @Measurable _ _ (rows (N n a)) _ (F a)) ∧
      (∀ a ω, 0 ≤ F a ω ∧ F a ω ≤ K) ∧
      (∀ a, (∫ ω, |min K (Z a ω) - F a ω| ∂Measure.infinitePi (fun _ : I => ν)) ≤ η))
    (hescape : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ,
      ∀ᶠ r in atTop, ∀ᵐ a ∂κ r d, Disjoint S (N n a)) :
    ∀ ε > 0, ∀ᶠ r in atTop,
      (∫ x : D × (I → A), f x * (∫ a, Z a x.2 ∂κ r x.1)
        ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ C + ε := by
  classical
  let σ : Measure unitInterval := volume
  choose s hs hmap using fun r => Kernel.exists_measurable_map_eq_unitInterval (κ r)
  let g : (D × unitInterval) × (I → A) → ℝ := fun x => f (x.1.1,x.2)
  have hg : Measurable g := hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)
  obtain ⟨hgi,hgH,hg1⟩ := randomized_density δ σ ν hf hfi hH
  have hesc : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ.prod σ,
      ∀ᶠ r in atTop, Disjoint S (N n (s r d.1 d.2)) := by
    intro n S hS
    exact kernel_escape_sampled δ σ κ s hs hmap (fun _ a => Disjoint S (N n a)) (hescape n S hS)
  have hbound := sampled_entropy_decorrelation (δ.prod σ) ν hc hC hg
    (fun x => hf0 _) hgi (hg1.trans hf1) hgH hZ hZ0 he heQ hZi hZC N
    (fun r => Function.uncurry (s r)) hs hloc hesc
  have heq : ∀ r, (∫ x : (D × unitInterval) × (I → A),
      g x * Z (s r x.1.1 x.1.2) x.2 ∂(δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) =
      (∫ x : D × (I → A), f x * (∫ a, Z a x.2 ∂κ r x.1)
        ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) := by
    intro r
    have hi := integrable_density_mul_of_entropy (by linarith : 0 < 2*c) hg
      (measurable_countable_sample hZ (hs r)) (fun x => hf0 _) (fun x => hZ0 _ _) hgH
      (sampled_exponential_integrable (δ.prod σ) ν hZ he heQ (hs r)).1
    exact sampled_kernel_integral δ σ (Measure.infinitePi (fun _ : I => ν))
      (κ r) (s r) (hs r) (hmap r) hf hZ hi
  intro ε hε
  filter_upwards [hbound ε hε] with r hr
  rw [← heq r]
  exact hr

end KernelCompletion
end TailDecorrelation

end

end OAI