Bandits.ArrayModel.indepFun_snd_apply_aux
No 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))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_ofPred_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_ofPred_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]Actions: Source Β· Open Issue
Meaning last changed in v4.34.0-rc2-1-g439785b (2026-08-23), the 5th recorded change.
Self-contained, with its dependencies inlined and proofs replaced by sorry: download the raw file Β· open it in the Lean web editor.
Dependency graph
Audit surface: 4 project declarations, 55 external constants
β Proved: no sorry anywhere in its closure
This is the tool's own reading of one build's recorded axioms, and it is not robust against an author who wants it to pass. Checking meant to be relied on should go through Comparator, which replays the proof through the kernel from an export against an explicit list of permitted axioms.