Bandits.identDistrib_rewardByCountUntil_add_one_cond
From the authors
Conditionally on the event that the action at time t is b and that b was pulled k
times before, the arrays rewardByCountUntil A R (t + 1) and rewardByCountUntil A R t have the
same law: they differ only in the entry (b, k), which is R t in the first and an auxiliary
reward in the second, and both are independent of the rest of the array with law Ξ½ b.
-
π : Type u_1mπ : MeasurableSpace πA measurable space is a space equipped with a Ο-algebra.DecidableEq πMeasurableSingletonClass πA typeclass mixin forMeasurableSpaces such that each singleton is measurable.Countable πA typeΞ±is countable if there exists an injective mapΞ± β β. -
Ξ© : Type u_2mΞ© : MeasurableSpace Ξ©
-
O : β β Ξ© β Unit -
A : β β Ξ© β π -
R : β β Ξ© β β -
P : MeasureTheory.Measure Ξ©A measure is defined to be an outer measure that is countably additive on measurable sets, with the additional assumption that the outer measure is the canonical extension of the restricted measure.MeasureTheory.IsProbabilityMeasure PA measureΞΌis called a probability measure ifΞΌ univ = 1. -
alg : Learning.Algorithm Unit π βA stochastic, sequential algorithm. -
Ξ½ : ProbabilityTheory.Kernel π βA kernel from a measurable spaceΞ±to another measurable spaceΞ²is a measurable functionΞΊ : Ξ± β Measure Ξ².ProbabilityTheory.IsMarkovKernel Ξ½A kernel is a Markov kernel if every measure in its image is a probability measure. -
t : β -
b : π -
k : β
-
h : Learning.IsAlgEnvSeq O A R alg (Learning.stationaryEnv Ξ½) PAn algorithm-environment sequence: a sequence of observations, actions and feedbacks generated by an algorithm interacting with an environment.
ProbabilityTheory.IdentDistrib (Learning.rewardByCountUntil A R (t + 1)) (Learning.rewardByCountUntil A R t)
(P[|{x | A t x = b β§ Learning.pullCount A b t x = k}].prod (streamMeasure Ξ½))
(P[|{x | A t x = b β§ Learning.pullCount A b t x = k}].prod (streamMeasure Ξ½))Two functions defined on two (possibly different) measure spaces are identically distributed if their image measures coincide.MeasurableSpace : Type u_6 β Type u_6A measurable space is a space equipped with a Ο-algebra.
DecidableEq : Sort u β Sort (max 1 u)Propositional equality is `Decidable` for all elements of a type. In other words, an instance of `DecidableEq Ξ±` is a means of deciding the proposition `a = b` is for all `a b : Ξ±`.
MeasurableSingletonClass : (Ξ± : Type u_6) β [MeasurableSpace Ξ±] β PropA typeclass mixin for `MeasurableSpace`s such that each singleton is measurable.
Countable : Sort u β PropA type `Ξ±` is countable if there exists an injective map `Ξ± β β`.
Unit : TypeThe canonical type with one element. This element is written `()`. `Unit` has a number of uses: * It can be used to model control flow that returns from a function call without providing other information. * Monadic actions that return `Unit` have side effects without computing values. * In polymorphic types, it can be used to indicate that no data is to be stored in a particular field.
Nat : TypeThe natural numbers, starting at zero. This type is special-cased by both the kernel and the compiler, and overridden with an efficient implementation. Both use a fast arbitrary-precision arithmetic library (usually [GMP](https://gmplib.org/)); at runtime, `Nat` values that are sufficiently small are unboxed.
Real : TypeThe type `β` of real numbers constructed as equivalence classes of Cauchy sequences of rational numbers.
MeasureTheory.IsProbabilityMeasure : {Ξ± : Type u_1} β {m0 : MeasurableSpace Ξ±} β MeasureTheory.Measure Ξ± β PropA measure `ΞΌ` is called a probability measure if `ΞΌ univ = 1`.
MeasureTheory.Measure : (Ξ± : Type u_5) β [MeasurableSpace Ξ±] β Type u_5A measure is defined to be an outer measure that is countably additive on measurable sets, with the additional assumption that the outer measure is the canonical extension of the restricted measure. The measure of a set `s`, denoted `ΞΌ s`, is an extended nonnegative real. The real-valued version is written `ΞΌ.real s`.
Learning.Algorithm : (π : Type u_5) β
(π : Type u_6) β
(π¨ : Type u_7) β [MeasurableSpace π] β [MeasurableSpace π] β [MeasurableSpace π¨] β Type (max (max u_5 u_6) u_7)A stochastic, sequential algorithm. At each round, it sees an observation in `π`, then takes an action in `π`, and finally receives feedback in `π¨`. The action is a random function of the past rounds and the current observation.Go to its page
ProbabilityTheory.IsMarkovKernel : {Ξ± : Type u_1} β
{Ξ² : Type u_2} β {mΞ± : MeasurableSpace Ξ±} β {mΞ² : MeasurableSpace Ξ²} β ProbabilityTheory.Kernel Ξ± Ξ² β PropA kernel is a Markov kernel if every measure in its image is a probability measure.
ProbabilityTheory.Kernel : (Ξ± : Type u_1) β (Ξ² : Type u_2) β [MeasurableSpace Ξ±] β [MeasurableSpace Ξ²] β Type (max u_1 u_2)A kernel from a measurable space `Ξ±` to another measurable space `Ξ²` is a measurable function `ΞΊ : Ξ± β Measure Ξ²`. The measurable space structure on `MeasureTheory.Measure Ξ²` is given by `MeasureTheory.Measure.instMeasurableSpace`. A map `ΞΊ : Ξ± β MeasureTheory.Measure Ξ²` is measurable iff `β s : Set Ξ², MeasurableSet s β Measurable (fun a β¦ ΞΊ a s)`.
Learning.IsAlgEnvSeq : {π : Type u_1} β
{π : Type u_2} β
{π¨ : Type u_3} β
{Ξ© : Type u_4} β
{mπ : MeasurableSpace π} β
{mπ : MeasurableSpace π} β
{mπ¨ : MeasurableSpace π¨} β
{mΞ© : MeasurableSpace Ξ©} β
(β β Ξ© β π) β
(β β Ξ© β π) β
(β β Ξ© β π¨) β
Learning.Algorithm π π π¨ ββ¦An algorithm-environment sequence: a sequence of observations, actions and feedbacks generated by an algorithm interacting with an environment.Go to its page
Learning.stationaryEnv : {π : Type u_2} β
{π¨ : Type u_3} β
{mπ : MeasurableSpace π} β
{mπ¨ : MeasurableSpace π¨} β
(Ξ½ : ProbabilityTheory.Kernel π π¨) β [ProbabilityTheory.IsMarkovKernel Ξ½] β Learning.Environment Unit π π¨A stationary environment without observations, in which the distribution of the next feedback depends only on the last action.Go to its page
ProbabilityTheory.IdentDistrib : {Ξ± : Type u_1} β
{Ξ² : Type u_2} β
{Ξ³ : Type u_3} β
[inst : MeasurableSpace Ξ±] β
[inst_1 : MeasurableSpace Ξ²] β
[MeasurableSpace Ξ³] β
(Ξ± β Ξ³) β
(Ξ² β Ξ³) β
autoParam (MeasureTheory.Measure Ξ±) ProbabilityTheory.IdentDistrib._auto_1 β
autoParam (MeasureTheory.Measure Ξ²) ProbabilityTheory.IdentDistrib._auto_3 β Proβ¦Two functions defined on two (possibly different) measure spaces are identically distributed if their image measures coincide. This only makes sense when the functions are ae measurable (as otherwise the image measures are not defined), so we require this as well in the definition.
Learning.rewardByCountUntil : {π : Type u_2} β
{R : Type u_3} β {Ξ© : Type u_4} β [DecidableEq π] β (β β Ξ© β π) β (β β Ξ© β R) β β β Ξ© Γ (β β π β R) β π Γ β β RArray of rewards by count, truncated at time `t`: the entry `(a, m)` is the reward received at the `(m + 1)`-th pull of action `a` if that pull happened before time `t`, and the entry `(m + 1, a)` of the auxiliary array `Ο.2` otherwise. This is an auxiliary definition used to prove results about the distribution of `rewardByCount`. It is defined recursively: at time `t`, the entry `(A t, pullCount A (A t) t)` is replaced by the reward `R' t`. See `rewardByCountUntil_apply_of_lt_pullCount` and `rewardByCountUntil_apply_of_pullCount_le`.Go to its page
HAdd.hAdd : {Ξ± : Type u} β {Ξ² : Type v} β {Ξ³ : outParam (Type w)} β [self : HAdd Ξ± Ξ² Ξ³] β Ξ± β Ξ² β Ξ³`a + b` computes the sum of `a` and `b`. The meaning of this notation is type-dependent. Conventions for notations in identifiers: * The recommended spelling of `+` in identifiers is `add`.
ProbabilityTheory.cond : {Ξ© : Type u_1} β {m : MeasurableSpace Ξ©} β MeasureTheory.Measure Ξ© β Set Ξ© β MeasureTheory.Measure Ξ©The conditional probability measure of measure `ΞΌ` on set `s` is `ΞΌ` restricted to `s` and scaled by the inverse of `ΞΌ s` (to make it a probability measure): `(ΞΌ s)β»ΒΉ β’ ΞΌ.restrict s`.
Set.ofPred : {Ξ± : Type u} β (Ξ± β Prop) β Set Ξ±Turn a predicate `p : Ξ± β Prop` into a set, also written as `{x | p x}`Eq : {Ξ± : Sort u_1} β Ξ± β Ξ± β PropThe equality relation. It has one introduction rule, `Eq.refl`.
We use `a = b` as notation for `Eq a b`.
A fundamental property of equality is that it is an equivalence relation.
```
variable (Ξ± : Type) (a b c d : Ξ±)
variable (hab : a = b) (hcb : c = b) (hcd : c = d)
example : a = d :=
Eq.trans (Eq.trans hab (Eq.symm hcb)) hcd
```
Equality is much more than an equivalence relation, however. It has the important property that every assertion
respects the equivalence, in the sense that we can substitute equal expressions without changing the truth value.
That is, given `h1 : a = b` and `h2 : p a`, we can construct a proof for `p b` using substitution: `Eq.subst h1 h2`.
Example:
```
example (Ξ± : Type) (a b : Ξ±) (p : Ξ± β Prop)
(h1 : a = b) (h2 : p a) : p b :=
Eq.subst h1 h2
example (Ξ± : Type) (a b : Ξ±) (p : Ξ± β Prop)
(h1 : a = b) (h2 : p a) : p b :=
h1 βΈ h2
```
The triangle in the second presentation is a macro built on top of `Eq.subst` and `Eq.symm`, and you can enter it by typing `\t`.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)
Conventions for notations in identifiers:
* The recommended spelling of `=` in identifiers is `eq`.And : Prop β Prop β Prop`And a b`, or `a β§ b`, is the conjunction of propositions. It can be constructed and destructed like a pair: if `ha : a` and `hb : b` then `β¨ha, hbβ© : a β§ b`, and if `h : a β§ b` then `h.left : a` and `h.right : b`. Conventions for notations in identifiers: * The recommended spelling of `β§` in identifiers is `and`.
Learning.pullCount : {π : Type u_2} β {Ξ© : Type u_4} β [DecidableEq π] β (β β Ξ© β π) β π β β β Ξ© β βNumber of times action `a` was chosen up to time `t` (excluding `t`).Go to its page
MeasureTheory.Measure.prod : {Ξ± : Type u_4} β
{Ξ² : Type u_5} β
[inst : MeasurableSpace Ξ±] β
[inst_1 : MeasurableSpace Ξ²] β MeasureTheory.Measure Ξ± β MeasureTheory.Measure Ξ² β MeasureTheory.Measure (Ξ± Γ Ξ²)The binary product of measures. They are defined for arbitrary measures, but we basically prove all properties under the assumption that at least one of them is s-finite.
Bandits.streamMeasure : {π : Type u_1} β
{π‘ : Type u_2} β
{mπ : MeasurableSpace π} β
{mπ‘ : MeasurableSpace π‘} β ProbabilityTheory.Kernel π π‘ β MeasureTheory.Measure (β β π β π‘)Measure of an infinite stream of rewards from each action.Go to its page
Code
lemma identDistrib_rewardByCountUntil_add_one_cond (h : IsAlgEnvSeq O A R alg (stationaryEnv Ξ½) P)
(t : β) (b : π) (k : β) :
IdentDistrib (rewardByCountUntil A R (t + 1)) (rewardByCountUntil A R t)
((P[|{x | A t x = b β§ pullCount A b t x = k}]).prod (streamMeasure Ξ½))
((P[|{x | A t x = b β§ pullCount A b t x = k}]).prod (streamMeasure Ξ½))Proof
by
have hA := h.measurable_action
have hR := h.measurable_feedback
set Eβ := {x | A t x = b β§ pullCount A b t x = k} with hEβ
have hEβ_meas : MeasurableSet Eβ := measurableSet_action_eq_and_pullCount_eq hA t b k
by_cases hP : P Eβ = 0
Β· rw [cond_eq_zero.2 (Or.inr hP), Measure.zero_prod]
exact β¨(measurable_rewardByCountUntil hA hR _).aemeasurable,
(measurable_rewardByCountUntil hA hR _).aemeasurable, by simpβ©
have : IsProbabilityMeasure (P[|Eβ]) := cond_isProbabilityMeasure hP
set ΞΌ' := (P[|Eβ]).prod (streamMeasure Ξ½) with hΞΌ'
have h_ae : βα΅ Ο βΞΌ', A t Ο.1 = b β§ pullCount A b t Ο.1 = k := by
rw [ae_iff]
have h_set : {Ο : Ξ© Γ (β β π β β) | Β¬ (A t Ο.1 = b β§ pullCount A b t Ο.1 = k)}
= EβαΆ ΓΛ’ Set.univ := by
ext Ο
simp [hEβ]
rw [h_set, hΞΌ', Measure.prod_prod, cond_apply hEβ_meas, Set.inter_compl_self, measure_empty,
mul_zero, zero_mul]
set W : Ξ© Γ (β β π β β) β π Γ β β β :=
fun Ο β¦ Function.update (rewardByCountUntil A R t Ο) (b, k) 0 with hW
have hWm : Measurable W := measurable_update_left.comp (measurable_rewardByCountUntil hA hR t)
have h1 : rewardByCountUntil A R (t + 1)
=α΅[ΞΌ'] fun Ο β¦ Function.update (W Ο) (b, k) (R t Ο.1) := by
filter_upwards [h_ae] with Ο hΟ
obtain β¨hb, hkβ© := hΟ
simp only [hW, rewardByCountUntil_add_one, Function.update_idem, hb, hk]
have h2 : rewardByCountUntil A R t
=α΅[ΞΌ'] fun Ο β¦ Function.update (W Ο) (b, k) (Ο.2 (k + 1) b) := by
filter_upwards [h_ae] with Ο hΟ
obtain β¨hb, hkβ© := hΟ
simp only [hW, Function.update_idem]
rw [β rewardByCountUntil_apply_of_pullCount_le hk.le, Function.update_eq_self]
-- both `(W, R t)` and `(W, Ο.2 (k + 1) b)` have law `(ΞΌ'.map W).prod (Ξ½ b)`
have hW : HasLaw W (ΞΌ'.map W) ΞΌ' := hWm.hasLaw_map ΞΌ'
have h1' : HasLaw (fun Ο β¦ Function.update (W Ο) (b, k) (R t Ο.1))
(((ΞΌ'.map W).prod (Ξ½ b)).map
fun q : (π Γ β β β) Γ β β¦ Function.update q.1 (b, k) q.2) ΞΌ' :=
((measurable_update' (a := (b, k))).hasLaw_map _).comp
((indepFun_update_rewardByCountUntil_reward h t b k).hasLaw_prod hW
(hasLaw_reward_cond_prod h t b k hP))
have h2' : HasLaw (fun Ο : Ξ© Γ (β β π β β) β¦ Function.update (W Ο) (b, k) (Ο.2 (k + 1) b))
(((ΞΌ'.map W).prod (Ξ½ b)).map
fun q : (π Γ β β β) Γ β β¦ Function.update q.1 (b, k) q.2) ΞΌ' :=
((measurable_update' (a := (b, k))).hasLaw_map _).comp
((indepFun_update_rewardByCountUntil_eval hA hR _ t b k).hasLaw_prod hW
(hasLaw_snd_apply_prod_streamMeasure _ _ _ _))
exact ((IdentDistrib.of_ae_eq (measurable_rewardByCountUntil hA hR _).aemeasurable h1).trans
(h1'.identDistrib h2')).trans
(IdentDistrib.of_ae_eq (measurable_rewardByCountUntil hA hR _).aemeasurable h2).symmMeaning last changed in v4.34.0-rc2-76-g565f652 (2026-09-10), the 3th 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: 11 project declarations, 64 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.