LeanMachineLearning

Bandits.ArrayModel.hasCondDistrib_reward_hist_action_pullCount๐Ÿ”—

Lemma

The conditional distribution of the reward at time n + 1, given the history up to time n, the action at time n + 1, and the number of times that action has been pulled before time n + 1, is equal to the kernel ฮฝ.

๐Ÿ”—theorem
Bandits.ArrayModel.hasCondDistrib_reward_hist_action_pullCount.{u_1, u_2} {๐“ : Type u_1} {R : Type u_2} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [Nonempty ๐“] [StandardBorelSpace ๐“] [DecidableEq ๐“] [Countable ๐“] [StandardBorelSpace R] [Nonempty R] (alg : Learning.Algorithm ๐“ R) (ฮฝ : ProbabilityTheory.Kernel ๐“ R) [ProbabilityTheory.IsMarkovKernel ฮฝ] (n : โ„•) : ProbabilityTheory.HasCondDistrib (reward alg (n + 1)) (fun ฯ‰ => (hist alg ฯ‰ n, action alg (n + 1) ฯ‰, Learning.pullCount (action alg) (action alg (n + 1) ฯ‰) (n + 1) ฯ‰)) (ProbabilityTheory.Kernel.prodMkLeft (โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— R) (ProbabilityTheory.Kernel.prodMkRight โ„• ฮฝ)) (arrayMeasure ฮฝ)
Bandits.ArrayModel.hasCondDistrib_reward_hist_action_pullCount.{u_1, u_2} {๐“ : Type u_1} {R : Type u_2} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [Nonempty ๐“] [StandardBorelSpace ๐“] [DecidableEq ๐“] [Countable ๐“] [StandardBorelSpace R] [Nonempty R] (alg : Learning.Algorithm ๐“ R) (ฮฝ : ProbabilityTheory.Kernel ๐“ R) [ProbabilityTheory.IsMarkovKernel ฮฝ] (n : โ„•) : ProbabilityTheory.HasCondDistrib (reward alg (n + 1)) (fun ฯ‰ => (hist alg ฯ‰ n, action alg (n + 1) ฯ‰, Learning.pullCount (action alg) (action alg (n + 1) ฯ‰) (n + 1) ฯ‰)) (ProbabilityTheory.Kernel.prodMkLeft (โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— R) (ProbabilityTheory.Kernel.prodMkRight โ„• ฮฝ)) (arrayMeasure ฮฝ)

Code

lemma hasCondDistrib_reward_hist_action_pullCount
    (alg : Algorithm ๐“ R) (ฮฝ : Kernel ๐“ R) [IsMarkovKernel ฮฝ] (n : โ„•) :
    HasCondDistrib (reward alg (n + 1))
      (fun ฯ‰ โ†ฆ (hist alg ฯ‰ n, action alg (n + 1) ฯ‰,
        pullCount (action alg) (action alg (n + 1) ฯ‰) (n + 1) ฯ‰))
      ((ฮฝ.prodMkRight _).prodMkLeft _) (arrayMeasure ฮฝ)
Proof
by
  have h_meas : Measurable fun ฯ‰ โ†ฆ pullCount (action alg) (action alg (n + 1) ฯ‰) (n + 1) ฯ‰ := by
    change Measurable ((fun p : (probSpace ๐“ R) ร— ๐“ โ†ฆ pullCount (action alg) p.2 (n + 1) p.1) โˆ˜
      (fun ฯ‰ : probSpace ๐“ R โ†ฆ (ฯ‰, action alg (n + 1) ฯ‰)))
    exact (measurable_uncurry_pullCount (by fun_prop) _).comp (by fun_prop)
  refine hasCondDistrib_of_condDistrib_eq (by fun_prop) (by fun_prop) ?_
  refine condDistrib_prod_of_forall_condDistrib_cond (by fun_prop) (by fun_prop) (by fun_prop) _ ?_
  intro (a, m) ham
  have h_eq : ((ฮฝ.prodMkRight _).prodMkLeft _).comap (fun ฯ‰ : (Iic n โ†’ ๐“ ร— R) โ†ฆ (ฯ‰, a, m))
        (by fun_prop) =
      Kernel.const _ (ฮฝ a) := by ext; simp
  rw [h_eq, condDistrib_congr_left (reward_ae_eq_cond alg ฮฝ a n m)]
  refine (condDistrib_of_indepFun ?_ (by fun_prop) (by fun_prop)).trans (ae_of_all _ fun ฯ‰ โ†ฆ ?_)
  ยท exact (indepFun_snd_hist_cond alg ฮฝ a n m).symm
  ยท simp only [Kernel.const_apply]
    have : (fun ฯ‰ โ†ฆ (action alg (n + 1) ฯ‰,
          pullCount (action alg) (action alg (n + 1) ฯ‰) (n + 1) ฯ‰)) โปยน' {(a, m)} =
        ({ฯ‰ | action alg (n + 1) ฯ‰ = a โˆง
          pullCount (action alg) a (n + 1) ฯ‰ = m}).indicator 1 โปยน' {1} := by
      ext ฯ‰
      simp [Set.indicator_apply]
      grind
    rw [this, cond_of_indepFun, map_snd_apply_arrayMeasure m a]
    ยท exact (indepFun_snd_apply_pullCount_action alg ฮฝ a m n).symm
    ยท refine Measurable.indicator (by fun_prop) ?_
      exact MeasurableSet.inter ((measurableSet_singleton _).preimage (by fun_prop))
        ((measurableSet_singleton _).preimage (by fun_prop))
    ยท fun_prop
    ยท simp
    ยท convert ham
      ext ฯ‰
      simp only [Set.mem_preimage, Set.indicator_apply, Set.mem_ofPred_eq, Pi.one_apply,
        Set.mem_singleton_iff, ite_eq_left_iff, not_and, zero_ne_one, imp_false, Classical.not_imp,
        Decidable.not_not, Prod.mk.injEq, and_congr_right_iff]
      intro ha
      simp [ha]

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: 14 project declarations, 95 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.