LeanMachineLearning exposition

Learning.RoundRobin.pullCount_mul๐Ÿ”—

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

LemmaLearning.RoundRobin.pullCount_mul

At time K * m, the number of times each action is chosen is equal to m.

๐Ÿ”—theorem
Learning.RoundRobin.pullCount_mul.{u_1, u_2} {๐“จ : Type u_1} {m๐“จ : MeasurableSpace ๐“จ} {K : โ„•} {hK : 0 < K} {ฮฝ : ProbabilityTheory.Kernel (Fin K) ๐“จ} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_2} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ„• โ†’ ฮฉ โ†’ Fin K} {Y : โ„• โ†’ ฮฉ โ†’ ๐“จ} (m : โ„•) (h : IsAlgEnvSeqUntil A Y (roundRobinAlgorithm hK) (stationaryEnv ฮฝ) P (K * m - 1)) (a : Fin K) : pullCount A a (K * m) =แต[P] fun x => m
Learning.RoundRobin.pullCount_mul.{u_1, u_2} {๐“จ : Type u_1} {m๐“จ : MeasurableSpace ๐“จ} {K : โ„•} {hK : 0 < K} {ฮฝ : ProbabilityTheory.Kernel (Fin K) ๐“จ} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_2} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ„• โ†’ ฮฉ โ†’ Fin K} {Y : โ„• โ†’ ฮฉ โ†’ ๐“จ} (m : โ„•) (h : IsAlgEnvSeqUntil A Y (roundRobinAlgorithm hK) (stationaryEnv ฮฝ) P (K * m - 1)) (a : Fin K) : pullCount A a (K * m) =แต[P] fun x => m

Code

lemma pullCount_mul (m : โ„•)
    (h : IsAlgEnvSeqUntil A Y (roundRobinAlgorithm hK) (stationaryEnv ฮฝ) P (K * m - 1))
    (a : Fin K) :
    pullCount A a (K * m) =แต[P] fun _ โ†ฆ m
Type uses (4)
Body uses (4)
Used by (2)

Actions: Source ยท Open Issue

Proof
by
  rw [Filter.EventuallyEq]
  simp_rw [pullCount_eq_sum]
  have h_arm (n : range (K * m)) : A n =แต[P] fun _ โ†ฆ โŸจn % K, Nat.mod_lt _ hKโŸฉ :=
    action_ae_eq n (h.mono (by have := n.2; simp only [mem_range] at this; grind))
  simp_rw [Filter.EventuallyEq, โ† ae_all_iff] at h_arm
  filter_upwards [h_arm] with ฯ‰ h_arm
  have h_arm' {i : โ„•} (hi : i โˆˆ range (K * m)) : A i ฯ‰ = โŸจi % K, Nat.mod_lt _ hKโŸฉ := h_arm โŸจi, hiโŸฉ
  calc (โˆ‘ s โˆˆ range (K * m), if A s ฯ‰ = a then 1 else 0)
  _ = (โˆ‘ s โˆˆ range (K * m), if โŸจs % K, Nat.mod_lt _ hKโŸฉ = a then 1 else 0) :=
    sum_congr rfl fun s hs โ†ฆ by rw [h_arm' hs]
  _ = m := sum_mod_range_mul hK m a

Dependency graph

Type dependencies (4)

IsAlgEnvSeqUntil๐Ÿ”—

StructureLearning.IsAlgEnvSeqUntil

An algorithm-environment sequence: a sequence of actions and feedbacks generated by an algorithm interacting with an environment.

๐Ÿ”—structure
Learning.IsAlgEnvSeqUntil.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} {mฮฉ : MeasurableSpace ฮฉ} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (alg : Algorithm ๐“ ๐“จ) (env : Environment ๐“ ๐“จ) (P : MeasureTheory.Measure ฮฉ) [MeasureTheory.IsFiniteMeasure P] (N : โ„•) : Prop
Learning.IsAlgEnvSeqUntil.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} {mฮฉ : MeasurableSpace ฮฉ} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (alg : Algorithm ๐“ ๐“จ) (env : Environment ๐“ ๐“จ) (P : MeasureTheory.Measure ฮฉ) [MeasureTheory.IsFiniteMeasure P] (N : โ„•) : Prop

Code

structure IsAlgEnvSeqUntil
    (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (alg : Algorithm ๐“ ๐“จ) (env : Environment ๐“ ๐“จ)
    (P : Measure ฮฉ) [IsFiniteMeasure P] (N : โ„•) : Prop where
  /-- The action sequence is measurable. -/
  measurable_action n : Measurable (A n) := by fun_prop
  /-- The feedback sequence is measurable. -/
  measurable_feedback n : Measurable (Y n) := by fun_prop
  /-- The first action has the correct law. -/
  hasLaw_action_zero : HasLaw (fun ฯ‰ โ†ฆ (A 0 ฯ‰)) alg.p0 P
  /-- The first feedback has the correct conditional distribution. -/
  hasCondDistrib_feedback_zero : HasCondDistrib (Y 0) (A 0) env.ฮฝ0 P
  /-- The next action has the correct conditional distribution given the history. -/
  hasCondDistrib_action n (hn : n < N) :
    HasCondDistrib (A (n + 1)) (history A Y n) (alg.policy n) P
  /-- The next feedback has the correct conditional distribution given the history and
  next action. -/
  hasCondDistrib_feedback n (hn : n < N) :
    HasCondDistrib (Y (n + 1)) (fun ฯ‰ โ†ฆ (history A Y n ฯ‰, A (n + 1) ฯ‰))
      (env.feedback n) P
Type uses (3)
Used by (22)

Actions: Source ยท Open Issue

roundRobinAlgorithm๐Ÿ”—

DefinitionLearning.roundRobinAlgorithm

The Round-Robin algorithm: deterministic algorithm that chooses action n % K at time n.

๐Ÿ”—def
Learning.roundRobinAlgorithm.{u_1} {๐“จ : Type u_1} {m๐“จ : MeasurableSpace ๐“จ} {K : โ„•} (hK : 0 < K) : Algorithm (Fin K) ๐“จ
Learning.roundRobinAlgorithm.{u_1} {๐“จ : Type u_1} {m๐“จ : MeasurableSpace ๐“จ} {K : โ„•} (hK : 0 < K) : Algorithm (Fin K) ๐“จ

Code

noncomputable
def roundRobinAlgorithm (hK : 0 < K) : Algorithm (Fin K) ๐“จ :=
  detAlgorithm (fun n _ โ†ฆ RoundRobin.nextAction hK n) (by fun_prop) โŸจ0, hKโŸฉ
Type uses (1)
Body uses (2)
Used by (13)

Actions: Source ยท Open Issue

stationaryEnv๐Ÿ”—

DefinitionLearning.stationaryEnv

A stationary environment, in which the distribution of the next feedback depends only on the last action.

๐Ÿ”—def
Learning.stationaryEnv.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (ฮฝ : ProbabilityTheory.Kernel ๐“ ๐“จ) [ProbabilityTheory.IsMarkovKernel ฮฝ] : Environment ๐“ ๐“จ
Learning.stationaryEnv.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (ฮฝ : ProbabilityTheory.Kernel ๐“ ๐“จ) [ProbabilityTheory.IsMarkovKernel ฮฝ] : Environment ๐“ ๐“จ

Code

def stationaryEnv (ฮฝ : Kernel ๐“ ๐“จ) [IsMarkovKernel ฮฝ] : Environment ๐“ ๐“จ := obliviousEnv fun _ โ†ฆ ฮฝ
Type uses (1)
Body uses (1)
Used by (81)

Actions: Source ยท Open Issue

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

All dependencies, transitively (6)

Algorithm๐Ÿ”—

StructureLearning.Algorithm

A stochastic, sequential algorithm.

๐Ÿ”—structure
Learning.Algorithm.{u_4, u_5} (๐“ : Type u_4) (๐“จ : Type u_5) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] : Type (max u_4 u_5)
Learning.Algorithm.{u_4, u_5} (๐“ : Type u_4) (๐“จ : Type u_5) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] : Type (max u_4 u_5)

Code

structure Algorithm (๐“ ๐“จ : Type*) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] where
  /-- Policy or sampling rule: distribution of the next action. -/
  policy : (n : โ„•) โ†’ Kernel (Iic n โ†’ ๐“ ร— ๐“จ) ๐“
  /-- The policy is a Markov kernel. -/
  [h_policy : โˆ€ n, IsMarkovKernel (policy n)]
  /-- Distribution of the first action. -/
  p0 : Measure ๐“
  /-- The first action distribution is a probability measure. -/
  [hp0 : IsProbabilityMeasure p0]
Used by (216)

Actions: Source ยท Open Issue

Environment๐Ÿ”—

StructureLearning.Environment

A stochastic environment.

๐Ÿ”—structure
Learning.Environment.{u_4, u_5} (๐“ : Type u_4) (๐“จ : Type u_5) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] : Type (max u_4 u_5)
Learning.Environment.{u_4, u_5} (๐“ : Type u_4) (๐“จ : Type u_5) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] : Type (max u_4 u_5)

Code

structure Environment (๐“ ๐“จ : Type*) [MeasurableSpace ๐“] [MeasurableSpace ๐“จ] where
  /-- Distribution of the next observation as function of the past history. -/
  feedback : (n : โ„•) โ†’ Kernel ((Iic n โ†’ ๐“ ร— ๐“จ) ร— ๐“) ๐“จ
  /-- The feedback kernels are Markov kernels. -/
  [h_feedback : โˆ€ n, IsMarkovKernel (feedback n)]
  /-- Distribution of the first observation given the first action. -/
  ฮฝ0 : Kernel ๐“ ๐“จ
  /-- The initial observation kernel is a Markov kernel. -/
  [hp0 : IsMarkovKernel ฮฝ0]
Used by (128)

Actions: Source ยท Open Issue

history๐Ÿ”—

DefinitionLearning.history

History of the algorithm-environment sequence up to time n.

๐Ÿ”—def
Learning.history.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ
Learning.history.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ

Code

def history (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : Iic n โ†’ ๐“ ร— ๐“จ :=
  fun i โ†ฆ (A i ฯ‰, Y i ฯ‰)
Used by (72)

Actions: Source ยท Open Issue

detAlgorithm๐Ÿ”—

DefinitionLearning.detAlgorithm

A deterministic algorithm, which chooses the action given by the function nextAction.

๐Ÿ”—def
Learning.detAlgorithm.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (nextA : (n : โ„•) โ†’ (โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ) โ†’ ๐“) (h_next : โˆ€ (n : โ„•), Measurable (nextA n)) (action0 : ๐“) : Algorithm ๐“ ๐“จ
Learning.detAlgorithm.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (nextA : (n : โ„•) โ†’ (โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ) โ†’ ๐“) (h_next : โˆ€ (n : โ„•), Measurable (nextA n)) (action0 : ๐“) : Algorithm ๐“ ๐“จ

Code

noncomputable
def detAlgorithm (nextA : (n : โ„•) โ†’ (Iic n โ†’ ๐“ ร— ๐“จ) โ†’ ๐“)
    (h_next : โˆ€ n, Measurable (nextA n)) (action0 : ๐“) :
    Algorithm ๐“ ๐“จ where
  policy n := Kernel.deterministic (nextA n) (h_next n)
  p0 := Measure.dirac action0
Type uses (1)
Used by (15)

Actions: Source ยท Open Issue

nextAction๐Ÿ”—

DefinitionLearning.RoundRobin.nextAction

Action chosen by the Round-Robin algorithm at time n + 1. This is action (n + 1) % K.

๐Ÿ”—def
Learning.RoundRobin.nextAction {K : โ„•} (hK : 0 < K) (n : โ„•) : Fin K
Learning.RoundRobin.nextAction {K : โ„•} (hK : 0 < K) (n : โ„•) : Fin K

Code

noncomputable
def RoundRobin.nextAction (hK : 0 < K) (n : โ„•) : Fin K := โŸจ(n + 1) % K, Nat.mod_lt _ hKโŸฉ
Used by (14)

Actions: Source ยท Open Issue

obliviousEnv๐Ÿ”—

DefinitionLearning.obliviousEnv

An oblivious environment, in which the distribution of the next feedback depends only on the last action, but in a possibly time-dependent manner.

๐Ÿ”—def
Learning.obliviousEnv.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (ฮฝ : โ„• โ†’ ProbabilityTheory.Kernel ๐“ ๐“จ) [โˆ€ (n : โ„•), ProbabilityTheory.IsMarkovKernel (ฮฝ n)] : Environment ๐“ ๐“จ
Learning.obliviousEnv.{u_1, u_2} {๐“ : Type u_1} {๐“จ : Type u_2} {m๐“ : MeasurableSpace ๐“} {m๐“จ : MeasurableSpace ๐“จ} (ฮฝ : โ„• โ†’ ProbabilityTheory.Kernel ๐“ ๐“จ) [โˆ€ (n : โ„•), ProbabilityTheory.IsMarkovKernel (ฮฝ n)] : Environment ๐“ ๐“จ

Code

def obliviousEnv (ฮฝ : โ„• โ†’ Kernel ๐“ ๐“จ) [โˆ€ n, IsMarkovKernel (ฮฝ n)] : Environment ๐“ ๐“จ where
  feedback n := (ฮฝ (n + 1)).prodMkLeft _
  ฮฝ0 := ฮฝ 0
Type uses (1)
Used by (10)

Actions: Source ยท Open Issue