Bandits.ArrayModel.indepFun_snd_apply_aux
This page has the declaration's own card below, then its dependency graph, then a card for each dependency (type dependencies first, then the rest of the transitive closure). For a theorem, the graph and the dependency cards only follow its statement's dependencies (its proof is replaced by sorry, so what it proves doesn't depend on how); for everything else, both the type and the body/value are followed, since their content is part of what later declarations build on.
indepFun_snd_apply_aux๐
Bandits.ArrayModel.indepFun_snd_apply_auxNo docstring.
Bandits.ArrayModel.indepFun_snd_apply_aux.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} [DecidableEq ๐] [Nonempty R] (ฮฝ : ProbabilityTheory.Kernel ๐ R) [ProbabilityTheory.IsMarkovKernel ฮฝ] (a : ๐) (m : โ) : ProbabilityTheory.IndepFun (fun ฯ => Prod.snd ฯ m a) (fun ฯ => (Prod.fst ฯ, fun k b => if b = a then if m โ 0 then Prod.snd ฯ (min k (m - 1)) b else Nonempty.some โฏ else Prod.snd ฯ k b)) (arrayMeasure ฮฝ)Bandits.ArrayModel.indepFun_snd_apply_aux.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} [DecidableEq ๐] [Nonempty R] (ฮฝ : ProbabilityTheory.Kernel ๐ R) [ProbabilityTheory.IsMarkovKernel ฮฝ] (a : ๐) (m : โ) : ProbabilityTheory.IndepFun (fun ฯ => Prod.snd ฯ m a) (fun ฯ => (Prod.fst ฯ, fun k b => if b = a then if m โ 0 then Prod.snd ฯ (min k (m - 1)) b else Nonempty.some โฏ else Prod.snd ฯ k b)) (arrayMeasure ฮฝ)
Code
lemma indepFun_snd_apply_aux (ฮฝ : Kernel ๐ R) [IsMarkovKernel ฮฝ] (a : ๐) (m : โ) :
(fun ฯ โฆ ฯ.2 m a) โแตข[arrayMeasure ฮฝ]
(fun ฯ โฆ (ฯ.1, fun k b โฆ if b = a then if m โ 0 then ฯ.2 (min k (m - 1)) b
else Nonempty.some inferInstance else ฯ.2 k b))Type uses (3)
Body uses (2)
Actions: Source ยท Open Issue
Proof
by
unfold arrayMeasure
let ฮผโ : Measure (โ โ I) := Measure.infinitePi fun _ โฆ volume
let ฮผโ : Measure (โ โ ๐ โ R) := Measure.infinitePi fun _ โฆ Measure.infinitePi ฮฝ
-- Independence within ฮผโ: coordinates ฯ i are independent
have h_indepโ : iIndepFun (fun i (ฯ : โ โ ๐ โ R) โฆ ฯ i) ฮผโ :=
iIndepFun_infinitePi (fun _ โฆ measurable_id)
-- Independence within each infinitePi ฮฝ: coordinates f b are independent
have h_indep_inner : iIndepFun (fun (b : ๐) (f : ๐ โ R) โฆ f b) (Measure.infinitePi ฮฝ) :=
iIndepFun_infinitePi (fun _ โฆ measurable_id)
rw [indepFun_iff_measure_inter_preimage_eq_mul]
intro s t hs ht
let X : (โ โ I) ร (โ โ ๐ โ R) โ R := fun ฯ โฆ ฯ.2 m a
let Y : (โ โ I) ร (โ โ ๐ โ R) โ (โ โ I) ร (โ โ ๐ โ R) :=
fun ฯ โฆ (ฯ.1, fun k b โฆ if b = a then if m โ 0 then ฯ.2 (min k (m - 1)) b
else Nonempty.some inferInstance else ฯ.2 k b)
have hX_meas : Measurable X :=
(measurable_pi_apply a).comp ((measurable_pi_apply m).comp measurable_snd)
have hY_meas : Measurable Y := by
change Measurable (fun ฯ : (โ โ I) ร (โ โ ๐ โ R) โฆ
(ฯ.1, fun k b โฆ if b = a then if m โ 0 then ฯ.2 (min k (m - 1)) b
else Nonempty.some inferInstance else ฯ.2 k b))
refine Measurable.prod measurable_fst ?_
refine measurable_pi_lambda _ (fun k โฆ ?_)
refine measurable_pi_lambda _ (fun b โฆ ?_)
by_cases hb : b = a
ยท simp only [hb, โreduceIte]
by_cases hm : m โ 0
ยท simp only [ne_eq, hm, not_false_eq_true, โreduceIte]
exact (measurable_pi_apply a).comp
((measurable_pi_apply (min k (m - 1))).comp measurable_snd)
ยท simp only [hm, โreduceIte]
exact measurable_const
ยท simp only [hb, โreduceIte]
exact (measurable_pi_apply b).comp ((measurable_pi_apply k).comp measurable_snd)
change (ฮผโ.prod ฮผโ) (X โปยน' s โฉ Y โปยน' t) = (ฮผโ.prod ฮผโ) (X โปยน' s) * (ฮผโ.prod ฮผโ) (Y โปยน' t)
-- Use Fubini on ฮผโ.prod ฮผโ
rw [Measure.prod_apply (hs.preimage hX_meas),
Measure.prod_apply (ht.preimage hY_meas),
Measure.prod_apply ((hs.preimage hX_meas).inter (ht.preimage hY_meas))]
-- X only depends on ฯโ, so its fiber is constant in ฯโ
have hX_fst : โ ฯโ, ฮผโ (Prod.mk ฯโ โปยน' (X โปยน' s)) = ฮผโ ((fun ฯโ โฆ ฯโ m a) โปยน' s) := fun _ โฆ rfl
simp_rw [hX_fst]
-- The LHS integral: fiber of X โฉ Y at ฯโ
-- Key: X depends only on ฯโ m a, while Y's dependence on ฯโ avoids (m, a)
-- Define the "truncation" map on ฯโ
let trunc : (โ โ ๐ โ R) โ (โ โ ๐ โ R) :=
fun ฯโ k b โฆ if b = a then if m โ 0 then ฯโ (min k (m - 1)) b
else Nonempty.some inferInstance else ฯโ k b
-- The fiber of Y at ฯโ only depends on trunc(ฯโ)
have hY_fiber : โ ฯโ, Prod.mk ฯโ โปยน' (Y โปยน' t) = (fun ฯโ โฆ (ฯโ, trunc ฯโ)) โปยน' t := fun _ โฆ rfl
-- The fiber of X โฉ Y factors
have hXY_fiber : โ ฯโ, Prod.mk ฯโ โปยน' (X โปยน' s โฉ Y โปยน' t) =
((fun ฯโ โฆ ฯโ m a) โปยน' s) โฉ ((fun ฯโ โฆ (ฯโ, trunc ฯโ)) โปยน' t) := fun _ โฆ rfl
simp_rw [hXY_fiber, hY_fiber]
-- Now we use independence in ฮผโ: (ฯโ m a) is independent of (trunc ฯโ)
-- because trunc only uses indices (k, a) with k < m, and (k, b) with b โ a
have h_trunc_meas : Measurable trunc := by
refine measurable_pi_lambda _ (fun k โฆ ?_)
refine measurable_pi_lambda _ (fun b โฆ ?_)
simp only [trunc]
by_cases hb : b = a
ยท simp only [hb, โreduceIte]
by_cases hm : m = 0
ยท simp only [hm]
exact measurable_const
ยท simp only [ne_eq, hm, not_false_eq_true, โreduceIte]
exact (measurable_pi_apply a).comp (measurable_pi_apply (min k (m - 1)))
ยท simp only [hb, โreduceIte]
exact (measurable_pi_apply b).comp (measurable_pi_apply k)
-- Key independence: (ฯโ m a) โ trunc because trunc only uses coordinates โ (m, a)
have h_indep_trunc : IndepFun (fun ฯโ โฆ ฯโ m a) trunc ฮผโ := by
-- Factor trunc through proj which extracts the relevant coordinates
let proj : (โ โ ๐ โ R) โ ((โ โ R) ร (โ โ {b : ๐ // b โ a} โ R)) := fun ฯโ โฆ
(fun k โฆ if m โ 0 then ฯโ (min k (m - 1)) a else Nonempty.some inferInstance,
fun k โจb, _โฉ โฆ ฯโ k b)
have h_trunc_proj : โ ฯโ, trunc ฯโ = (fun p k b โฆ
if h : b = a then if m โ 0 then p.1 k
else Nonempty.some inferInstance else p.2 k โจb, hโฉ) (proj ฯโ) := by
intro ฯโ; ext k b; simp only [trunc, proj]; by_cases hb : b = a <;> simp [hb]; grind
have h_proj_meas : Measurable proj := by
refine Measurable.prod ?_ ?_
ยท refine measurable_pi_lambda _ fun k โฆ ?_
by_cases hm : m โ 0
ยท simp only [proj, ne_eq, hm, not_false_eq_true, โreduceIte]
exact (measurable_pi_apply a).comp (measurable_pi_apply (min k (m - 1)))
ยท simp [proj, hm]
ยท exact measurable_pi_lambda _ (fun k โฆ measurable_pi_lambda _ (fun โจb, _โฉ โฆ
(measurable_pi_apply b).comp (measurable_pi_apply k)))
have h_g_meas : Measurable (fun p : (โ โ R) ร (โ โ {b : ๐ // b โ a} โ R) โฆ
(fun k b โฆ if h : b = a then if m โ 0 then p.1 k else Nonempty.some inferInstance
else p.2 k โจb, hโฉ)) := by
refine measurable_pi_lambda _ (fun k โฆ measurable_pi_lambda _ (fun b โฆ ?_))
by_cases hb : b = a
ยท simp only [hb, โreduceDIte]
by_cases hm : m โ 0
ยท simp only [ne_eq, hm, not_false_eq_true]
exact (measurable_pi_apply k).comp measurable_fst
ยท simp [hm]
ยท simp only [hb, โreduceDIte]
exact (measurable_pi_apply (โจb, hbโฉ : {b : ๐ // b โ a})).comp
((measurable_pi_apply k).comp measurable_snd)
-- Show (ฯโ m a) โ proj: proj uses coordinates disjoint from (m, a)
have h_indep_proj : IndepFun (fun ฯโ โฆ ฯโ m a) proj ฮผโ := by
have h_row_bound (hm : m โ 0) : โ k, min k (m - 1) < m := by
intro k
calc min k (m - 1) โค m - 1 := Nat.min_le_right k (m - 1)
_ < m := Nat.sub_lt (by grind) Nat.one_pos
rw [indepFun_iff_measure_inter_preimage_eq_mul]
intro s t' hs ht'
-- rows_lt_m extracts column a at rows < m, other_cols extracts columns โ a
let rows_lt_m : (โ โ ๐ โ R) โ (Iio m โ R) := fun ฯโ โจj, _โฉ โฆ ฯโ j a
let other_cols : (โ โ ๐ โ R) โ (โ โ {b : ๐ // b โ a} โ R) := fun ฯโ k โจb, _โฉ โฆ ฯโ k b
have h_proj_factor : โ ฯโ, proj ฯโ =
((fun r k โฆ if hm : m โ 0 then r โจmin k (m - 1), Finset.mem_Iio.mpr (h_row_bound hm k)โฉ
else Nonempty.some inferInstance) (rows_lt_m ฯโ),
other_cols ฯโ) := by
intro ฯโ; ext1
ยท ext k
by_cases hm : m โ 0
ยท simp [proj, rows_lt_m, hm]
ยท simp [proj, hm]
ยท rfl
-- Use iIndepFun structure of the doubly-indexed infinite product
have h_iindep : iIndepFun (fun (p : โ ร ๐) ฯ โฆ ฯ p.1 p.2) ฮผโ :=
iIndepFun_uncurry_infinitePi' (X := fun _ _ โฆ id) (fun _ โฆ ฮฝ) (by fun_prop)
have h_rows_meas : Measurable rows_lt_m :=
measurable_pi_lambda _ (fun โจj, _โฉ โฆ (measurable_pi_apply a).comp (measurable_pi_apply j))
have h_other_meas : Measurable other_cols :=
measurable_pi_lambda _ (fun k โฆ measurable_pi_lambda _ (fun โจb, _โฉ โฆ
(measurable_pi_apply b).comp (measurable_pi_apply k)))
-- Show (ฯโ m a) โ (rows_lt_m, other_cols) via indep_iSup_of_disjoint
have h_indep_combined : IndepFun (fun ฯโ โฆ ฯโ m a)
(fun ฯโ โฆ (rows_lt_m ฯโ, other_cols ฯโ)) ฮผโ := by
rw [IndepFun_iff_Indep]
have h_comap_le : (MeasurableSpace.pi.prod MeasurableSpace.pi).comap
(fun ฯโ โฆ (rows_lt_m ฯโ, other_cols ฯโ)) โค
โจ (p : {p : โ ร ๐ // p โ (m, a)}), mR.comap (fun ฯ โฆ ฯ p.val.1 p.val.2) := by
rw [MeasurableSpace.comap_prodMk]
refine sup_le ?_ ?_
ยท rw [MeasurableSpace.comap_pi]
refine iSup_le (fun โจj, hjโฉ โฆ ?_)
have h_ne : (j, a) โ (m, a) := fun h โฆ (Finset.mem_Iio.mp hj).ne (Prod.mk.inj h).1
exact le_iSup_of_le โจ(j, a), h_neโฉ le_rfl
ยท rw [MeasurableSpace.comap_pi]
refine iSup_le (fun k โฆ ?_)
rw [MeasurableSpace.comap_pi]
refine iSup_le (fun โจb, hbโฉ โฆ ?_)
have h_ne : (k, b) โ (m, a) := fun h โฆ hb (Prod.mk.inj h).2
exact le_iSup_of_le โจ(k, b), h_neโฉ le_rfl
refine indep_of_indep_of_le_right ?_ h_comap_le
have h_disjoint : Disjoint ({(m, a)} : Set (โ ร ๐)) {p | p โ (m, a)} := by simp
have h_le : โ p : โ ร ๐, mR.comap (fun ฯ : โ โ ๐ โ R โฆ ฯ p.1 p.2) โค
MeasurableSpace.pi (m := fun _ โฆ MeasurableSpace.pi) := fun p โฆ
Measurable.comap_le ((measurable_pi_apply p.2).comp (measurable_pi_apply p.1))
have h_iindep' : iIndep (fun p : โ ร ๐ โฆ mR.comap (fun ฯ : โ โ ๐ โ R โฆ ฯ p.1 p.2)) ฮผโ :=
h_iindep.iIndep
have h_indep := indep_iSup_of_disjoint h_le h_iindep' h_disjoint
convert h_indep using 2
ยท simp only [Set.mem_singleton_iff, iSup_iSup_eq_left]
ยท simp only [ne_eq, Set.mem_setOf_eq, iSup_subtype']
have h_proj_preimage : proj โปยน' t' = (fun ฯโ โฆ (rows_lt_m ฯโ, other_cols ฯโ)) โปยน'
{p | ((fun r k โฆ if hm : m โ 0 then
r โจmin k (m - 1), Finset.mem_Iio.mpr (h_row_bound hm k)โฉ
else Nonempty.some inferInstance) p.1, p.2) โ t'}
:= by ext ฯโ; simp only [Set.mem_preimage, Set.mem_setOf_eq, h_proj_factor]
rw [indepFun_iff_measure_inter_preimage_eq_mul] at h_indep_combined
rw [h_proj_preimage]
let T : Set ((Iio m โ R) ร (โ โ {b : ๐ // b โ a} โ R)) :=
{p | ((fun r k โฆ if hm : m โ 0 then
r โจmin k (m - 1), Finset.mem_Iio.mpr (h_row_bound hm k)โฉ
else Nonempty.some inferInstance) p.1, p.2) โ t'}
have hT_meas : MeasurableSet T := by
refine ht'.preimage (Measurable.prod ?_ measurable_snd)
refine measurable_pi_lambda _ (fun k โฆ ?_)
by_cases hm : m โ 0
ยท simp only [ne_eq, hm, not_false_eq_true, โreduceDIte]
exact (measurable_pi_apply (โจmin k (m - 1), Finset.mem_Iio.mpr (h_row_bound hm k)โฉ :
Iio m)).comp measurable_fst
ยท simp [hm]
change ฮผโ ((fun ฯโ โฆ ฯโ m a) โปยน' s โฉ (fun ฯโ โฆ (rows_lt_m ฯโ, other_cols ฯโ)) โปยน' T) =
ฮผโ ((fun ฯโ โฆ ฯโ m a) โปยน' s) *
ฮผโ ((fun ฯโ โฆ (rows_lt_m ฯโ, other_cols ฯโ)) โปยน' T)
exact h_indep_combined s T hs hT_meas
have h_eq : trunc = (fun p k b โฆ if h : b = a then if m โ 0 then p.1 k
else Nonempty.some inferInstance else p.2 k โจb, hโฉ) โ proj := by
funext ฯโ; exact h_trunc_proj ฯโ
rw [h_eq]
exact h_indep_proj.comp measurable_id h_g_meas
rw [indepFun_iff_measure_inter_preimage_eq_mul] at h_indep_trunc
have h_const : โ ฯโ, ฮผโ (((fun ฯโ โฆ ฯโ m a) โปยน' s) โฉ ((fun ฯโ โฆ (ฯโ, trunc ฯโ)) โปยน' t)) =
ฮผโ ((fun ฯโ โฆ ฯโ m a) โปยน' s) * ฮผโ ((fun ฯโ โฆ (ฯโ, trunc ฯโ)) โปยน' t) := fun ฯโ โฆ
h_indep_trunc s _ hs (ht.preimage (by fun_prop))
simp_rw [h_const]
let c := ฮผโ ((fun ฯโ โฆ ฯโ m a) โปยน' s)
change โซโป x, c * ฮผโ ((fun ฯโ โฆ (x, trunc ฯโ)) โปยน' t) โฮผโ =
(โซโป _, c โฮผโ) * โซโป x, ฮผโ ((fun ฯโ โฆ (x, trunc ฯโ)) โปยน' t) โฮผโ
have h_preimage : โ x, (fun ฯโ โฆ (x, trunc ฯโ)) โปยน' t = trunc โปยน' (Prod.mk x โปยน' t) := fun _ โฆ rfl
simp_rw [h_preimage]
have h_map : โ x, ฮผโ (trunc โปยน' (Prod.mk x โปยน' t)) = (ฮผโ.map trunc) (Prod.mk x โปยน' t) := by
intro x; rw [Measure.map_apply h_trunc_meas (ht.preimage (by fun_prop))]
simp_rw [h_map]
rw [lintegral_const_mul _ (measurable_measure_prodMk_left_finite ht),
lintegral_const, measure_univ, mul_one]Dependency graph
Type dependencies (3)
probSpace๐
Bandits.ArrayModel.probSpaceProbability space for the array model of stochastic bandits.
Bandits.ArrayModel.probSpace.{u_1, u_2} (๐ : Type u_1) (R : Type u_2) : Type (max u_1 u_2)Bandits.ArrayModel.probSpace.{u_1, u_2} (๐ : Type u_1) (R : Type u_2) : Type (max u_1 u_2)
Code
def probSpace : Type _ := (โ โ I) ร (โ โ ๐ โ R)
Actions: Source ยท Open Issue
instMeasurableSpaceProbSpace๐
Bandits.ArrayModel.instMeasurableSpaceProbSpaceNo docstring.
Bandits.ArrayModel.instMeasurableSpaceProbSpace.{u_3, u_4} {๐ : Type u_3} {R : Type u_4} [MeasurableSpace R] : MeasurableSpace (probSpace ๐ R)Bandits.ArrayModel.instMeasurableSpaceProbSpace.{u_3, u_4} {๐ : Type u_3} {R : Type u_4} [MeasurableSpace R] : MeasurableSpace (probSpace ๐ R)
Code
instance {๐ R : Type*} [MeasurableSpace R] : MeasurableSpace (probSpace ๐ R)Type uses (1)
Actions: Source ยท Open Issue
Proof
inferInstanceAs (MeasurableSpace ((โ โ I) ร (โ โ ๐ โ R)))
arrayMeasure๐
Bandits.ArrayModel.arrayMeasureProbability measure for the array model of stochastic bandits.
Bandits.ArrayModel.arrayMeasure.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} (ฮฝ : ProbabilityTheory.Kernel ๐ R) : MeasureTheory.Measure (probSpace ๐ R)Bandits.ArrayModel.arrayMeasure.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} (ฮฝ : ProbabilityTheory.Kernel ๐ R) : MeasureTheory.Measure (probSpace ๐ R)
Code
noncomputable def arrayMeasure (ฮฝ : Kernel ๐ R) : Measure (probSpace ๐ R) := (Measure.infinitePi fun _ โฆ volume).prod (streamMeasure ฮฝ)
Type uses (2)
Body uses (1)
Actions: Source ยท Open Issue
All dependencies, transitively (1)
streamMeasure๐
Bandits.streamMeasureMeasure of an infinite stream of rewards from each action.
Bandits.streamMeasure.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} (ฮฝ : ProbabilityTheory.Kernel ๐ R) : MeasureTheory.Measure (โ โ ๐ โ R)Bandits.streamMeasure.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} {m๐ : MeasurableSpace ๐} {mR : MeasurableSpace R} (ฮฝ : ProbabilityTheory.Kernel ๐ R) : MeasureTheory.Measure (โ โ ๐ โ R)
Code
noncomputable def streamMeasure (ฮฝ : Kernel ๐ R) : Measure (โ โ ๐ โ R) := Measure.infinitePi fun _ โฆ Measure.infinitePi ฮฝ
Used by (56)
Actions: Source ยท Open Issue