LeanMachineLearning exposition

Learning.pullCount_le_add๐Ÿ”—

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_le_add๐Ÿ”—

LemmaLearning.pullCount_le_add

No docstring.

๐Ÿ”—theorem
Learning.pullCount_le_add.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (n C : โ„•) (ฯ‰ : ฮฉ) : pullCount A a n ฯ‰ โ‰ค C + 1 + โˆ‘ s โˆˆ Finset.range n, Set.indicator {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰} 1 s
Learning.pullCount_le_add.{u_1, u_3} {๐“ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (n C : โ„•) (ฯ‰ : ฮฉ) : pullCount A a n ฯ‰ โ‰ค C + 1 + โˆ‘ s โˆˆ Finset.range n, Set.indicator {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰} 1 s

Code

lemma pullCount_le_add (a : ๐“) (n C : โ„•) (ฯ‰ : ฮฉ) :
    pullCount A a n ฯ‰ โ‰ค C + 1 +
      โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰}.indicator 1 s
Type uses (1)
Body uses (1)
Used by (1)

Actions: Source ยท Open Issue

Proof
by
  rw [pullCount_eq_sum]
  calc โˆ‘ s โˆˆ range n, if A s ฯ‰ = a then 1 else 0
  _ โ‰ค โˆ‘ s โˆˆ range n, ({s | A s ฯ‰ = a โˆง pullCount A a s ฯ‰ โ‰ค C}.indicator 1 s +
      {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰}.indicator 1 s) := by
    gcongr with s hs
    simp [Set.indicator_apply]
    grind
  _ = โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง pullCount A a s ฯ‰ โ‰ค C}.indicator 1 s +
      โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰}.indicator 1 s := by
    rw [Finset.sum_add_distrib]
  _ โ‰ค C + 1 + โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰}.indicator 1 s := by
    gcongr
    have h_le n : โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง pullCount A a s ฯ‰ โ‰ค C}.indicator 1 s โ‰ค
        pullCount A a n ฯ‰ := by
      rw [pullCount_eq_sum]
      gcongr with s hs
      simp only [Set.indicator_apply, Set.mem_setOf_eq, Pi.one_apply]
      grind
    induction n with
    | zero => simp
    | succ n hn =>
      rw [Finset.sum_range_succ]
      rcases le_or_gt (pullCount A a n ฯ‰) C with h_pc | h_pc
      ยท have hn' : โˆ‘ s โˆˆ range n, {s | A s ฯ‰ = a โˆง pullCount A a s ฯ‰ โ‰ค C}.indicator 1 s โ‰ค C :=
          (h_le n).trans h_pc
        grw [hn']
        gcongr
        simp only [Set.indicator_apply, Set.mem_setOf_eq, Pi.one_apply]
        grind
      ยท refine le_trans ?_ hn
        simp [h_pc]

Dependency graph

Type dependencies (1)

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