LeanMachineLearning exposition

Learning.pullCount_stepsUntil๐Ÿ”—

This page has the declaration's own card below, then its dependency graph, then a card for each dependency (type dependencies first, then the rest of the transitive closure). For a theorem, the graph and the dependency cards only follow its statement's dependencies (its proof is replaced by sorry, so what it proves doesn't depend on how); for everything else, both the type and the body/value are followed, since their content is part of what later declarations build on.

Minimal Lean file

pullCount_stepsUntil๐Ÿ”—

LemmaLearning.pullCount_stepsUntil

No docstring.

๐Ÿ”—theorem
Learning.pullCount_stepsUntil.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h_exists : โˆƒ s, pullCount A a (s + 1) ฯ‰ = m) : pullCount A a (ENat.toNat (stepsUntil A a m ฯ‰)) ฯ‰ = m - 1
Learning.pullCount_stepsUntil.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h_exists : โˆƒ s, pullCount A a (s + 1) ฯ‰ = m) : pullCount A a (ENat.toNat (stepsUntil A a m ฯ‰)) ฯ‰ = m - 1

Code

lemma pullCount_stepsUntil (hm : m โ‰  0) (h_exists : โˆƒ s, pullCount A a (s + 1) ฯ‰ = m) :
    pullCount A a (stepsUntil A a m ฯ‰).toNat ฯ‰ = m - 1
Type uses (2)
Body uses (4)
Used by (1)

Actions: Source ยท Open Issue

Proof
by
  have h_action := action_eq_of_stepsUntil_eq_coe (A := A) (n := (stepsUntil A a m ฯ‰).toNat)
    (a := a) (ฯ‰ := ฯ‰) hm ?_
  swap; ยท symm; simpa [stepsUntil_eq_top_iff]
  have h_add_one := pullCount_stepsUntil_add_one h_exists
  nth_rw 1 [โ† h_action] at h_add_one
  rw [ENat.toNat_add ?_ (by simp), ENat.toNat_one, pullCount_action_eq_pullCount_add_one]
    at h_add_one
  swap; ยท simpa [stepsUntil_eq_top_iff]
  grind

Dependency graph

Type dependencies (2)

pullCount๐Ÿ”—

DefinitionLearning.pullCount

Number of times action a was chosen up to time t (excluding t).

๐Ÿ”—def
Learning.pullCount.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) : โ„•
Learning.pullCount.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) : โ„•

Code

noncomputable
def pullCount (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) : โ„• :=
  #(filter (fun s โ†ฆ A s ฯ‰ = a) (range t))
Used by (146)

Actions: Source ยท Open Issue

stepsUntil๐Ÿ”—

DefinitionLearning.stepsUntil

Number of steps until action a was pulled exactly m times.

๐Ÿ”—def
Learning.stepsUntil.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ) : โ„•โˆž
Learning.stepsUntil.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ) : โ„•โˆž

Code

noncomputable
def stepsUntil (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ) : โ„•โˆž :=
  sInf ((โ†‘) '' {s | pullCount A a (s + 1) ฯ‰ = m})
Body uses (1)
Used by (46)

Actions: Source ยท Open Issue