Algorithms and environments #
We define structures for stochastic, sequential algorithms and environments, and the notion of an algorithm-environment sequence, which is a sequence of observations, actions and feedbacks generated by an algorithm interacting with an environment.
A round of interaction consists of an observation in 𝓞, an action in 𝓐 and a feedback in 𝓨,
in that order: it is an element of Round 𝓞 𝓐 𝓨 = 𝓞 × 𝓐 × 𝓨.
At time n, the algorithm has seen the n complete rounds at times 0, ..., n - 1.
That history is an element of Hist 𝓞 𝓐 𝓨 n = Fin n → Round 𝓞 𝓐 𝓨. The environment then draws
an observation O n given the history, the algorithm chooses an action A n according to its
policy applied to the history and O n, and the environment returns a feedback Y n given the
history, O n and A n.
In particular, the first observation is drawn according to the observation kernel at time 0,
applied to the empty history (the unique element of Hist 𝓞 𝓐 𝓨 0).
Main definitions #
Round 𝓞 𝓐 𝓨: one round of interaction, an observation-action-feedback triple.Hist 𝓞 𝓐 𝓨 n: a history ofncomplete rounds.Algorithm 𝓞 𝓐 𝓨: a stochastic, sequential algorithm.Environment 𝓞 𝓐 𝓨: a stochastic environment.history O A Y n: the history before timen, a random variable with values inHist 𝓞 𝓐 𝓨 n.IsAlgEnvSeq O A Y alg env P: an algorithm-environment sequence. That is, a sequence of observationsO, actionsAand feedbacksYthat have the correct conditional distributions to be generated by an algorithmalginteracting with an environmentenv, defined on a probability space(Ω, P).IsAlgEnvSeqUntil O A Y alg env P N:O,AandYform an algorithm-environment sequence for the timesn < N.
One round of interaction: an observation, then an action, then a feedback.
Equations
- Learning.Round 𝓞 𝓐 𝓨 = (𝓞 × 𝓐 × 𝓨)
Instances For
History of n complete rounds; n = 0 is the empty history.
Equations
- Learning.Hist 𝓞 𝓐 𝓨 n = (Fin n → Learning.Round 𝓞 𝓐 𝓨)
Instances For
A stochastic, sequential algorithm.
At each round, it sees an observation in 𝓞, then takes an action in 𝓐, and finally receives
feedback in 𝓨. The action is a random function of the past rounds and the current observation.
- policy (n : ℕ) : ProbabilityTheory.Kernel (Hist 𝓞 𝓐 𝓨 n × 𝓞) 𝓐
Law of the action of round
ngiven the past rounds and the current observation. - isMarkovKernel_policy (n : ℕ) : ProbabilityTheory.IsMarkovKernel (self.policy n)
The policy is a Markov kernel.
Instances For
Equations
- Learning.instMeasurableSpaceAlgorithm = MeasurableSpace.comap (fun (alg : Learning.Algorithm 𝓞 𝓐 𝓨) => alg.policy) inferInstance
A stochastic environment. At each round, an observation is drawn prior to the algorithm taking an action. Then the environment provides feedback based on the observation and the action.
- obs (n : ℕ) : ProbabilityTheory.Kernel (Hist 𝓞 𝓐 𝓨 n) 𝓞
Law of the observation of round
ngiven the past rounds. - feedback (n : ℕ) : ProbabilityTheory.Kernel ((Hist 𝓞 𝓐 𝓨 n × 𝓞) × 𝓐) 𝓨
Law of the feedback of round
ngiven the past rounds, the observation and the action. - isMarkovKernel_obs (n : ℕ) : ProbabilityTheory.IsMarkovKernel (self.obs n)
The observation kernel is a Markov kernel.
- isMarkovKernel_feedback (n : ℕ) : ProbabilityTheory.IsMarkovKernel (self.feedback n)
The feedback kernel is a Markov kernel.
Instances For
Equations
- Learning.instMeasurableSpaceEnvironment = MeasurableSpace.comap (fun (env : Learning.Environment 𝓞 𝓐 𝓨) => (env.obs, env.feedback)) inferInstance
Distribution of the first observation: the observation kernel at time 0 applied to the empty
history.
Instances For
Distribution of the first action given the first observation: the policy at time 0 applied to
the empty history.
Instances For
Distribution of the first feedback given the first observation and action: the feedback kernel
at time 0 applied to the empty history.
Instances For
Kernel describing the distribution of the round at time n given the history before n.
Equations
Instances For
An algorithm-environment sequence: a sequence of observations, actions and feedbacks generated by an algorithm interacting with an environment.
- measurable_obs (n : ℕ) : Measurable (O n)
The observation sequence is measurable.
- measurable_action (n : ℕ) : Measurable (A n)
The action sequence is measurable.
- measurable_feedback (n : ℕ) : Measurable (Y n)
The feedback sequence is measurable.
- hasCondDistrib_obs (n : ℕ) : ProbabilityTheory.HasCondDistrib (O n) (history O A Y n) (env.obs n) P
The observation at time
nhas the correct conditional distribution given the history. - hasCondDistrib_action (n : ℕ) : ProbabilityTheory.HasCondDistrib (A n) (fun (ω : Ω) => (history O A Y n ω, O n ω)) (alg.policy n) P
The action at time
nhas the correct conditional distribution given the history and the observation at timen. - hasCondDistrib_feedback (n : ℕ) : ProbabilityTheory.HasCondDistrib (Y n) (fun (ω : Ω) => ((history O A Y n ω, O n ω), A n ω)) (env.feedback n) P
The feedback at time
nhas the correct conditional distribution given the history, the observation and the action at timen.
Instances For
An algorithm-environment sequence until time N: a sequence of observations, actions and
feedbacks such that the rounds at times n < N are generated by an algorithm interacting with
an environment. In particular, the law of history O A Y N is determined.
- measurable_obs (n : ℕ) : Measurable (O n)
The observation sequence is measurable.
- measurable_action (n : ℕ) : Measurable (A n)
The action sequence is measurable.
- measurable_feedback (n : ℕ) : Measurable (Y n)
The feedback sequence is measurable.
- hasCondDistrib_obs (n : ℕ) (hn : n < N) : ProbabilityTheory.HasCondDistrib (O n) (history O A Y n) (env.obs n) P
The observation at time
n < Nhas the correct conditional distribution given the history. - hasCondDistrib_action (n : ℕ) (hn : n < N) : ProbabilityTheory.HasCondDistrib (A n) (fun (ω : Ω) => (history O A Y n ω, O n ω)) (alg.policy n) P
The action at time
n < Nhas the correct conditional distribution given the history and the observation at timen. - hasCondDistrib_feedback (n : ℕ) (hn : n < N) : ProbabilityTheory.HasCondDistrib (Y n) (fun (ω : Ω) => ((history O A Y n ω, O n ω), A n ω)) (env.feedback n) P
The feedback at time
n < Nhas the correct conditional distribution given the history, the observation and the action at timen.
Instances For
If two algorithms have the same policy before time N, then a sequence generated by the first
one interacting with an environment is a sequence generated by the second one until time N.
IsAlgEnvSeq only depends on the almost everywhere equivalence classes of the processes.
Laws at time 0 #
At time 0 the history is the unique element of Hist 𝓞 𝓐 𝓨 0: conditioning on it is the same
as not conditioning. Note that those results need P to be a probability measure.
The history before time 0 is a constant.
Conditionally on the event (O 0, A 0) = p, the first feedback has law env.ν0 p.
Filtration generated by the history up to time n (included): h.filtration n is the
σ-algebra generated by history O A Y (n + 1), that is by the rounds at times 0, ..., n.
Equations
- h.filtration = { seq := fun (n : ℕ) => MeasurableSpace.comap (Learning.history O A Y (n + 1)) inferInstance, mono' := ⋯, le' := ⋯ }
Instances For
Filtration generated by the history before time n together with the observation at
time n.
Equations
- h.filtrationObs = { seq := fun (n : ℕ) => MeasurableSpace.comap (fun (ω : Ω) => (Learning.history O A Y n ω, O n ω)) inferInstance, mono' := ⋯, le' := ⋯ }
Instances For
Filtration generated by the history before time n together with the observation and the
action at time n.
Equations
- h.filtrationAction = { seq := fun (n : ℕ) => MeasurableSpace.comap (fun (ω : Ω) => ((Learning.history O A Y n ω, O n ω), A n ω)) inferInstance, mono' := ⋯, le' := ⋯ }
Instances For
Environments without observations #
An environment with 𝓞 = Unit provides no information to the algorithm before it takes its action:
the algorithm only sees the past rounds. Since Unit carries a unique probability measure, the
observation kernels of such an environment are all equal to Kernel.const _ (Measure.dirac ()),
and the observation process of an algorithm-environment sequence is noObs.
Every Markov kernel with codomain Unit is the constant kernel at Measure.dirac ().
A random variable with values in Unit admits any Markov kernel as conditional
distribution.
The observation process of an algorithm-environment sequence without observations.
Equations
- Learning.noObs Ω x✝¹ x✝ = ()