LeanMachineLearning

Learning.pullCount_le_add๐Ÿ”—

Lemma

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
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_ofPred_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_ofPred_eq, Pi.one_apply]
        grind
      ยท refine le_trans ?_ hn
        simp [h_pc]

Actions: Source ยท Open Issue

Meaning unchanged since v4.33.0-rc1-29-gce231eb, the oldest revision on record (2026-07-30).

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: 1 project declarations, 25 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.