Learning.eventually_rewardByCountUntil_eq
From the authors
For each entry, rewardByCountUntil A R' t ฯ coincides with rewardByCount for t large
enough.
-
๐ : Type u_2DecidableEq ๐ -
R : Type u_3 -
ฮฉ : Type u_4
-
A : โ โ ฮฉ โ ๐ -
R' : โ โ ฮฉ โ R -
ฯ : ฮฉ ร (โ โ ๐ โ R) -
p : ๐ ร โ
โแถ (t : โ) in Filter.atTop, rewardByCountUntil A R' t ฯ p = rewardByCount A R' p.1 (p.2 + 1) ฯf.Eventually p or โแถ x in f, p x mean that {x | p x} โ f.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 : ฮฑ`.
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.
Prod : Type u โ Type v โ Type (max u v)The product type, usually written `ฮฑ ร ฮฒ`. Product types are also called pair or tuple types. Elements of this type are pairs in which the first element is an `ฮฑ` and the second element is a `ฮฒ`. Products nest to the right, so `(x, y, z) : ฮฑ ร ฮฒ ร ฮณ` is equivalent to `(x, (y, z)) : ฮฑ ร (ฮฒ ร ฮณ)`. Conventions for notations in identifiers: * The recommended spelling of `ร` in identifiers is `Prod`.
Filter.Eventually : {ฮฑ : Type u_1} โ (ฮฑ โ Prop) โ Filter ฮฑ โ Prop`f.Eventually p` or `โแถ x in f, p x` mean that `{x | p x} โ f`. E.g., `โแถ x in atTop, p x`
means that `p` holds true for sufficiently large `x`.Filter.atTop : {ฮฑ : Type u_2} โ [Preorder ฮฑ] โ Filter ฮฑ`atTop` is the filter representing the limit `โ โ` on an ordered set.
It is generated by the collection of up-sets `{b | a โค b}`.
(The preorder need not have a top element for this to be well defined,
and indeed is trivial when a top element `x` exists, i.e., it coincides with `pure x`.)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
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`.Learning.rewardByCount : {๐ : Type u_2} โ
{R : Type u_3} โ {ฮฉ : Type u_4} โ [DecidableEq ๐] โ (โ โ ฮฉ โ ๐) โ (โ โ ฮฉ โ R) โ ๐ โ โ โ ฮฉ ร (โ โ ๐ โ R) โ RReward obtained when pulling action `a` for the `m`-th time. If it is never pulled `m` times, the reward is given by the second component of `ฯ`, which in applications will be indepedent with same law.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`.
Code
lemma eventually_rewardByCountUntil_eq (ฯ : ฮฉ ร (โ โ ๐ โ R)) (p : ๐ ร โ) :
โแถ t in Filter.atTop,
rewardByCountUntil A R' t ฯ p = rewardByCount A R' p.1 (p.2 + 1) ฯProof
by
obtain โจa, mโฉ := p
by_cases h : โ t, m < pullCount A a t ฯ.1
ยท obtain โจt, htโฉ := h
filter_upwards [Filter.eventually_ge_atTop t] with s hs
exact rewardByCountUntil_apply_of_lt_pullCount (ht.trans_le (pullCount_mono a hs ฯ.1))
ยท push Not at h
refine Filter.Eventually.of_forall fun t โฆ ?_
rw [rewardByCountUntil_apply_of_pullCount_le (h t), rewardByCount_of_stepsUntil_eq_top]
rw [stepsUntil_eq_top_iff]
exact fun s โฆ ((h (s + 1)).trans_lt (Nat.lt_succ_self m)).neMeaning last changed in v4.34.0-rc2-76-g565f652 (2026-09-10).
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: 4 project declarations, 44 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.