Module mathcomp.analysis.kernel

From HB Require Import structures.
From mathcomp Require Import boot order ssralg ssrnum ssrint interval.
From mathcomp Require Import interval_inference archimedean.
From mathcomp Require Import boolp classical_sets functions cardinality fsbigop.
From mathcomp Require Import reals topology ereal normedtype sequences esum.
From mathcomp Require Import measure numfun real_measure lebesgue_integral.

# Kernels This file provides a formation of kernels, s-finite kernels, sigma-finite kernels, finite transition kernels, finite kernels, subprobability kernels, and probability kernels, organized as a hierarchy of mathematical structures. The main formalized results are stability by composition for s-finite kernels [Lemma 3, Staton, ESOP 2017] and subprobability kernels [Theorem 14.26, Klenke 2014]. References: - R. Affeldt, C. Cohen, A. Saito. Semantics of probabilistic programs using s-finite kernels in Coq. CPP 2023 - S. Staton. Commutative Semantics for Probabilistic Programming. ESOP 2017 - A. Klenke. Probability theory: A comprehensive course. 2014 ``` R.-ker X ~> Y == kernel from X to Y where X and Y are of type measurableType The HB class is Kernel. kseries == countable sum of kernels It is declared as an instance of the structure Kernel. It will also be shown to be an instance of SFiniteKernel if the sum is over s-finite kernels. measure_fam_uub k == the kernel k is uniformly upper-bounded R.-sfker X ~> Y == s-finite kernel The HB class is SFiniteKernel. kzero == kernel defined using the mzero measure R.-sigmafker X ~> Y == sigma-finite transition kernel The HB class is SigmaFiniteTransitionKernel. R.-ftker X ~> Y == finite transition kernel The HB class is FiniteTransitionKernel. R.-fker X ~> Y == finite kernel The HB class is FiniteKernel. R.-spker X ~> Y == subprobability kernel The HB class is SubProbabilityKernel. R.-pker X ~> Y == probability kernel The HB class is ProbabilityKernel. kdirac mf == kernel defined by a measurable function kprobability m == kernel defined by a probability measure kadd k1 k2 == lifting of the addition of measures to kernels knormalize f P := fun x => mnormalize (f x) P kcomp l k == "parameterized" composition for kernels l has type X -> {measure set Y -> \bar R} k has type X * Y -> {measure set Z -> \bar R} kcomp l k as type X -> set Z -> \bar R l \; k == same as kcomp l k but equipped with the type X -> {measure set Z -> \bar R} kfcomp k f == composition of a "kernel" and a function k has type X -> {measure set Y -> \bar R}. kproduct k1 k2 == "parameterized" product of kernels k1 has type T0 -> {measure set T1 -> \bar R}. k2 has type T0 * T1 -> {measure set T2 -> \bar R}. The result has type T0 -> set (T1 * T2) -> \bar R. mkproduct k1 k2 == same as kproduct k1 k2 but equipped with the type T0 -> {measure set (T1 * T2) -> \bar R} kproduct_snd k1 k2 := kproduct k1 (k2 \o snd) k2 has T1 -> {measure set T2 -> \bar R} It "ignores" the first argument of k2. kcomp_noparam k1 k2 := composition of kernels k1 has type T0 -> {measure set T1 -> \bar R}. k2 has type T1 -> {measure set T2 -> \bar R}. The return type is T0 -> set (T1 * T2) -> \bar R ```

Unset SsrOldRewriteGoalsOrder.  
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Theory.
Import numFieldTopology.Exports.

Local Open Scope classical_set_scope.
Local Open Scope ring_scope.
Local Open Scope ereal_scope.

Reserved Notation "R .-ker X ~> Y"
  (at level 42, format "R .-ker X ~> Y").
Reserved Notation "R .-sfker X ~> Y"
  (at level 42, format "R .-sfker X ~> Y").
Reserved Notation "R .-sigmafker X ~> Y"
  (at level 42, format "R .-sigmafker X ~> Y").
Reserved Notation "R .-ftker X ~> Y"
  (at level 42, format "R .-ftker X ~> Y").
Reserved Notation "R .-fker X ~> Y"
  (at level 42, format "R .-fker X ~> Y").
Reserved Notation "R .-spker X ~> Y"
  (at level 42, format "R .-spker X ~> Y").
Reserved Notation "R .-pker X ~> Y"
  (at level 42, format "R .-pker X ~> Y").

HBSource code.mixinSource code RecordSource code isKernelSource code dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
    (R : realType) (k : X -> {measure set Y -> \bar R}) := {
  measurable_kernel :
    forall USource code, measurable U -> measurable_fun [set: X] (k ^~ U) }.

#[shortSource code(type=kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code KernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code & isKernel _ _ X Y R k }.
Notation "R .-ker X ~> Y"Source code := (kernel X%type Y R).

Arguments measurable_kernel {_ _ _ _ _} _.

Lemma kernel_measurable_eq_cstSource code dSource code d'Source code (TSource code : measurableType d)
    (T'Source code : measurableType d') (RSource code : realType) (fSource code : R.-ker T ~> T') kSource code :
  measurable [set tSource code | f t [set: T'] == k].
Proof.
rewrite [X in measurable X](_ : _ = (f ^~ setT) @^-1` [set k]).
  by apply/seteqP; split => t/= /eqP.
have /(_ measurableT [set k]) := measurable_kernel f setT measurableT.
by rewrite setTI; exact.
Qed.

Lemma kernel_measurable_neq_cstSource code dSource code d'Source code (TSource code : measurableType d)
    (T'Source code : measurableType d') (RSource code : realType)  (fSource code : R.-ker T ~> T') kSource code :
  measurable [set tSource code | f t [set: T'] != k].
Proof.
rewrite [X in measurable X](_ : _ = (f ^~ setT) @^-1` [set~ k]).
  by apply/seteqP; split => t /eqP.
have /(_ measurableT [set~ k]) := measurable_kernel f setT measurableT.
by rewrite setTI; apply => //; exact: measurableC.
Qed.

Lemma kernel_measurable_fun_eq_cstSource code dSource code d'Source code (TSource code : measurableType d)
    (T'Source code : measurableType d') (RSource code : realType) (fSource code : R.-ker T ~> T') kSource code :
  measurable_fun [set: T] (fun tSource code => f t [set: T'] == k).
Proof.
move=> _ /= B mB; rewrite setTI.
have [/eqP->|/eqP->|/eqP->|/eqP->] := set_bool B.
- exact: kernel_measurable_eq_cst.
- rewrite (_ : _ @^-1` _ = [set bSource code | f b setT != k]).
    by apply/seteqP; split => [t /negbT//|t /negbTE].
  exact: kernel_measurable_neq_cst.
- by rewrite preimage_set0.
- by rewrite preimage_setT.
Qed.

Lemma eq_kernelSource code dSource code d'Source code (TSource code : measurableType d) (T'Source code : measurableType d')
    (RSource code : realType) (k1Source code k2Source code : R.-ker T ~> T') :
  (forall xSource code USource code, k1 x U = k2 x U) -> k1 = k2.
Proof.
move: k1 k2 => [m1 [[?]]] [m2 [[?]]] /= k12.
have ? : m1 = m2.
  by apply/funext => t; apply/eq_measure; apply/funext => U; rewrite k12.
by subst m1; f_equal; f_equal; f_equal; apply/Prop_irrelevance.
Qed.

Section kseries.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variable kSource code : (R.-ker X ~> Y)^nat.

Definition kseries

kseries : forall [d d' : measure_display] [X : measurableType d] [Y : measurableType d'] [R : realType], (R.-ker X ~> Y) ^nat -> X -> {measure set Y -> \bar R}%R kseries is not universe polymorphic Arguments kseries [d d']%_measure_display_scope [X Y R] k x kseries is transparent Expands to: Constant mathcomp.analysis.kernel.kseries Declared in library mathcomp.analysis.kernel, line 164, characters 11-18


Source code
 (xSource code : X) : {measure set Y -> \bar R} := mseries (k ^~ x) 0.

Lemma measurable_fun_kseriesSource code (USource code : set Y) :
  measurable U -> measurable_fun [set: X] (kseries ^~ U).
Proof.
by move=> mU; apply: ge0_emeasurable_sum => // n _; exact/measurable_kernel.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  isKernel.Build _ _ _ _ _ kseries measurable_fun_kseries.

End kseries.

Lemma integral_kseriesSource code dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d')
  (RSource code : realType) (kSource code : (R.-ker X ~> Y)^nat) (fSource code : Y -> \bar R) xSource code :
  (forall ySource code, 0 <= f y) ->
  measurable_fun [set: Y] f ->
  \int[kseries k x]_ySource code (f y) = \sum_(iSource code <oo) \int[k i x]_ySource code (f y).
Proof.
by move=> f0 mf; rewrite /kseries/= ge0_integral_measure_series.
Qed.

Section measure_fam_uub.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : numFieldType).
Variable kSource code : X -> {measure set Y -> \bar R}.

Definition measure_fam_uub

measure_fam_uub : forall [d d' : measure_display] [X : measurableType d] [Y : measurableType d'] [R : numFieldType], (X -> {measure set Y -> \bar R}%R) -> Prop measure_fam_uub is not universe polymorphic Arguments measure_fam_uub [d d']%_measure_display_scope [X Y R] k%_function_scope measure_fam_uub is transparent Expands to: Constant mathcomp.analysis.kernel.measure_fam_uub Declared in library mathcomp.analysis.kernel, line 190, characters 11-26


Source code
:= exists rSource code, forall xSource code, k x [set: Y] < r%:E.

Lemma measure_fam_uubPSource code : measure_fam_uub <->
  exists rSource code : {posnum R}, forall xSource code, k x [set: Y] < r%:num%:E.
Proof.
split => [|] [r kr]; last by exists r%:num.
have [[point _]|/forallNP empty] := pselect (exists rSource code : X, True).
  suff r_gt0 : (0 < r)%R by exists (PosNum r_gt0).
  rewrite -lte_fin; exact: le_lt_trans (kr point).
by exists (PosNum ltr01) => x; have := empty x.
Qed.

End measure_fam_uub.

HBSource code.mixinSource code RecordSource code isSFiniteKernel_subdefSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) := {
  sfinite_kernel_subdef : exists2 sSource code : (R.-ker X ~> Y)^nat,
    forall nSource code, measure_fam_uub (s n) &
    forall xSource code USource code, measurable U -> k x U = kseries s x U }.

HBSource code.structureSource code DefinitionSource code SFiniteKernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @Kernel _ _ _ _ R k &
         isSFiniteKernel_subdef _ _ X Y R k }.
Notation "R .-sfker X ~> Y"Source code := (SFiniteKernel.type X%type Y R).
Arguments sfinite_kernel_subdef {_ _ _ _ _} _.

Lemma eq_sfkernelSource code dSource code d'Source code (TSource code : measurableType d) (T'Source code : measurableType d')
    (RSource code : realType) (k1Source code k2Source code : R.-sfker T ~> T') :
  (forall xSource code USource code, k1 x U = k2 x U) -> k1 = k2.
Proof.
move: k1 k2 => [m1 [[?] [?]]] [m2 [[?] [?]]] /= k12.
have ? : m1 = m2.
  by apply/funext => t; apply/eq_measure; apply/funext => U; rewrite k12.
by subst m1; f_equal; f_equal; f_equal; apply/Prop_irrelevance.
Qed.

Section kzero.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).

Definition kzero

kzero : forall [d d' : measure_display] [X : measurableType d] (Y : measurableType d') (R : realType), X -> {measure set Y -> \bar R}%R kzero is not universe polymorphic Arguments kzero [d d']%_measure_display_scope [X] Y R _ kzero is transparent Expands to: Constant mathcomp.analysis.kernel.kzero Declared in library mathcomp.analysis.kernel, line 231, characters 11-16


Source code
 (_ : X) : {measure set Y -> \bar R} := mzero.

Let measurable_fun_kzeroSource code USource code : measurable U ->
  measurable_fun [set: X] (kzero ^~ U).
Proof.
by move=> ?/=; exact: measurable_cst. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isKernelSource code.Build _ _ X Y R kzero measurable_fun_kzero.

Lemma kzero_uubSource code : measure_fam_uub kzero.
Proof.
by exists 1%R => /= t; rewrite /mzero/=. Qed.

End kzero.

HBSource code.mixinSource code RecordSource code isSigmaFiniteTransitionKernelSource code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
    (R : realType) (k : X -> {measure set Y -> \bar R}) := {
  kernel_sigma_finite : forall xSource code, sigma_finite [set: Y] (k x) }.

#[shortSource code(type=sigma_finite_kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code SigmaFiniteTransitionKernelSource code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @Kernel _ _ _ _ _ k &
         isSigmaFiniteTransitionKernel _ _ X Y R k }.

Notation "R .-sigmafker X ~> Y"Source code := (sigma_finite_kernel X%type Y R).

HBSource code.mixinSource code RecordSource code isFiniteTransitionKernelSource code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
    (R : realType) (k : X -> {measure set Y -> \bar R}) := {
  kernel_finite_transition : forall xSource code, fin_num_fun (k x) }.

#[deprecated(since="mathcomp-analysis 1.11.0",
             note="Use isFiniteTransitionKernel instead.")]
Notation isFiniteTransitionSource code x1 x2 x3 x4 x5 x6 :=
  (isFiniteTransitionKernel x1 x2 x3 x4 x5 x6).

#[shortSource code(type=finite_transition_kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code FiniteTransitionKernelSource code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @SFiniteKernel _ _ _ _ _ k &
         isFiniteTransitionKernel _ _ X Y R k }.

Module isFiniteTransitionSource code.
#[deprecated(since="mathcomp-analysis 1.11.0",
             note="Use isFiniteTransitionKernel.Build instead.")]
Notation BuildSource code x1 x2 x3 x4 x5 x6 :=
  (isFiniteTransitionKernel.Build x1 x2 x3 x4 x5 x6) (only parsing).
End isFiniteTransition.

Notation "R .-ftker X ~> Y"Source code := (finite_transition_kernel X%type Y R).

HBSource code.mixinSource code RecordSource code isMeasureFamUubSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) := {
  measure_uub : measure_fam_uub k }.

#[shortSource code(type=finite_kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code FiniteKernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @FiniteTransitionKernel _ _ _ _ _ k &
         isMeasureFamUub _ _ X Y R k }.
Notation "R .-fker X ~> Y"Source code := (finite_kernel X%type Y R).
Arguments measure_uub {_ _ _ _ _} _.

HBSource code.factorySource code RecordSource code Kernel_isFiniteSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) & isKernel _ _ _ _ _ k := {
  measure_uub : measure_fam_uub k }.

HBSource code.buildersSource code ContextSource code dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
  (R : realType) k & Kernel_isFinite d d' X Y R k.

Let sfinite_finiteSource code :
  exists2 k_Source code : (R.-ker _ ~> _)^nat, forall nSource code, measure_fam_uub (k_ n) &
    forall xSource code USource code, measurable U -> k x U = mseries (k_ ^~ x) 0 U.
Proof.
exists (fun nSource code => if n is O return R.-ker X ~> Y then k else @kzero _ _ X Y R).
  by case => [|_]; [exact: measure_uub|exact: kzero_uub].
move=> t U mU/=; rewrite /mseries.
rewrite (nneseries_split _ 1%N)// big_mkord big_ord_recl/= big_ord0 adde0.
rewrite ereal_series (@eq_eseriesr _ _ (fun=> 0)); first by case.
by rewrite eseries0// adde0.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isSFiniteKernel_subdefSource code.Build d d' X Y R k sfinite_finite.

Let kernel_sigma_finiteSource code xSource code : sigma_finite setT (k x).
Proof.
apply: fin_num_fun_sigma_finite; first by rewrite measure0.
apply: lty_fin_num_fun.
by have [r kr] := measure_uub; rewrite (lt_trans (kr x)) ?ltry.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isSigmaFiniteTransitionKernelSource code.Build d d' X Y R k kernel_sigma_finite.

Let finite_transition_finiteSource code : forall xSource code, fin_num_fun (k x).
Proof.
move=> x U mU.
have [r kr] := measure_uub.
rewrite ge0_fin_numE//.
rewrite (@le_lt_trans _ _ (k x setT)) ?le_measure ?inE//.
by rewrite (lt_trans (kr x)) ?ltry.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isFiniteTransitionKernelSource code.Build d d' X Y R k finite_transition_finite.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isMeasureFamUubSource code.Build d d' X Y R k measure_uub.

HBSource code.endSource code.

Section sfinite.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d').
Variables (RSource code : realType) (kSource code : R.-sfker X ~> Y).

Let sSource code : (X -> {measure set Y -> \bar R})^nat :=
  let: exist2 x _ _ := cid2 (sfinite_kernel_subdef k) in x.

Let msSource code nSource code : @isKernel d d' X Y R (s n).
Proof.
split; rewrite /s; case: cid2 => /= s' s'_uub kE.
exact: measurable_kernel.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code nSource code :=Source code msSource code n.

Let s_uubSource code nSource code : measure_fam_uub (s n).
Proof.
by rewrite /s; case: cid2. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code nSource code :=Source code @Kernel_isFiniteSource code.Build d d' X Y R (s n) (s_uub n).

Lemma sfinite_kernelSource code : exists sSource code : (R.-fker X ~> Y)^nat,
  forall xSource code USource code, measurable U -> k x U = kseries s x U.
Proof.
by exists s => x U mU; rewrite /s /= /s; case: cid2 => ? ? ->. Qed.

End sfinite.

Lemma sfinite_kernel_measureSource code dSource code d'Source code (ZSource code : measurableType d) (XSource code : measurableType d')
    (RSource code : realType) (kSource code : R.-sfker Z ~> X) (zSource code : Z) :
  sfinite_measure (k z).
Proof.
have [s ks] := sfinite_kernel k.
exists (s ^~ z).
  move=> n; have [r snr] := measure_uub (s n).
  by apply: lty_fin_num_fun; rewrite (lt_le_trans (snr _))// leey.
by move=> U mU; rewrite ks.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  @Kernel_isFinite.Build _ _ _ _ R (@kzero _ _ X Y R)
                                   (@kzero_uub _ _ X Y R).

HBSource code.factorySource code RecordSource code Kernel_isSFiniteSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) & isKernel _ _ _ _ _ k := {
  sfinite : exists sSource code : (R.-fker X ~> Y)^nat,
    forall xSource code USource code, measurable U -> k x U = kseries s x U }.

HBSource code.buildersSource code ContextSource code dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
  (R : realType) k & Kernel_isSFinite d d' X Y R k.

Lemma sfinite_subdefSource code : isSFiniteKernel_subdef d d' X Y R k.
Proof.
split; have [s sE] := sfinite; exists s => //.
by move=> n; exact: measure_uub.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code sfinite_subdefSource code.

HBSource code.endSource code.

Section sfkseries.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variables kSource code : (R.-sfker X ~> Y)^nat.

Let sfinite_kseriesSource code : exists2 k_Source code : (R.-ker _ ~> _)^nat,
  forall nSource code, measure_fam_uub (k_ n) &
  forall xSource code USource code, measurable U -> kseries k x U = mseries (k_ ^~ x) 0 U.
Proof.
have /ppcard_eqP[f] : ([set: nat] #= [set: nat * nat])%card.
  by rewrite card_eq_sym; exact: card_nat2.
pose p nSource code : (R.-fker X ~> Y)^nat := sval (cid (sfinite_kernel (k n))).
exists (fun iSource code => p (f i).1 (f i).2).
  move=> n; have [r Hr] := measure_uub (p (f n).1 (f n).2).
  by exists r => x /=; exact: Hr.
move=> x U mU; rewrite /kseries /mseries/= /mseries/=.
have kE i : k i x U = \sum_(jSource code <oo) p i j x U.
  by rewrite /p /sval/=; case: cid => k_ ->.
transitivity (\esum_(lSource code in [set: nat] `*` [set: nat]) p l.1 l.2 x U).
  rewrite (_ : _ `*` _ = setT `*`` (fun=> setT)); first by apply/seteqP; split.
  rewrite -(@esum_esum _ _ _ _ _ (fun iSource code jSource code => p i j x U))//.
  rewrite nneseries_esumT//; apply: eq_esum => i _.
  by rewrite kE// nneseries_esumT.
rewrite (reindex_esum [set: nat] _ f)//.
  have := @bijTT _ _ f.
  by rewrite -setTT_bijective/= -[in X in set_bij _ X _ -> _](@setXTT nat nat).
by rewrite nneseries_esumT//; exact: eq_esum.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  isSFiniteKernel_subdef.Build _ _ _ _ R (kseries k) sfinite_kseries.
End sfkseries.

HBSource code.mixinSource code RecordSource code isSubProbabilityKernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) := {
  sprob_kernel : ereal_sup [set k x [set: Y] | xSource code in [set: X]] <= 1 }.

#[shortSource code(type=sprobability_kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code SubProbabilityKernelSource code
    dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @FiniteKernel _ _ _ _ _ k &
         isSubProbabilityKernel _ _ X Y R k }.
Notation "R .-spker X ~> Y"Source code := (sprobability_kernel X%type Y R).

Lemma sprob_kernelPSource code dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d')
    (RSource code : realType) (kSource code : X -> set Y -> \bar R) :
  ereal_sup [set k x [set: _] | xSource code in [set: _]] <= 1 <->
  forall xSource code, k x [set: Y] <= 1.
Proof.
split => [+ x|k1]; last by apply: ge_ereal_sup => _ /= [z _ <-]; exact: k1.
by apply/le_trans/ereal_sup_ubound => /=; exists x.
Qed.

Lemma sprob_kernel_le1Source code dSource code d'Source code (XSource code : measurableType d)
    (YSource code : measurableType d') (RSource code : realType) (kSource code : R.-spker X ~> Y) xSource code :
  k x [set: Y] <= 1.
Proof.
by apply: (sprob_kernelP (fun xSource code ASource code => k x A)).1; exact: sprob_kernel. Qed.

HBSource code.factorySource code RecordSource code Kernel_isSubProbabilitySource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) & isKernel _ _ X Y R k := {
  sprob_kernel : ereal_sup [set k x [set: Y] | xSource code in [set: X]] <= 1 }.

HBSource code.buildersSource code ContextSource code dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
  (R : realType) k & Kernel_isSubProbability d d' X Y R k.

Let finiteSource code : @Kernel_isFinite d d' X Y R k.
Proof.
split; exists 2%R => /= ?; rewrite (@le_lt_trans _ _ 1%:E) ?lte_fin ?ltr1n//.
by rewrite (le_trans _ sprob_kernel)//; exact: ereal_sup_ubound.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code finiteSource code.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isSubProbabilityKernelSource code.Build _ _ _ _ _ k sprob_kernel.

HBSource code.endSource code.

HBSource code.mixinSource code RecordSource code isProbabilityKernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) := {
  prob_kernel : forall xSource code, k x [set: Y] = 1 }.

#[shortSource code(type=probability_kernelSource code)]Source code
HBSource code.structureSource code DefinitionSource code ProbabilityKernelSource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType) :=
  { kSource code of @SubProbabilityKernel _ _ _ _ _ k &
         isProbabilityKernel _ _ X Y R k }.
Notation "R .-pker X ~> Y"Source code := (probability_kernel X%type Y R).

HBSource code.factorySource code RecordSource code Kernel_isProbabilitySource code dSource code d'Source code
    (XSource code :Source code measurableTypeSource code d) (Y : measurableType d') (R : realType)
    (k : X -> {measure set Y -> \bar R}) & isKernel _ _ X Y R k := {
  prob_kernel : forall xSource code, k x [set: Y] = 1 }.

HBSource code.buildersSource code ContextSource code dSource code d'Source code (XSource code :Source code measurableTypeSource code d) (Y : measurableType d')
  (R : realType) k & Kernel_isProbability d d' X Y R k.

Let sprob_kernelSource code : @Kernel_isSubProbability d d' X Y R k.
Proof.
by split; apply: ge_ereal_sup => x [y _ <-{x}]; rewrite prob_kernel.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code sprob_kernelSource code.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isProbabilityKernelSource code.Build _ _ _ _ _ k prob_kernel.

HBSource code.endSource code.

Lemma finite_kernel_measureSource code dSource code d'Source code (XSource code : measurableType d)
    (YSource code : measurableType d') (RSource code : realType) (kSource code : R.-fker X ~> Y) (xSource code : X) :
  fin_num_fun (k x).
Proof.
have [r k_r] := measure_uub k.
by apply: lty_fin_num_fun; rewrite (@lt_trans _ _ r%:E) ?ltey.
Qed.

Section measurable_prod_subset_kernel.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Implicit Types A : set (X * Y).

Section xsection_kernel.
Variable (kSource code : R.-ker X ~> Y) (DSource code : set Y) (mDSource code : measurable D).
Let kDSource code xSource code := mrestr (k x) mD.
HBSource code.instanceSource code DefinitionSource code _Source code xSource code :=Source code MeasureSource code.on (kD x).
Let phiSource code ASource code := fun xSource code => kD x (xsection A x).
Let XYSource code := [set ASource code | measurable A /\ measurable_fun [set: X] (phi A)].

Let phiMSource code (ASource code : set X) BSource code : phi (A `*` B) = (fun xSource code => kD x B * (\1_A x)%:E).
Proof.
rewrite funeqE => x; rewrite indicE /phi/=.
have [xA|xA] := boolP (x \in A); first by rewrite mule1 in_xsectionX.
by rewrite mule0 notin_xsectionX// set0I measure0.
Qed.

Lemma measurable_prod_subset_xsection_kernelSource code :
    (forall xSource code, exists MSource code, forall XSource code, measurable X -> kD x X < M%:E) ->
  measurable `<=` XY.
Proof.
move=> kD_ub.
rewrite prod_measurable_rectangle; set C := rectangle _ _.
have CI : setI_closed C by apply: setI_closed_rectangle=> *; exact: measurableI.
have CT : C setT by rewrite -setXTT; exact: rectangle_setX.
have CXY : C `<=` XY.
  move=> _ [A mA [B mB <-]]; split; first exact: measurableX.
  rewrite phiM.
  apply: emeasurable_funM => //; first exact/measurable_kernel/measurableI.
  by apply/measurable_EFinP; rewrite (_ : \1_ _ = mindic R mA).
suff lsystemB : lambda_system setT XY by exact: lambda_system_subset.
split => //; [exact: CXY| |exact: xsection_ndseq_closed].
move=> A B BA [mA mphiA] [mB mphiB]; split; first exact: measurableD.
suff : phi (A `\` B) = (fun xSource code => phi A x - phi B x).
  by move=> ->; exact: emeasurable_funB.
rewrite funeqE => x; rewrite /phi/= xsectionD// measureD/=.
- exact: measurable_xsection.
- exact: measurable_xsection.
- have [M kM] := kD_ub x.
  rewrite (lt_le_trans (kM (xsection A x) _)) ?leey//.
  exact: measurable_xsection.
- by rewrite setIidr//; exact: le_xsection.
Qed.

End xsection_kernel.

End measurable_prod_subset_kernel.

Section measurable_fun_xsection_finite_kernel.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variable kSource code : R.-fker X ~> Y.
Implicit Types A : set (X * Y).

Let phiSource code ASource code := fun xSource code => k x (xsection A x).
Let XYSource code := [set ASource code | measurable A /\ measurable_fun [set: X] (phi A)].

Lemma measurable_fun_xsection_finite_kernelSource code ASource code :
  A \in measurable -> measurable_fun [set: X] (phi A).
Proof.
move: A; suff : measurable `<=` XY by move=> + A; rewrite inE => /[apply] -[].
move=> /= A mA; rewrite /XY/=; split => //; rewrite (_ : phi _ =
    (fun xSource code => mrestr (k x) measurableT (xsection A x))).
  by apply/funext => x//=; rewrite /mrestr setIT.
apply measurable_prod_subset_xsection_kernel => // x.
have [r hr] := measure_uub k; exists r => B mB.
by rewrite (le_lt_trans _ (hr x)) // /mrestr /= setIT le_measure// inE.
Qed.

End measurable_fun_xsection_finite_kernel.

Section measurable_fun_integral_finite_sfinite.
Context {dSource code d'Source code} {XSource code : measurableType d} {YSource code : measurableType d'} {RSource code : realType}
  (kSource code : X * Y -> \bar R).

Import HBNNSimple.
Import MeasurableR.

Lemma measurable_fun_xsection_integralSource code
    (lSource code : X -> {measure set Y -> \bar R})
    (k_Source code : {nnsfun (X * Y) >-> R}^nat)
    (ndk_Source code : nondecreasing_seq (k_ : (X * Y -> R)^nat))
    (k_kSource code : forall zSource code, (k_ n z)%:E @[nSource code --> \oo] --> k z) :
  (forall nSource code rSource code,
    measurable_fun [set: X] (fun xSource code => l x (xsection (k_ n @^-1` [set r]) x))) ->
  measurable_fun [set: X] (fun xSource code => \int[l x]_ySource code k (x, y)).
Proof.
move=> h.
rewrite (_ : (fun xSource code => _) =
    (fun xSource code => limn_esup (fun nSource code => \int[l x]_ySource code (k_ n (x, y))%:E))).
  apply/funext => x.
  transitivity (lim (\int[l x]_ySource code (k_ n (x, y))%:E @[nSource code --> \oo])); last first.
    rewrite is_cvg_limn_esupE//.
    apply: ereal_nondecreasing_is_cvgn => m n mn.
    apply: ge0_le_integral => //.
    - by move=> y _; rewrite lee_fin.
    - exact/measurable_EFinP/measurableT_comp.
    - exact/measurable_EFinP/measurableT_comp.
    - by move=> y _; rewrite lee_fin; exact/lefP/ndk_.
  rewrite -monotone_convergence//.
  - by move=> n; exact/measurable_EFinP/measurableT_comp.
  - by move=> n y _; rewrite lee_fin.
  - by move=> y _ m n mn; rewrite lee_fin; exact/lefP/ndk_.
  - by apply: eq_integral => y _; apply/esym/cvg_lim => //; exact: k_k.
apply: measurable_fun_limn_esup => n.
rewrite [X in measurable_fun _ X](_ : _ = (fun xSource code => \int[l x]_ySource code
    (\sum_(rSource code \in range (k_ n))
      r * \1_(k_ n @^-1` [set r]) (x, y))%:E)).
  by apply/funext => x; apply: eq_integral => y _; rewrite fimfunE.
rewrite [X in measurable_fun _ X](_ : _ = (fun xSource code => \sum_(rSource code \in range (k_ n))
    (\int[l x]_ySource code (r * \1_(k_ n @^-1` [set r]) (x, y))%:E))).
  apply/funext => x; rewrite -ge0_integral_fsum//.
  - move=> r.
    apply/measurable_EFinP/measurableT_comp => [//|].
    exact/measurableT_comp.
  - by move=> m y _; rewrite nnfun_muleindic_ge0.
  - by apply: eq_integral => y _; rewrite -fsumEFin.
apply: emeasurable_fsum => // r.
rewrite [X in measurable_fun _ X](_ : _ = fun xSource code => r%:E *
    \int[l x]_ySource code (\1_(k_ n @^-1` [set r]) (x, y))%:E).
  apply/funext => x; under eq_integral do rewrite EFinM.
  have [r0|r0] := leP 0%R r.
    by rewrite ge0_integralZl//; exact/measurable_EFinP/measurableT_comp.
  rewrite integral0_eq.
    by move=> y _; rewrite preimage_nnfun0// indic0 mule0.
  by rewrite integral0_eq ?mule0// => y _; rewrite preimage_nnfun0// indic0.
apply/measurable_funeM.
rewrite (_ : (fun xSource code => _) = (fun xSource code => l x (xsection (k_ n @^-1` [set r]) x))); last first.
  exact/h.
apply/funext => x; rewrite integral_indic//; last first.
  congr (l x _); apply/funext => y1/=; rewrite /xsection/= inE.
  by apply/propext; tauto.
rewrite (_ : (fun xSource code => _) = xsection (k_ n @^-1` [set r]) x); last first.
  exact: measurable_xsection.
by rewrite /xsection; apply/seteqP; split=> y/= /[!inE].
Qed.

Lemma measurable_fun_integral_finite_kernelSource code (lSource code : R.-fker X ~> Y)
    (k0Source code : forall zSource code, 0 <= k z) (mkSource code : measurable_fun [set: X * Y] k) :
  measurable_fun [set: X] (fun xSource code => \int[l x]_ySource code k (x, y)).
Proof.
pose k_ := nnsfun_approx measurableT mk.
apply: (@measurable_fun_xsection_integral _ k_).
- by move=> a b ab; exact/nd_nnsfun_approx.
- by move=> z; exact/cvg_nnsfun_approx.
- move => n r.
  have [l_ hl_] := measure_uub l.
  by apply: measurable_fun_xsection_finite_kernel => // /[!inE].
Qed.

Lemma measurable_fun_integral_sfinite_kernelSource code (lSource code : R.-sfker X ~> Y)
    (k0Source code : forall tSource code, 0 <= k t) (mkSource code : measurable_fun [set: X * Y] k) :
  measurable_fun [set: X] (fun xSource code => \int[l x]_ySource code k (x, y)).
Proof.
pose k_ := nnsfun_approx measurableT mk.
apply: (@measurable_fun_xsection_integral _ k_).
- by move=> a b ab; exact/nd_nnsfun_approx.
- by move=> z; exact/cvg_nnsfun_approx.
- move => n r.
  have [l_ hl_] := sfinite_kernel l.
  rewrite (_ : (fun xSource code => _) = (fun xSource code =>
      mseries (l_ ^~ x) 0 (xsection (k_ n @^-1` [set r]) x))).
    by apply/funext => x; rewrite hl_//; exact/measurable_xsection.
  apply: ge0_emeasurable_sum => // m _.
  by apply: measurable_fun_xsection_finite_kernel => // /[!inE].
Qed.

End measurable_fun_integral_finite_sfinite.
Arguments measurable_fun_xsection_integral {_ _ _ _ _} k l.
Arguments measurable_fun_integral_finite_kernel {_ _ _ _ _} k l.
Arguments measurable_fun_integral_sfinite_kernel {_ _ _ _ _} k l.

Section kdirac.
Context {dSource code d'Source code} {XSource code : measurableType d} {YSource code : measurableType d'} {RSource code : realType}
 (fSource code : X -> Y).

Definition kdirac

kdirac : forall {d d' : measure_display} {X : measurableType d} {Y : measurableType d'} {R : realType} {f : X -> Y}, measurable_fun (T:=X) (U:=Y) [set: X] f -> X -> {measure set Y -> \bar R}%R kdirac is not universe polymorphic Arguments kdirac {d d'}%_measure_display_scope {X Y R} {f}%_function_scope mf x kdirac is transparent Expands to: Constant mathcomp.analysis.kernel.kdirac Declared in library mathcomp.analysis.kernel, line 712, characters 11-17


Source code
 (mfSource code : measurable_fun [set: X] f) (xSource code : X) :
  {measure set Y -> \bar R} := dirac (f x).

Hypothesis mfSource code : measurable_fun [set: X] f.

Import MeasurableR.

Let measurable_fun_kdiracSource code USource code : measurable U ->
  measurable_fun [set: X] (kdirac mf ^~ U).
Proof.
move=> mU; apply/measurable_EFinP.
by rewrite (_ : (fun xSource code => _) = mindic R mU \o f)//; exact/measurableT_comp.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code isKernelSource code.Build _ _ _ _ _ (kdirac mf)
  measurable_fun_kdirac.

Let kdirac_probSource code xSource code : kdirac mf x [set: Y] = 1.
Proof.
by rewrite /kdirac/= diracT. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code Kernel_isProbabilitySource code.Build _ _ _ _ _
  (kdirac mf) kdirac_prob.

End kdirac.
Arguments kdirac {d d' X Y R f}.

Section kprobability.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variable PSource code : X -> pprobability Y R.

Definition kprobability

kprobability : forall [d d' : measure_display] [X : measurableType d] [Y : measurableType d'] [R : realType] [P : X -> pprobability Y R], measurable_fun (T:=X) (U:=pprobability Y R) [set: X] P -> X -> {measure set Y -> \bar R}%R kprobability is not universe polymorphic Arguments kprobability [d d']%_measure_display_scope [X Y R] [P]%_function_scope mP _ kprobability is transparent Expands to: Constant mathcomp.analysis.kernel.kprobability Declared in library mathcomp.analysis.kernel, line 742, characters 11-23


Used by
  • mathcomp.analysis.probability_theory.bernoulli_distribution

Source code
 (mPSource code : measurable_fun [set: X] P)
  : X -> {measure set Y -> \bar R} := P.

Hypothesis mPSource code : measurable_fun [set: X] P.

Let measurable_fun_kprobabilitySource code USource code : measurable U ->
  measurable_fun [set: X] (kprobability mP ^~ U).
Proof.
move=> mU.
apply: (measurability _ (ErealGenInftyO.measurableE R)) => _ /= -[_ [r ->] <-].
rewrite setTI preimage_itvNyo -/(P @^-1` mset U r).
have [r0|r0] := leP 0%R r; last by rewrite lt0_mset// preimage_set0.
have [r1|r1] := leP r 1%R; last by rewrite gt1_mset// preimage_setT.
move: mP => /(_ measurableT (mset U r)); rewrite setTI; apply.
by apply: sub_sigma_algebra; exists r => /=; [rewrite in_itv/= r0|exists U].
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isKernelSource code.Build _ _ X Y R (kprobability mP) measurable_fun_kprobability.

Let kprobability_probSource code xSource code : kprobability mP x [set: Y] = 1.
Proof.
by rewrite /kprobability/= probability_setT. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @Kernel_isProbabilitySource code.Build _ _ X Y R (kprobability mP) kprobability_prob.

End kprobability.

Section kadd.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variables k1Source code k2Source code : R.-ker X ~> Y.

Definition kadd

kadd : forall [d d' : measure_display] [X : measurableType d] [Y : measurableType d'] [R : realType], R.-ker X ~> Y -> R.-ker X ~> Y -> X -> {measure set Y -> \bar R}%R kadd is not universe polymorphic Arguments kadd [d d']%_measure_display_scope [X Y R] k1 k2 x kadd is transparent Expands to: Constant mathcomp.analysis.kernel.kadd Declared in library mathcomp.analysis.kernel, line 774, characters 11-15


Source code
 (xSource code : X) : {measure set Y -> \bar R} :=
  measure_add (k1 x) (k2 x).

Let measurable_fun_kaddSource code USource code : measurable U -> measurable_fun [set: X] (kadd ^~ U).
Proof.
move=> mU; rewrite /kadd.
rewrite (_ : (fun _ => _) = (fun xSource code => k1 x U + k2 x U)).
  by apply/funext => x; rewrite -measure_addE.
by apply: emeasurable_funD; exact/measurable_kernel.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isKernelSource code.Build _ _ _ _ _ kadd measurable_fun_kadd.

End kadd.

Section sfkadd.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variables k1Source code k2Source code : R.-sfker X ~> Y.

Let sfinite_kaddSource code : exists2 k_Source code : (R.-ker _ ~> _)^nat,
  forall nSource code, measure_fam_uub (k_ n) &
  forall xSource code USource code, measurable U ->
    kadd k1 k2 x U = mseries (k_ ^~ x) 0 U.
Proof.
have [f1 hk1] := sfinite_kernel k1; have [f2 hk2] := sfinite_kernel k2.
exists (fun nSource code => kadd (f1 n) (f2 n)).
  move=> n.
  have [r1 f1r1] := measure_uub (f1 n).
  have [r2 f2r2] := measure_uub (f2 n).
  exists (r1 + r2)%R => x/=.
  by rewrite /msum !big_ord_recr/= big_ord0 add0e EFinD lteD.
move=> x U mU.
rewrite /kadd/= -/(measure_add (k1 x) (k2 x)) measure_addE hk1//= hk2//=.
rewrite /mseries -nneseriesD//; apply: eq_eseriesr => n _ /=.
by rewrite -/(measure_add (f1 n x) (f2 n x)) measure_addE.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code tSource code :=Source code
  isSFiniteKernel_subdef.Build _ _ _ _ R (kadd k1 k2) sfinite_kadd.

End sfkadd.

Section fkadd.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Variables k1Source code k2Source code : R.-fker X ~> Y.

Let kadd_finite_uubSource code : measure_fam_uub (kadd k1 k2).
Proof.
have [f1 hk1] := measure_uub k1; have [f2 hk2] := measure_uub k2.
exists (f1 + f2)%R => x; rewrite /kadd /=.
rewrite -/(measure_add (k1 x) (k2 x)).
by rewrite measure_addE EFinD; exact: lteD.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code tSource code :=Source code
  Kernel_isFinite.Build _ _ _ _ R (kadd k1 k2) kadd_finite_uub.

End fkadd.

Section knormalize.
Context {dSource code d'Source code} {XSource code : measurableType d} {YSource code : measurableType d'} {RSource code : realType}
 (fSource code : R.-ker X ~> Y).

Definition knormalize

knormalize : forall {d d' : measure_display} {X : measurableType d} {Y : measurableType d'} {R : realType}, R.-ker X ~> Y -> probability Y R -> X -> {measure set Y -> \bar R}%R knormalize is not universe polymorphic Arguments knormalize {d d'}%_measure_display_scope {X Y R} f P _ knormalize is transparent Expands to: Constant mathcomp.analysis.kernel.knormalize Declared in library mathcomp.analysis.kernel, line 838, characters 11-21


Source code
 (PSource code : probability Y R) : X -> {measure set Y -> \bar R} :=
  fun xSource code => mnormalize (f x) P.

Import MeasurableR.

Let measurable_knormalizeSource code (PSource code : probability Y R) USource code :
  measurable U -> measurable_fun [set: X] (knormalize P ^~ U).
Proof.
move=> mU; rewrite /knormalize/= /mnormalize /=.
rewrite (_ : (fun _ => _) = (fun xSource code =>
     if f x setT == 0 then P U else if f x setT == +oo then P U
     else f x U * (fine (f x setT))^-1%:E)).
  apply/funext => x; case: ifPn => [/orP[->//|->]|]; first by case: ifPn.
  by rewrite negb_or=> /andP[/negbTE -> /negbTE ->].
apply: measurable_fun_if => //; [exact: kernel_measurable_fun_eq_cst|].
apply: measurable_fun_if => //.
- rewrite setTI [X in measurable X](_ : _ = [set tSource code | f t setT != 0]).
    by apply/seteqP; split => [x /negbT//|x /negbTE].
  exact: kernel_measurable_neq_cst.
- by apply: measurable_funTS => //; exact: kernel_measurable_fun_eq_cst.
- apply: emeasurable_funM.
    exact: measurable_funS (measurable_kernel f U mU).
  apply/measurable_EFinP.
  apply: (@measurable_comp _ _ _ _ _ _ [set rSource code : R | r != 0%R]) => //.
  + exact: open_measurable.
  + move=> /= r [t] [] [_ ft0] ftoo ftr; apply/eqP => r0.
    move: (ftr); rewrite r0 => /eqP; rewrite fine_eq0 ?ft0//.
    by rewrite ge0_fin_numE// lt_neqAle leey ftoo.
  + apply: open_continuous_measurable_fun => //; apply/in_setP => x /= x0.
    exact: inv_continuous.
  + apply: measurableT_comp => //=.
    by have := measurable_kernel f _ measurableT; exact: measurable_funS.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code (PSource code :Source code probabilitySource code Y R) :=
  isKernel.Build _ _ _ _ R (knormalize P) (measurable_knormalize P).

Let knormalize1Source code (PSource code : probability Y R) xSource code : knormalize P x [set: Y] = 1.
Proof.
by rewrite /knormalize/= probability_setT. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code (PSource code :Source code probabilitySource code Y R):=
  @Kernel_isProbability.Build _ _ _ _ _ (knormalize P) (knormalize1 P).

End knormalize.

Import MeasurableR.

Lemma measurable_fun_mnormalizeSource code dSource code d'Source code (XSource code : measurableType d)
    (YSource code : pmeasurableType d') (RSource code : realType) (kSource code : R.-ker X ~> Y) :
  measurable_fun [set: X] (fun xSource code => mnormalize (k x) point : pprobability Y R).
Proof.
apply: (measurability (@pset _ _ _ : set_system (pprobability Y R))) => //.
move=> _ -[_ [r r01] [Ys mYs <-]] <-.
rewrite /mnormalize /mset /preimage/=.
apply: emeasurable_fun_infty_o => //.
rewrite /mnormalize/=.
rewrite (_ : (fun xSource code => _) = (fun xSource code => if (k x setT == 0) || (k x setT == +oo)
    then \d_point Ys else k x Ys * ((fine (k x setT))^-1)%:E)).
  by apply/funext => x/=; case: ifPn.
apply: measurable_fun_if => //.
- apply: (measurable_fun_bool true) => //.
  rewrite (_ : _ @^-1` _ = [set tSource code | k t setT == 0] `|`
                           [set tSource code | k t setT == +oo]).
    by apply/seteqP; split=> x /= /orP.
  by rewrite setTI; apply: measurableU; exact: kernel_measurable_eq_cst.
- apply/emeasurable_funM; first exact/measurable_funTS/measurable_kernel.
  apply/measurable_EFinP; rewrite setTI.
  apply: (@measurable_comp _ _ _ _ _ _ [set rSource code : R | r != 0%R]).
  + exact: open_measurable.
  + by move=> /= _ [x /norP[s0 soo]] <-; rewrite -eqe fineK ?ge0_fin_numE ?ltey.
  + apply: open_continuous_measurable_fun => //; apply/in_setP => x /= x0.
    exact: inv_continuous.
  + by apply: measurableT_comp => //; exact/measurable_funS/measurable_kernel.
Qed.

Section kcomp_def.
Context d1Source code d2Source code d3Source code (XSource code : measurableType d1) (YSource code : measurableType d2)
  (ZSource code : measurableType d3) (RSource code : realType).
Variable lSource code : X -> {measure set Y -> \bar R}.
Variable kSource code : X * Y -> {measure set Z -> \bar R}.

Definition kcomp

kcomp : forall [d1 d2 d3 : measure_display] [X : measurableType d1] [Y : measurableType d2] [Z : measurableType d3] [R : realType], (X -> {measure set Y -> \bar R}%R) -> (X * Y -> {measure set Z -> \bar R}%R) -> X -> set Z -> GRing.BaseAddMagma.sort \bar R kcomp is not universe polymorphic Arguments kcomp [d1 d2 d3]%_measure_display_scope [X Y Z R] (l k)%_function_scope x U%_classical_set_scope kcomp is transparent Expands to: Constant mathcomp.analysis.kernel.kcomp Declared in library mathcomp.analysis.kernel, line 921, characters 11-16


Source code
xSource code (USource code : set Z) := \int[l x]_ySource code k (x, y) U.

End kcomp_def.

Section kcomp_is_measure.
Context d1Source code d2Source code d3Source code (XSource code : measurableType d1) (YSource code : measurableType d2)
 (ZSource code : measurableType d3) (RSource code : realType).
Variables (lSource code : R.-ker X ~> Y) (kSource code : R.-ker (X * Y) ~> Z).

Let kcomp0Source code xSource code : kcomp l k x set0 = 0.
Proof.
by rewrite /kcomp (eq_integral (cst 0)) ?integral0// => y _; rewrite measure0.
Qed.

Let kcomp_ge0Source code xSource code USource code : 0 <= kcomp l k x U
Proof.
exact: integral_ge0. Qed.

Let kcomp_sigma_additiveSource code xSource code : semi_sigma_additive (kcomp l k x).
Proof.
move=> U mU tU mUU; rewrite [X in _ --> X](_ : _ =
  \int[l x]_ySource code (\sum_(nSource code <oo) k (x, y) (U n))).
  apply: eq_integral => V _.
  by apply/esym/cvg_lim => //; exact/measure_semi_sigma_additive.
apply/cvg_closeP; split.
  by apply: is_cvg_nneseries => n _ _; exact: integral_ge0.
rewrite closeE// integral_nneseries// => n.
exact: measurableT_comp (measurable_kernel k _ (mU n)) _.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code xSource code :=Source code isMeasureSource code.Build _ _ R
  (kcomp l k x) (kcomp0 x) (kcomp_ge0 x) (@kcomp_sigma_additive x).

Definition mkcomp

mkcomp : forall [d1 d2 d3 : measure_display] [X : measurableType d1] [Y : measurableType d2] [Z : measurableType d3] [R : realType], R.-ker X ~> Y -> R.-ker X * Y ~> Z -> X -> {measure set Z -> \bar R}%R mkcomp is not universe polymorphic Arguments mkcomp [d1 d2 d3]%_measure_display_scope [X Y Z R] l k _ mkcomp is transparent Expands to: Constant mathcomp.analysis.kernel.mkcomp Declared in library mathcomp.analysis.kernel, line 953, characters 11-17


Source code
: X -> {measure set Z -> \bar R} := kcomp l k.

End kcomp_is_measure.

Notation "l \; k"Source code := (mkcomp l k) : ereal_scope.

Module KCOMP_FINITE_KERNELSource code.

Section kcomp_finite_kernel_kernel.
Context dSource code d'Source code d3Source code (XSource code : measurableType d) (YSource code : measurableType d')
  (ZSource code : measurableType d3) (RSource code : realType) (lSource code : R.-fker X ~> Y)
  (kSource code : R.-ker (X * Y) ~> Z).

Lemma measurable_fun_kcomp_finiteSource code USource code :
  measurable U -> measurable_fun [set: X] ((l \; k) ^~ U).
Proof.
move=> mU; apply: (measurable_fun_integral_finite_kernel (k ^~ U)) => //=.
exact/measurable_kernel.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  isKernel.Build _ _ X Z R (l \; k) measurable_fun_kcomp_finite.

End kcomp_finite_kernel_kernel.

Section kcomp_finite_kernel_finite.
Context dSource code d'Source code d3Source code (XSource code : measurableType d) (YSource code : measurableType d')
  (ZSource code : measurableType d3) (RSource code : realType).
Variables (lSource code : R.-fker X ~> Y) (kSource code : R.-fker (X * Y) ~> Z).

Let mkcomp_finiteSource code : measure_fam_uub (kcomp l k).
Proof.
have /measure_fam_uubP[r hr] := measure_uub k.
have /measure_fam_uubP[s hs] := measure_uub l.
apply/measure_fam_uubP; exists (PosNum [gt0 of (r%:num * s%:num)%R]) => x /=.
apply: (@le_lt_trans _ _ (\int[l x]__ r%:num%:E)).
  apply: ge0_le_integral => //.
  - exact: measurableT_comp (measurable_kernel k _ measurableT) _.
  - by move=> y _; exact/ltW/hr.
by rewrite integral_cst//= EFinM lte_pmul2l.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  Kernel_isFinite.Build _ _ X Z R (l \; k) mkcomp_finite.

End kcomp_finite_kernel_finite.
End KCOMP_FINITE_KERNEL.

Section kcomp_sfinite_kernel.
Context dSource code d'Source code d3Source code (XSource code : measurableType d) (YSource code : measurableType d')
  (ZSource code : measurableType d3) (RSource code : realType).
Variable (lSource code : R.-sfker X ~> Y) (kSource code : R.-sfker (X * Y) ~> Z).

Import KCOMP_FINITE_KERNEL.

Lemma mkcomp_sfiniteSource code : exists k_Source code : (R.-fker X ~> Z)^nat,
  forall xSource code USource code, measurable U -> (l \; k) x U = kseries k_ x U.
Proof.
have [k_ hk_] := sfinite_kernel k; have [l_ hl_] := sfinite_kernel l.
have [kl hkl] : exists klSource code : (R.-fker X ~> Z) ^nat, forall xSource code USource code,
    \esum_(iSource code in setT) (l_ i.2 \; k_ i.1) x U = \sum_(iSource code <oo) kl i x U.
  have /ppcard_eqP[f] : ([set: nat] #= [set: nat * nat])%card.
    by rewrite card_eq_sym; exact: card_nat2.
  exists (fun iSource code => l_ (f i).2 \; k_ (f i).1) => x U.
  by rewrite (reindex_esum [set: nat] _ f)// nneseries_esumT.
exists kl => x U mU.
transitivity ((kseries l_ \; kseries k_) x U).
  rewrite /= /kcomp [in RHS](eq_measure_integral (l x)).
    by move=> *; rewrite hl_.
  by apply: eq_integral => y _; rewrite hk_.
rewrite /= /kcomp/= integral_nneseries//=.
  by move=> n; exact: measurableT_comp (measurable_kernel (k_ n) _ mU) _.
transitivity (\sum_(iSource code <oo) \sum_(jSource code <oo) (l_ j \; k_ i) x U).
  apply: eq_eseriesr => i _; rewrite integral_kseries//.
  by exact: measurableT_comp (measurable_kernel (k_ i) _ mU) _.
rewrite /mseries -hkl/=.
rewrite (_ : setT = setT `*`` (fun=> setT)); first by apply/seteqP; split.
rewrite -(@esum_esum _ _ _ _ _ (fun iSource code jSource code => (l_ j \; k_ i) x U))//.
rewrite nneseries_esumT; first by move=> *; exact: nneseries_ge0.
by apply: eq_esum => /= i _; rewrite nneseries_esumT.
Qed.

Lemma measurable_fun_mkcomp_sfiniteSource code USource code : measurable U ->
  measurable_fun [set: X] ((l \; k) ^~ U).
Proof.
move=> mU; apply: (measurable_fun_integral_sfinite_kernel (k ^~ U)) => //.
exact/measurable_kernel.
Qed.

End kcomp_sfinite_kernel.

Module KCOMP_SFINITE_KERNELSource code.
Section kcomp_sfinite_kernel.
Context dSource code d'Source code d3Source code (XSource code : measurableType d) (YSource code : measurableType d')
  (ZSource code : measurableType d3) (RSource code : realType).
Variables (lSource code : R.-sfker X ~> Y) (kSource code : R.-sfker (X * Y) ~> Z).

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  isKernel.Build _ _ X Z R (l \; k) (measurable_fun_mkcomp_sfinite l k).

#[export]Source code
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  Kernel_isSFinite.Build _ _ X Z R (l \; k) (mkcomp_sfinite l k).

End kcomp_sfinite_kernel.
End KCOMP_SFINITE_KERNEL.
HB.export KCOMP_SFINITE_KERNEL.

Section measurable_fun_preimage_integral.
Context dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType).
Import HBNNSimple.
Variables (kSource code : Y -> \bar R)
  (k_Source code : ({nnsfun Y >-> R}) ^nat)
  (ndk_Source code : nondecreasing_seq (k_ : (Y -> R)^nat))
  (k_kSource code : forall zSource code, [set: Y] z -> (k_ n z)%:E @[nSource code --> \oo] --> k z).

Let k_2Source code : (X * Y -> R)^nat := fun nSource code => k_ n \o snd.

Let k_2_ge0Source code nSource code xSource code : (0 <= k_2 n x)%R
Proof.
by []. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code nSource code :=Source code @isNonNegFunSource code.Build _ _ _ (k_2_ge0 n).

Let mk_2Source code nSource code : measurable_fun [set: X * Y] (k_2 n).
Proof.
by apply: measurableT_comp => //; exact: measurable_snd. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code nSource code :=Source code @isMeasurableFunSource code.Build _ _ _ _ _ (mk_2 n).

Let fk_2Source code nSource code : finite_set (range (k_2 n)).
Proof.
have [[point _]|/forallNP empty] := pselect (exists pointSource code : X, True).
  have := fimfunP (k_ n).
  suff : range (k_ n) = range (k_2 n) by move=> <-.
  by apply/seteqP; split => r [y ?] <-; [exists (point, y)|exists y.2].
by rewrite (_ : range _ = set0)// -subset0 => r [[x]]; have := empty x.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code nSource code :=Source code @FiniteImageSource code.Build _ _ _ (fk_2 n).

Lemma measurable_fun_preimage_integralSource code (lSource code : X -> {measure set Y -> \bar R}) :
  (forall nSource code rSource code, measurable_fun [set: X] (l ^~ (k_ n @^-1` [set r]))) ->
  measurable_fun [set: X] (fun xSource code => \int[l x]_zSource code k z).
Proof.
move=> h; apply: (measurable_fun_xsection_integral (k \o snd) l k_2) => /=.
- by rewrite /k_2 => m n mn; apply/lefP => -[x y] /=; exact/lefP/ndk_.
- by move=> [x y]; exact: k_k.
- move=> n r _ /= B mB.
  have := h n r measurableT B mB; rewrite !setTI.
  suff : (l ^~ (k_ n @^-1` [set r])) @^-1` B =
         (fun xSource code => l x (xsection (k_2 n @^-1` [set r]) x)) @^-1` B by move=> ->.
  by apply/seteqP; split => x/=;
    rewrite (comp_preimage _ snd (k_ n)) xsection_preimage_snd.
Qed.

End measurable_fun_preimage_integral.

Section measurable_fun_integral_kernel.

Import HBNNSimple.

Lemma measurable_fun_integral_kernelSource code
    dSource code d'Source code (XSource code : measurableType d) (YSource code : measurableType d') (RSource code : realType)
    (lSource code : X -> {measure set Y -> \bar R})
    (mlSource code : forall USource code, measurable U -> measurable_fun [set: X] (l ^~ U))
    (kSource code : Y -> \bar R) (k0Source code : forall zSource code, 0 <= k z) (mkSource code : measurable_fun [set: Y] k) :
  measurable_fun [set: X] (fun xSource code => \int[l x]_ySource code k y).
Proof.
pose k_ := nnsfun_approx measurableT mk.
apply: (@measurable_fun_preimage_integral _ _ _ _ _ _ k_) => //.
- by move=> a b ab; exact/nd_nnsfun_approx.
- by move=> z _; exact/cvg_nnsfun_approx.
- by move=> n r; exact/ml.
Qed.

End measurable_fun_integral_kernel.

Section integral_kcomp.
Context dSource code d2Source code d3Source code (XSource code : measurableType d) (YSource code : measurableType d2)
  (ZSource code : measurableType d3) (RSource code : realType).
Variables (lSource code : R.-sfker X ~> Y) (kSource code : R.-sfker (X * Y) ~> Z).

Let integral_kcomp_indicSource code xSource code ESource code (mESource code : measurable E) :
  \int[kcomp l k x]_zSource code (\1_E z)%:E = \int[l x]_ySource code (\int[k (x, y)]_zSource code (\1_E z)%:E).
Proof.
rewrite integral_indic//= /kcomp.
by apply: eq_integral => y _; rewrite integral_indic.
Qed.

Import HBNNSimple.

Let integral_kcomp_nnsfunSource code xSource code (fSource code : {nnsfun Z >-> R}) :
  \int[kcomp l k x]_zSource code (f z)%:E = \int[l x]_ySource code (\int[k (x, y)]_zSource code (f z)%:E).
Proof.
under [in LHS]eq_integral do rewrite fimfunE -fsumEFin//.
rewrite ge0_integral_fsum//.
- by move=> r; exact/measurable_EFinP/measurableT_comp.
- by move=> r z _; rewrite EFinM nnfun_muleindic_ge0.
under [in RHS]eq_integral.
  move=> y _.
  under eq_integral.
    by move=> z _; rewrite fimfunE -fsumEFin//; over.
  rewrite /= ge0_integral_fsum//.
  - by move=> r; exact/measurable_EFinP/measurableT_comp.
  - by move=> r z _; rewrite EFinM nnfun_muleindic_ge0.
  under eq_fsbigr.
    move=> r _.
    rewrite (integralZl_indic _ (fun rSource code => f @^-1` [set r]))//.
      by move=> r0; rewrite preimage_nnfun0.
    rewrite integral_indic// setIT.
    over.
  over.
rewrite /= ge0_integral_fsum//.
  - move=> r; apply: measurable_funeM.
    exact: measurableT_comp (measurable_kernel k (f @^-1` [set r]) _) _.
  - move=> n y _.
    have := mulemu_ge0 (fun nSource code => f @^-1` [set n]).
    by apply; exact: preimage_nnfun0.
apply: eq_fsbigr => r _.
rewrite (integralZl_indic _ (fun rSource code => f @^-1` [set r]))//.
  exact: preimage_nnfun0.
rewrite /= integral_kcomp_indic//.
have [r0|r0] := leP 0%R r.
  rewrite ge0_integralZl//.
    exact: measurableT_comp (measurable_kernel k (f @^-1` [set r]) _) _.
  by under eq_integral do rewrite integral_indic// setIT.
rewrite integral0_eq ?mule0.
  by move=> y _; rewrite integral0_eq// => z _; rewrite preimage_nnfun0// indic0.
by rewrite integral0_eq// => y _; rewrite preimage_nnfun0// measure0 mule0.
Qed.

Lemma integral_kcompSource code xSource code fSource code : (forall zSource code, 0 <= f z) -> measurable_fun [set: Z] f ->
  \int[kcomp l k x]_zSource code f z = \int[l x]_ySource code (\int[k (x, y)]_zSource code f z).
Proof.
move=> f0 mf.
pose f_ := nnsfun_approx measurableT mf.
transitivity (\int[kcomp l k x]_zSource code (lim ((f_ n z)%:E @[nSource code --> \oo]))).
  by apply/eq_integral => z _; apply/esym/cvg_lim => //=; exact: cvg_nnsfun_approx.
rewrite monotone_convergence//.
  by move=> n; exact/measurable_EFinP.
  by move=> n z _; rewrite lee_fin.
  by move=> z _ a b ab; rewrite lee_fin; exact/lefP/nd_nnsfun_approx.
rewrite (_ : (fun _ => _) =
    (fun nSource code => \int[l x]_ySource code (\int[k (x, y)]_zSource code (f_ n z)%:E)))//.
  by apply/funext => n; rewrite integral_kcomp_nnsfun.
transitivity (\int[l x]_ySource code lim ((\int[k (x, y)]_zSource code (f_ n z)%:E) @[nSource code --> \oo])).
  rewrite -monotone_convergence//; last 3 first.
  - move=> n; apply: measurable_fun_integral_kernel => //.
    + by move=> U mU; exact: measurableT_comp (measurable_kernel k _ mU) _.
    + by move=> z; rewrite lee_fin.
    + exact/measurable_EFinP.
  - by move=> n y _; apply: integral_ge0 => // z _; rewrite lee_fin.
  - move=> y _ a b ab; apply: ge0_le_integral => //.
    + by move=> z _; rewrite lee_fin.
    + exact/measurable_EFinP.
    + exact/measurable_EFinP.
    + by move=> z _; rewrite lee_fin; exact/lefP/nd_nnsfun_approx.
apply: eq_integral => y _; rewrite -monotone_convergence//.
  - by move=> n; exact/measurable_EFinP.
  - by move=> n z _; rewrite lee_fin.
  - by move=> z _ a b ab; rewrite lee_fin; exact/lefP/nd_nnsfun_approx.
by apply: eq_integral => z _; apply/cvg_lim => //; exact: cvg_nnsfun_approx.
Qed.

End integral_kcomp.

Section kfcomp.
Context {d1Source code} {d2Source code} {T1Source code : measurableType d1} {T2Source code : measurableType d2}
  {RSource code : realType}.

Definition kfcomp

kfcomp : forall {d1 d2 : measure_display} {T1 : measurableType d1} {T2 : measurableType d2} {R : realType}, (T1 -> {measure set T2 -> \bar R}%R) -> (T1 * T2 -> \bar R) -> T1 -> \bar R kfcomp is not universe polymorphic Arguments kfcomp {d1 d2}%_measure_display_scope {T1 T2 R} (k f)%_function_scope _ kfcomp is transparent Expands to: Constant mathcomp.analysis.kernel.kfcomp Declared in library mathcomp.analysis.kernel, line 1226, characters 11-17


Source code
 (kSource code : T1 -> {measure set T2 -> \bar R})
    (fSource code : T1 * T2 -> \bar R) : T1 -> \bar R :=
  fun xSource code => \int[k x]_ySource code f (x, y).

Lemma kfcompk1Source code (kSource code : T1 -> {measure set T2 -> \bar R}) :
  kfcomp k (EFin \o cst 1%R) = (k ^~ [set: T2]).
Proof.
by apply/funext => x/=; rewrite /kfcomp/= integral_cst// mul1e. Qed.

Lemma kfcompkindicSource code (kSource code : T1 -> {measure set T2 -> \bar R}) ASource code : measurable A ->
  kfcomp k (EFin \o \1_A) = (fun xSource code => k x (xsection A x)).
Proof.
move=> mA; apply/funext=> x; rewrite /kfcomp /= integral_indic// ?setIT//.
- rewrite -[X in measurable X]/(_ @^-1` _) -xsectionE.
  exact: measurable_xsection.
- by rewrite -[X in k x X = _]/(_ @^-1` _) -xsectionE.
Qed.

End kfcomp.

Section measurable_kfcomp.

Let finite_measure_sigma_finiteSource code dSource code (TSource code : measurableType d) (RSource code : realType)
    (muSource code : {measure set T -> \bar R}) :
  fin_num_fun mu -> sigma_finite [set: T] mu.
Proof.
by move=> fmu; apply: fin_num_fun_sigma_finite => //; rewrite measure0.
Qed.

Let finite_measure_sfiniteSource code dSource code (TSource code : measurableType d) (RSource code : realType)
    (muSource code : {measure set T -> \bar R}) :
  fin_num_fun mu -> sfinite_measure mu.
Proof.
move=> fmu.
exists (fun nSource code => if n is O then mu else mzero) => [[]//|U mU].
by rewrite /mseries nneseries_recl// eseries0 ?adde0// => -[|].
Qed.

Variables (d1Source code d2Source code : measure_display) (T1Source code : measurableType d1)
  (T2Source code : measurableType d2) (RSource code : realType) (kSource code : R.-ftker T1 ~> T2)
  (fSource code : T1 * T2 -> \bar R).

Let gSource code (A1Source code : set T1) (A2Source code : set T2) : T1 * T2 -> \bar R := EFin \o \1_(A1 `*` A2).

Let kfcompkgSource code (A1Source code : set T1) (A2Source code : set T2) : measurable A1 -> measurable A2 ->
  kfcomp k (g A1 A2) = (fun xSource code => (\1_A1 x)%:E * k x A2).
Proof.
move=> mA1 mA2; apply/funext => x.
rewrite /kfcomp /g/= integral_indic//.
  rewrite [X in measurable X](_ : _ = xsection (A1 `*` A2) x).
    by rewrite xsectionE.
  by apply: measurable_xsection; exact: measurableX.
have [xA1|xA1] := boolP (x \in A1).
  by rewrite indicE xA1 mul1e setIT -[X in _ _ X = _]xsectionE in_xsectionX.
rewrite indicE (negbTE xA1) mul0e setIT.
by rewrite -[X in _ _ X = _]xsectionE notin_xsectionX.
Qed.

Let DSource code := [set ASource code | measurable A /\ measurable_fun setT (kfcomp k (EFin \o \1_A))].

Let setSD_DSource code : setSD_closed D.
Proof.
move=> B A AB; rewrite /D/= => -[mB mIB] [mA mIA].
suff KE : kfcomp k (EFin \o \1_(B `\` A)) =
    kfcomp k (EFin \o \1_B) \- kfcomp k(EFin \o \1_A).
  by split; [exact: measurableD|rewrite KE; exact: emeasurable_funB].
apply/funext => x/=.
pose kx : {measure set T2 -> \bar R} := k x.
pose H1 := isFinNumFun.Build _ _ _ _ (@kernel_finite_transition _ _ _ _ R k x).
pose H2 := isSFinite.Build _ _ _ _ (finite_measure_sfinite
  (@kernel_finite_transition _ _ _ _ R k x)).
pose H3 := isSigmaFinite.Build _ _ _ _ (finite_measure_sigma_finite
  (@kernel_finite_transition _ _ _ _ R k x)).
pose kx' := HB.pack_for (FiniteMeasure.type T2 R) (Measure.sort kx) H1 H2 H3.
have kxE : kx = kx' by exact: eq_measure.
rewrite [in RHS]/kfcomp -integralB_EFin//.
- rewrite -/kx kxE; apply: integrable_indic => //.
  by rewrite -[X in measurable X]xsectionE; exact: measurable_xsection.
- rewrite -/kx kxE; apply: integrable_indic => //.
  by rewrite -[X in measurable X]xsectionE; exact: measurable_xsection.
apply: eq_integral => y _/=; rewrite setDE indicI indicC/=.
rewrite -[in RHS](setCK A) indicC in_setC.
have [xyA|xyA] := boolP (_ \in A); rewrite /= ?mulr1 ?mulr0 ?oppr0 ?adde0//.
by move/set_mem : xyA => /AB Bxy; rewrite indicE mem_set//= EFinN subee.
Qed.

Let lambda_DSource code : lambda_system setT D.
Proof.
split => //.
- by rewrite /D/= indicT kfcompk1; split => //; exact: measurable_kernel.
- suff: D = [set ASource code | (d1, d2).-prod.-measurable A /\
         measurable_fun [set: T1] ((fun CSource code xSource code => k x (xsection C x)) A)].
    by move=> ->; exact: xsection_ndseq_closed.
  apply/seteqP; split=> [/= A [mA /= mIA]|/= A [/= mA mIA]].
  + by split => //; rewrite -kfcompkindic.
  + by split => //; rewrite kfcompkindic.
Qed.

Import HBNNSimple.

Lemma measurable_kfcompSource code : measurable_fun [set: T1 * T2] f ->
  (forall tSource code, 0 <= f t) -> measurable_fun [set: T1] (kfcomp k f).
Proof.
move=> mf f0.
pose f_ := nnsfun_approx measurableT mf.
pose K := kfcomp k.
have Kf_cvg x : K (EFin \o f_ n) x @[nSource code --> \oo] --> K f x.
  pose g' nSource code ySource code := (EFin \o f_ n) (x, y).
  rewrite [X in _ --> X](_ : _ =
      \int[k x]_ySource code (fun tSource code => limn (g' ^~ t)) y).
    apply: eq_integral => y _.
    by apply/esym/cvg_lim => //; exact: cvg_nnsfun_approx.
  apply: cvg_monotone_convergence => //.
  - by move=> n; apply/measurable_EFinP; exact: measurableT_comp.
  - by move=> n y _; rewrite /= lee_fin.
  - by move=> y _ a b ab/=; rewrite lee_fin; exact/lefP/nd_nnsfun_approx.
apply: (emeasurable_fun_cvg (fun nSource code => K (EFin \o f_ n))); last first.
  by move=> ? _; exact: Kf_cvg.
move=> m.
have DE : D = @measurable _ (T1 * T2)%type.
  apply/seteqP; split => [/= A []//|].
  rewrite prod_measurable_rectangle.
  apply: lambda_system_subset => //=.
    by apply: setI_closed_rectangle => *; exact: measurableI.
  move=> C [A mA [B mB] <-].
  split; [exact: measurableX|rewrite /K kfcompkg//].
  by apply: emeasurable_funM; [exact/measurable_EFinP|exact: measurable_kernel].
have mK1 (ASource code : set (T1 * T2)) : measurable A ->
    measurable_fun setT (K (EFin \o \1_A)).
  by rewrite -DE => -[].
rewrite [X in measurable_fun _ X](_ : _ = K
    (EFin \o (fun xSource code => \sum_(ySource code \in range (f_ m)) y *
                       \1_(f_ m @^-1` [set y]) x))%R).
  by apply/funext => x/=; apply: eq_integral => y _ /=; rewrite fimfunE.
rewrite /I/= [X in measurable_fun _ X](_ : _ = (fun xSource code =>
   \sum_(ySource code \in range (f_ m))
     (\int[k x]_w2Source code (y * \1_(f_ m @^-1` [set y]) (x, w2))%:E))).
  apply/funext => x; rewrite /K /kfcomp.
  under eq_integral do rewrite /= -fsumEFin//.
  rewrite /= ge0_integral_fsum//=.
    move=> r.
    under eq_fun do rewrite EFinM.
    by apply: emeasurable_funM => //; exact/measurable_EFinP/measurableT_comp.
  by move=> r y _; rewrite EFinM nnfun_muleindic_ge0.
apply: emeasurable_fsum => // r.
rewrite [X in measurable_fun _ X](_ : _ = (fun xSource code =>
    (r%:E * \int[k x]_ySource code (\1_(f_ m @^-1` [set r]) (x, y))%:E))).
  apply/funext => x.
  under eq_integral do rewrite EFinM.
  rewrite integralZl//.
  pose kx : {measure set T2 -> \bar R} := k x.
  pose H1 := isFinNumFun.Build _ _ _ _ (@kernel_finite_transition _ _ _ _ R k x).
  pose H2 := isSFinite.Build _ _ _ _ (finite_measure_sfinite
    (@kernel_finite_transition _ _ _ _ R k x)).
  pose H3 := isSigmaFinite.Build _ _ _ _ (finite_measure_sigma_finite
    (@kernel_finite_transition _ _ _ _ R k x)).
  pose kx' := HB.pack_for (FiniteMeasure.type T2 R) (Measure.sort kx) H1 H2 H3.
  have kxE : kx = kx' by exact: eq_measure.
  rewrite -/kx kxE; apply: integrable_indic => //.
  by rewrite -[X in measurable X]xsectionE; exact: measurable_xsection.
by apply: emeasurable_funM => //; exact: mK1.
Qed.

End measurable_kfcomp.

Section kproduct_def.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0) (T1Source code : measurableType d1)
  (T2Source code : measurableType d2) {RSource code : realType}.
Variable k1Source code : T0 -> {measure set T1 -> \bar R}.
Variable k2Source code : T0 * T1 -> {measure set T2 -> \bar R}.

Local Definition intker_indic

intker_indic not a defined object.


Source code
 (kSource code : T0 * T1 -> {measure set T2 -> \bar R}) ASource code :=
  fun xySource code => \int[k xy]_zSource code (\1_A (xy.2, z))%:E.

Definition kproduct

kproduct : forall [d0 d1 d2 : measure_display] [T0 : measurableType d0] [T1 : measurableType d1] [T2 : measurableType d2] {R : realType}, (T0 -> {measure set T1 -> \bar R}%R) -> (T0 * T1 -> {measure set T2 -> \bar R}%R) -> T0 -> set (T1 * T2) -> GRing.BaseAddMagma.sort \bar R kproduct is not universe polymorphic Arguments kproduct [d0 d1 d2]%_measure_display_scope [T0 T1 T2] {R} (k1 k2)%_function_scope x A%_classical_set_scope kproduct is transparent Expands to: Constant mathcomp.analysis.kernel.kproduct Declared in library mathcomp.analysis.kernel, line 1404, characters 11-19


Source code
xSource code (ASource code : set (T1 * T2)) :=
  \int[k1 x]_ySource code intker_indic k2 A (x, y).

End kproduct_def.

Section intker_indic_lemmas.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}.
Variable kSource code : R.-ftker T0 * T1 ~> T2.

Local Lemma measurable_intker_indicSource code ASource code : measurable A ->
  measurable_fun [set: T0 * T1] (intker_indic k A).
Proof.
move=> mA; apply: (@measurable_kfcomp _ _ (T0 * T1)%type T2 R k
    (fun abcSource code => (\1_A (abc.1.2, abc.2))%:E)) => //.
apply/measurable_EFinP => //=; apply: measurableT_comp => //=.
apply/measurable_fun_pairP; split => /=.
  rewrite [X in measurable_fun _ X](_ : _ = snd \o fst)//.
  exact: measurableT_comp.
by rewrite [X in measurable_fun _ X](_ : _ = snd).
Qed.

Local Lemma intker_indicESource code ASource code xSource code ySource code : measurable A ->
  intker_indic k A (x, y) = k (x, y) (xsection A y).
Proof.
move=> mA; rewrite /intker_indic(*NB:lemma?*) integral_indic//.
  by rewrite -[X in measurable X]xsectionE; exact: measurable_xsection.
by rewrite setIT xsectionE.
Qed.

Local Lemma intker_indic_bigcupSource code xSource code ySource code (ASource code : (set (T1 * T2)) ^nat) :
  trivIset [set: nat] A -> (forall nSource code, measurable (A n)) ->
  intker_indic k (\bigcup_nSource code A n) (x, y) =
  \big[+%R/0%R]_(0 <= iSource code <oo) intker_indic k (A i) (x, y).
Proof.
move=> tA mA.
rewrite /intker_indic -(@integral_nneseries _ _ R (k (x, y)) _ measurableT
  (fun iSource code zSource code => (\1_(A i) (y, z))%:E))//.
- move=> n; apply/measurable_EFinP => //; apply: measurable_indic.
  by rewrite -[X in measurable X]xsectionE; exact: measurable_xsection.
- by apply: eq_integral => z _ /=; rewrite indic_bigcup.
Qed.

End intker_indic_lemmas.

Section kproduct_snd_def.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0) (T1Source code : measurableType d1)
  (T2Source code : measurableType d2) {RSource code : realType}.
Variable k1Source code : T0 -> {measure set T1 -> \bar R}.
Variable k2Source code : T1 -> {measure set T2 -> \bar R}.

Definition kproduct_snd

kproduct_snd : forall [d0 d1 d2 : measure_display] [T0 : measurableType d0] [T1 : measurableType d1] [T2 : measurableType d2] {R : realType}, (T0 -> {measure set T1 -> \bar R}%R) -> (T1 -> {measure set T2 -> \bar R}%R) -> T0 -> set (T1 * T2) -> \bar R kproduct_snd is not universe polymorphic Arguments kproduct_snd [d0 d1 d2]%_measure_display_scope [T0 T1 T2] {R} (k1 k2)%_function_scope _ _%_classical_set_scope kproduct_snd is transparent Expands to: Constant mathcomp.analysis.kernel.kproduct_snd Declared in library mathcomp.analysis.kernel, line 1455, characters 11-23


Source code
  : T0 -> set (T1 * T2) -> \bar R :=
  kproduct k1 (k2 \o snd).

End kproduct_snd_def.

Theorem measurable_kproductSource code d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
    (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
    (k1Source code : R.-ftker T0 ~> T1) (k2Source code : R.-ftker (T0 * T1) ~> T2) ASource code :
  measurable A -> measurable_fun [set: T0] (kproduct k1 k2 ^~ A).
Proof.
move=> mA; apply: measurable_kfcomp => // t.
  exact: measurable_intker_indic.
by apply: integral_ge0 => y _; rewrite lee_fin.
Qed.

Theorem semi_sigma_additive_kproductSource code d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
    (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
    (k1Source code : R.-ftker T0 ~> T1) (k2Source code : R.-ftker (T0 * T1) ~> T2) xSource code :
  semi_sigma_additive (kproduct k1 k2 x).
Proof.
move=> /= A mA tA mbigcup.
rewrite (_ : (fun nSource code => _) = (fun nSource code =>
    \int[k1 x]_ySource code (\sum_(0 <= iSource code < n) intker_indic k2 (A i) (x, y)))).
  apply/funext => n; rewrite ge0_integral_sum//.
    by move=> m; exact: measurable_fun_pair2 (measurable_intker_indic k2 _).
  by move=> m y _; rewrite intker_indicE.
pose g nSource code ySource code := \sum_(0 <= iSource code < n) intker_indic k2 (A i) (x, y).
rewrite [X in _ --> X](_ : _ = \int[k1 x]_ySource code limn (g ^~ y)).
  by apply: eq_integral => y _; rewrite /g intker_indic_bigcup.
apply: (@cvg_monotone_convergence _ _ _ (k1 x) _ measurableT g) => //.
- move=> n; apply: (@emeasurable_sum _ _ R setT _ _
    (fun iSource code tSource code => intker_indic k2 (A i) (x, t))) => m.
  exact: measurable_fun_pair2 (measurable_intker_indic k2 (mA m)).
- by move=> n y _; apply: sume_ge0 => m _; rewrite intker_indicE.
- move=> y _ a b ab; apply: lee_sum_nneg_natr => // m _ _.
  by rewrite intker_indicE.
Qed.

Section kproduct_measure.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
  (k1Source code : R.-ftker T0 ~> T1) (k2Source code : R.-ftker (T0 * T1) ~> T2).

Let kproduct0Source code xSource code : kproduct k1 k2 x set0 = 0.
Proof.
by apply: integral0_eq => y _; apply: integral0_eq => z _; rewrite indic0.
Qed.

Let kproduct_ge0Source code xSource code ASource code : 0 <= kproduct k1 k2 x A.
Proof.
by apply: integral_ge0 => y _; apply: integral_ge0 => z _; rewrite lee_fin.
Qed.

Let kproduct_additiveSource code xSource code : semi_sigma_additive (kproduct k1 k2 x).
Proof.

HBSource code.instanceSource code DefinitionSource code _Source code xSource code :=Source code isMeasureSource code.Build
  (measure_prod_display (d1, d2)) (T1 * T2)%type R (kproduct k1 k2 x)
  (kproduct0 x) (kproduct_ge0 x) (@kproduct_additive x).

Definition mkproduct

mkproduct : forall [d0 d1 d2 : measure_display] [T0 : measurableType d0] [T1 : measurableType d1] [T2 : measurableType d2] {R : realType}, R.-ftker T0 ~> T1 -> R.-ftker T0 * T1 ~> T2 -> T0 -> {measure set (T1 * T2) -> \bar R}%R mkproduct is not universe polymorphic Arguments mkproduct [d0 d1 d2]%_measure_display_scope [T0 T1 T2] {R} k1 k2 _ mkproduct is transparent Expands to: Constant mathcomp.analysis.kernel.mkproduct Declared in library mathcomp.analysis.kernel, line 1517, characters 11-20


Source code
:=
  (kproduct k1 k2 : T0 -> {measure set (T1 * T2) -> \bar R}).

End kproduct_measure.

HBSource code.instanceSource code DefinitionSource code _Source code d0Source code d1Source code d2Source code (T0Source code :Source code measurableTypeSource code d0)
    (T1 : measurableType d1) (T2 : measurableType d2) {R : realType}
    (k1 : R.-ftker T0 ~> T1) (k2 : R.-ftker (T0 * T1) ~> T2) :=
  @isKernel.Build _ _ T0 (T1 * T2)%type R
    (mkproduct k1 k2) (measurable_kproduct k1 k2).

Section sigma_finite_kproduct.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
  (k1Source code : R.-ftker T0 ~> T1) (k2Source code : R.-ftker (T0 * T1) ~> T2).

Theorem sigma_finite_mkproductSource code xSource code :
  sigma_finite [set: T1 * T2] (mkproduct k1 k2 x).
Proof.
pose A nSource code := [set w1Source code | k2 (x, w1) setT < n%:R%:E].
have mA n : measurable (A n).
  rewrite /A -[X in measurable X]setTI.
  apply: emeasurable_fun_infty_o => //.
  have := @measurable_kernel _ _ _ _ R k2 _ measurableT.
  exact: measurable_fun_pair2.
have bigcupA : \bigcup_nSource code A n = setT.
  have fink2 xy : fin_num_fun (k2 xy) by exact: kernel_finite_transition.
  apply/seteqP; split => // y _.
  have {}fink2 := fink2 (x, y) _ measurableT.
  exists (Num.truncn (fine (k2 (x, y) setT))).+1 => //=.
  have : (0 <= fine (k2 (x, y) [set: T2]))%R by rewrite fine_ge0.
  by move=> /truncn_itv/andP[_]; rewrite -lte_fin fineK.
have lty n : kproduct k1 k2 x (A n `*` setT) < +oo.
  have fink1 : fin_num_fun (k1 x) by exact: kernel_finite_transition.
  apply: (@le_lt_trans _ _ (n%:R%:E * k1 x (A n))) => /=.
    rewrite [leLHS](_ : _ = \int[k1 x]_(ySource code in A n) k2 (x, y) setT).
      rewrite /kproduct [RHS]integral_mkcond; apply: eq_integral => y _.
      rewrite intker_indicE//; first exact: measurableX.
      rewrite patchE; case: ifPn => [Anx|Anx].
        by rewrite in_xsectionX.
      by rewrite notin_xsectionX// measure0.
    apply: (@le_trans _ _ (\int[k1 x]_(xSource code in A n) n%:R%:E)).
      apply: ge0_le_integral => //.
      - apply: measurable_funTS.
        have := @measurable_kernel _ _ _ _ _ k2 _ measurableT.
        exact: measurable_fun_pair2.
      - by move=> y; rewrite /A/= => /ltW.
      - by rewrite integral_cst.
    by rewrite lte_mul_pinfty// ltey_eq fink1.
exists (fun nSource code => A n `*` setT) => /=.
  by rewrite -setX_bigcupl bigcupA setXTT.
by move=> n; split => //; exact: measurableX.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code xSource code :=Source code @isSigmaFiniteTransitionKernelSource code.Build d0
  (measure_prod_display (d1, d2)) T0 (T1 * T2)%type R
    (mkproduct k1 k2) sigma_finite_mkproduct.

End sigma_finite_kproduct.

Section kcomp_noparam_def.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0) (T1Source code : measurableType d1)
  (T2Source code : measurableType d2) {RSource code : realType}.
Variable k1Source code : T0 -> {measure set T1 -> \bar R}.
Variable k2Source code : T1 -> {measure set T2 -> \bar R}.

Definition kcomp_noparam

kcomp_noparam : forall [d0 d1 d2 : measure_display] [T0 : measurableType d0] [T1 : measurableType d1] [T2 : measurableType d2] {R : realType}, (T0 -> {measure set T1 -> \bar R}%R) -> (T1 -> {measure set T2 -> \bar R}%R) -> T0 -> set T2 -> \bar R kcomp_noparam is not universe polymorphic Arguments kcomp_noparam [d0 d1 d2]%_measure_display_scope [T0 T1 T2] {R} (k1 k2)%_function_scope x A%_classical_set_scope kcomp_noparam is transparent Expands to: Constant mathcomp.analysis.kernel.kcomp_noparam Declared in library mathcomp.analysis.kernel, line 1587, characters 11-24


Source code
 (xSource code : T0) (ASource code : set T2) : \bar R :=
  \int[k1 x]_ySource code (k2 y A).

End kcomp_noparam_def.

Section spker_snd.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
  (kSource code : R.-spker T1 ~> T2).

Local Definition kernel_snd

kernel_snd not a defined object.


Source code
: (T0 * T1)%type -> {measure set T2 -> \bar R} :=
  k \o snd.

Let measurable_kernel_sndSource code USource code : measurable U ->
  measurable_fun [set: _] (kernel_snd ^~ U).
Proof.
move=> mU; have /= mk1 := measurable_kernel k _ mU.
move=> _ /= Y mY; have {}mk1 := mk1 measurableT _ mY.
have -> : [set: T0 * T1] `&` (kernel_snd ^~ U) @^-1` Y =
    setT `*` ([set: T1] `&` (k ^~ U) @^-1` Y).
  by rewrite !setTI setTX.
exact: measurableX.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @isKernelSource code.Build _ _ _ _ _ kernel_snd measurable_kernel_snd.

Let measure_uub_kernel_sndSource code : measure_fam_uub kernel_snd.
Proof.
exists 2%R => /= -[x y].
rewrite /kernel_snd/= (@le_lt_trans _ _ 1%:E) ?lte1n//.
exact: sprob_kernel_le1.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
  @Kernel_isFiniteSource code.Build _ _ _ _ _ kernel_snd measure_uub_kernel_snd.

Let sprob_kernel_kernel_sndSource code :
  ereal_sup [set kernel_snd z [set: _] | zSource code in [set: _]] <= 1.
Proof.
by apply: (sprob_kernelP kernel_snd).2 => -[x y]; exact: sprob_kernel_le1.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code isSubProbabilityKernelSource code.Build _ _ _ _ _
  kernel_snd sprob_kernel_kernel_snd.

Lemma intker_indic_sndSource code (ASource code : set T2) xSource code ySource code : measurable A ->
  intker_indic kernel_snd ([set: _] `*` A) (x, y) = k y A.
Proof.
move=> mA; rewrite intker_indicE//=; first exact: measurableX.
by congr (k y _); rewrite xsectionE//= setTX.
Qed.

End spker_snd.

Lemma kcomp_noparamESource code d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
    (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
    (k1Source code : T0 -> {measure set T1 -> \bar R})
    (k2Source code : T1 -> {measure set T2 -> \bar R}) xSource code ASource code :
  measurable A ->
  kcomp_noparam k1 k2 x A = kproduct_snd k1 k2 x (snd @^-1` A).
Proof.
move=> mA; rewrite /kcomp_noparam /kproduct_snd /kproduct.
apply: eq_integral => y _ /=.
by rewrite /intker_indic/= integral_indic// setIT.
Qed.

Section kcomp_noparam_measure.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
  (k1Source code : R.-spker T0 ~> T1) (k2Source code : R.-spker T1 ~> T2).

Let kcomp_noparam0Source code xSource code : kcomp_noparam k1 k2 x set0 = 0.
Proof.
by apply: integral0_eq => y _; rewrite measure0. Qed.

Let kcomp_noparam_ge0Source code xSource code ASource code : 0 <= kcomp_noparam k1 k2 x A.
Proof.
by apply: integral_ge0 => y _; exact: measure_ge0. Qed.

Let kcomp_noparam_additiveSource code xSource code :
  semi_sigma_additive (kcomp_noparam k1 k2 x).
Proof.
move=> F mF tF mUF.
rewrite kcomp_noparamE// (_ : (fun _ => _) = (fun nSource code =>
    \sum_(0 <= iSource code < n) kproduct_snd k1 k2 x (snd @^-1` F i))).
  by apply/funext => n; apply: eq_bigr => k _; rewrite kcomp_noparamE.
pose F' nSource code := [set: T1] `*` F n.
have kcomp_noparam_bigcup : kcomp_noparam k1 k2 x (\bigcup_nSource code F n) =
    kproduct k1 (kernel_snd k2) x (\bigcup_nSource code F' n).
  by apply: eq_integral => y _; rewrite -setX_bigcupr intker_indic_snd.
rewrite -kcomp_noparamE// kcomp_noparam_bigcup.
rewrite (_ : (fun nSource code => _) = (fun nSource code =>
    \sum_(0 <= iSource code < n) kproduct k1 (kernel_snd k2) x (F' i))).
  apply/funext => n; apply: eq_bigr => i _.
  apply: eq_integral => y _; apply: eq_integral => z _.
  by rewrite /F' setTX.
apply: semi_sigma_additive_kproduct => //.
- by move=> i; exact: measurableX.
- apply/trivIsetP => i j _ _ ij.
  rewrite /F' -setXI setTI.
  move/trivIsetP : tF => /(_ i j Logic.I Logic.I ij) ->.
  by rewrite setX0.
- by apply: bigcup_measurable => k _; exact: measurableX.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code xSource code :=Source code isMeasureSource code.Build d2 T2 R (kcomp_noparam k1 k2 x)
  (kcomp_noparam0 x) (kcomp_noparam_ge0 x) (@kcomp_noparam_additive x).

Definition mkcomp_noparam

mkcomp_noparam : forall [d0 d1 d2 : measure_display] [T0 : measurableType d0] [T1 : measurableType d1] [T2 : measurableType d2] {R : realType}, R.-spker T0 ~> T1 -> R.-spker T1 ~> T2 -> T0 -> {measure set T2 -> \bar R}%R mkcomp_noparam is not universe polymorphic Arguments mkcomp_noparam [d0 d1 d2]%_measure_display_scope [T0 T1 T2] {R} k1 k2 _ mkcomp_noparam is transparent Expands to: Constant mathcomp.analysis.kernel.mkcomp_noparam Declared in library mathcomp.analysis.kernel, line 1696, characters 11-25


Source code
:=
  (kcomp_noparam k1 k2 : T0 -> {measure set T2 -> \bar R}).

Let measurable_kernel_mkcomp_noparamSource code USource code :
  measurable U -> measurable_fun [set: _] (mkcomp_noparam ^~ U).
Proof.
move=> mU.
rewrite [X in measurable_fun _ X](_ : _ =
    (kproduct k1 (kernel_snd k2))^~ ([set: T1] `*` U)).
  apply/funext => x.
  by apply: eq_integral => y _; rewrite intker_indic_snd.
by apply: measurable_kproduct; exact: measurableX.
Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code @isKernelSource code.Build _ _ _ _ R
  mkcomp_noparam measurable_kernel_mkcomp_noparam.

End kcomp_noparam_measure.

Section subprobability_kcomp_noparam.
Context d0Source code d1Source code d2Source code (T0Source code : measurableType d0)
  (T1Source code : measurableType d1) (T2Source code : measurableType d2) {RSource code : realType}
  (k1Source code : R.-spker T0 ~> T1) (k2Source code : R.-spker T1 ~> T2).

Lemma sprob_mkcomp_noparamSource code xSource code : mkcomp_noparam k1 k2 x setT <= 1.
Proof.
rewrite /mkcomp_noparam [leLHS]kcomp_noparamE// preimage_setT.
rewrite /kproduct_snd /kproduct.
rewrite [leLHS](_ : _ = \int[k1 x]_ySource code k2 y setT).
  apply: eq_integral => y _.
  rewrite /intker_indic integral_indic//.
    rewrite [X in measurable X](_ : _ = ysection setT y).
      by rewrite ysectionE.
    exact: measurable_ysection.
  by rewrite setIT.
apply: (@le_trans _ _ (\int[k1 x]__ 1)); last first.
  by rewrite integral_cst// mul1e; exact: sprob_kernel_le1.
apply: ge0_le_integral => //; first exact: measurable_kernel.
by move=> y _; exact: sprob_kernel_le1.
Qed.

Let sprob_kernel_kcomp_noparamSource code :
  ereal_sup [set (kcomp_noparam k1 k2) x setT | xSource code in [set: T0]] <= 1.
Proof.
by apply/sprob_kernelP => x; exact: sprob_mkcomp_noparam. Qed.

HBSource code.instanceSource code DefinitionSource code _Source code :=Source code Kernel_isSubProbabilitySource code.Build
  _ _ _ _ R (mkcomp_noparam k1 k2) sprob_kernel_kcomp_noparam.

End subprobability_kcomp_noparam.