Bandits.indepFun_update_rewardByCountUntil_reward
From the authors
Conditionally on the event that the action at time t is b and that b was pulled k
times before, the array rewardByCountUntil A R t with the entry (b, k) erased is independent of
the reward at time t.
-
๐ : 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.IndepFun (fun ฯ => Function.update (Learning.rewardByCountUntil A R t ฯ) (b, k) 0) (fun ฯ => R t ฯ.1)
(P[|{x | A t x = b โง Learning.pullCount A b t x = k}].prod (streamMeasure ฮฝ))Two functions are independent if the two measurable space structures they generate are independent.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.IndepFun : {ฮฉ : Type u_1} โ
{ฮฒ : Type u_6} โ
{ฮณ : Type u_7} โ
{_mฮฉ : MeasurableSpace ฮฉ} โ
[MeasurableSpace ฮฒ] โ
[MeasurableSpace ฮณ] โ
(ฮฉ โ ฮฒ) โ (ฮฉ โ ฮณ) โ autoParam (MeasureTheory.Measure ฮฉ) ProbabilityTheory.IndepFun._auto_1 โ PropTwo functions are independent if the two measurable space structures they generate are independent. For a function `f` with codomain having measurable space structure `m`, the generated measurable space structure is `MeasurableSpace.comap f m`. We use the notation `f โแตข[ฮผ] g` for `IndepFun f g ฮผ` (scoped in `ProbabilityTheory`).
Function.update : {ฮฑ : Sort u} โ {ฮฒ : ฮฑ โ Sort v} โ [DecidableEq ฮฑ] โ ((a : ฮฑ) โ ฮฒ a) โ (a' : ฮฑ) โ ฮฒ a' โ (a : ฮฑ) โ ฮฒ aReplacing the value of a function at a given point by a given value.
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
Prod.mk : {ฮฑ : Type u} โ {ฮฒ : Type v} โ ฮฑ โ ฮฒ โ ฮฑ ร ฮฒConstructs a pair. This is usually written `(x, y)` instead of `Prod.mk x y`. Conventions for notations in identifiers: * The recommended spelling of `(a, b)` in identifiers is `mk`.
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 indepFun_update_rewardByCountUntil_reward (h : IsAlgEnvSeq O A R alg (stationaryEnv ฮฝ) P)
(t : โ) (b : ๐) (k : โ) :
(fun ฯ โฆ Function.update (rewardByCountUntil A R t ฯ) (b, k) 0)
โแตข[(P[|{x | A t x = b โง pullCount A b t x = k}]).prod (streamMeasure ฮฝ)]
(fun ฯ โฆ R t ฯ.1)Proof
by
have hA := h.measurable_action
have hR := h.measurable_feedback
by_cases hP : P {x | A t x = b โง pullCount A b t x = k} = 0
ยท rw [cond_eq_zero.2 (Or.inr hP), Measure.zero_prod]
exact indepFun_zero_measure _ _
have : IsProbabilityMeasure (P[|{x | A t x = b โง pullCount A b t x = k}]) :=
cond_isProbabilityMeasure hP
have h_indep := (indepFun_history_reward_cond h t b k).symm.fst_prod
(ฮฝ := streamMeasure ฮฝ) (hR t) (by fun_prop)
refine (h_indep.of_measurable_right ?_).symm
refine Measurable.comp measurable_update_left ?_
refine measurable_rewardByCountUntil_of t (fun i hi โฆ ?_) (fun i hi โฆ ?_) ?_
ยท exact measurable_comp_comap
(fun ฯ : ฮฉ ร (โ โ ๐ โ โ) โฆ (((history O A R t ฯ.1, O t ฯ.1), A t ฯ.1), ฯ.2))
(g := fun v : ((Hist Unit ๐ โ t ร Unit) ร ๐) ร (โ โ ๐ โ โ) โฆ (v.1.1.1 โจi, hiโฉ).action)
(by fun_prop)
ยท exact measurable_comp_comap
(fun ฯ : ฮฉ ร (โ โ ๐ โ โ) โฆ (((history O A R t ฯ.1, O t ฯ.1), A t ฯ.1), ฯ.2))
(g := fun v : ((Hist Unit ๐ โ t ร Unit) ร ๐) ร (โ โ ๐ โ โ) โฆ (v.1.1.1 โจi, hiโฉ).feedback)
(by fun_prop)
ยท exact measurable_comp_comap
(fun ฯ : ฮฉ ร (โ โ ๐ โ โ) โฆ (((history O A R t ฯ.1, O t ฯ.1), A t ฯ.1), ฯ.2))
(g := fun v : ((Hist Unit ๐ โ t ร Unit) ร ๐) ร (โ โ ๐ โ โ) โฆ v.2) measurable_sndMeaning 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, 66 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.