Bandits.ArrayModel.hasCondDistrib_reward_pullCount_action
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.
hasCondDistrib_reward_pullCount_actionπ
Bandits.ArrayModel.hasCondDistrib_reward_pullCount_action
The conditional distribution of the reward at time n + 1, given 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 Ξ½.
Bandits.ArrayModel.hasCondDistrib_reward_pullCount_action.{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 Ο => (action alg (n + 1) Ο, Learning.pullCount (action alg) (action alg (n + 1) Ο) (n + 1) Ο)) (ProbabilityTheory.Kernel.prodMkRight β Ξ½) (arrayMeasure Ξ½)Bandits.ArrayModel.hasCondDistrib_reward_pullCount_action.{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 Ο => (action alg (n + 1) Ο, Learning.pullCount (action alg) (action alg (n + 1) Ο) (n + 1) Ο)) (ProbabilityTheory.Kernel.prodMkRight β Ξ½) (arrayMeasure Ξ½)
Code
lemma hasCondDistrib_reward_pullCount_action
(alg : Algorithm π R) (Ξ½ : Kernel π R) [IsMarkovKernel Ξ½] (n : β) :
HasCondDistrib (reward alg (n + 1))
(fun Ο β¦ (action alg (n + 1) Ο, pullCount (action alg) (action alg (n + 1) Ο) (n + 1) Ο))
(Ξ½.prodMkRight _) (arrayMeasure Ξ½)Type uses (7)
Used by (1)
Actions: Source Β· Open Issue
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_ae_eq_cond
(Measurable.prodMk (by fun_prop) (by fun_prop)) (by fun_prop)).trans ?_
rw [Filter.EventuallyEq, ae_iff_of_countable]
intro β¨a, mβ© ham
simp only [Kernel.prodMkRight_apply]
calc
Measure.map (reward alg (n + 1))
(arrayMeasure Ξ½)[|(fun Ο β¦ (action alg (n + 1) Ο,
pullCount (action alg) (action alg (n + 1) Ο) (n + 1) Ο)) β»ΒΉ' {(a, m)}]
_ = Measure.map (fun Ο β¦ Ο.2 m a)
(arrayMeasure Ξ½)[|(fun Ο β¦ (action alg (n + 1) Ο,
pullCount (action alg) (action alg (n + 1) Ο) (n + 1) Ο)) β»ΒΉ' {(a, m)}] := by
rw [reward_eq]
refine Measure.map_congr
(ae_cond_of_forall_mem ((measurableSet_singleton _).preimage (by fun_prop)) (fun x hx β¦ ?_))
simp only [Set.mem_preimage, Set.mem_singleton_iff, Prod.mk.injEq] at hx
simp only [hx.1] at hx β’
simp [hx.2]
_ = Measure.map (fun Ο β¦ Ο.2 m a)
(arrayMeasure Ξ½)[|({Ο | action alg (n + 1) Ο = a β§
pullCount (action alg) a (n + 1) Ο = m}).indicator 1 β»ΒΉ' {1}] := by
congr with Ο
simp only [Set.mem_preimage, Set.mem_singleton_iff, Prod.mk.injEq, Set.indicator_apply,
Set.mem_setOf_eq, Pi.one_apply, ite_eq_left_iff, not_and, zero_ne_one, imp_false,
Classical.not_imp, Decidable.not_not, and_congr_right_iff]
intro ha
simp [ha]
_ = Ξ½ a := by
rw [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
Β· rw [Measure.map_apply (by fun_prop) (by simp)] at ham
convert ham
ext Ο
simp only [Set.mem_preimage, Set.indicator_apply, Set.mem_setOf_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]Dependency graph
Type dependencies (7)
Algorithmπ
Learning.AlgorithmA stochastic, sequential algorithm.
Learning.Algorithm.{u_4, u_5} (π : Type u_4) (π¨ : Type u_5) [MeasurableSpace π] [MeasurableSpace π¨] : Type (max u_4 u_5)Learning.Algorithm.{u_4, u_5} (π : Type u_4) (π¨ : Type u_5) [MeasurableSpace π] [MeasurableSpace π¨] : Type (max u_4 u_5)
Code
structure Algorithm (π π¨ : Type*) [MeasurableSpace π] [MeasurableSpace π¨] where /-- Policy or sampling rule: distribution of the next action. -/ policy : (n : β) β Kernel (Iic n β π Γ π¨) π /-- The policy is a Markov kernel. -/ [h_policy : β n, IsMarkovKernel (policy n)] /-- Distribution of the first action. -/ p0 : Measure π /-- The first action distribution is a probability measure. -/ [hp0 : IsProbabilityMeasure p0]
Used by (216)
Actions: Source Β· Open Issue
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)))
rewardπ
Bandits.ArrayModel.reward
Reward received at time n in the array model.
Bandits.ArrayModel.reward.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (n : β) (Ο : probSpace π R) : RBandits.ArrayModel.reward.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (n : β) (Ο : probSpace π R) : R
Code
noncomputable def reward [DecidableEq π] (alg : Algorithm π R) (n : β) (Ο : probSpace π R) : R := (hist alg Ο n β¨n, by simpβ©).2
Body uses (1)
Used by (24)
Actions: Source Β· Open Issue
actionπ
Bandits.ArrayModel.action
Action taken at time n in the array model.
Bandits.ArrayModel.action.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (n : β) (Ο : probSpace π R) : πBandits.ArrayModel.action.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (n : β) (Ο : probSpace π R) : π
Code
noncomputable def action [DecidableEq π] (alg : Algorithm π R) (n : β) (Ο : probSpace π R) : π := (hist alg Ο n β¨n, by simpβ©).1
Body uses (1)
Used by (43)
Actions: Source Β· Open Issue
pullCountπ
Learning.pullCount
Number of times action a was chosen up to time t (excluding t).
Learning.pullCount.{u_1, u_3} {π : Type u_1} {Ξ© : Type u_3} [DecidableEq π] (A : β β Ξ© β π) (a : π) (t : β) (Ο : Ξ©) : βLearning.pullCount.{u_1, u_3} {π : Type u_1} {Ξ© : Type u_3} [DecidableEq π] (A : β β Ξ© β π) (a : π) (t : β) (Ο : Ξ©) : β
Code
noncomputable def pullCount (A : β β Ξ© β π) (a : π) (t : β) (Ο : Ξ©) : β := #(filter (fun s β¦ A s Ο = a) (range t))
Actions: Source Β· Open Issue
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 (7)
instIsProbabilityMeasureP0π
Learning.instIsProbabilityMeasureP0No docstring.
Learning.instIsProbabilityMeasureP0.{u_1, u_2} {π : Type u_1} {π¨ : Type u_2} {mπ : MeasurableSpace π} {mπ¨ : MeasurableSpace π¨} (alg : Algorithm π π¨) : MeasureTheory.IsProbabilityMeasure (Algorithm.p0 alg)Learning.instIsProbabilityMeasureP0.{u_1, u_2} {π : Type u_1} {π¨ : Type u_2} {mπ : MeasurableSpace π} {mπ¨ : MeasurableSpace π¨} (alg : Algorithm π π¨) : MeasureTheory.IsProbabilityMeasure (Algorithm.p0 alg)
Code
instance (alg : Algorithm π π¨) : IsProbabilityMeasure alg.p0
Type uses (1)
Used by (13)
Actions: Source Β· Open Issue
Proof
alg.hp0
initAlgFunctionπ
Bandits.ArrayModel.initAlgFunctionThe initial action is the image of a uniform random variable by this function.
Bandits.ArrayModel.initAlgFunction.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] (alg : Learning.Algorithm π R) : βunitInterval β πBandits.ArrayModel.initAlgFunction.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] (alg : Learning.Algorithm π R) : βunitInterval β π
Code
noncomputable def initAlgFunction (alg : Algorithm π R) : I β π := (Measure.exists_measurable_map_eq alg.p0).choose
Type uses (1)
Body uses (1)
Used by (12)
Actions: Source Β· Open Issue
instIsMarkovKernelForallSubtypeNatMemFinsetIicProdPolicyπ
Learning.instIsMarkovKernelForallSubtypeNatMemFinsetIicProdPolicyNo docstring.
Learning.instIsMarkovKernelForallSubtypeNatMemFinsetIicProdPolicy.{u_1, u_2} {π : Type u_1} {π¨ : Type u_2} {mπ : MeasurableSpace π} {mπ¨ : MeasurableSpace π¨} (alg : Algorithm π π¨) (n : β) : ProbabilityTheory.IsMarkovKernel (Algorithm.policy alg n)Learning.instIsMarkovKernelForallSubtypeNatMemFinsetIicProdPolicy.{u_1, u_2} {π : Type u_1} {π¨ : Type u_2} {mπ : MeasurableSpace π} {mπ¨ : MeasurableSpace π¨} (alg : Algorithm π π¨) (n : β) : ProbabilityTheory.IsMarkovKernel (Algorithm.policy alg n)
Code
instance (alg : Algorithm π π¨) (n : β) : IsMarkovKernel (alg.policy n)
Type uses (1)
Actions: Source Β· Open Issue
Proof
alg.h_policy n
algFunctionπ
Bandits.ArrayModel.algFunctionThe next action is the image of the history and a uniform random variable by this function.
Bandits.ArrayModel.algFunction.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] (alg : Learning.Algorithm π R) (n : β) : (β₯(Finset.Iic n) β π Γ R) β βunitInterval β πBandits.ArrayModel.algFunction.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] (alg : Learning.Algorithm π R) (n : β) : (β₯(Finset.Iic n) β π Γ R) β βunitInterval β π
Code
noncomputable
def algFunction (alg : Algorithm π R) (n : β) :
(Iic n β π Γ R) β I β π :=
(Kernel.exists_measurable_map_eq_unitInterval (alg.policy n)).chooseType uses (1)
Body uses (1)
Used by (17)
Actions: Source Β· Open Issue
pullCount'π
Learning.pullCount'
Number of pulls of arm a up to (and including) time n.
This is the number of entries in h in which the arm is a.
Learning.pullCount'.{u_1, u_2} {π : Type u_1} {R : Type u_2} [DecidableEq π] (n : β) (h : β₯(Finset.Iic n) β π Γ R) (a : π) : βLearning.pullCount'.{u_1, u_2} {π : Type u_1} {R : Type u_2} [DecidableEq π] (n : β) (h : β₯(Finset.Iic n) β π Γ R) (a : π) : β
Code
noncomputable
def pullCount' (n : β) (h : Iic n β π Γ R) (a : π) := #{s | (h s).1 = a}Used by (29)
Actions: Source Β· Open Issue
histπ
Bandits.ArrayModel.hist
History of actions and rewards up to time n in the array model.
Bandits.ArrayModel.hist.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (Ο : probSpace π R) (n : β) : β₯(Finset.Iic n) β π Γ RBandits.ArrayModel.hist.{u_1, u_2} {π : Type u_1} {R : Type u_2} {mπ : MeasurableSpace π} {mR : MeasurableSpace R} [Nonempty π] [StandardBorelSpace π] [DecidableEq π] (alg : Learning.Algorithm π R) (Ο : probSpace π R) (n : β) : β₯(Finset.Iic n) β π Γ R
Code
noncomputable def hist [DecidableEq π] (alg : Algorithm π R) (Ο : probSpace π R) : (n : β) β Iic n β π Γ R | 0 => fun _ β¦ (initAlgFunction alg (Ο.1 0), Ο.2 0 (initAlgFunction alg (Ο.1 0))) | n + 1 => let hn : Iic n β π Γ R := hist alg Ο n let a : π := algFunction alg n hn (Ο.1 (n + 1)) fun i β¦ if hin : i β€ n then hn β¨i, by simp [hin]β© else (a, Ο.2 (pullCount' n hn a) a)
Body uses (3)
Used by (30)
Actions: Source Β· Open Issue
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