Skip to content

Commit 3ff93c0

Browse files
authored
MeasurableSpace on kernels, algorithms, environments (#239)
2 parents 565f652 + 7ae2db6 commit 3ff93c0

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

β€ŽLeanMachineLearning.leanβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public import LeanMachineLearning.ForMathlib.Probability.Kernel.Composition.MapC
2828
public import LeanMachineLearning.ForMathlib.Probability.Kernel.Composition.MeasureCompProd
2929
public import LeanMachineLearning.ForMathlib.Probability.Kernel.IonescuTulcea.Traj
3030
public import LeanMachineLearning.ForMathlib.Probability.Kernel.KernelSub
31+
public import LeanMachineLearning.ForMathlib.Probability.Kernel.MeasurableSpace
3132
public import LeanMachineLearning.ForMathlib.Probability.Moments.SubExponential
3233
public import LeanMachineLearning.ForMathlib.Probability.Moments.SubGaussian
3334
public import LeanMachineLearning.ForMathlib.Probability.WithDensity
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/-
2+
Copyright (c) 2026 RΓ©my Degenne. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: RΓ©my Degenne
5+
-/
6+
module
7+
8+
public import Mathlib.Probability.Kernel.Basic
9+
10+
/-!
11+
# Measurable space of kernels
12+
13+
-/
14+
15+
@[expose] public section
16+
17+
open MeasureTheory
18+
19+
namespace ProbabilityTheory
20+
21+
variable {𝓧 𝓨 𝓩 : Type*} {m𝓧 : MeasurableSpace 𝓧} {m𝓨 : MeasurableSpace 𝓨} {m𝓩 : MeasurableSpace 𝓩}
22+
23+
instance instMeasurableSpaceKernel : MeasurableSpace (Kernel 𝓧 𝓨) :=
24+
MeasurableSpace.comap (fun ΞΊ ↦ (ΞΊ : 𝓧 β†’ Measure 𝓨)) inferInstance
25+
26+
lemma measurable_kernel_iff (f : 𝓧 β†’ Kernel 𝓨 𝓩) : Measurable f ↔ βˆ€ y, Measurable (f Β· y) := by
27+
unfold instMeasurableSpaceKernel
28+
rw [measurable_comap_iff, measurable_pi_iff]
29+
simp
30+
31+
@[fun_prop]
32+
lemma Kernel.measurable_const : Measurable (@Kernel.const 𝓧 𝓨 m𝓧 m𝓨) := by
33+
rw [measurable_kernel_iff]
34+
simp only [const_apply]
35+
fun_prop
36+
37+
end ProbabilityTheory

β€ŽLeanMachineLearning/SequentialLearning/Algorithm.leanβ€Ž

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module
77

88
public import LeanMachineLearning.ForMathlib.MeasureTheory.Measurable
99
public import LeanMachineLearning.ForMathlib.Probability.Kernel.IonescuTulcea.Traj
10+
public import LeanMachineLearning.ForMathlib.Probability.Kernel.MeasurableSpace
1011

1112
/-!
1213
# Algorithms and environments
@@ -110,6 +111,15 @@ structure Algorithm (π“ž 𝓐 𝓨 : Type*) [MeasurableSpace π“ž] [MeasurableS
110111
instance (alg : Algorithm π“ž 𝓐 𝓨) (n : β„•) : IsMarkovKernel (alg.policy n) :=
111112
alg.isMarkovKernel_policy n
112113

114+
instance : MeasurableSpace (Algorithm π“ž 𝓐 𝓨) :=
115+
MeasurableSpace.comap (fun alg ↦ alg.policy) inferInstance
116+
117+
lemma measurable_algorithm_iff (f : Ξ© β†’ Algorithm π“ž 𝓐 𝓨) :
118+
Measurable f ↔ βˆ€ n, Measurable fun x ↦ (f x).policy n := by
119+
unfold instMeasurableSpaceAlgorithm
120+
rw [measurable_comap_iff, measurable_pi_iff]
121+
simp
122+
113123
/-- A stochastic environment.
114124
At each round, an observation is drawn prior to the algorithm taking an action. Then the environment
115125
provides feedback based on the observation and the action. -/
@@ -129,6 +139,16 @@ instance (env : Environment π“ž 𝓐 𝓨) (n : β„•) : IsMarkovKernel (env.obs
129139
instance (env : Environment π“ž 𝓐 𝓨) (n : β„•) : IsMarkovKernel (env.feedback n) :=
130140
env.isMarkovKernel_feedback n
131141

142+
instance : MeasurableSpace (Environment π“ž 𝓐 𝓨) :=
143+
MeasurableSpace.comap (fun env ↦ (env.obs, env.feedback)) inferInstance
144+
145+
lemma measurable_environment_iff (f : Ξ© β†’ Environment π“ž 𝓐 𝓨) :
146+
Measurable f ↔
147+
βˆ€ n, Measurable (fun x ↦ (f x).obs n) ∧ Measurable (fun x ↦ (f x).feedback n) := by
148+
simp_rw [measurable_comap_iff, measurable_fun_prod, forall_and, measurable_pi_iff,
149+
measurable_kernel_iff]
150+
rfl
151+
132152
/-- Distribution of the first observation: the observation kernel at time `0` applied to the empty
133153
history. -/
134154
def Environment.obs0 (env : Environment π“ž 𝓐 𝓨) : Measure π“ž :=

0 commit comments

Comments
Β (0)