LeanMachineLearning exposition

Learning.measurable_comap_indicator_stepsUntil_eq🔗

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

measurable_comap_indicator_stepsUntil_eq🔗

LemmaLearning.measurable_comap_indicator_stepsUntil_eq

No docstring.

🔗theorem
Learning.measurable_comap_indicator_stepsUntil_eq.{u_1, u_2, u_3} {𝓐 : Type u_1} {R : Type u_2} {Ω : Type u_3} {m𝓐 : MeasurableSpace 𝓐} {mR : MeasurableSpace R} { : MeasurableSpace Ω} [DecidableEq 𝓐] {A : Ω 𝓐} {R' : Ω R} [MeasurableSingletonClass 𝓐] (hA : (n : ), Measurable (A n)) (hR' : (n : ), Measurable (R' n)) (a : 𝓐) (m n : ) : Measurable (Set.indicator {ω | stepsUntil A a m ω = n} fun x => 1)
Learning.measurable_comap_indicator_stepsUntil_eq.{u_1, u_2, u_3} {𝓐 : Type u_1} {R : Type u_2} {Ω : Type u_3} {m𝓐 : MeasurableSpace 𝓐} {mR : MeasurableSpace R} { : MeasurableSpace Ω} [DecidableEq 𝓐] {A : Ω 𝓐} {R' : Ω R} [MeasurableSingletonClass 𝓐] (hA : (n : ), Measurable (A n)) (hR' : (n : ), Measurable (R' n)) (a : 𝓐) (m n : ) : Measurable (Set.indicator {ω | stepsUntil A a m ω = n} fun x => 1)

Code

lemma measurable_comap_indicator_stepsUntil_eq [MeasurableSingletonClass 𝓐]
    (hA : ∀ n, Measurable (A n)) (hR' : ∀ n, Measurable (R' n)) (a : 𝓐) (m n : ℕ) :
    Measurable[MeasurableSpace.comap
        (fun ω : Ω ↦ (history A R' (n-1) ω, A n ω)) inferInstance]
      ({ω | stepsUntil A a m ω = ↑n}.indicator fun _ ↦ 1)
Type uses (2)
Body uses (8)
Used by (3)

Actions: Source · Open Issue

Proof
by
  by_cases hm : m = 0
  · simp only [hm]
    by_cases hn : n = 0
    · subst hn
      simp only [CharP.cast_eq_zero, stepsUntil_eq_zero_iff, ne_eq, true_and, zero_ne_one,
        false_and, or_false]
      refine Measurable.indicator measurable_const ?_
      refine (measurableSet_singleton _).compl.preimage ?_
      rw [measurable_iff_comap_le, Prod.instMeasurableSpace, MeasurableSpace.comap_prodMk]
      exact le_sup_of_le_right le_rfl
    · have : {ω | stepsUntil A a 0 ω = n} = ∅ := by
        ext ω
        by_cases ha : A 0 ω = a
        · simp [stepsUntil_zero_of_eq ha]
        · simp only [Set.mem_setOf_eq, stepsUntil_zero_of_ne ha, Set.mem_empty_iff_false,
            iff_false]
          norm_cast
          exact Ne.symm hn
      simp [this]
  simp_rw [stepsUntil_eq_iff' hm]
  refine Measurable.indicator measurable_const ?_
  refine ((measurableSet_singleton _).preimage ?_).inter ((measurableSet_singleton _).preimage ?_)
  · rw [measurable_iff_comap_le, Prod.instMeasurableSpace, MeasurableSpace.comap_prodMk]
    exact le_sup_of_le_right le_rfl
  · rw [measurable_iff_comap_le, Prod.instMeasurableSpace, MeasurableSpace.comap_prodMk]
    refine le_sup_of_le_left ?_
    rw [← measurable_iff_comap_le]
    by_cases hn : n = 0
    · simp only [hn, pullCount_zero]
      exact measurable_const
    have h_meas := adapted_pullCount_add_one hA hR' a (n - 1)
    have : 1 ≤ n := by grind
    convert h_meas using 1
    · rfl
    · simp [Nat.sub_add_cancel this]

Dependency graph

Type dependencies (2)

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

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

All dependencies, transitively (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