Learning.setOf_action_eq_and_pullCount_eq_eq_preimage
From the authors
The event that the action at time n is b and that b was pulled k times before is
a preimage by ((history O A R' n, O n), A n).
-
๐ : Type u_1 -
๐ : Type u_2DecidableEq ๐ -
R : Type u_3 -
ฮฉ : Type u_4
-
O : โ โ ฮฉ โ ๐ -
A : โ โ ฮฉ โ ๐ -
R' : โ โ ฮฉ โ R -
n : โ -
b : ๐ -
k : โ
{x | A n x = b โง pullCount A b n x = k} =
(fun x => ((history O A R' n x, O n x), A n x)) โปยน' {u | u.2 = b โง pullCount' n u.1.1 b = k}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.
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`.Set.ofPred : {ฮฑ : Type u} โ (ฮฑ โ Prop) โ Set ฮฑTurn a predicate `p : ฮฑ โ Prop` into a set, also written as `{x | p x}`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
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`.
Learning.history : {๐ : Type u_1} โ
{๐ : Type u_2} โ
{๐จ : Type u_3} โ {ฮฉ : Type u_4} โ (โ โ ฮฉ โ ๐) โ (โ โ ฮฉ โ ๐) โ (โ โ ฮฉ โ ๐จ) โ (n : โ) โ ฮฉ โ Learning.Hist ๐ ๐ ๐จ nHistory of the algorithm-environment sequence before time `n`: the rounds at times `0, ..., n - 1`.Go to its page
Set.preimage : {ฮฑ : Type u} โ {ฮฒ : Type v} โ (ฮฑ โ ฮฒ) โ Set ฮฒ โ Set ฮฑThe preimage of `s : Set ฮฒ` by `f : ฮฑ โ ฮฒ`, written `f โปยน' s`, is the set of `x : ฮฑ` such that `f x โ s`.
Learning.pullCount' : {๐ : Type u_1} โ {๐ : Type u_2} โ {R : Type u_3} โ [DecidableEq ๐] โ (n : โ) โ Learning.Hist ๐ ๐ R n โ ๐ โ โNumber of pulls of arm `a` in the history before time `n`. This is the number of entries in `h` in which the arm is `a`.Go to its page
Code
lemma setOf_action_eq_and_pullCount_eq_eq_preimage (n : โ) (b : ๐) (k : โ) :
{x | A n x = b โง pullCount A b n x = k}
= (fun x โฆ ((history O A R' n x, O n x), A n x))
โปยน' {u | u.2 = b โง pullCount' n u.1.1 b = k}Proof
by ext x simp only [Set.mem_ofPred_eq, Set.mem_preimage] rw [pullCount_eq_pullCount' (O := O) (R' := R')]
Meaning last changed in v4.35.0-rc2-1-g61e506b (2026-09-22), 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: 6 project declarations, 18 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.