Documentation

LeanMachineLearning.SequentialLearning.FiniteActions

Bookkeeping definitions for finite action space sequential learning problems #

If the number of actions is finite, it makes sense to define the number of times each action was chosen, the time at which an action was chosen for the nth time, the value of the reward at that time, the sum of rewards obtained for each action, the empirical mean reward for each action, etc.

For each definition that take as arguments a time t : โ„•, a history h : โ„• โ†’ ๐“ ร— R, and possibly other parameters, we put the time and history at the end in this order, so that the definition can be seen as a stochastic process indexed by time t on the measurable space โ„• โ†’ ๐“ ร— R.

noncomputable def Learning.pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) :

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

Equations
Instances For
    noncomputable def Learning.pullCount' {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} [DecidableEq ๐“] (n : โ„•) (h : Hist ๐“ž ๐“ R n) (a : ๐“) :

    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.

    Equations
    Instances For
      @[simp]
      theorem Learning.pullCount_zero {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) :
      pullCount A a 0 = 0
      theorem Learning.pullCount_zero_apply {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (ฯ‰ : ฮฉ) :
      pullCount A a 0 ฯ‰ = 0
      theorem Learning.pullCount_one {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {ฯ‰ : ฮฉ} :
      pullCount A a 1 ฯ‰ = if A 0 ฯ‰ = a then 1 else 0
      theorem Learning.monotone_pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (ฯ‰ : ฮฉ) :
      Monotone fun (x : โ„•) => pullCount A a x ฯ‰
      theorem Learning.pullCount_mono {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) {n m : โ„•} (hnm : n โ‰ค m) (ฯ‰ : ฮฉ) :
      pullCount A a n ฯ‰ โ‰ค pullCount A a m ฯ‰
      theorem Learning.pullCount_action_eq_pullCount_add_one {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (t : โ„•) (ฯ‰ : ฮฉ) :
      pullCount A (A t ฯ‰) (t + 1) ฯ‰ = pullCount A (A t ฯ‰) t ฯ‰ + 1
      theorem Learning.pullCount_eq_pullCount_of_action_ne {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {t : โ„•} {ฯ‰ : ฮฉ} (ha : A t ฯ‰ โ‰  a) :
      pullCount A a (t + 1) ฯ‰ = pullCount A a t ฯ‰
      theorem Learning.pullCount_add_one {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {t : โ„•} {ฯ‰ : ฮฉ} :
      pullCount A a (t + 1) ฯ‰ = pullCount A a t ฯ‰ + if A t ฯ‰ = a then 1 else 0
      theorem Learning.pullCount_eq_sum {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) :
      pullCount A a t ฯ‰ = โˆ‘ s โˆˆ Finset.range t, if A s ฯ‰ = a then 1 else 0
      theorem Learning.pullCount'_eq_sum {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} [DecidableEq ๐“] (n : โ„•) (h : Hist ๐“ž ๐“ R n) (a : ๐“) :
      pullCount' n h a = โˆ‘ s : Fin n, if (h s).action = a then 1 else 0
      theorem Learning.pullCount_eq_pullCount' {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {n : โ„•} {ฯ‰ : ฮฉ} :
      pullCount A a n ฯ‰ = pullCount' n (history O A R' n ฯ‰) a
      theorem Learning.pullCount_eq_comp_history {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (a : ๐“) (n : โ„•) :
      pullCount A a n = (fun (h : Hist ๐“ž ๐“ R n) => pullCount' n h a) โˆ˜ history O A R' n

      pullCount A a n is a function of the history before time n.

      theorem Learning.pullCount'_mono {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {ฯ‰ : ฮฉ} {n m : โ„•} (hnm : n โ‰ค m) :
      pullCount' n (history O A R' n ฯ‰) a โ‰ค pullCount' m (history O A R' m ฯ‰) a
      theorem Learning.pullCount_le {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (t : โ„•) (ฯ‰ : ฮฉ) :
      pullCount A a t ฯ‰ โ‰ค t
      theorem Learning.pullCount_congr {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {n : โ„•} {ฯ‰ ฯ‰' : ฮฉ} (h_eq : โˆ€ i โ‰ค n, A i ฯ‰ = A i ฯ‰') :
      pullCount A a (n + 1) ฯ‰ = pullCount A a (n + 1) ฯ‰'
      theorem Learning.pullCount_lt_of_forall_ne {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {n t : โ„•} {ฯ‰ : ฮฉ} (h_lt : โˆ€ (s : โ„•), pullCount A a (s + 1) ฯ‰ โ‰  t) (ht : t โ‰  0) :
      pullCount A a n ฯ‰ < t
      theorem Learning.exists_pullCount_eq_of_le {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {n t : โ„•} {ฯ‰ : ฮฉ} (hnm : t โ‰ค pullCount A a (n + 1) ฯ‰) (ht : t โ‰  0) :
      โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = t
      theorem Learning.pullCount_le_add {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (n C : โ„•) (ฯ‰ : ฮฉ) :
      pullCount A a n ฯ‰ โ‰ค C + 1 + โˆ‘ s โˆˆ Finset.range n, {s : โ„• | A s ฯ‰ = a โˆง C < pullCount A a s ฯ‰}.indicator 1 s
      theorem Learning.measurable_pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (a : ๐“) (t : โ„•) :
      Measurable fun (ฯ‰ : ฮฉ) => pullCount A a t ฯ‰
      theorem Learning.measurable_uncurry_pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableEq ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (t : โ„•) :
      Measurable fun (p : ฮฉ ร— ๐“) => pullCount A p.2 t p.1
      theorem Learning.measurable_uncurry_pullCount_comp {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [Countable ๐“] [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) {f : ฮฉ โ†’ ๐“} (hf : Measurable f) {g : ฮฉ โ†’ โ„•} (hg : Measurable g) :
      Measurable fun (ฯ‰ : ฮฉ) => pullCount A (f ฯ‰) (g ฯ‰) ฯ‰
      theorem Learning.measurable_pullCount' {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] [MeasurableSingletonClass ๐“] (n : โ„•) (a : ๐“) :
      Measurable fun (h : Hist ๐“ž ๐“ R n) => pullCount' n h a
      theorem Learning.measurable_uncurry_pullCount' {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] [MeasurableEq ๐“] (n : โ„•) :
      Measurable fun (p : Hist ๐“ž ๐“ R n ร— ๐“) => pullCount' n p.1 p.2
      theorem Learning.adapted_pullCount_add_one {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) :
      theorem Learning.stronglyAdapted_pullCount_add_one {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) :
      theorem Learning.isStronglyPredictable_pullCount {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) :
      theorem Learning.measurableSet_action_eq_and_pullCount_eq {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (t : โ„•) (b : ๐“) (k : โ„•) :
      MeasurableSet {x : ฮฉ | A t x = b โˆง pullCount A b t x = k}
      theorem Learning.measurableSet_snd_eq_and_pullCount'_eq {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] [MeasurableSingletonClass ๐“] (n : โ„•) (b : ๐“) (k : โ„•) :
      MeasurableSet {u : (Hist ๐“ž ๐“ R n ร— ๐“ž) ร— ๐“ | u.2 = b โˆง pullCount' n u.1.1 b = k}
      theorem Learning.setOf_action_eq_and_pullCount_eq_eq_preimage {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {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 : (Hist ๐“ž ๐“ R n ร— ๐“ž) ร— ๐“ | u.2 = b โˆง pullCount' n u.1.1 b = k}

      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).

      theorem Learning.integrable_pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (a : ๐“) (n : โ„•) :
      MeasureTheory.Integrable (fun (ฯ‰ : ฮฉ) => โ†‘(pullCount A a n ฯ‰)) P
      noncomputable def Learning.stepsUntil {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ) :

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

      Equations
      Instances For
        theorem Learning.stepsUntil_eq_top_iff {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} :
        stepsUntil A a m ฯ‰ = โŠค โ†” โˆ€ (s : โ„•), pullCount A a (s + 1) ฯ‰ โ‰  m
        theorem Learning.stepsUntil_ne_top {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (h_exists : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m) :
        theorem Learning.exists_pullCount_eq {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (h' : stepsUntil A a m ฯ‰ โ‰  โŠค) :
        โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m
        theorem Learning.stepsUntil_zero_of_ne {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {ฯ‰ : ฮฉ} (hka : A 0 ฯ‰ โ‰  a) :
        stepsUntil A a 0 ฯ‰ = 0
        theorem Learning.stepsUntil_zero_of_eq {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {ฯ‰ : ฮฉ} (hka : A 0 ฯ‰ = a) :
        stepsUntil A a 0 ฯ‰ = โŠค
        theorem Learning.stepsUntil_eq_dite {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ) [Decidable (โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m)] :
        stepsUntil A a m ฯ‰ = if h : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m then โ†‘(Nat.find h) else โŠค
        theorem Learning.stepsUntil_eq_leastGE {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {m : โ„•} (a : ๐“) (hm : m โ‰  0) :
        stepsUntil A a m = MeasureTheory.leastGE (fun (n : โ„•) (ฯ‰ : ฮฉ) => pullCount A a (n + 1) ฯ‰) m
        theorem Learning.stepsUntil_mono {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) (ฯ‰ : ฮฉ) {n m : โ„•} (hn : n โ‰  0) (hnm : n โ‰ค m) :
        stepsUntil A a n ฯ‰ โ‰ค stepsUntil A a m ฯ‰
        theorem Learning.stepsUntil_pullCount_le {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (ฯ‰ : ฮฉ) (a : ๐“) (t : โ„•) :
        stepsUntil A a (pullCount A a (t + 1) ฯ‰) ฯ‰ โ‰ค โ†‘t
        theorem Learning.stepsUntil_pullCount_eq {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (ฯ‰ : ฮฉ) (t : โ„•) :
        stepsUntil A (A t ฯ‰) (pullCount A (A t ฯ‰) (t + 1) ฯ‰) ฯ‰ = โ†‘t
        theorem Learning.stepsUntil_one_of_eq {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {ฯ‰ : ฮฉ} (hka : A 0 ฯ‰ = a) :
        stepsUntil A a 1 ฯ‰ = 0

        If we pull action a at time 0, the first time at which it is pulled once is 0.

        theorem Learning.stepsUntil_eq_zero_iff {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} :
        stepsUntil A a m ฯ‰ = 0 โ†” m = 0 โˆง A 0 ฯ‰ โ‰  a โˆจ m = 1 โˆง A 0 ฯ‰ = a
        theorem Learning.action_stepsUntil {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h_exists : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m) :
        A (stepsUntil A a m ฯ‰).toNat ฯ‰ = a
        theorem Learning.action_eq_of_stepsUntil_eq_coe {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m n : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h : stepsUntil A a m ฯ‰ = โ†‘n) :
        A n ฯ‰ = a
        theorem Learning.pullCount_stepsUntil_add_one {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (h_exists : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m) :
        pullCount A a (stepsUntil A a m ฯ‰ + 1).toNat ฯ‰ = m
        theorem Learning.pullCount_stepsUntil {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h_exists : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m) :
        pullCount A a (stepsUntil A a m ฯ‰).toNat ฯ‰ = m - 1
        theorem Learning.pullCount_lt_of_le_stepsUntil {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} (a : ๐“) {n m : โ„•} (ฯ‰ : ฮฉ) (h_exists : โˆƒ (s : โ„•), pullCount A a (s + 1) ฯ‰ = m) (hn : โ†‘n < stepsUntil A a m ฯ‰) :
        pullCount A a (n + 1) ฯ‰ < m
        theorem Learning.pullCount_eq_of_stepsUntil_eq_coe {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m n : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (h : stepsUntil A a m ฯ‰ = โ†‘n) :
        pullCount A a n ฯ‰ = m - 1
        theorem Learning.pullCount_add_one_eq_of_stepsUntil_eq_coe {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m n : โ„•} {ฯ‰ : ฮฉ} (h : stepsUntil A a m ฯ‰ = โ†‘n) :
        pullCount A a (n + 1) ฯ‰ = m
        theorem Learning.stepsUntil_eq_iff {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (n : โ„•) :
        stepsUntil A a m ฯ‰ = โ†‘n โ†” pullCount A a (n + 1) ฯ‰ = m โˆง โˆ€ k < n, pullCount A a (k + 1) ฯ‰ < m
        theorem Learning.stepsUntil_eq_iff' {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ} (hm : m โ‰  0) (n : โ„•) :
        stepsUntil A a m ฯ‰ = โ†‘n โ†” A n ฯ‰ = a โˆง pullCount A a n ฯ‰ = m - 1
        theorem Learning.stepsUntil_eq_congr {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {a : ๐“} {m n : โ„•} {ฯ‰ ฯ‰' : ฮฉ} (h_eq : โˆ€ i โ‰ค n, A i ฯ‰ = A i ฯ‰') :
        stepsUntil A a m ฯ‰ = โ†‘n โ†” stepsUntil A a m ฯ‰' = โ†‘n
        theorem Learning.isStoppingTime_stepsUntil {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {m : โ„•} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) (hm : m โ‰  0) :
        theorem Learning.measurable_stepsUntil {๐“ : Type u_2} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (a : ๐“) (m : โ„•) :
        theorem Learning.measurable_stepsUntil' {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (a : ๐“) (m : โ„•) :
        Measurable fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => stepsUntil A a m ฯ‰.1
        theorem Learning.measurable_comap_indicator_stepsUntil_eq {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (O : โ„• โ†’ ฮฉ โ†’ ๐“ž) (R' : โ„• โ†’ ฮฉ โ†’ R) (a : ๐“) (m n : โ„•) :
        Measurable ({ฯ‰ : ฮฉ | stepsUntil A a m ฯ‰ = โ†‘n}.indicator fun (x : ฮฉ) => 1)
        theorem Learning.measurable_indicator_stepsUntil_eq {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) (m n : โ„•) :
        Measurable ({ฯ‰ : ฮฉ | stepsUntil A a m ฯ‰ = โ†‘n}.indicator fun (x : ฮฉ) => 1)
        theorem Learning.measurableSet_stepsUntil_eq {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [MeasurableSingletonClass ๐“] (O : โ„• โ†’ ฮฉ โ†’ ๐“ž) (R' : โ„• โ†’ ฮฉ โ†’ R) (a : ๐“) (m n : โ„•) :
        MeasurableSet {ฯ‰ : ฮฉ | stepsUntil A a m ฯ‰ = โ†‘n}
        theorem Learning.isStoppingTime_stepsUntil_filtrationAction {๐“ž : Type u_1} {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ž : MeasurableSpace ๐“ž} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {alg : Algorithm ๐“ž ๐“ R} {env : Environment ๐“ž ๐“ R} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {O : โ„• โ†’ ฮฉ โ†’ ๐“ž} {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (h : IsAlgEnvSeq O A R' alg env P) (a : ๐“) (m : โ„•) :

        stepsUntil a m is a stopping time with respect to the filtration filtrationAction.

        noncomputable def Learning.rewardByCount {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (R' : โ„• โ†’ ฮฉ โ†’ R) (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
        R

        Reward 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.

        Equations
        Instances For
          theorem Learning.rewardByCount_eq_ite {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (a : ๐“) (m : โ„•) (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
          rewardByCount A R' a m ฯ‰ = if stepsUntil A a m ฯ‰.1 = โŠค then ฯ‰.2 m a else R' (stepsUntil A a m ฯ‰.1).toNat ฯ‰.1
          theorem Learning.rewardByCount_eq_add {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [AddMonoid R] (a : ๐“) (m : โ„•) :
          rewardByCount A R' a m = ({ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R) | stepsUntil A a m ฯ‰.1 โ‰  โŠค}.indicator fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => R' (stepsUntil A a m ฯ‰.1).toNat ฯ‰.1) + {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R) | stepsUntil A a m ฯ‰.1 = โŠค}.indicator fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => ฯ‰.2 m a
          theorem Learning.rewardByCount_of_stepsUntil_eq_top {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : stepsUntil A a m ฯ‰.1 = โŠค) :
          rewardByCount A R' a m ฯ‰ = ฯ‰.2 m a
          theorem Learning.rewardByCount_of_stepsUntil_ne_top {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : stepsUntil A a m ฯ‰.1 โ‰  โŠค) :
          rewardByCount A R' a m ฯ‰ = R' (stepsUntil A a m ฯ‰.1).toNat ฯ‰.1
          theorem Learning.rewardByCount_eq_stoppedValue {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : stepsUntil A a m ฯ‰.1 โ‰  โŠค) :
          rewardByCount A R' a m ฯ‰ = MeasureTheory.stoppedValue R' (stepsUntil A a m) ฯ‰.1
          theorem Learning.rewardByCount_of_stepsUntil_eq_coe {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m n : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : stepsUntil A a m ฯ‰.1 = โ†‘n) :
          rewardByCount A R' a m ฯ‰ = R' n ฯ‰.1
          @[simp]
          theorem Learning.rewardByCount_zero {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (a : ๐“) (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
          rewardByCount A R' a 0 ฯ‰ = if A 0 ฯ‰.1 = a then ฯ‰.2 0 a else R' 0 ฯ‰.1

          The value at 0 does not matter (it would be the "zeroth" reward). It should be considered a junk value.

          theorem Learning.rewardByCount_pullCount_add_one_eq_reward {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (t : โ„•) (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
          rewardByCount A R' (A t ฯ‰.1) (pullCount A (A t ฯ‰.1) t ฯ‰.1 + 1) ฯ‰ = R' t ฯ‰.1
          theorem Learning.measurable_rewardByCount {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableSingletonClass ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (hR' : โˆ€ (n : โ„•), Measurable (R' n)) (a : ๐“) (m : โ„•) :
          Measurable fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => rewardByCount A R' a m ฯ‰
          noncomputable def Learning.rewardByCountUntil {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] (A : โ„• โ†’ ฮฉ โ†’ ๐“) (R' : โ„• โ†’ ฮฉ โ†’ R) :
          โ„• โ†’ ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R) โ†’ ๐“ ร— โ„• โ†’ R

          Array 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.

          Equations
          Instances For
            @[simp]
            theorem Learning.rewardByCountUntil_zero {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
            rewardByCountUntil A R' 0 ฯ‰ = fun (p : ๐“ ร— โ„•) => ฯ‰.2 (p.2 + 1) p.1
            theorem Learning.rewardByCountUntil_add_one {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (t : โ„•) (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) :
            rewardByCountUntil A R' (t + 1) ฯ‰ = Function.update (rewardByCountUntil A R' t ฯ‰) (A t ฯ‰.1, pullCount A (A t ฯ‰.1) t ฯ‰.1) (R' t ฯ‰.1)
            theorem Learning.rewardByCountUntil_apply_of_pullCount_le {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m t : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : pullCount A a t ฯ‰.1 โ‰ค m) :
            rewardByCountUntil A R' t ฯ‰ (a, m) = ฯ‰.2 (m + 1) a

            If action a was pulled at most m times before time t, then the entry (a, m) of rewardByCountUntil A R' t ฯ‰ is the entry (m + 1, a) of the auxiliary array.

            theorem Learning.rewardByCountUntil_apply_of_lt_pullCount {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {a : ๐“} {m t : โ„•} {ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)} (h : m < pullCount A a t ฯ‰.1) :
            rewardByCountUntil A R' t ฯ‰ (a, m) = rewardByCount A R' a (m + 1) ฯ‰

            If action a was pulled more than m times before time t, then the entry (a, m) of rewardByCountUntil A R' t ฯ‰ is the reward received at the (m + 1)-th pull of a.

            theorem Learning.rewardByCountUntil_congr {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {x : ฮฉ} {z z' : โ„• โ†’ ๐“ โ†’ R} (t : โ„•) (p : ๐“ ร— โ„•) (hz : z (p.2 + 1) p.1 = z' (p.2 + 1) p.1) :
            rewardByCountUntil A R' t (x, z) p = rewardByCountUntil A R' t (x, z') p

            rewardByCountUntil A R' t (x, z) p depends on z only through z (p.2 + 1) p.1.

            theorem Learning.eventually_rewardByCountUntil_eq {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) (p : ๐“ ร— โ„•) :
            โˆ€แถ  (t : โ„•) in Filter.atTop, rewardByCountUntil A R' t ฯ‰ p = rewardByCount A R' p.1 (p.2 + 1) ฯ‰

            For each entry, rewardByCountUntil A R' t ฯ‰ coincides with rewardByCount for t large enough.

            theorem Learning.measurable_rewardByCountUntil_of {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} {m : MeasurableSpace (ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R))} [MeasurableEq ๐“] (t : โ„•) (hA : โˆ€ i < t, Measurable fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => A i ฯ‰.1) (hR : โˆ€ i < t, Measurable fun (ฯ‰ : ฮฉ ร— (โ„• โ†’ ๐“ โ†’ R)) => R' i ฯ‰.1) (hZ : Measurable Prod.snd) :

            Measurability of rewardByCountUntil A R' t with respect to a ฯƒ-algebra m for which the actions and rewards before time t and the auxiliary array are measurable.

            theorem Learning.measurable_rewardByCountUntil {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} {m๐“ : MeasurableSpace ๐“} {mR : MeasurableSpace R} {mฮฉ : MeasurableSpace ฮฉ} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {R' : โ„• โ†’ ฮฉ โ†’ R} [MeasurableEq ๐“] (hA : โˆ€ (n : โ„•), Measurable (A n)) (hR' : โˆ€ (n : โ„•), Measurable (R' n)) (t : โ„•) :
            theorem Learning.sum_pullCount_mul {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [Fintype ๐“] [Semiring R] (ฯ‰ : ฮฉ) (f : ๐“ โ†’ R) (t : โ„•) :
            โˆ‘ a : ๐“, โ†‘(pullCount A a t ฯ‰) * f a = โˆ‘ s โˆˆ Finset.range t, f (A s ฯ‰)
            theorem Learning.sum_pullCount {๐“ : Type u_2} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} {t : โ„•} [Fintype ๐“] {ฯ‰ : ฮฉ} :
            โˆ‘ a : ๐“, pullCount A a t ฯ‰ = t
            theorem Learning.sum_comp_pullCount {๐“ : Type u_2} {R : Type u_3} {ฮฉ : Type u_4} [DecidableEq ๐“] {A : โ„• โ†’ ฮฉ โ†’ ๐“} [Fintype ๐“] [AddCommMonoid R] (f : โ„• โ†’ R) (t : โ„•) (ฯ‰ : ฮฉ) :
            โˆ‘ s โˆˆ Finset.range t, f (pullCount A (A s ฯ‰) s ฯ‰) = โˆ‘ a : ๐“, โˆ‘ j โˆˆ Finset.range (pullCount A a t ฯ‰), f j
            theorem Learning.sum_pullCount' {๐“ž : Type u_1} {๐“ : Type u_2} [DecidableEq ๐“] [Fintype ๐“] (n : โ„•) (h : Hist ๐“ž ๐“ โ„ n) :
            โˆ‘ a : ๐“, pullCount' n h a = n