Bandits.hasLaw_reward_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 reward at time t has 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. -
Ω : 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. -
hP : P {x | A t x = b ∧ Learning.pullCount A b t x = k} ≠ 0
ProbabilityTheory.HasLaw (R t) (ν b) P[|{x | A t x = b ∧ Learning.pullCount A b t x = k}]The predicate HasLaw X μ P registers the fact that the random variable X has law μ under the measure P, in other words that P.map X = μ.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.
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
Ne : {α : Sort u} → α → α → Prop`a ≠ b`, or `Ne a b` is defined as `¬ (a = b)` or `a = b → False`, and asserts that `a` and `b` are not equal. Conventions for notations in identifiers: * The recommended spelling of `≠` in identifiers is `ne`.
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
ProbabilityTheory.HasLaw : {Ω : Type u_1} →
{𝓧 : Type u_2} →
{mΩ : MeasurableSpace Ω} →
{m𝓧 : MeasurableSpace 𝓧} →
(Ω → 𝓧) → MeasureTheory.Measure 𝓧 → autoParam (MeasureTheory.Measure Ω) ProbabilityTheory.HasLaw._auto_1 → PropThe predicate `HasLaw X μ P` registers the fact that the random variable `X` has law `μ` under the measure `P`, in other words that `P.map X = μ`. We also require `X` to be `AEMeasurable`, to allow for nice interactions with operations on the codomain of `X`. See for instance `HasLaw.comp`, `IndepFun.hasLaw_mul` and `IndepFun.hasLaw_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`.
Code
lemma hasLaw_reward_cond (h : IsAlgEnvSeq O A R alg (stationaryEnv ν) P) (t : ℕ) (b : 𝓐) (k : ℕ)
(hP : P {x | A t x = b ∧ pullCount A b t x = k} ≠ 0) :
HasLaw (R t) (ν b) (P[|{x | A t x = b ∧ pullCount A b t x = k}])Proof
by
rw [setOf_action_eq_and_pullCount_eq_eq_preimage (O := O) (R' := R)] at hP ⊢
exact h.hasLaw_feedback_cond_stationaryEnv t (measurableSet_snd_eq_and_pullCount'_eq t b k)
(fun u hu ↦ hu.1) hPMeaning 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: 9 project declarations, 53 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.