Skip to content

Commit 9f9cdbe

Browse files
authored
Rename history and step (#140)
2 parents 258e90f + d748595 commit 9f9cdbe

11 files changed

Lines changed: 134 additions & 124 deletions

File tree

‎LeanMachineLearning/Online/Bandit/Algorithms/ETC.lean‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ lemma arm_zero [Nonempty (Fin K)]
8686

8787
lemma arm_ae_eq_etcNextArm [Nonempty (Fin K)]
8888
(h : IsAlgEnvSeq A R (etcAlgorithm hK m) (stationaryEnv ν) P) (n : ℕ) :
89-
A (n + 1) =ᵐ[P] fun ω ↦ nextArm hK m n (IsAlgEnvSeq.hist A R n ω) := by
89+
A (n + 1) =ᵐ[P] fun ω ↦ nextArm hK m n (history A R n ω) := by
9090
have : Nonempty (Fin K) := Fin.pos_iff_nonempty.mp hK
9191
exact h.action_detAlgorithm_ae_eq n
9292

@@ -101,7 +101,7 @@ phase. -/
101101
lemma arm_mul [Nonempty (Fin K)]
102102
(h : IsAlgEnvSeq A R (etcAlgorithm hK m) (stationaryEnv ν) P) (hm : m ≠ 0) :
103103
A (K * m) =ᵐ[P] fun ω ↦ measurableArgmax (empMean' (K * m - 1))
104-
(IsAlgEnvSeq.hist A R (K * m - 1) ω) := by
104+
(history A R (K * m - 1) ω) := by
105105
have : K * m = (K * m - 1) + 1 := by
106106
have : 0 < K * m := Nat.mul_pos hK hm.bot_lt
107107
grind
@@ -176,7 +176,7 @@ lemma sumRewards_bestArm_le_of_arm_mul_eq [Nonempty (Fin K)]
176176
sumRewards A R a (K * m) h := by
177177
filter_upwards [arm_mul h hm, pullCount_mul h a, pullCount_mul h (bestArm ν)]
178178
with h h_arm ha h_best h_eq
179-
have h_max := isMaxOn_measurableArgmax (empMean' (K * m - 1)) (IsAlgEnvSeq.hist A R (K * m - 1) h)
179+
have h_max := isMaxOn_measurableArgmax (empMean' (K * m - 1)) (history A R (K * m - 1) h)
180180
(bestArm ν)
181181
rw [← h_arm, h_eq] at h_max
182182
rw [sumRewards_eq_pullCount_mul_empMean, sumRewards_eq_pullCount_mul_empMean, ha, h_best]

‎LeanMachineLearning/Online/Bandit/Algorithms/UCB.lean‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ lemma measurable_ucbWidth (hA : ∀ n, Measurable (A n)) (c : ℝ) (a : Fin K) :
9090
fun_prop
9191

9292
lemma ucbWidth_eq_ucbWidth' (c : ℝ) (a : Fin K) (n : ℕ) (ω : Ω) (hn : n ≠ 0) :
93-
ucbWidth A c a n ω = ucbWidth' c (n - 1) (IsAlgEnvSeq.hist A R (n - 1) ω) a := by
93+
ucbWidth A c a n ω = ucbWidth' c (n - 1) (history A R (n - 1) ω) a := by
9494
simp only [ucbWidth, pullCount_eq_pullCount' (A := A) (R' := R) hn, Nat.cast_nonneg, sqrt_div',
9595
ucbWidth']
9696
congr 4
@@ -104,13 +104,13 @@ lemma arm_zero [Nonempty (Fin K)]
104104

105105
lemma arm_ae_eq_ucbNextArm [Nonempty (Fin K)]
106106
(h : IsAlgEnvSeq A R (ucbAlgorithm hK c) (stationaryEnv ν) P) (n : ℕ) :
107-
A (n + 1) =ᵐ[P] fun ω ↦ nextArm hK c n (IsAlgEnvSeq.hist A R n ω) := by
107+
A (n + 1) =ᵐ[P] fun ω ↦ nextArm hK c n (history A R n ω) := by
108108
have : Nonempty (Fin K) := Fin.pos_iff_nonempty.mp hK
109109
exact h.action_detAlgorithm_ae_eq n
110110

111111
lemma arm_ae_all_eq [Nonempty (Fin K)]
112112
(h : IsAlgEnvSeq A R (ucbAlgorithm hK c) (stationaryEnv ν) P) :
113-
∀ᵐ h ∂P, A 0 h = ⟨0, hK⟩ ∧ ∀ n, A (n + 1) h = nextArm hK c n (IsAlgEnvSeq.hist A R n h) := by
113+
∀ᵐ h ∂P, A 0 h = ⟨0, hK⟩ ∧ ∀ n, A (n + 1) h = nextArm hK c n (history A R n h) := by
114114
rw [eventually_and, ae_all_iff]
115115
exact ⟨arm_zero h, arm_ae_eq_ucbNextArm h⟩
116116

@@ -126,7 +126,7 @@ lemma ucbIndex_le_ucbIndex_arm [Nonempty (Fin K)]
126126
simp_rw [h_arm, empMean_eq_empMean' (by grind : n ≠ 0),
127127
ucbWidth_eq_ucbWidth' (A := A) (R := R) _ _ _ _ (by grind : n ≠ 0)]
128128
exact isMaxOn_measurableArgmax (fun h a ↦ empMean' (n - 1) h a + ucbWidth' c (n - 1) h a)
129-
(IsAlgEnvSeq.hist A R (n - 1) h) a
129+
(history A R (n - 1) h) a
130130

131131
lemma forall_arm_eq_mod_of_lt [Nonempty (Fin K)]
132132
(h : IsAlgEnvSeq A R (ucbAlgorithm hK c) (stationaryEnv ν) P) :

‎LeanMachineLearning/Online/Bandit/RewardByCountMeasure.lean‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ lemma condIndepFun_reward_stepsUntil_action' [StandardBorelSpace Ω]
9595
simp only [hn]
9696
refine h_indep.of_measurable_right (hX := hA 0) ?_
9797
exact measurable_comap_indicator_stepsUntil_eq_zero a m
98-
· have h_indep : R n ⟂ᵢ[A n, hA n; P] fun ω ↦ (IsAlgEnvSeq.hist A R (n - 1) ω, A n ω) :=
99-
IsAlgEnvSeq.condIndepFun_feedback_hist_action_action' h n (by grind)
98+
· have h_indep : R n ⟂ᵢ[A n, hA n; P] fun ω ↦ (history A R (n - 1) ω, A n ω) :=
99+
IsAlgEnvSeq.condIndepFun_feedback_history_action_action' h n (by grind)
100100
refine h_indep.of_measurable_right (hX := hA n) ?_
101101
exact measurable_comap_indicator_stepsUntil_eq hA hR a m n
102102

‎LeanMachineLearning/SequentialLearning/Algorithm.lean‎

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,13 @@ variable {A : ℕ → Ω → 𝓐} {Y : ℕ → Ω → 𝓨} {alg : Algorithm
9797
{P : Measure Ω} [IsFiniteMeasure P] {N : ℕ}
9898

9999
/-- Step of the algorithm-environment sequence: the action-feedback pair at time `n`. -/
100-
def IsAlgEnvSeq.step (A : ℕ → Ω → 𝓐) (Y : ℕ → Ω → 𝓨) (n : ℕ) (ω : Ω) : 𝓐 × 𝓨 :=
100+
def step (A : ℕ → Ω → 𝓐) (Y : ℕ → Ω → 𝓨) (n : ℕ) (ω : Ω) : 𝓐 × 𝓨 :=
101101
(A n ω, Y n ω)
102102

103103
@[fun_prop]
104-
lemma IsAlgEnvSeq.measurable_step (n : ℕ) (hA : Measurable (A n))
105-
(hY : Measurable (Y n)) :
106-
Measurable (IsAlgEnvSeq.step A Y n) := by
107-
unfold IsAlgEnvSeq.step
104+
lemma measurable_step (n : ℕ) (hA : Measurable (A n)) (hY : Measurable (Y n)) :
105+
Measurable (step A Y n) := by
106+
unfold step
108107
fun_prop
109108

110109
/-- A random variable that gives the sequence of action-feedback pairs. -/
@@ -117,24 +116,24 @@ lemma measurable_trajectory {A : ℕ → Ω → 𝓐} {Y : ℕ → Ω → 𝓨}
117116
fun_prop
118117

119118
/-- History of the algorithm-environment sequence up to time `n`. -/
120-
def IsAlgEnvSeq.hist (A : ℕ → Ω → 𝓐) (Y : ℕ → Ω → 𝓨) (n : ℕ) (ω : Ω) : Iic n → 𝓐 × 𝓨 :=
119+
def history (A : ℕ → Ω → 𝓐) (Y : ℕ → Ω → 𝓨) (n : ℕ) (ω : Ω) : Iic n → 𝓐 × 𝓨 :=
121120
fun i ↦ (A i ω, Y i ω)
122121

123122
@[fun_prop]
124-
lemma IsAlgEnvSeq.measurable_hist (hA : ∀ n, Measurable (A n))
123+
lemma measurable_history (hA : ∀ n, Measurable (A n))
125124
(hY : ∀ n, Measurable (Y n)) (n : ℕ) :
126-
Measurable (IsAlgEnvSeq.hist A Y n) := by
127-
unfold IsAlgEnvSeq.hist
125+
Measurable (history A Y n) := by
126+
unfold history
128127
fun_prop
129128

130-
lemma IsAlgEnvSeq.eval_comp_hist (n : ℕ) :
131-
(fun x ↦ x ⟨n, by simp⟩) ∘ (hist A Y n) = step A Y n := rfl
129+
lemma eval_comp_history (n : ℕ) :
130+
(fun x ↦ x ⟨n, by simp⟩) ∘ (history A Y n) = step A Y n := rfl
132131

133-
lemma IsAlgEnvSeq.fst_eval_comp_hist (n : ℕ) :
134-
(fun x ↦ (x ⟨n, by simp⟩).1) ∘ (hist A Y n) = A n := rfl
132+
lemma fst_eval_comp_history (n : ℕ) :
133+
(fun x ↦ (x ⟨n, by simp⟩).1) ∘ (history A Y n) = A n := rfl
135134

136-
lemma IsAlgEnvSeq.snd_eval_comp_hist (n : ℕ) :
137-
(fun x ↦ (x ⟨n, by simp⟩).2) ∘ (hist A Y n) = Y n := rfl
135+
lemma snd_eval_comp_history (n : ℕ) :
136+
(fun x ↦ (x ⟨n, by simp⟩).2) ∘ (history A Y n) = Y n := rfl
138137

139138
section IsAlgEnvSeq
140139

@@ -155,11 +154,11 @@ structure IsAlgEnvSeq
155154
hasCondDistrib_feedback_zero : HasCondDistrib (Y 0) (A 0) env.ν0 P
156155
/-- The next action has the correct conditional distribution given the history. -/
157156
hasCondDistrib_action n :
158-
HasCondDistrib (A (n + 1)) (IsAlgEnvSeq.hist A Y n) (alg.policy n) P
157+
HasCondDistrib (A (n + 1)) (history A Y n) (alg.policy n) P
159158
/-- The next feedback has the correct conditional distribution given the history and
160159
next action. -/
161160
hasCondDistrib_feedback n :
162-
HasCondDistrib (Y (n + 1)) (fun ω ↦ (IsAlgEnvSeq.hist A Y n ω, A (n + 1) ω))
161+
HasCondDistrib (Y (n + 1)) (fun ω ↦ (history A Y n ω, A (n + 1) ω))
163162
(env.feedback n) P
164163

165164
/-- An algorithm-environment sequence: a sequence of actions and feedbacks generated
@@ -177,11 +176,11 @@ structure IsAlgEnvSeqUntil
177176
hasCondDistrib_feedback_zero : HasCondDistrib (Y 0) (A 0) env.ν0 P
178177
/-- The next action has the correct conditional distribution given the history. -/
179178
hasCondDistrib_action n (hn : n < N) :
180-
HasCondDistrib (A (n + 1)) (IsAlgEnvSeq.hist A Y n) (alg.policy n) P
179+
HasCondDistrib (A (n + 1)) (history A Y n) (alg.policy n) P
181180
/-- The next feedback has the correct conditional distribution given the history and
182181
next action. -/
183182
hasCondDistrib_feedback n (hn : n < N) :
184-
HasCondDistrib (Y (n + 1)) (fun ω ↦ (IsAlgEnvSeq.hist A Y n ω, A (n + 1) ω))
183+
HasCondDistrib (Y (n + 1)) (fun ω ↦ (history A Y n ω, A (n + 1) ω))
185184
(env.feedback n) P
186185

187186
lemma IsAlgEnvSeqUntil.mono (h : IsAlgEnvSeqUntil A Y alg env P N) {N' : ℕ} (hN : N' ≤ N) :
@@ -202,47 +201,61 @@ lemma IsAlgEnvSeq.isAlgEnvSeqUntil (h : IsAlgEnvSeq A Y alg env P) (N : ℕ) :
202201
hasCondDistrib_action n _ := h.hasCondDistrib_action n
203202
hasCondDistrib_feedback n _ := h.hasCondDistrib_feedback n
204203

204+
@[fun_prop]
205+
lemma IsAlgEnvSeq.measurable_step (h : IsAlgEnvSeq A Y alg env P) (n : ℕ) :
206+
Measurable (step A Y n) := by
207+
have hA := h.measurable_action
208+
have hY := h.measurable_feedback
209+
fun_prop
210+
211+
@[fun_prop]
212+
lemma IsAlgEnvSeq.measurable_history (h : IsAlgEnvSeq A Y alg env P) (n : ℕ) :
213+
Measurable (history A Y n) := by
214+
have hA := h.measurable_action
215+
have hY := h.measurable_feedback
216+
fun_prop
217+
205218
lemma IsAlgEnvSeq.hasLaw_step_zero (h : IsAlgEnvSeq A Y alg env P) :
206219
HasLaw (step A Y 0) (alg.p0 ⊗ₘ env.ν0) P :=
207220
HasLaw.prod_of_hasCondDistrib h.hasLaw_action_zero h.hasCondDistrib_feedback_zero
208221

209222
lemma IsAlgEnvSeqUntil.hasLaw_step_zero (h : IsAlgEnvSeqUntil A Y alg env P N) :
210-
HasLaw (IsAlgEnvSeq.step A Y 0) (alg.p0 ⊗ₘ env.ν0) P :=
223+
HasLaw (step A Y 0) (alg.p0 ⊗ₘ env.ν0) P :=
211224
HasLaw.prod_of_hasCondDistrib h.hasLaw_action_zero h.hasCondDistrib_feedback_zero
212225

213226
lemma IsAlgEnvSeq.hasCondDistrib_step (h : IsAlgEnvSeq A Y alg env P) (n : ℕ) :
214-
HasCondDistrib (step A Y (n + 1)) (hist A Y n) (stepKernel alg env n) P :=
227+
HasCondDistrib (step A Y (n + 1)) (history A Y n) (stepKernel alg env n) P :=
215228
HasCondDistrib.prod (h.hasCondDistrib_action n) (h.hasCondDistrib_feedback n)
216229

217230
lemma IsAlgEnvSeqUntil.hasCondDistrib_step (h : IsAlgEnvSeqUntil A Y alg env P N)
218231
(n : ℕ) (hn : n < N) :
219-
HasCondDistrib (IsAlgEnvSeq.step A Y (n + 1)) (IsAlgEnvSeq.hist A Y n)
232+
HasCondDistrib (step A Y (n + 1)) (history A Y n)
220233
(stepKernel alg env n) P :=
221234
HasCondDistrib.prod (h.hasCondDistrib_action n hn) (h.hasCondDistrib_feedback n hn)
222235

223-
lemma IsAlgEnvSeq.hasLaw_hist_zero (h : IsAlgEnvSeq A Y alg env P) : HasLaw (hist A Y 0)
236+
lemma IsAlgEnvSeq.hasLaw_history_zero (h : IsAlgEnvSeq A Y alg env P) : HasLaw (history A Y 0)
224237
((P.map (step A Y 0)).map (MeasurableEquiv.piUnique (fun _ : Iic 0 ↦ 𝓐 × 𝓨)).symm) P where
225-
aemeasurable := (measurable_hist h.measurable_action h.measurable_feedback 0).aemeasurable
238+
aemeasurable := (h.measurable_history 0).aemeasurable
226239
map_eq := by
227240
have he : (MeasurableEquiv.piUnique (fun _ : Iic 0 ↦ 𝓐 × 𝓨)).symm ∘ step A Y 0 =
228-
hist A Y 0 := by
241+
history A Y 0 := by
229242
funext _ ⟨0, _⟩
230243
rfl
231244
rw [← he]
232245
have hA := h.measurable_action
233246
have hY := h.measurable_feedback
234247
exact (Measure.map_map (by fun_prop) (by fun_prop)).symm
235248

236-
lemma IsAlgEnvSeq.hasLaw_hist_succ (h : IsAlgEnvSeq A Y alg env P) (n : ℕ) :
237-
HasLaw (hist A Y (n + 1))
238-
((P.map (hist A Y n) ⊗ₘ condDistrib (step A Y (n + 1)) (hist A Y n) P).map
249+
lemma IsAlgEnvSeq.hasLaw_history_succ (h : IsAlgEnvSeq A Y alg env P) (n : ℕ) :
250+
HasLaw (history A Y (n + 1))
251+
((P.map (history A Y n) ⊗ₘ condDistrib (step A Y (n + 1)) (history A Y n) P).map
239252
(MeasurableEquiv.IicSuccProd (fun _ ↦ 𝓐 × 𝓨) n).symm) P where
240-
aemeasurable := (measurable_hist h.measurable_action h.measurable_feedback (n + 1)).aemeasurable
253+
aemeasurable := (h.measurable_history (n + 1)).aemeasurable
241254
map_eq := by
242255
have he : (MeasurableEquiv.IicSuccProd (fun _ ↦ 𝓐 × 𝓨) n).symm ∘
243-
(fun ω ↦ (hist A Y n ω, step A Y (n + 1) ω)) = hist A Y (n + 1) := by
256+
(fun ω ↦ (history A Y n ω, step A Y (n + 1) ω)) = history A Y (n + 1) := by
244257
funext ω
245-
exact (MeasurableEquiv.IicSuccProd (fun _ ↦ 𝓐 × 𝓨) n).symm_apply_apply (hist A Y (n + 1) ω)
258+
exact (MeasurableEquiv.IicSuccProd (fun _ ↦ 𝓐 × 𝓨) n).symm_apply_apply (history A Y (n + 1) ω)
246259
have hA := h.measurable_action
247260
have hY := h.measurable_feedback
248261
rw [← he, ← Measure.map_map (by fun_prop) (by fun_prop)]
@@ -254,49 +267,49 @@ end IsAlgEnvSeq
254267
/-- Filtration generated by the history up to time `n`. -/
255268
def IsAlgEnvSeq.filtration (hA : ∀ n, Measurable (A n)) (hY : ∀ n, Measurable (Y n)) :
256269
Filtration ℕ mΩ where
257-
seq i := MeasurableSpace.comap (hist A Y i) inferInstance
270+
seq i := MeasurableSpace.comap (history A Y i) inferInstance
258271
mono' i j hij := by
259272
simp only
260273
rw [← measurable_iff_comap_le]
261-
have : hist A Y i = (fun h k ↦ h ⟨k.1, by grind⟩) ∘ hist A Y j := rfl
274+
have : history A Y i = (fun h k ↦ h ⟨k.1, by grind⟩) ∘ history A Y j := rfl
262275
rw [this]
263276
exact measurable_comp_comap _ (by fun_prop)
264277
le' i := by
265278
rw [← measurable_iff_comap_le]
266-
exact measurable_hist hA hY i
279+
exact Learning.measurable_history hA hY i
267280

268-
lemma IsAlgEnvSeq.adapted_hist
281+
lemma IsAlgEnvSeq.adapted_history
269282
(hA : ∀ n, Measurable (A n)) (hY : ∀ n, Measurable (Y n)) :
270-
Adapted (filtration hA hY) (IsAlgEnvSeq.hist A Y) :=
283+
Adapted (filtration hA hY) (history A Y) :=
271284
fun _ ↦ measurable_iff_comap_le.mpr le_rfl
272285

273286
lemma IsAlgEnvSeq.adapted_step
274287
(hA : ∀ n, Measurable (A n)) (hY : ∀ n, Measurable (Y n)) :
275288
Adapted (filtration hA hY) (step A Y) := by
276289
intro n
277-
have : step A Y n = (fun h ↦ (h ⟨n, by simp⟩)) ∘ (hist A Y n) := by
290+
have : step A Y n = (fun h ↦ (h ⟨n, by simp⟩)) ∘ (history A Y n) := by
278291
ext ω : 1
279-
simp [hist, step]
292+
simp [history, step]
280293
rw [this]
281294
exact measurable_comp_comap _ (by fun_prop)
282295

283296
lemma IsAlgEnvSeq.adapted_action
284297
(hA : ∀ n, Measurable (A n)) (hY : ∀ n, Measurable (Y n)) :
285298
Adapted (filtration hA hY) A := by
286299
intro n
287-
have : A n = (fun h ↦ (h ⟨n, by simp⟩).1) ∘ (hist A Y n) := by
300+
have : A n = (fun h ↦ (h ⟨n, by simp⟩).1) ∘ (history A Y n) := by
288301
ext ω : 1
289-
simp [IsAlgEnvSeq.hist]
302+
simp [history]
290303
rw [this]
291304
exact measurable_comp_comap _ (by fun_prop)
292305

293306
lemma IsAlgEnvSeq.adapted_feedback
294307
(hA : ∀ n, Measurable (A n)) (hY : ∀ n, Measurable (Y n)) :
295308
Adapted (filtration hA hY) Y := by
296309
intro n
297-
have : Y n = (fun h ↦ (h ⟨n, by simp⟩).2) ∘ (hist A Y n) := by
310+
have : Y n = (fun h ↦ (h ⟨n, by simp⟩).2) ∘ (history A Y n) := by
298311
ext ω : 1
299-
simp [IsAlgEnvSeq.hist]
312+
simp [history]
300313
rw [this]
301314
exact measurable_comp_comap _ (by fun_prop)
302315

@@ -351,7 +364,7 @@ lemma IsAlgEnvSeq.filtrationAction_zero_eq_comap
351364
lemma IsAlgEnvSeq.filtrationAction_eq_comap
352365
{hA : ∀ n, Measurable (A n)} {hY : ∀ n, Measurable (Y n)} (n : ℕ) (hn : n ≠ 0) :
353366
filtrationAction hA hY n =
354-
MeasurableSpace.comap (fun ω ↦ (hist A Y (n - 1) ω, A n ω)) inferInstance := by
367+
MeasurableSpace.comap (fun ω ↦ (history A Y (n - 1) ω, A n ω)) inferInstance := by
355368
simp only [filtrationAction, filtration, ← MeasurableSpace.comap_prodMk, hn, ↓reduceIte]
356369
rfl
357370

‎LeanMachineLearning/SequentialLearning/AlgorithmDensity.lean‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ concept that we also introduce here.
3232
* `absolutelyContinuous_map_hist`: the law of the history at time `n` under `alg` is absolutely
3333
continuous with respect to the law of the history at time `n` under `alg₀` when they
3434
are interacting with the same environment and `alg ≪ₐ alg₀`.
35-
* `hasLaw_hist_withDensity`: the law of the history at time `n` under `alg` is the law of the
35+
* `hasLaw_history_withDensity`: the law of the history at time `n` under `alg` is the law of the
3636
history at time `n` under `alg₀` with density `alg.density alg₀ n` when they are interacting
3737
with the same environment and `alg ≪ₐ alg₀`.
3838
@@ -94,32 +94,31 @@ variable {alg₀ : Algorithm 𝓐 𝓨}
9494
variable {A₀ : ℕ → Ω₀ → 𝓐} {Y₀ : ℕ → Ω₀ → 𝓨}
9595
variable {P₀ : Measure Ω₀} [IsProbabilityMeasure P₀]
9696

97-
lemma absolutelyContinuous_map_hist (h : IsAlgEnvSeq A Y alg env P)
97+
lemma absolutelyContinuous_map_history (h : IsAlgEnvSeq A Y alg env P)
9898
(h₀ : IsAlgEnvSeq A₀ Y₀ alg₀ env P₀) (hc : alg ≪ₐ alg₀) (n : ℕ) :
99-
P.map (IsAlgEnvSeq.hist A Y n) ≪ P₀.map (IsAlgEnvSeq.hist A₀ Y₀ n) := by
99+
P.map (history A Y n) ≪ P₀.map (history A₀ Y₀ n) := by
100100
induction n with
101101
| zero =>
102-
rw [h.hasLaw_hist_zero.map_eq, h₀.hasLaw_hist_zero.map_eq]
102+
rw [h.hasLaw_history_zero.map_eq, h₀.hasLaw_history_zero.map_eq]
103103
apply Measure.AbsolutelyContinuous.map _ (by fun_prop)
104104
rw [h.hasLaw_step_zero.map_eq, h₀.hasLaw_step_zero.map_eq]
105105
exact Measure.AbsolutelyContinuous.compProd_left hc.p0 _
106106
| succ n ih =>
107-
rw [(h.hasLaw_hist_succ n).map_eq, (h₀.hasLaw_hist_succ n).map_eq]
107+
rw [(h.hasLaw_history_succ n).map_eq, (h₀.hasLaw_history_succ n).map_eq]
108108
apply Measure.AbsolutelyContinuous.map _ (by fun_prop)
109109
rw [Measure.compProd_congr (h.hasCondDistrib_step n).condDistrib_eq,
110110
Measure.compProd_congr (h₀.hasCondDistrib_step n).condDistrib_eq]
111111
apply Measure.AbsolutelyContinuous.compProd ih
112112
filter_upwards with h' using Measure.AbsolutelyContinuous.compProd_left_apply (hc.policy n h') _
113113

114-
lemma hasLaw_hist_withDensity (h : IsAlgEnvSeq A Y alg env P) (h₀ : IsAlgEnvSeq A₀ Y₀ alg₀ env P₀)
115-
(hc : alg ≪ₐ alg₀) (n : ℕ) : HasLaw (IsAlgEnvSeq.hist A Y n)
116-
((P₀.map (IsAlgEnvSeq.hist A₀ Y₀ n)).withDensity (alg.density alg₀ n)) P where
117-
aemeasurable :=
118-
(IsAlgEnvSeq.measurable_hist h.measurable_action h.measurable_feedback n).aemeasurable
114+
lemma hasLaw_history_withDensity (h : IsAlgEnvSeq A Y alg env P)
115+
(h₀ : IsAlgEnvSeq A₀ Y₀ alg₀ env P₀) (hc : alg ≪ₐ alg₀) (n : ℕ) : HasLaw (history A Y n)
116+
((P₀.map (history A₀ Y₀ n)).withDensity (alg.density alg₀ n)) P where
117+
aemeasurable := (h.measurable_history n).aemeasurable
119118
map_eq := by
120119
induction n with
121120
| zero =>
122-
rw [h.hasLaw_hist_zero.map_eq, h₀.hasLaw_hist_zero.map_eq, h.hasLaw_step_zero.map_eq,
121+
rw [h.hasLaw_history_zero.map_eq, h₀.hasLaw_history_zero.map_eq, h.hasLaw_step_zero.map_eq,
123122
h₀.hasLaw_step_zero.map_eq]
124123
rw [← Measure.withDensity_rnDeriv_eq _ _ hc.p0,
125124
Measure.compProd_withDensity_left (by fun_prop)]
@@ -132,7 +131,7 @@ lemma hasLaw_hist_withDensity (h : IsAlgEnvSeq A Y alg env P) (h₀ : IsAlgEnvSe
132131
have : IsMarkovKernel ((stepKernel alg₀ env n).withDensity ρ) := by
133132
rw [← hs]
134133
infer_instance
135-
rw [(h.hasLaw_hist_succ n).map_eq, (h₀.hasLaw_hist_succ n).map_eq,
134+
rw [(h.hasLaw_history_succ n).map_eq, (h₀.hasLaw_history_succ n).map_eq,
136135
Measure.compProd_congr (h.hasCondDistrib_step n).condDistrib_eq,
137136
Measure.compProd_congr (h₀.hasCondDistrib_step n).condDistrib_eq, ih, hs,
138137
Measure.compProd_withDensity_withDensity (by fun_prop) (by fun_prop)]

0 commit comments

Comments
 (0)