import Mathlib.MeasureTheory.Order.Lattice 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.Analysis.Normed.Ring.Basic import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.Probability.Kernel.Composition.MapComap /-! # Standalone extraction for `Learning.IT.instIsProbabilityMeasureForallNatProdBayesTrajMeasure` Definitions are copied verbatim; theorem proofs are replaced by `sorry`. Auto-generated by Referee. -/ 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 namespace Learning.IT end Learning.IT -- ═══ 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 Ω} /-- A stochastic, sequential algorithm. -/ 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] instance (alg : Algorithm 𝓐 𝓨) (n : ℕ) : IsMarkovKernel (alg.policy n) := alg.h_policy n instance (alg : Algorithm 𝓐 𝓨) : IsProbabilityMeasure alg.p0 := alg.hp0 /-- An algorithm with observations in `𝓧 × 𝓨` obtained from an algorithm with observations in `𝓨` by ignoring the `𝓧` component of each observation. -/ @[simps] def Algorithm.prodLeft (𝓧 : Type*) [MeasurableSpace 𝓧] (alg : Algorithm 𝓐 𝓨) : Algorithm 𝓐 (𝓧 × 𝓨) where policy n := (alg.policy n).comap (fun h i ↦ ((h i).1, (h i).2.2)) (sorry) p0 := alg.p0 /-- A stochastic environment. -/ 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] instance (env : Environment 𝓐 𝓨) (n : ℕ) : IsMarkovKernel (env.feedback n) := env.h_feedback n instance (env : Environment 𝓐 𝓨) : IsMarkovKernel env.ν0 := env.hp0 /-- Kernel describing the distribution of the next action-feedback pair given the history up to `n`. -/ noncomputable def stepKernel (alg : Algorithm 𝓐 𝓨) (env : Environment 𝓐 𝓨) (n : ℕ) : Kernel (Iic n → 𝓐 × 𝓨) (𝓐 × 𝓨) := alg.policy n ⊗ₖ env.feedback n instance (alg : Algorithm 𝓐 𝓨) (env : Environment 𝓐 𝓨) (n : ℕ) : IsMarkovKernel (stepKernel alg env n) := sorry end Learning end -- ═══ SequentialLearning.IonescuTulceaSpace ═══ section open MeasureTheory ProbabilityTheory Filter Real Finset open scoped ENNReal NNReal namespace Learning variable {𝓐 𝓨 Ω : Type*} {m𝓐 : MeasurableSpace 𝓐} {m𝓨 : MeasurableSpace 𝓨} {mΩ : MeasurableSpace Ω} /-- Measure on the sequence of actions and observations generated by the algorithm/environment. -/ noncomputable def trajMeasure (alg : Algorithm 𝓐 𝓨) (env : Environment 𝓐 𝓨) : Measure (ℕ → 𝓐 × 𝓨) := Kernel.trajMeasure (alg.p0 ⊗ₘ env.ν0) (stepKernel alg env) instance (alg : Algorithm 𝓐 𝓨) (env : Environment 𝓐 𝓨) : IsProbabilityMeasure (trajMeasure alg env) := sorry end Learning end -- ═══ SequentialLearning.BayesStationaryEnv ═══ section open MeasureTheory ProbabilityTheory Finset open scoped ENNReal NNReal namespace Learning variable {𝓔 𝓐 𝓨 Ω : Type*} variable [MeasurableSpace 𝓔] [MeasurableSpace 𝓐] [MeasurableSpace 𝓨] [MeasurableSpace Ω] section IsAlgEnvSeq /-- An environment with observations in `𝓔 × 𝓨`. The first element `e` of an observation is sampled from `Q` once and remains constant. The second element of an observation is sampled from `κ (e, a)`, where `a` is the corresponding action. -/ noncomputable def bayesStationaryEnv (Q : Measure 𝓔) [IsProbabilityMeasure Q] (κ : Kernel (𝓔 × 𝓐) 𝓨) [IsMarkovKernel κ] : Environment 𝓐 (𝓔 × 𝓨) where feedback n := let g : (Iic n → 𝓐 × 𝓔 × 𝓨) × 𝓐 → 𝓔 × 𝓐 := fun (h, a) => ((h ⟨0, sorry⟩).2.1, a) (Kernel.deterministic (Prod.fst ∘ g) (sorry)) ×ₖ (κ.comap g (sorry)) ν0 := (Kernel.const _ Q) ⊗ₖ κ.swapLeft variable {Q : Measure 𝓔} [IsProbabilityMeasure Q] {κ : Kernel (𝓔 × 𝓐) 𝓨} [IsMarkovKernel κ] variable {alg : Algorithm 𝓐 𝓨} {A : ℕ → Ω → 𝓐} {Y : ℕ → Ω → 𝓔 × 𝓨} variable {P : Measure Ω} [IsProbabilityMeasure P] end IsAlgEnvSeq namespace IT /-- A measure `P` on a measurable space that carries random variables `E`, `A`, and `Y` such that `IsBayesAlgEnvSeq Q κ alg E A Y P`. -/ noncomputable def bayesTrajMeasure (Q : Measure 𝓔) [IsProbabilityMeasure Q] (κ : Kernel (𝓔 × 𝓐) 𝓨) [IsMarkovKernel κ] (alg : Algorithm 𝓐 𝓨) : Measure (ℕ → 𝓐 × 𝓔 × 𝓨) := trajMeasure (alg.prodLeft 𝓔) (bayesStationaryEnv Q κ) instance (Q : Measure 𝓔) [IsProbabilityMeasure Q] (κ : Kernel (𝓔 × 𝓐) 𝓨) [IsMarkovKernel κ] (alg : Algorithm 𝓐 𝓨) : IsProbabilityMeasure (bayesTrajMeasure Q κ alg) := sorry end IT end Learning end