Mathlib.Probability.Kernel
Kernel-measure probability helpers: graph-map product identities and composition-product assembly lemmas for conditional-law arguments.
CompProdAssembly 2 core · 1 supporting This file packages recurring measure-kernel assembly steps for composition products. ★ compProd_eq_of_inner_ae_kernel★ compProd_eq_of_inner_ae
Composition-product assembly lemmas
This file packages recurring measure-kernel assembly steps for composition products. The main lemmas turn an almost-everywhere equality of inner kernels on a product space into equality of the resulting outer composition products:
* compProd_eq_of_inner_ae: the inner kernels are mixed against a fixed s-finite measure;
* compProd_eq_of_inner_ae_kernel: the inner kernels are mixed against an indexed s-finite
kernel;
* compProd_map_snd_apply: the second-coordinate marginal of a kernel composition product
is the bind of the section of the inner kernel against the outer kernel value.
These results isolate the Fubini-style steps that otherwise require repeating
Measure.ext_prod, compProd_apply_prod, ae_ae_of_ae_compProd, and
lintegral_congr_ae.
CompProd assembly from an a.e. inner equality, indexed-integrator form. Consider two Markov-style kernels KL, KR from a base space to an outer space, each built by mixing the section at a base point of an inner kernel — fL, respectively fR, on the product of the base space and an intermediate space — against a fixed intermediate kernel κ evaluated at that point: KL a equals the section fL(a,·) composed with κ a and KR a equals the section fR(a,·) composed with κ a. If the inner kernels fL and fR agree almost everywhere with respect to the composition product of the base measure ν and κ, then the composition products ν ⊗ₘ KL and ν ⊗ₘ KR are equal.
Formal statement
Proof (Lean source)
CompProd assembly from an a.e. inner equality. Consider two Markov-style kernels KL, KR from a base space to an outer space, each built by mixing the section at a base point of an inner kernel — fL, respectively fR, on the product of the base space and an intermediate space — against a fixed intermediate measure μ: KL a equals the section fL(a,·) composed with μ and KR a equals the section fR(a,·) composed with μ. If the inner kernels fL and fR agree almost everywhere with respect to the composition product of the base measure ν with the constant-μ kernel, then the composition products ν ⊗ₘ KL and ν ⊗ₘ KR are equal.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
compProd_map_snd_applytheorem — Snd-marginal of a composition product, pointwise (disintegration backbone).Proof (Lean source)
theorem compProd_map_snd_apply {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] (κ₁ : Kernel α β) (κ₂ : Kernel (α × β) γ) [IsSFiniteKernel κ₁] [IsSFiniteKernel κ₂] (a : α) : ((κ₁ ⊗ₖ κ₂).map snd) a = (κ₂.sectR a) ∘ₘ (κ₁ a) := by rw [Kernel.map_apply _ measurable_snd, Kernel.compProd_apply_eq_compProd_sectR, ← Measure.snd, Measure.snd_compProd]
GraphMapProd 2 core · 2 supporting If νₗ is an s-finite measure on γ and Φ : β × γ → δ is measurable, then pushing a product measure α ⊗ νₗ forward along the *graph map* (o, l) ↦ (o, Φ (o, l)) produces a composition product α.compProd κ, where the disinte ★ map_graph_prod_eq_compProd
The graph push-forward of a product measure is a composition product
If νₗ is an s-finite measure on γ and Φ : β × γ → δ is measurable, then
pushing a product measure α ⊗ νₗ forward along the graph map
(o, l) ↦ (o, Φ (o, l)) produces a composition product α.compProd κ, where the
disintegration kernel κ o = νₗ.map (fun l => Φ (o, l)) reads the first
coordinate as a parameter and pushes the γ-marginal through the slice of Φ.
This is the abstract measure-theoretic core of "exogenous noise plus a structural
mechanism gives an environment-invariant conditional law": the predictor marginal
is α, the exogenous-noise law is νₗ, the mechanism is Φ, and the resulting
conditional law of the response given the predictor is the kernel κ.
For three measurable spaces serving respectively as predictor, exogenous-noise, and response spaces, a measure on the exogenous-noise space, and a mechanism mapping a predictor--noise pair to a response, the structural-mechanism kernel assigns to each predictor value the push-forward of the noise measure through the corresponding slice of the mechanism.
Graph push-forward of a product measure is a composition product. For an s-finite measure α on a first factor, an s-finite measure νₗ on a second factor, and a measurable mechanism map Φ combining the two factors into a third space, pushing the product measure α.prod νₗ forward along the graph map (o, l) ↦ (o, Φ (o, l)) equals the composition product of α with the mechanism kernel that sends each value o of the first coordinate to the pushforward of νₗ through the slice l ↦ Φ (o, l).
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
mechanismKernel_applytheorem — Pointwise value of mechanismKernel: κ o = νₗ.map (fun l => Φ (o, l)).hypothesesβ :sharedType u_1γ :sharedType u_2δ :sharedType u_3Φ :β × γ → δhΦ :o :βconclusionmechanismKernel νₗ Φ o = νₗ.map (fun l => Φ (o, l))Proof (Lean source)
theorem mechanismKernel_apply (νₗ : Measure γ) [SFinite νₗ] {Φ : β × γ → δ} (hΦ : Measurable Φ) (o : β) : mechanismKernel νₗ Φ o = νₗ.map (fun l => Φ (o, l)) := by unfold mechanismKernel rw [ProbabilityTheory.Kernel.map_apply _ hΦ, ProbabilityTheory.Kernel.prod_apply, ProbabilityTheory.Kernel.id_apply, ProbabilityTheory.Kernel.const_apply, MeasureTheory.Measure.dirac_prod, MeasureTheory.Measure.map_map hΦ measurable_prodMk_left] rfl -
instIsMarkovKernelMechanismKerneltheorem — The mechanism kernel is Markov when the exogenous-noise law is a probability measure and the mechanism is measurable.hypothesesβ :sharedType u_1γ :sharedType u_2δ :sharedType u_3νₗ :Φ :β × γ → δhΦ :conclusionIsMarkovKernel (mechanismKernel νₗ Φ)Proof (Lean source)
theorem instIsMarkovKernelMechanismKernel (νₗ : Measure γ) [IsProbabilityMeasure νₗ] {Φ : β × γ → δ} (hΦ : Measurable Φ) : IsMarkovKernel (mechanismKernel νₗ Φ) := by unfold mechanismKernel exact ProbabilityTheory.Kernel.IsMarkovKernel.map _ hΦ
ParameterizedKernelQuantileRealization 4 core · 6 supporting This file constructs a jointly measurable realization of a real-valued Markov kernel supported on the closed unit interval by one uniform variable. ★ map_quantileRealization
Parameterized quantile realization of real Markov kernels
This file constructs a jointly measurable realization of a real-valued Markov kernel supported on the closed unit interval by one uniform variable. The construction is the generalized inverse of each fiber's distribution function, valued first in the unit interval and then extended to real randomization inputs by clamping them to that interval. It proves both the exact fiberwise pushforward law and the pointwise range guarantee needed by parameterized coupling and conditional law constructions.
For a real-valued kernel, the unit-interval support property says that each parameter-specific fiber measure assigns mass one to the closed interval from zero to one. The kernel is not required to be Markov here; for a Markov kernel, as in the realization theorems, this says each fiber is a probability distribution supported on that interval.
Definition (Lean source)
For a real-valued kernel, a parameter value, and a uniform level in the closed unit interval, the unit-interval-valued parameterized quantile is the supremum of the points x of the unit interval whose fiber mass on the closed interval from zero to x is strictly smaller than the supplied level. The kernel is not required to be Markov here; the quantile interpretation holds for Markov kernels, as assumed by the realization theorems.
Definition (Lean source)
For a real-valued kernel and a parameter--randomization pair, the real-valued quantile realization evaluates the unit-interval quantile after clamping the randomization coordinate to the closed unit interval.
Definition (Lean source)
Given a real-valued Markov kernel, the condition that each fiber is supported on the closed unit interval, and a parameter value, pushing Lebesgue measure restricted to the closed unit interval through the real quantile section exactly recovers that kernel fiber.
Formal statement
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
quantileRealization_mem_unitIntervaltheorem — For a real-valued Markov kernel and a parameter--randomization pair, the corresponding realization value belongs to the closed unit interval.hypothesesconclusionquantileRealization κ p ∈ Icc (0 : ℝ) 1Proof (Lean source)
theorem quantileRealization_mem_unitInterval (κ : Kernel S ℝ) (p : S × ℝ) : quantileRealization κ p ∈ Icc (0 : ℝ) 1 := by exact (kernelUnitQuantile κ p.1 (projIcc (0 : ℝ) 1 zero_le_one p.2)).property -
measurable_kernelUnitQuantiletheorem — For a real-valued Markov kernel that is Markov, the unit-interval generalized inverse is jointly measurable in the kernel parameter and uniform level.Proof (Lean source)
theorem measurable_kernelUnitQuantile (κ : Kernel S ℝ) [IsMarkovKernel κ] : Measurable (uncurry (kernelUnitQuantile κ)) := by refine measurable_of_Ioi fun a ↦ ?_ simp only [preimage, uncurry, mem_Ioi] have h_monotone s : Monotone (fun x : unitInterval ↦ (κ s).real (Icc (0 : ℝ) x)) := fun x y hxy ↦ measureReal_mono (by gcongr) have sSup_eq_iUnion_rat : {x : S × unitInterval | a < kernelUnitQuantile κ x.1 x.2} = ⋃ (q : ℚ) (hqI : (↑q : ℝ) ∈ unitInterval) (_ : a < (q : ℝ)), {e | (κ e.1).real (Icc (0 : ℝ) ((⟨(q : ℝ), hqI⟩ : unitInterval) : ℝ)) < e.2} := by ext e simp_all only [lt_sSup_iff, mem_ofPred_eq, Subtype.exists, mem_Icc, Rat.cast_nonneg, mem_iUnion, exists_prop, exists_and_left, kernelUnitQuantile] constructor · rintro ⟨y, y_mem, hyI, (hy : a.1 < y)⟩ obtain ⟨q, hqa, hqy⟩ := exists_rat_btwn hy have hq0 : 0 ≤ q := by exact (Rat.cast_nonneg (K := ℝ)).mp (a.2.1.trans hqa.le) have hqI : (q : ℝ) ∈ unitInterval := ⟨a.2.1.trans hqa.le, hqy.le.trans hyI.2⟩ refine ⟨q, ⟨hq0, hqI.2⟩, hqa, lt_of_lt_of_le' y_mem ?_⟩ exact h_monotone e.1 (a := ⟨(q : ℝ), hqI⟩) (b := ⟨y, hyI⟩) hqy.le · intro he obtain ⟨q, hqI, hqa, h⟩ := he exact ⟨q, h, ⟨by simp [hqI.1], hqI.2⟩, hqa⟩ rw [sSup_eq_iUnion_rat] refine MeasurableSet.iUnion (fun b ↦ MeasurableSet.iUnion (fun bI ↦ MeasurableSet.iUnion (fun _ ↦ ?_))) refine measurableSet_lt ?_ measurable_snd.subtype_val simp_rw [measureReal_def] have hκ := κ.measurable_coe (s := Icc (0 : ℝ) ((⟨(b : ℝ), bI⟩ : unitInterval) : ℝ)) measurableSet_Icc fun_prop -
measurable_quantileRealizationtheorem — For a real-valued Markov kernel, the real-valued quantile realization is jointly measurable in its parameter and real randomization input.Proof (Lean source)
theorem measurable_quantileRealization (κ : Kernel S ℝ) [IsMarkovKernel κ] : Measurable (quantileRealization κ) := by change Measurable (fun p : S × ℝ ↦ ((kernelUnitQuantile κ p.1 (projIcc (0 : ℝ) 1 zero_le_one p.2) : unitInterval) : ℝ)) exact measurable_subtype_coe.comp <| (measurable_kernelUnitQuantile κ).comp <| measurable_fst.prodMk ((continuous_projIcc (a := (0 : ℝ)) (b := 1) (h := zero_le_one)).measurable.comp measurable_snd) -
measurable_quantileRealization_sectiontheorem — For a real-valued Markov kernel and a fixed parameter value, the resulting real-valued function of the randomization input is measurable.hypothesesconclusionMeasurable (fun u : ℝ => quantileRealization κ (s, u))Proof (Lean source)
@[fun_prop] theorem measurable_quantileRealization_section (κ : Kernel S ℝ) [IsMarkovKernel κ] (s : S) : Measurable (fun u : ℝ => quantileRealization κ (s, u)) := by exact (measurable_quantileRealization κ).comp (measurable_const.prodMk measurable_id) -
map_kernelUnitQuantiletheorem — Given a real-valued Markov kernel, the condition that each fiber is supported on the closed unit interval, and a parameter value, pushing canonical uniform unit-interval volume through the fiber's quantile map exactly recovers that kernel fiber.hypothesesconclusionMeasure.map (fun u : unitInterval => (kernelUnitQuantile κ s u : ℝ)) volume = κ sProof (Lean source)
theorem map_kernelUnitQuantile (κ : Kernel S ℝ) [IsMarkovKernel κ] (hκ : SupportedOnUnitInterval κ) (s : S) : Measure.map (fun u : unitInterval => (kernelUnitQuantile κ s u : ℝ)) volume = κ s := by let f := fun u : unitInterval => (kernelUnitQuantile κ s u : ℝ) have hf : Measurable f := measurable_subtype_coe.comp (measurable_kernelUnitQuantile κ).of_uncurry_left have hκ_compl : κ s (Icc (0 : ℝ) 1)ᶜ = 0 := by rw [measure_compl measurableSet_Icc (measure_ne_top (κ s) _), hκ s, measure_univ] simp have hκ_ae : ∀ᵐ y ∂κ s, y ∈ Icc (0 : ℝ) 1 := by rw [ae_iff] exact hκ_compl have hκ_Iic (z : unitInterval) : κ s (Iic (z : ℝ)) = κ s (Icc 0 (z : ℝ)) := by apply measure_congr refine hκ_ae.mono ?_ intro y hy apply propext exact ⟨fun h ↦ ⟨hy.1, h⟩, And.right⟩ refine (Measure.map f volume).ext_of_Iic (κ s) fun x ↦ ?_ rw [Measure.map_apply hf measurableSet_Iic] change volume {u : unitInterval | (kernelUnitQuantile κ s u : ℝ) ≤ x} = κ s (Iic x) by_cases hx0 : x < 0 · have hpre : {u : unitInterval | (kernelUnitQuantile κ s u : ℝ) ≤ x} = ∅ := by ext u simp only [mem_ofPred_eq, mem_empty_iff_false, iff_false] exact not_le.mpr (hx0.trans_le (kernelUnitQuantile κ s u).property.1) have hnull : κ s (Iic x) = 0 := by refine measure_mono_null ?_ hκ_compl intro y hy simp only [mem_Iic] at hy simp only [mem_compl_iff, mem_Icc, not_and_or] exact inl (not_le.mpr (hy.trans_lt hx0)) rw [hpre, measure_empty, hnull] · have hx0' : 0 ≤ x := le_of_not_gt hx0 by_cases hx1 : x ≤ 1 · let xI : unitInterval := ⟨x, hx0', hx1⟩ have hIic : κ s (Iic x) = κ s (Icc 0 x) := hκ_Iic xI have κ_in_I : ((κ s).real (Icc (0 : ℝ) x)) ∈ unitInterval := ⟨measureReal_nonneg, measureReal_le_one⟩ rw [hIic, ← ofReal_measureReal (measure_ne_top (κ s) _), ← unitInterval.volume_Iic ⟨_, κ_in_I⟩] congr with ξ constructor · intro (hξ : kernelUnitQuantile κ s ξ ≤ xI) change ξ ≤ (κ s).real (Icc (0 : ℝ) x) by_cases hx : xI = 1 · have hx' : x = 1 := congrArg val hx rw [hx', measureReal_def, hκ s] simpa using ξ.2.2 let g := fun y : unitInterval ↦ (κ s).real (Icc (0 : ℝ) y) let nebot : NeBot (𝓝[>] xI) := by refine nhdsGT_neBot_of_exists_gt ?_ use 1 exact lt_of_le_of_ne xI.2.2 hx refine le_of_tendsto_of_tendsto (b := 𝓝[>] xI) (g := g) continuousWithinAt_const ?_ ?_ · let h := cdf (κ s) have h_continuousWithinAt := continuousWithinAt_Ioi_iff_Ici.mpr (h.right_continuous (xI : ℝ)) have hreal (y : unitInterval) : (κ s).real (Icc (0 : ℝ) (y : ℝ)) = h (y : ℝ) := by change (κ s).real (Icc (0 : ℝ) (y : ℝ)) = cdf (κ s) (y : ℝ) rw [ProbabilityTheory.cdf_eq_real, measureReal_def, measureReal_def, hκ_Iic y] simp_rw [g, hreal] rw [hreal xI] exact h_continuousWithinAt.comp (Continuous.continuousWithinAt (by fun_prop)) (fun y hy ↦ hy) · refine eventually_nhdsWithin_of_forall fun y hy ↦ ?_ by_contra! h simp only [sSup_le_iff, kernelUnitQuantile] at hξ specialize hξ y h grind · intro (hξ : ξ ≤ (κ s).real (Icc (0 : ℝ) x)) change kernelUnitQuantile κ s ξ ≤ xI simp only [sSup_le_iff, kernelUnitQuantile] intro c hc by_contra! h have h_lt : ¬(κ s).real (Icc (0 : ℝ) x) ≤ (κ s).real (Icc (0 : ℝ) c) := not_le.mpr (lt_of_le_of_lt' hξ hc) refine h_lt ?_ refine measureReal_mono ?_ intro z hz exact ⟨hz.1, hz.2.trans (by exact_mod_cast h.le)⟩ · have hx1' : 1 < x := lt_of_not_ge hx1 have hpre : {u : unitInterval | (kernelUnitQuantile κ s u : ℝ) ≤ x} = univ := by ext u simp only [mem_ofPred_eq, mem_univ, iff_true] exact (kernelUnitQuantile κ s u).property.2.trans hx1'.le have hfull : κ s (Iic x) = 1 := by calc κ s (Iic x) = κ s univ := by apply measure_congr refine hκ_ae.mono ?_ intro y hy exact propext ⟨fun _ ↦ mem_univ y, fun _ ↦ hy.2.trans hx1'.le⟩ _ = 1 := measure_univ rw [hpre, measure_univ, hfull] -
ae_quantileRealization_mem_unitIntervaltheorem — For a real-valued Markov kernel and a parameter value, the realization section lies in the closed unit interval almost everywhere under the uniform law.hypothesesconclusion∀ᵐ u ∂(volume.restrict (Icc (0 : ℝ) 1)), quantileRealization κ (s, u) ∈ Icc (0 : ℝ) 1Proof (Lean source)
theorem ae_quantileRealization_mem_unitInterval (κ : Kernel S ℝ) (s : S) : ∀ᵐ u ∂(volume.restrict (Icc (0 : ℝ) 1)), quantileRealization κ (s, u) ∈ Icc (0 : ℝ) 1 := by exact Filter.Eventually.of_forall fun u => quantileRealization_mem_unitInterval κ (s, u)
ProductCondDistrib 2 core · 0 supporting Let ρ be a finite base measure on α, and let κ : Kernel α β and η : Kernel α γ be Markov kernels. ★ condDistrib_fst_of_compProd_prod★ condDistrib_snd_of_compProd_prod
Conditional distributions for product kernels
Let ρ be a finite base measure on α, and let κ : Kernel α β and
η : Kernel α γ be Markov kernels. After sampling (B, C) from the product kernel
Kernel.prod κ η over the base coordinate, the conditional distribution of B given the
base coordinate is κ, and the conditional distribution of C given the base coordinate
is η.
The public theorems condDistrib_fst_of_compProd_prod and
condDistrib_snd_of_compProd_prod record these two coordinate conditionals for
Measure.compProd ρ (Kernel.prod κ η).
For the joint law formed by combining a finite base measure ρ with the product of two Markov kernels κ and η, the conditional distribution of the first product-kernel coordinate given the base coordinate equals κ, for ρ-almost every base point.
Formal statement
Proof (Lean source)
For the joint law formed by combining a finite base measure ρ with the product of two Markov kernels κ and η, the conditional distribution of the second product-kernel coordinate given the base coordinate equals η, for ρ-almost every base point.