import Mathlib.MeasureTheory.Order.Lattice import Mathlib.Probability.Kernel.Basic import Mathlib.Probability.Kernel.IonescuTulcea.Traj import Mathlib.Probability.Process.FiniteDimensionalLaws import Mathlib.Probability.HasCondDistrib import Mathlib.MeasureTheory.Measure.ProbabilityMeasure import Mathlib.Probability.Independence.Basic import Mathlib.Probability.Independence.Conditional import Mathlib.MeasureTheory.Measure.SubFinite import Mathlib.Probability.Kernel.RadonNikodym import Mathlib.MeasureTheory.MeasurableSpace.Embedding import Mathlib.Order.Restriction import Mathlib.Probability.Kernel.IonescuTulcea.Maps import Mathlib.Analysis.Normed.Ring.Basic import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Standalone extraction for `Learning.Environment.feedback_comap` Definitions are copied verbatim; theorem proofs are replaced by `sorry`. Auto-generated by ChallengeGen. -/ set_option quotPrecheck false -- Namespace stubs (so later `open`s resolve). namespace Finset end Finset namespace MeasureTheory end MeasureTheory namespace ProbabilityTheory end ProbabilityTheory namespace ENNReal end ENNReal namespace Learning end Learning -- ═══ ForMathlib.MeasureTheory.Order.Lattice ═══ section open Finset variable {α δ : Type*} [MeasurableSpace δ] [SemilatticeInf α] {m : MeasurableSpace α} [MeasurableInf₂ α] attribute [to_dual existing] MeasurableInf₂ end -- ═══ SequentialLearning.Algorithm ═══ section open MeasureTheory ProbabilityTheory Filter Real Finset open scoped ENNReal NNReal namespace Learning variable {𝓞 𝓐 𝓨 Ω : Type*} {m𝓞 : MeasurableSpace 𝓞} {m𝓐 : MeasurableSpace 𝓐} {m𝓨 : MeasurableSpace 𝓨} {mΩ : MeasurableSpace Ω} /-- One round of interaction: an observation, then an action, then a feedback. -/ abbrev Round (𝓞 𝓐 𝓨 : Type*) := 𝓞 × 𝓐 × 𝓨 /-- History of `n` complete rounds; `n = 0` is the empty history. -/ abbrev Hist (𝓞 𝓐 𝓨 : Type*) (n : ℕ) := Fin n → Round 𝓞 𝓐 𝓨 /-- 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. -/ @[ext] structure Environment (𝓞 𝓐 𝓨 : Type*) [MeasurableSpace 𝓞] [MeasurableSpace 𝓐] [MeasurableSpace 𝓨] where /-- Law of the observation of round `n` given the past rounds. -/ obs : (n : ℕ) → Kernel (Hist 𝓞 𝓐 𝓨 n) 𝓞 /-- Law of the feedback of round `n` given the past rounds, the observation and the action. -/ feedback : (n : ℕ) → Kernel ((Hist 𝓞 𝓐 𝓨 n × 𝓞) × 𝓐) 𝓨 /-- The observation kernel is a Markov kernel. -/ [isMarkovKernel_obs : ∀ n, IsMarkovKernel (obs n)] /-- The feedback kernel is a Markov kernel. -/ [isMarkovKernel_feedback : ∀ n, IsMarkovKernel (feedback n)] instance (env : Environment 𝓞 𝓐 𝓨) (n : ℕ) : IsMarkovKernel (env.obs n) := env.isMarkovKernel_obs n instance (env : Environment 𝓞 𝓐 𝓨) (n : ℕ) : IsMarkovKernel (env.feedback n) := env.isMarkovKernel_feedback n end Learning end -- ═══ SequentialLearning.Comap ═══ section open MeasureTheory ProbabilityTheory namespace Learning variable {𝓞 𝓞' 𝓞'' 𝓐 𝓐' 𝓐'' 𝓨 𝓨' 𝓨'' Ω : Type*} {m𝓞 : MeasurableSpace 𝓞} {m𝓞' : MeasurableSpace 𝓞'} {m𝓞'' : MeasurableSpace 𝓞''} {m𝓐 : MeasurableSpace 𝓐} {m𝓐' : MeasurableSpace 𝓐'} {m𝓐'' : MeasurableSpace 𝓐''} {m𝓨 : MeasurableSpace 𝓨} {m𝓨' : MeasurableSpace 𝓨'} {m𝓨'' : MeasurableSpace 𝓨''} {mΩ : MeasurableSpace Ω} {fo : 𝓞 → 𝓞'} {fa : 𝓐 → 𝓐'} {fy : 𝓨 → 𝓨'} {go : 𝓞' → 𝓞''} {ga : 𝓐' → 𝓐''} {gy : 𝓨' → 𝓨''} section Comap section ComapAction variable {F : (n : ℕ) → Hist 𝓞 𝓐' 𝓨 n → Hist 𝓞 𝓐 𝓨 n} {f : 𝓐' → 𝓐} /-- The environment that reads the summary `F n` of the past rounds and reads `f a` when the algorithm plays `a` in the current round. This is the primitive transport operation on environments, dual to `Algorithm.comap`: `Environment.comapAction` is the special case in which `F n` is the round-wise map of the actions. Only the action can change type, since the observations and the feedbacks are outputs of the environment; `F n` can nonetheless forget or summarize the past rounds, as an environment that reads only the last round does. -/ def Environment.comap (env : Environment 𝓞 𝓐 𝓨) (F : (n : ℕ) → Hist 𝓞 𝓐' 𝓨 n → Hist 𝓞 𝓐 𝓨 n) (hF : ∀ n, Measurable (F n)) (f : 𝓐' → 𝓐) (hf : Measurable f) : Environment 𝓞 𝓐' 𝓨 where obs n := (env.obs n).comap (F n) (hF n) feedback n := (env.feedback n).comap (fun p ↦ ((F n p.1.1, p.1.2), f p.2)) (sorry) @[simp] lemma Environment.feedback_comap (env : Environment 𝓞 𝓐 𝓨) (hF : ∀ n, Measurable (F n)) (hf : Measurable f) (n : ℕ) : (env.comap F hF f hf).feedback n = (env.feedback n).comap (fun p ↦ ((F n p.1.1, p.1.2), f p.2)) (by fun_prop) := sorry end ComapAction end Comap end Learning end