diff --git a/thys/Disintegration/Disintegration.thy b/thys/Disintegration/Disintegration.thy --- a/thys/Disintegration/Disintegration.thy +++ b/thys/Disintegration/Disintegration.thy @@ -1,2453 +1,2524 @@ (* Title: Disintegration.thy Author: Michikazu Hirata, Tokyo Institute of Technology *) section \ Disintegration Theorem \ theory Disintegration imports "S_Finite_Measure_Monad.Kernels" "Lemmas_Disintegration" begin subsection \ Definition 14.D.2. (Mixture and Disintegration) \ context measure_kernel begin definition mixture_of :: "[('a \'b) measure, 'a measure] \ bool" where "mixture_of \ \ \ sets \ = sets (X \\<^sub>M Y) \ sets \ = sets X \ (\C\sets (X \\<^sub>M Y). \ C = (\\<^sup>+x. \\<^sup>+y. indicator C (x,y) \(\ x) \\))" definition disintegration :: "[('a \'b) measure, 'a measure] \ bool" where "disintegration \ \ \ sets \ = sets (X \\<^sub>M Y) \ sets \ = sets X \ (\A\sets X. \B\sets Y. \ (A \ B) = (\\<^sup>+x\A. (\ x B) \\))" lemma disintegrationI: assumes "sets \ = sets (X \\<^sub>M Y)" "sets \ = sets X" and "\A B. A \ sets X \ B \ sets Y \ \ (A \ B) = (\\<^sup>+x\A. (\ x B) \\)" shows "disintegration \ \" by(simp add: disintegration_def assms) lemma mixture_of_disintegration: assumes "mixture_of \ \" shows "disintegration \ \" unfolding disintegration_def proof safe fix A B assume [simp]:"A \ sets X" "B \ sets Y" have [simp,measurable_cong]: "sets \ = sets X" "space \ = space X" using assms by(auto simp: mixture_of_def intro!: sets_eq_imp_space_eq) have "A \ B \ sets (X \\<^sub>M Y)" by simp with assms have "\ (A \ B) = (\\<^sup>+x. \\<^sup>+y. indicator (A \ B) (x,y) \(\ x) \\)" by(simp add: mixture_of_def) also have "... = (\\<^sup>+x. \\<^sup>+y. indicator A x * indicator B y \(\ x) \\)" by(simp add: indicator_times) also have "... = (\\<^sup>+x\A. (\ x B) \\)" by(auto intro!: nn_integral_cong simp: kernel_sets nn_integral_cmult_indicator mult.commute) finally show "emeasure \ (A \ B) = \\<^sup>+x\A. emeasure (\ x) B\\" . qed(use assms[simplified mixture_of_def] in auto) lemma shows mixture_of_sets_eq: "mixture_of \ \ \ sets \ = sets (X \\<^sub>M Y)" "mixture_of \ \ \ sets \ = sets X" and mixture_of_space_eq: "mixture_of \ \ \ space \ = space (X \\<^sub>M Y)" "mixture_of \ \ \ space \ = space X" and disintegration_sets_eq: "disintegration \ \ \ sets \ = sets (X \\<^sub>M Y)" "disintegration \ \ \ sets \ = sets X" and disintegration_space_eq: "disintegration \ \ \ space \ = space (X \\<^sub>M Y)" "disintegration \ \ \ space \ = space X" by(auto simp: mixture_of_def disintegration_def intro!: sets_eq_imp_space_eq) lemma shows mixture_ofD: "mixture_of \ \ \ C \ sets (X \\<^sub>M Y) \ \ C = (\\<^sup>+x. \\<^sup>+y. indicator C (x,y) \(\ x) \\)" and disintegrationD: "disintegration \ \ \ A \ sets X \ B \ sets Y \ \ (A \ B) = (\\<^sup>+x\A. (\ x B) \\)" by(auto simp: mixture_of_def disintegration_def) lemma disintegration_restrict_space: assumes "disintegration \ \" "A \ space X \ sets X" shows "measure_kernel.disintegration (restrict_space X A) Y \ (restrict_space \ (A \ space Y)) (restrict_space \ A)" proof(rule measure_kernel.disintegrationI[OF restrict_measure_kernel[of A]]) have "sets (restrict_space \ (A \ space Y)) = sets (restrict_space (X \\<^sub>M Y) (A \ space Y))" by(auto simp: disintegration_sets_eq[OF assms(1)] intro!: sets_restrict_space_cong) also have "... = sets (restrict_space X A \\<^sub>M Y)" using sets_pair_restrict_space[of X A Y "space Y"] by simp finally show "sets (restrict_space \ (A \ space Y)) = sets (restrict_space X A \\<^sub>M Y)" . next show "sets (restrict_space \ A) = sets (restrict_space X A)" by(auto simp: disintegration_sets_eq[OF assms(1)] intro!: sets_restrict_space_cong) next fix a b assume h:"a \ sets (restrict_space X A)" "b \ sets Y" then have "restrict_space \ (A \ space Y) (a \ b) = \ (a \ b)" using sets.sets_into_space by(auto intro!: emeasure_restrict_space simp: disintegration_space_eq[OF assms(1)] disintegration_sets_eq[OF assms(1)] sets_restrict_space) (metis Sigma_Int_distrib1 assms(2) pair_measureI sets.top space_pair_measure) also have "... = (\\<^sup>+x\a. emeasure (\ x) b \\)" using sets_restrict_space_iff[OF assms(2)] h assms(1) by(auto simp: disintegration_def) also have "... = (\\<^sup>+x\A. (emeasure (\ x) b * indicator a x) \\)" using h(1) by(auto intro!: nn_integral_cong simp: sets_restrict_space) (metis IntD1 indicator_simps(1) indicator_simps(2) mult.comm_neutral mult_zero_right) also have "... = (\\<^sup>+x\a. emeasure (\ x) b \restrict_space \ A)" by (metis (no_types, lifting) assms disintegration_sets_eq(2) disintegration_space_eq(2) nn_integral_cong nn_integral_restrict_space) finally show "restrict_space \ (A \ space Y) (a \ b) = (\\<^sup>+x\a. emeasure (\ x) b \restrict_space \ A)" . qed end context subprob_kernel begin lemma countable_disintegration_AE_unique: assumes "countable (space Y)" and [measurable_cong]:"sets Y = Pow (space Y)" and "subprob_kernel X Y \'" "sigma_finite_measure \" and "disintegration \ \" "measure_kernel.disintegration X Y \' \ \" shows "AE x in \. \ x = \' x" proof - interpret \': subprob_kernel X Y \' by fact interpret s: sigma_finite_measure \ by fact have sets_eq[measurable_cong]: "sets \ = sets X" "sets \ = sets (X \\<^sub>M Y)" using assms(5) by(auto simp: disintegration_def) have 1:"AE x in \. \y \ space Y. \ x {y} = \' x {y}" unfolding AE_ball_countable[OF assms(1)] proof fix y assume y: "y \ space Y" show "AE x in \. emeasure (\ x) {y} = emeasure (\' x) {y}" proof(rule s.sigma_finite) fix J :: "nat \ _" assume J:"range J \ sets \" " \ (range J) = space \" "\i. emeasure \ (J i) \ \" from y have [measurable]: "(\x. \ x {y}) \ borel_measurable X" "(\x. \' x {y}) \ borel_measurable X" using emeasure_measurable \'.emeasure_measurable by auto define A where "A \ {x \ space \. \ x {y} \ \' x {y}}" have [measurable]:"A \ sets \" by(auto simp: A_def) have A: "\x. x \ space \ \ x \ A \ \' x {y} \ \ x {y}" by(auto simp: A_def) have 1: "AE x\A in \. \ x {y} = \' x {y}" proof - have "AE x in \. \n. (x \ A \ J n \ \ x {y} = \' x {y})" unfolding AE_all_countable proof fix n have ninf:"(\\<^sup>+x\A \ J n. (\ x) {y}\\) < \" proof - have "(\\<^sup>+x\A \ J n. (\ x) {y}\\) \ (\\<^sup>+x\A \ J n. (\ x) (space Y) \\)" using kernel_sets y by(auto intro!: nn_integral_mono emeasure_mono simp: indicator_def disintegration_space_eq(2)[OF assms(5)]) also have "... \ (\\<^sup>+x\A \ J n. 1 \\)" using subprob_space by(auto intro!: nn_integral_mono simp: indicator_def disintegration_space_eq(2)[OF assms(5)]) also have "... = \ (A \ J n)" using J by simp also have "... \ \ (J n)" using J by (auto intro!: emeasure_mono) also have "... < \" using J(3)[of n] by (simp add: top.not_eq_extremum) finally show ?thesis . qed have "(\\<^sup>+x. (\' x) {y} * indicator (A \ J n) x - (\ x) {y} * indicator (A \ J n) x \\) = (\\<^sup>+x\A \ J n. (\' x) {y} \\) - (\\<^sup>+x\A \ J n. (\ x) {y} \\)" using J ninf by(auto intro!: nn_integral_diff simp: indicator_def A_def) also have "... = 0" proof - have 0: "\ ((A \ J n) \ {y}) = (\\<^sup>+x\A \ J n. (\ x) {y} \\)" using J y sets_eq by(auto intro!: disintegrationD[OF assms(5),of "A \ J n" "{y}"]) have [simp]: "(\\<^sup>+x\A \ J n. (\' x) {y} \\) = \ ((A \ J n) \ {y})" using J y sets_eq by(auto intro!: \'.disintegrationD[OF assms(6),of "A \ J n" "{y}",symmetric]) show ?thesis using ninf by (simp add: 0 diff_eq_0_iff_ennreal) qed finally have assm:"AE x in \. (\' x) {y} * indicator (A \ J n) x - (\ x) {y} * indicator (A \ J n) x = 0" using J by(simp add: nn_integral_0_iff_AE) show "AE x\A \ J n in \. (\ x) {y} = (\' x) {y}" proof(rule AE_mp[OF assm]) show "AE x in \. emeasure (\' x) {y} * indicator (A \ J n) x - emeasure (\ x) {y} * indicator (A \ J n) x = 0 \ x \ A \ J n \ emeasure (\ x) {y} = emeasure (\' x) {y}" proof - { fix x assume h: "(\' x) {y} - (\ x) {y} = 0" "x \ A" have "(\ x) {y} = (\' x) {y}" using h(2) by(auto intro!: antisym ennreal_minus_eq_0[OF h(1)] simp: A_def) } thus ?thesis by(auto simp: indicator_def) qed qed qed hence "AE x\A \ (\ (range J))in \. \ x {y} = \' x {y}" by auto thus ?thesis using J(2) by auto qed have 2: "AE x\ (space \ - A) in \. \ x {y} = \' x {y}" proof - have "AE x in \. \n. x \ (space \ - A) \ J n \ \ x {y} = \' x {y}" unfolding AE_all_countable proof fix n have ninf:"(\\<^sup>+x\(space \ - A) \ J n. (\' x) {y}\\) < \" proof - have "(\\<^sup>+x\(space \ - A) \ J n. (\' x) {y}\\) \ (\\<^sup>+x\(space \ - A) \ J n. (\' x) (space Y) \\)" using kernel_sets y by(auto intro!: nn_integral_mono emeasure_mono simp: indicator_def disintegration_space_eq(2)[OF assms(5)]) also have "... \ (\\<^sup>+x\(space \ - A) \ J n. 1 \\)" using \'.subprob_space by(auto intro!: nn_integral_mono simp: indicator_def disintegration_space_eq(2)[OF assms(5)]) also have "... = \ ((space \ - A) \ J n)" using J by simp also have "... \ \ (J n)" using J by (auto intro!: emeasure_mono) also have "... < \" using J(3)[of n] by (simp add: top.not_eq_extremum) finally show ?thesis . qed have "(\\<^sup>+x. (\ x) {y} * indicator ((space \ - A) \ J n) x - (\' x) {y} * indicator ((space \ - A) \ J n) x \\) = (\\<^sup>+x\(space \ - A) \ J n. (\ x) {y} \\) - (\\<^sup>+x\(space \ - A) \ J n. (\' x) {y} \\)" using J ninf A by(auto intro!: nn_integral_diff simp: indicator_def) also have "... = 0" proof - have 0: "(\\<^sup>+x\(space \ - A) \ J n. (\' x) {y} \\) = \ (((space \ - A) \ J n) \ {y})" using J y sets_eq by(auto intro!: \'.disintegrationD[OF assms(6),of "(space \ - A) \ J n" "{y}",symmetric]) have [simp]: "\ (((space \ - A) \ J n) \ {y}) = (\\<^sup>+x\(space \ - A) \ J n. (\ x) {y} \\)" using J y sets_eq by(auto intro!: disintegrationD[OF assms(5),of "(space \ - A) \ J n" "{y}"]) show ?thesis using ninf by (simp add: 0 diff_eq_0_iff_ennreal) qed finally have assm:"AE x in \. (\ x) {y} * indicator ((space \ - A) \ J n) x - (\' x) {y} * indicator ((space \ - A) \ J n) x = 0" using J by(simp add: nn_integral_0_iff_AE) show "AE x\(space \ - A) \ J n in \. (\ x) {y} = (\' x) {y}" proof(rule AE_mp[OF assm]) show "AE x in \. emeasure (\ x) {y} * indicator ((space \ - A) \ J n) x - emeasure (\' x) {y} * indicator ((space \ - A) \ J n) x = 0 \ x \ (space \ - A) \ J n \ emeasure (\ x) {y} = emeasure (\' x) {y}" proof - { fix x assume h: "(\ x) {y} - (\' x) {y} = 0" "x \ space \" "x \ A" have "(\ x) {y} = (\' x) {y}" using A[OF h(2,3)] by(auto intro!: antisym ennreal_minus_eq_0[OF h(1)] simp: A_def) } thus ?thesis by(auto simp: indicator_def) qed qed qed hence "AE x\(space \ - A) \ (\ (range J))in \. \ x {y} = \' x {y}" by auto thus ?thesis using J(2) by auto qed show "AE x in \. \ x {y} = \' x {y}" using 1 2 by(auto simp: A_def) qed qed show ?thesis proof(rule AE_mp[OF 1]) { fix x assume x: "x \ space X" and h: "\y\space Y. \ x {y} = \' x {y}" have "\ x = \' x " by (simp add: \'.kernel_sets assms h kernel_sets measure_eqI_countable x) } thus " AE x in \. (\y\space Y. emeasure (\ x) {y} = emeasure (\' x) {y}) \ \ x = \' x" by(auto simp: sets_eq_imp_space_eq[OF sets_eq(1)]) qed qed end lemma(in subprob_kernel) nu_mu_spaceY_le: assumes "disintegration \ \" "A \ sets X" shows "\ (A \ space Y) \ \ A" proof - have "\ (A \ space Y) = (\\<^sup>+x\A. (\ x (space Y)) \\)" using assms by(simp add: disintegration_def) also have "... \ (\\<^sup>+x\A. 1 \\)" using assms subprob_space by(auto intro!: nn_integral_mono simp: disintegration_space_eq) (metis dual_order.refl indicator_simps(1) indicator_simps(2) mult.commute mult_1 mult_zero_right) also have "... = \ A" using assms by (simp add: disintegration_def) finally show ?thesis . qed context prob_kernel begin lemma countable_disintegration_AE_unique_prob: assumes "countable (space Y)" and [measurable_cong]:"sets Y = Pow (space Y)" and "prob_kernel X Y \'" "sigma_finite_measure \" and "disintegration \ \" "measure_kernel.disintegration X Y \' \ \" shows "AE x in \. \ x = \' x" by(auto intro!: countable_disintegration_AE_unique[OF assms(1,2) _ assms(4-6)] prob_kernel.subprob_kernel assms(3)) end subsection \ Lemma 14.D.3. \ lemma(in prob_kernel) nu_mu_spaceY: assumes "disintegration \ \" "A \ sets X" shows "\ (A \ space Y) = \ A" proof - have "\ (A \ space Y) = (\\<^sup>+x\A. (\ x (space Y)) \\)" using assms by(simp add: disintegration_def) also have "... = (\\<^sup>+x\A. 1 \\)" using assms by(auto intro!: nn_integral_cong simp: prob_space disintegration_space_eq) also have "... = \ A" using assms by (simp add: disintegration_def) finally show ?thesis . qed corollary(in subprob_kernel) nu_finite: assumes "disintegration \ \" "finite_measure \" shows "finite_measure \" proof have "\ (space \) = \ (space (X \\<^sub>M Y))" using assms by(simp add: disintegration_space_eq) also have "... \ \ (space \)" using assms by(simp add: nu_mu_spaceY_le disintegration_space_eq space_pair_measure) finally show "\ (space \) \ \" using assms(2) by (metis finite_measure.emeasure_finite infinity_ennreal_def neq_top_trans) qed corollary(in subprob_kernel) nu_subprob_space: assumes "disintegration \ \" "subprob_space \" shows "subprob_space \" proof have "\ (space \) = \ (space (X \\<^sub>M Y))" using assms by(simp add: disintegration_space_eq) also have "... \ \ (space \)" using assms by(simp add: nu_mu_spaceY_le disintegration_space_eq space_pair_measure) finally show "\ (space \) \ 1" using assms(2) order.trans subprob_space.emeasure_space_le_1 by auto next show "space \ \ {}" using Y_not_empty assms by(auto simp: disintegration_space_eq subprob_space_def subprob_space_axioms_def space_pair_measure) qed corollary(in prob_kernel) nu_prob_space: assumes "disintegration \ \" "prob_space \" shows "prob_space \" proof have "\ (space \) = \ (space (X \\<^sub>M Y))" using assms by(simp add: disintegration_space_eq) also have "... = \ (space \)" using assms by(simp add: nu_mu_spaceY disintegration_space_eq space_pair_measure) finally show "\ (space \) = 1" by (simp add: assms(2) prob_space.emeasure_space_1) qed lemma(in subprob_kernel) nu_sigma_finite: assumes "disintegration \ \" "sigma_finite_measure \" shows "sigma_finite_measure \" proof obtain A where A:"countable A" "A \ sets \" "\ A = space \" "\a\A. emeasure \ a \ \" using assms(2) by (meson sigma_finite_measure.sigma_finite_countable) have "countable {a \ space Y |a. a \ A}" using countable_image[OF A(1),of "\a. a \ space Y"] by (simp add: Setcompr_eq_image) moreover have "{a \ space Y |a. a \ A} \ sets \" using A(2) assms(1) disintegration_def by auto moreover have "\ {a \ space Y |a. a \ A} = space \" using assms A(3) by(simp add: disintegration_space_eq space_pair_measure) blast moreover have "\b\{a \ space Y |a. a \ A}. emeasure \ b \ \" using neq_top_trans[OF _ nu_mu_spaceY_le[OF assms(1)]] A(2,4) assms disintegration_sets_eq(2) by auto ultimately show "\B. countable B \ B \ sets \ \ \ B = space \ \ (\b\B. emeasure \ b \ \)" by blast qed subsection \ Theorem 14.D.4. (Measure Mixture Theorem) \ lemma(in measure_kernel) exist_nu: assumes "sets \ = sets X" shows "\\. disintegration \ \" proof - define \ where "\ = extend_measure (space X \ space Y) {(a, b). a \ sets X \ b \ sets Y} (\(a, b). a \ b) (\(a, b). \\<^sup>+x\a. emeasure (\ x) b\\) " have 1: "sets \ = sets (X \\<^sub>M Y)" proof - have "sets \ = sigma_sets (space X \ space Y) ((\(a, b). a \ b) ` {(a, b). a \ sets X \ b \ sets Y})" unfolding \_def by(rule sets_extend_measure) (use sets.space_closed[of X] sets.space_closed[of Y] in blast) also have "... = sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" by(auto intro!: sigma_sets_eqI) also have "... = sets (X \\<^sub>M Y)" by(simp add: sets_pair_measure) finally show ?thesis . qed have 2: "\ (A \ B) = (\\<^sup>+x\A. (\ x B) \\)" if "A \ sets X" "B \ sets Y" for A B proof(rule extend_measure_caratheodory_pair[OF \_def]) fix i j k l assume "i \ sets X \ j \ sets Y" "k \ sets X \ l \ sets Y" "i \ j = k \ l" then consider "i = k" "j = l" | "i \ j = {}" "k \ l = {}" by blast thus "(\\<^sup>+x\i. emeasure (\ x) j \\) = (\\<^sup>+x\k. emeasure (\ x) l \\)" by cases auto next fix A B j k assume h: "\n::nat. A n \ sets X \ B n \ sets Y" "j \ sets X \ k \ sets Y" "disjoint_family (\n. A n \ B n)" "(\i. A i \ B i) = j \ k" show "(\n. \\<^sup>+x\A n. emeasure (\ x) (B n)\\) = (\\<^sup>+x\j. emeasure (\ x) k\\)" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+x. (\n. \ x (B n) * indicator (A n) x)\\)" proof(rule nn_integral_suminf[symmetric]) fix n have [measurable]:"(\x. emeasure (\ x) (B n)) \ borel_measurable \" "indicator (A n) \ borel_measurable \" using h(1)[of n] emeasure_measurable[of "B n"] assms(1) by auto thus "(\x. emeasure (\ x) (B n) * indicator (A n) x) \ borel_measurable \" by simp qed also have "... = ?rhs" proof(safe intro!: nn_integral_cong) fix x assume "x \ space \" consider "j = {}" | "k = {}" | "j \ {}" "k \ {}" by auto then show "(\n. emeasure (\ x) (B n) * indicator (A n) x) = emeasure (\ x) k * indicator j x" proof cases case 1 then have "\n. A n \ B n = {}" using h(4) by auto have "emeasure (\ x) (B n) * indicator (A n) x = 0" for n using \A n \ B n = {}\ by(auto simp: Sigma_empty_iff) thus ?thesis by(simp only: 1,simp) next case 2 then have "\n. A n \ B n = {}" using h(4) by auto have "emeasure (\ x) (B n) * indicator (A n) x = 0" for n using \A n \ B n = {}\ by(auto simp: Sigma_empty_iff) thus ?thesis by(simp only: 2,simp) next case 3 then have xinjiff:"x \ j \ (\i. \y\B i. (x,y) \ A i \ B i)" using h(4) by blast have bunk:"\ (B ` {i. x \ A i}) = k" if "x \ j" using that 3 h(4) by blast show ?thesis proof(cases "x \ j") case False then have "\n. x \ A n \ B n = {}" using h(4) 3 xinjiff by auto have "emeasure (\ x) (B n) * indicator (A n) x = 0" for n using \x \ A n \ B n = {}\ by auto thus ?thesis by(simp only:)(simp add: False) next case True then have [simp]: "emeasure (\ x) k * indicator j x = emeasure (\ x) k" by simp have "(\n. emeasure (\ x) (B n) * indicator (A n) x) = (\n. emeasure (\ x) (if x \ A n then B n else {}))" by(auto intro!: suminf_cong) also have "... = emeasure (\ x) (\n. if x \ A n then B n else {})" proof(rule suminf_emeasure) show "disjoint_family (\i. if x \ A i then B i else {})" using disjoint_family_onD[OF h(3)] by (auto simp: disjoint_family_on_def) next show "range (\i. if x \ A i then B i else {}) \ sets (\ x)" using h(1) kernel_sets[of x] \x \ space \\ sets_eq_imp_space_eq[OF assms(1)] by auto qed also have "... = emeasure (\ x) k" using True by(simp add: bunk) finally show ?thesis by simp qed qed qed finally show ?thesis . qed qed(use that in auto) show ?thesis using 1 2 assms by(auto simp: disintegration_def) qed lemma(in subprob_kernel) exist_unique_nu_sigma_finite': assumes "sets \ = sets X" "sigma_finite_measure \" shows "\!\. disintegration \ \" proof - obtain \ where disi: "disintegration \ \" using exist_nu[OF assms(1)] by auto with assms(2) interpret sf: sigma_finite_measure \ by(simp add: nu_sigma_finite) interpret \: sigma_finite_measure \ by fact show ?thesis proof(rule ex1I[where a=\]) fix \' assume disi':"disintegration \' \" show "\' = \" proof(rule \.sigma_finite_disjoint) fix A :: "nat \ _" assume A: "range A \ sets \" "\ (range A) = space \" "\i. emeasure \ (A i) \ \" "disjoint_family A" define B where "B \ \i. A i \ space Y" show "\' = \" proof(rule measure_eqI_generator_eq[where E=" {a \ b|a b. a \ sets X \ b \ sets Y}" and A=B and \="space X \ space Y"]) show "\C. C \ {a \ b |a b. a \ sets X \ b \ sets Y} \ emeasure \' C = emeasure \ C" "sets \' = sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" "sets \ = sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" using disi disi' by(auto simp: disintegration_def sets_pair_measure) next show "range B \ {a \ b |a b. a \ sets X \ b \ sets Y}" "\ (range B) = space X \ space Y" using A(1,2) by(auto simp: B_def assms(1) sets_eq_imp_space_eq[OF assms(1)]) next fix i show "emeasure \' (B i) \ \" using A(1) nu_mu_spaceY_le[OF disi',of "A i"] A(3)[of i] by(auto simp: B_def assms top.extremum_uniqueI) qed(simp_all add: Int_stable_pair_measure_generator pair_measure_closed) qed qed fact qed lemma(in subprob_kernel) exist_unique_nu_sigma_finite: assumes "sets \ = sets X" "sigma_finite_measure \" shows "\!\. disintegration \ \ \ sigma_finite_measure \" using assms exist_unique_nu_sigma_finite' nu_sigma_finite by blast lemma(in subprob_kernel) exist_unique_nu_finite: assumes "sets \ = sets X" "finite_measure \" shows "\!\. disintegration \ \ \ finite_measure \" using assms nu_finite finite_measure.sigma_finite_measure[OF assms(2)] exist_unique_nu_sigma_finite' by blast lemma(in subprob_kernel) exist_unique_nu_sub_prob_space: assumes "sets \ = sets X" "subprob_space \" shows "\!\. disintegration \ \ \ subprob_space \" using assms nu_subprob_space subprob_space_imp_sigma_finite[OF assms(2)] exist_unique_nu_sigma_finite' by blast lemma(in prob_kernel) exist_unique_nu_prob_space: assumes "sets \ = sets X" "prob_space \" shows "\!\. disintegration \ \ \ prob_space \" using assms nu_prob_space prob_space_imp_sigma_finite[OF assms(2)] exist_unique_nu_sigma_finite' by blast lemma(in subprob_kernel) nn_integral_fst_finite': assumes "f \ borel_measurable (X \\<^sub>M Y)" "disintegration \ \" "finite_measure \" shows "(\\<^sup>+z. f z \\) = (\\<^sup>+x. \\<^sup>+y. f (x,y) \(\ x) \\)" using assms(1) proof induction case (cong f g) have "integral\<^sup>N \ f = integral\<^sup>N \ g" using cong(3) by(auto intro!: nn_integral_cong simp: disintegration_space_eq(1)[OF assms(2)]) with cong(3) show ?case by(auto simp: cong(4) kernel_space disintegration_space_eq(2)[OF assms(2)] space_pair_measure intro!: nn_integral_cong) next case (set A) show ?case proof(rule sigma_sets_induct_disjoint[of "{a \ b|a b. a \ sets X \ b \ sets Y}" "space X \ space Y"]) show "A \ sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" using set by(simp add: sets_pair_measure) next fix A assume "A \ {a \ b |a b. a \ sets X \ b \ sets Y}" then obtain a b where ab: "A = a \ b" "a \ sets X" "b \ sets Y" by auto with assms(2) have "integral\<^sup>N \ (indicator A) = (\\<^sup>+x\a. (\ x b) \\)" by(simp add: disintegration_def) also have "... = (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" by(auto simp: ab(1) indicator_times disintegration_space_eq(2)[OF assms(2)] ab(3) kernel_sets mult.commute nn_integral_cmult_indicator intro!: nn_integral_cong) finally show "integral\<^sup>N \ (indicator A) = (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" . next fix A assume h: "A \ sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" "integral\<^sup>N \ (indicator A) = (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" show "integral\<^sup>N \ (indicator (space X \ space Y - A)) = (\\<^sup>+ x. \\<^sup>+ y. indicator (space X \ space Y - A) (x, y) \\ x \\)" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+ z. 1 - indicator A z \\)" by(auto intro!: nn_integral_cong simp: disintegration_space_eq(1)[OF assms(2)] space_pair_measure indicator_def) also have "... = (\\<^sup>+ z. 1 \\) - (\\<^sup>+ z. indicator A z \\)" proof(rule nn_integral_diff) show "integral\<^sup>N \ (indicator A) \ \" using h(1)[simplified sets_pair_measure[symmetric]] disintegration_sets_eq(1)[OF assms(2)] finite_measure.emeasure_finite[OF nu_finite[OF assms(2,3)]] by auto next show "indicator A \ borel_measurable \" using h(1)[simplified sets_pair_measure[symmetric]] disintegration_sets_eq(1)[OF assms(2)] by simp qed(simp_all add: indicator_def) also have "... = (\\<^sup>+ z. 1 \\) - (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" by(simp add: h(2)) also have "... = \ (space X \ space Y) - (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" using nn_integral_indicator[OF sets.top[of \]] by(simp add: space_pair_measure disintegration_space_eq(1)[OF assms(2)]) also have "... = (\\<^sup>+ x. \ x (space Y) \\) - (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" proof - have "\ (space X \ space Y) = (\\<^sup>+ x. \ x (space Y) \\)" using assms(2) by(auto simp: disintegration_def disintegration_space_eq(2)[OF assms(2)] intro!: nn_integral_cong) thus ?thesis by simp qed also have "... = (\\<^sup>+ x. \\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x \\) - (\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\)" proof - have "(\\<^sup>+ x. \ x (space Y) \\) = (\\<^sup>+ x. \\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x \\)" using kernel_sets by(auto intro!: nn_integral_cong simp: indicator_times disintegration_space_eq(2)[OF assms(2)] ) thus ?thesis by simp qed also have "... = (\\<^sup>+ x. (\\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x) - (\\<^sup>+ y. indicator A (x, y) \\ x) \\)" proof(rule nn_integral_diff[symmetric]) show "(\x. \\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x) \ borel_measurable \" "(\x. \\<^sup>+ y. indicator A (x, y) \\ x) \ borel_measurable \" by(use disintegration_sets_eq[OF assms(2)] nn_integral_measurable_f h(1)[simplified sets_pair_measure[symmetric]] in auto)+ next have "(\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\) \ (\\<^sup>+ x. \\<^sup>+ y. 1 \\ x \\)" by(rule nn_integral_mono)+ (simp add: indicator_def) also have "... \ (\\<^sup>+ x. 1 \\)" by(rule nn_integral_mono) (simp add: subprob_spaces disintegration_space_eq(2)[OF assms(2)] subprob_space.subprob_emeasure_le_1) also have "... < \" using finite_measure.emeasure_finite[OF assms(3)] by (simp add: top.not_eq_extremum) finally show "(\\<^sup>+ x. \\<^sup>+ y. indicator A (x, y) \\ x \\) \ \" by auto next have "A \ space X \ space Y" by (metis h(1) sets.sets_into_space sets_pair_measure space_pair_measure) hence "\x. (\\<^sup>+ y. indicator A (x, y) \\ x) \ (\\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x)" by(auto intro!: nn_integral_mono) thus "AE x in \. (\\<^sup>+ y. indicator A (x, y) \\ x) \ (\\<^sup>+ y. indicator (space X \ space Y) (x, y) \\ x)" by simp qed also have "... = (\\<^sup>+ x. (\\<^sup>+ y. indicator (space X \ space Y) (x, y) - indicator A (x, y) \\ x) \\)" proof(intro nn_integral_cong nn_integral_diff[symmetric]) fix x assume "x \ space \" then have "x \ space X" by(auto simp: disintegration_space_eq(2)[OF assms(2)]) with kernel_sets[OF this] h(1)[simplified sets_pair_measure[symmetric]] show "(\y. indicator (space X \ space Y) (x, y)) \ borel_measurable (\ x)" "(\y. indicator A (x, y)) \ borel_measurable (\ x)" by auto next fix x assume "x \ space \" then have "x \ space X" by(auto simp: disintegration_space_eq(2)[OF assms(2)]) have "(\\<^sup>+ y. indicator A (x, y) \\ x) \ (\\<^sup>+ y. 1 \\ x)" by(rule nn_integral_mono) (simp add: indicator_def) also have "... \ 1" using subprob_spaces[OF \x \ space X\] by (simp add: subprob_space.subprob_emeasure_le_1) also have "... < \" by auto finally show "(\\<^sup>+ y. indicator A (x, y) \\ x) \ \" by simp have "A \ space X \ space Y" by (metis h(1) sets.sets_into_space sets_pair_measure space_pair_measure) thus "AE y in \ x. indicator A (x, y) \ (indicator (space X \ space Y) (x, y) :: ennreal)" by auto qed also have "... = ?rhs" by(auto simp: indicator_def intro!: nn_integral_cong) finally show ?thesis . qed next fix A assume h:"disjoint_family A" "range A \ sigma_sets (space X \ space Y) {a \ b |a b. a \ sets X \ b \ sets Y}" "\i::nat. integral\<^sup>N \ (indicator (A i)) = (\\<^sup>+ x. \\<^sup>+ y. indicator (A i) (x, y) \\ x \\)" show "integral\<^sup>N \ (indicator (\ (range A))) = (\\<^sup>+ x. \\<^sup>+ y. indicator (\ (range A)) (x, y) \\ x \\)" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+ z. (\i. indicator (A i) z) \\)" by(simp add: suminf_indicator[OF h(1)]) also have "... = (\i. (\\<^sup>+ z. indicator (A i) z \\))" by(rule nn_integral_suminf) (use disintegration_sets_eq(1)[OF assms(2)] h(2)[simplified sets_pair_measure[symmetric]] in simp) also have "... = (\i. (\\<^sup>+ x. \\<^sup>+ y. indicator (A i) (x, y) \\ x \\))" by(simp add: h) also have "... = (\\<^sup>+ x. (\i. (\\<^sup>+ y. indicator (A i) (x, y) \\ x)) \\)" by(rule nn_integral_suminf[symmetric]) (use h(2)[simplified sets_pair_measure[symmetric]] disintegration_sets_eq(2)[OF assms(2)] nn_integral_measurable_f in simp) also have "... = (\\<^sup>+ x. \\<^sup>+ y. (\i. indicator (A i) (x, y)) \\ x \\)" using h(2)[simplified sets_pair_measure[symmetric]] kernel_sets by(auto intro!: nn_integral_cong nn_integral_suminf[symmetric] simp: disintegration_space_eq(2)[OF assms(2)]) also have "... = ?rhs" by(simp add: suminf_indicator[OF h(1)]) finally show ?thesis . qed qed(simp_all add: Int_stable_pair_measure_generator pair_measure_closed) next case (mult u c) show ?case (is "?lhs = ?rhs") proof - have "?lhs = c * (\\<^sup>+ z. u z \\)" using disintegration_sets_eq(1)[OF assms(2)] mult by(simp add: nn_integral_cmult) also have "... = c * ( \\<^sup>+ x. \\<^sup>+ y. u (x, y) \\ x \\)" by(simp add: mult) also have "... = ( \\<^sup>+ x. c * (\\<^sup>+ y. u (x, y) \\ x) \\)" using nn_integral_measurable_f'[OF mult(2)] disintegration_sets_eq(2)[OF assms(2)] by(simp add: nn_integral_cmult) also have "... = ?rhs" using mult by(auto intro!: nn_integral_cong nn_integral_cmult[symmetric] simp: disintegration_space_eq(2)[OF assms(2)]) finally show ?thesis . qed next case (add u v) show ?case (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+ z. v z \\) + (\\<^sup>+ z. u z \\)" using add disintegration_sets_eq(1)[OF assms(2)] by (simp add: nn_integral_add) also have "... = (\\<^sup>+ x. \\<^sup>+ y. v (x, y) \\ x \\) + (\\<^sup>+ x. \\<^sup>+ y. u (x, y) \\ x \\)" by(simp add: add) also have "... = (\\<^sup>+ x. (\\<^sup>+ y. v (x, y) \\ x) + (\\<^sup>+ y. u (x, y) \\ x) \\)" using nn_integral_measurable_f'[OF add(1)] nn_integral_measurable_f'[OF add(3)] disintegration_sets_eq[OF assms(2)] by(auto intro!: nn_integral_add[symmetric]) also have "... = (\\<^sup>+ x. (\\<^sup>+ y. v (x, y) + u (x, y) \\ x) \\)" using add by(auto intro!: nn_integral_add[symmetric] nn_integral_cong simp: disintegration_space_eq(2)[OF assms(2)]) finally show ?thesis . qed next case (seq fi) have "(\\<^sup>+ y. (\ range fi) (x, y) \\ x) = (\i. \\<^sup>+ y. fi i (x, y) \\ x)" (is "?lhs = ?rhs") if "x \ space X" for x proof - have "?lhs = (\\<^sup>+ y. (\i. fi i (x, y)) \\ x)" by(metis SUP_apply) also have "... = ?rhs" proof(rule nn_integral_monotone_convergence_SUP) show "incseq (\i y. fi i (x, y))" using seq mono_compose by blast next fix i show "(\y. fi i (x, y)) \ borel_measurable (\ x)" using seq(1)[of i] that kernel_sets[OF that] by simp qed finally show ?thesis . qed have "integral\<^sup>N \ (\ range fi) = (\\<^sup>+ x. (\i. fi i x) \\)" by (metis SUP_apply) also have "... = (\i. integral\<^sup>N \ (fi i))" using disintegration_sets_eq(1)[OF assms(2)] seq(1,3) by(auto intro!: nn_integral_monotone_convergence_SUP) also have "... = (\i. \\<^sup>+ x. \\<^sup>+ y. fi i (x, y) \\ x \\)" by(simp add: seq) also have "... = (\\<^sup>+ x. (\i. \\<^sup>+ y. fi i (x, y) \\ x) \\)" proof(safe intro!: nn_integral_monotone_convergence_SUP[symmetric]) show "incseq (\i x. \\<^sup>+ y. fi i (x, y) \\ x)" using le_funD[OF incseq_SucD[OF seq(3)]] by(auto intro!: incseq_SucI le_funI nn_integral_mono) qed(use disintegration_sets_eq(2)[OF assms(2)] nn_integral_measurable_f'[OF seq(1)] in auto) also have "... = (\\<^sup>+ x. \\<^sup>+ y. (\i. fi i (x, y)) \\ x \\)" using kernel_sets seq(1) by(auto intro!: nn_integral_cong nn_integral_monotone_convergence_SUP[symmetric] simp: disintegration_space_eq(2)[OF assms(2)] mono_compose seq(3)) also have "... = (\\<^sup>+ x. \\<^sup>+ y. (\ range fi) (x, y) \\ x \\)" by(auto intro!: nn_integral_cong simp: image_image) finally show ?case . qed lemma(in prob_kernel) nn_integral_fst: assumes "f \ borel_measurable (X \\<^sub>M Y)" "disintegration \ \" "sigma_finite_measure \" shows "(\\<^sup>+z. f z \\) = (\\<^sup>+x. \\<^sup>+y. f (x,y) \(\ x) \\)" proof(rule sigma_finite_measure.sigma_finite_disjoint[OF assms(3)]) fix A assume A:"range A \ sets \" "\ (range A) = space \" "\i::nat. emeasure \ (A i) \ \" "disjoint_family A" then have A': "range (\i. A i \ space Y) \ sets \" "\ (range (\i. A i \ space Y)) = space \" "disjoint_family (\i. A i \ space Y)" by(auto simp: disintegration_sets_eq[OF assms(2)] disjoint_family_on_def disintegration_space_eq[OF assms(2)] space_pair_measure) blast show ?thesis (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+z\\ (range (\i. A i \ space Y)). f z \\)" using A'(2) by auto also have "... = (\i. \\<^sup>+z\ A i \ space Y. f z \\)" using A'(1,3) assms(1) disintegration_sets_eq[OF assms(2)] by(auto intro!: nn_integral_disjoint_family) also have "... = (\i. \\<^sup>+z. f z \restrict_space \ (A i \ space Y))" using A'(1) by(auto intro!: suminf_cong nn_integral_restrict_space[symmetric]) also have "... = (\i. \\<^sup>+x. \\<^sup>+y. f (x,y) \(\ x) \restrict_space \ (A i))" proof(safe intro!: suminf_cong) fix n interpret pk: prob_kernel "restrict_space X (A n)" Y \ by(rule restrict_probability_kernel) have An:"A n \ space X \ sets X" "A n \ space X = A n" using A(1) by(auto simp: disintegration_sets_eq[OF assms(2)]) have f:"f \ borel_measurable (restrict_space X (A n) \\<^sub>M Y)" proof - have 1:"sets (restrict_space X (A n) \\<^sub>M Y) = sets (restrict_space (X \\<^sub>M Y) (A n \ space Y))" using sets_pair_restrict_space[where Y=Y and B="space Y"] by simp show ?thesis using assms(1) by(simp add: measurable_cong_sets[OF 1 refl] measurable_restrict_space1) qed have fin: "finite_measure (restrict_space \ (A n))" by (metis A(1) A(3) UNIV_I emeasure_restrict_space finite_measureI image_subset_iff space_restrict_space space_restrict_space2 subset_eq) show "(\\<^sup>+z. f z \restrict_space \ (A n \ space Y)) = (\\<^sup>+x. \\<^sup>+y. f (x,y) \(\ x) \restrict_space \ (A n))" by(rule pk.nn_integral_fst_finite'[OF f disintegration_restrict_space[OF assms(2) An(1)] fin]) qed also have "... = (\i. \\<^sup>+x\A i. \\<^sup>+y. f (x,y) \(\ x) \\)" using A(1) by(auto intro!: suminf_cong nn_integral_restrict_space) also have "... = (\\<^sup>+x\\ (range A). \\<^sup>+y. f (x,y) \(\ x) \\)" using A(1,4) nn_integral_measurable_f'[OF assms(1)] disintegration_sets_eq[OF assms(2)] by(auto intro!: nn_integral_disjoint_family[symmetric]) also have "... = ?rhs" using A(2) by simp finally show ?thesis . qed qed lemma(in prob_kernel) integrable_eq1: fixes f :: "_ \ _::{banach, second_countable_topology}" assumes [measurable]:"f \ borel_measurable (X \\<^sub>M Y)" and "disintegration \ \" "sigma_finite_measure \" shows "(\\<^sup>+ z. ennreal (norm (f z)) \\) < \ \ (\\<^sup>+x. \\<^sup>+y. ennreal (norm (f (x,y))) \(\ x) \\) < \" by(simp add: nn_integral_fst[OF _ assms(2,3)]) lemma(in prob_kernel) integrable_kernel_integrable: fixes f :: "_ \ _::{banach, second_countable_topology}" assumes "integrable \ f" "disintegration \ \" "sigma_finite_measure \" shows "AE x in \. integrable (\ x) (\y. f (x,y))" proof - have [measurable]:"f \ borel_measurable (X \\<^sub>M Y)" using integrable_iff_bounded assms(1) disintegration_sets_eq[OF assms(2)] by simp show ?thesis unfolding integrable_iff_bounded proof - have 1:"(\\<^sup>+ x. \\<^sup>+ y. ennreal (norm (f (x,y))) \\ x \\) < \" using assms(1) integrable_eq1[OF _ assms(2,3),of f] by(simp add: integrable_iff_bounded) have "AE x in \. (\\<^sup>+ y. ennreal (norm (f (x,y))) \\ x) \ \" by(rule nn_integral_PInf_AE) (use 1 disintegration_sets_eq[OF assms(2)] nn_integral_measurable_f in auto) thus "AE x in \. (\y. f (x, y)) \ borel_measurable (\ x) \ (\\<^sup>+ y. ennreal (norm (f (x,y))) \\ x) < \" using top.not_eq_extremum by(fastforce simp: disintegration_space_eq[OF assms(2)]) qed qed lemma(in prob_kernel) integrable_lebesgue_integral_integrable': fixes f :: "_ \ _::{banach, second_countable_topology}" assumes "integrable \ f" "disintegration \ \" "sigma_finite_measure \" shows "integrable \ (\x. \y. f (x,y) \(\ x))" unfolding integrable_iff_bounded proof show "(\x. \y. f (x,y) \(\ x)) \ borel_measurable \" using disintegration_sets_eq[OF assms(2)] assms(1) integral_measurable_f'[of f] by(auto simp: integrable_iff_bounded) next have "(\\<^sup>+ x. ennreal (norm (\y. f (x,y) \(\ x))) \\) \ (\\<^sup>+ x. \\<^sup>+y. ennreal (norm (f (x,y))) \(\ x) \\)" using integral_norm_bound_ennreal integrable_kernel_integrable[OF assms] by(auto intro!: nn_integral_mono_AE) also have "... < \" using integrable_eq1[OF _ assms(2,3),of f] assms(1) disintegration_sets_eq[OF assms(2)] by(simp add: integrable_iff_bounded) finally show "(\\<^sup>+ x. ennreal (norm (\y. f (x,y) \(\ x))) \\) < \" . qed lemma(in prob_kernel) integrable_lebesgue_integral_integrable: fixes f :: "_ \_ \ _::{banach, second_countable_topology}" assumes "integrable \ (\(x,y). f x y)" "disintegration \ \" "sigma_finite_measure \" shows "integrable \ (\x. \y. f x y \(\ x))" using integrable_lebesgue_integral_integrable'[OF assms] by simp lemma(in prob_kernel) integral_fst: fixes f :: "_ \ _::{banach, second_countable_topology}" assumes "integrable \ f" "disintegration \ \" "sigma_finite_measure \" shows "(\z. f z \\) = (\x. \y. f (x,y) \(\ x) \\)" using assms(1) proof induct case b:(base A c) then have 0:"integrable \ (indicat_real A)" by blast then have 1[measurable]: "indicat_real A \ borel_measurable (X \\<^sub>M Y)" using disintegration_sets_eq[OF assms(2)] by auto have eq:"(\z. indicat_real A z \\) = (\x. \y. indicat_real A (x,y) \\ x \\)" (is "?lhs = ?rhs") proof - have "?lhs = enn2real (\\<^sup>+ z. ennreal (indicat_real A z) \\)" by(rule integral_eq_nn_integral) (use b in auto) also have "... = enn2real (\\<^sup>+ x. \\<^sup>+ y. ennreal (indicat_real A (x,y)) \\ x \\)" using nn_integral_fst[OF _ assms(2,3)] b disintegration_sets_eq[OF assms(2)] by auto also have "... = enn2real (\\<^sup>+ x. ennreal (\ y. indicat_real A (x,y) \\ x) \\)" proof - have "(\\<^sup>+ x. \\<^sup>+ y. ennreal (indicat_real A (x,y)) \\ x \\) = (\\<^sup>+ x. ennreal (\ y. indicat_real A (x,y) \\ x) \\)" proof(safe intro!: nn_integral_cong nn_integral_eq_integral) fix x assume "x \ space \" then have "x \ space X" by(simp add: disintegration_space_eq[OF assms(2)]) hence [simp]:"prob_space (\ x)" "sets (\ x) = sets Y" "space (\ x) = space Y" by(auto intro!: prob_spaces sets_eq_imp_space_eq kernel_sets) have [simp]:"{y. (x, y) \ A} \ sets Y" proof - have "{y. (x, y) \ A} = (\y. (x,y)) -` A \ space Y" using b(1)[simplified disintegration_sets_eq[OF assms(2)]] by auto also have "... \ sets Y" using b(1)[simplified disintegration_sets_eq[OF assms(2)]] \x \ space X\ by auto finally show ?thesis . qed have [simp]: "(\y. indicat_real A (x, y)) = indicat_real {y. (x,y) \ A}" by (auto simp: indicator_def) show "integrable (\ x) (\y. indicat_real A (x, y))" using prob_space.emeasure_le_1[of "\ x" "{y. (x, y) \ A}"] by(auto simp add: integrable_indicator_iff order_le_less_trans) qed simp thus ?thesis by simp qed also have "... = ?rhs" using disintegration_sets_eq[OF assms(2)] integral_measurable_f'[OF 1] by(auto intro!: integral_eq_nn_integral[symmetric]) finally show ?thesis . qed show ?case (is "?lhs = ?rhs") proof - have "?lhs = (\z. indicat_real A z \\) *\<^sub>R c" using 0 by auto also have "... = (\x. \y. indicat_real A (x,y) \\ x \\) *\<^sub>R c" by(simp only: eq) also have "... = (\x. (\y. indicat_real A (x,y) \\ x) *\<^sub>R c \\)" using integrable_lebesgue_integral_integrable'[OF 0 assms(2,3)] by(auto intro!: integral_scaleR_left[symmetric]) also have "... = ?rhs" using integrable_kernel_integrable[OF 0 assms(2,3)] integral_measurable_f'[of " indicat_real A"] integral_measurable_f'[of "\z. indicat_real A z *\<^sub>R c"] disintegration_sets_eq[OF assms(2)] by(auto intro!: integral_cong_AE) finally show ?thesis . qed next case fg:(add f g) note [measurable] = integrable_lebesgue_integral_integrable'[OF fg(1) assms(2,3)] integrable_lebesgue_integral_integrable'[OF fg(3) assms(2,3)] integrable_lebesgue_integral_integrable'[OF Bochner_Integration.integrable_add[OF fg(1,3)] assms(2,3)] show ?case (is "?lhs = ?rhs") proof - have "?lhs = (\x. (\y. f (x,y) \(\ x)) + (\y. g (x,y) \(\ x)) \\)" by(simp add: Bochner_Integration.integral_add[OF fg(1,3)] fg Bochner_Integration.integral_add[OF integrable_lebesgue_integral_integrable'[OF fg(1) assms(2,3)] integrable_lebesgue_integral_integrable'[OF fg(3) assms(2,3)]]) also have "... = ?rhs" using integrable_kernel_integrable[OF fg(1) assms(2,3)] integrable_kernel_integrable[OF fg(3) assms(2,3)] by(auto intro!: integral_cong_AE) finally show ?thesis . qed next case (lim f s) then have [measurable]: "f \ borel_measurable \" "\i. s i \ borel_measurable \" by auto show ?case proof (rule LIMSEQ_unique) show "(\i. integral\<^sup>L \ (s i)) \ integral\<^sup>L \ f" proof (rule integral_dominated_convergence) show "integrable \ (\x. 2 * norm (f x))" using lim(5) by auto qed(use lim in auto) next have "(\i. \ x. \ y. s i (x, y) \(\ x) \\) \ \ x. \ y. f (x, y) \(\ x) \\" proof (rule integral_dominated_convergence) have "AE x in \. \i. integrable (\ x) (\y. s i (x, y))" unfolding AE_all_countable using integrable_kernel_integrable[OF lim(1) assms(2,3)] .. with AE_space integrable_kernel_integrable[OF lim(5) assms(2,3)] show "AE x in \. (\i. \ y. s i (x, y) \(\ x)) \ \ y. f (x, y) \(\ x)" proof eventually_elim fix x assume x: "x \ space \" and s: "\i. integrable (\ x) (\y. s i (x, y))" and f: "integrable (\ x) (\y. f (x, y))" show "(\i. \ y. s i (x, y) \(\ x)) \ \ y. f (x, y) \(\ x)" proof (rule integral_dominated_convergence) show "integrable (\ x) (\y. 2 * norm (f (x, y)))" using f by auto show "AE xa in (\ x). (\i. s i (x, xa)) \ f (x, xa)" using x lim(3) kernel_space by (auto simp: space_pair_measure disintegration_space_eq[OF assms(2)]) show "\i. AE xa in (\ x). norm (s i (x, xa)) \ 2 * norm (f (x, xa))" using x lim(4) kernel_space by (auto simp: space_pair_measure disintegration_space_eq[OF assms(2)]) qed (use x disintegration_sets_eq[OF assms(2)] disintegration_space_eq[OF assms(2)] in auto) qed next show "integrable \ (\x. (\ y. 2 * norm (f (x, y)) \(\ x)))" using integrable_lebesgue_integral_integrable'[OF _ assms(2,3),of "\z. 2 * norm (f (fst z, snd z))"] lim(5) by auto next fix i show "AE x in \. norm (\ y. s i (x, y) \(\ x)) \ (\ y. 2 * norm (f (x, y)) \(\ x))" using AE_space integrable_kernel_integrable[OF lim(1) assms(2,3),of i] integrable_kernel_integrable[OF lim(5) assms(2,3)] proof eventually_elim case sf:(elim x) from sf(2) have "norm (\ y. s i (x, y) \(\ x)) \ (\\<^sup>+y. norm (s i (x, y)) \(\ x))" by (rule integral_norm_bound_ennreal) also have "\ \ (\\<^sup>+y. 2 * norm (f (x, y)) \(\ x))" using sf lim kernel_space by (auto intro!: nn_integral_mono simp: space_pair_measure disintegration_space_eq[OF assms(2)]) also have "\ = (\y. 2 * norm (f (x, y)) \(\ x))" using sf by (intro nn_integral_eq_integral) auto finally show "norm (\ y. s i (x, y) \(\ x)) \ (\ y. 2 * norm (f (x, y)) \(\ x))" by simp qed qed(use integrable_lebesgue_integral_integrable'[OF lim(1) assms(2,3)] integrable_lebesgue_integral_integrable'[OF lim(5) assms(2,3)] disintegration_sets_eq[OF assms(2)] in auto) then show "(\i. integral\<^sup>L \ (s i)) \ \ x. \ y. f (x, y) \(\ x) \\" using lim by simp qed qed subsection \ Marginal Measure \ definition marginal_measure_on :: "['a measure, 'b measure, ('a \ 'b) measure, 'b set] \ 'a measure" where "marginal_measure_on X Y \ B = measure_of (space X) (sets X) (\A. \ (A \ B))" abbreviation marginal_measure :: "['a measure, 'b measure, ('a \ 'b) measure] \ 'a measure" where "marginal_measure X Y \ \ marginal_measure_on X Y \ (space Y)" lemma space_marginal_measure: "space (marginal_measure_on X Y \ B) = space X" and sets_marginal_measure: "sets (marginal_measure_on X Y \ B) = sets X" by(simp_all add: marginal_measure_on_def) lemma emeasure_marginal_measure_on: assumes "sets \ = sets (X \\<^sub>M Y)" "B \ sets Y" "A \ sets X" shows "marginal_measure_on X Y \ B A = \ (A \ B)" unfolding marginal_measure_on_def proof(rule emeasure_measure_of_sigma) show "countably_additive (sets X) (\A. emeasure \ (A \ B))" proof(rule countably_additiveI) fix A :: "nat \ _" assume h:"range A \ sets X" "disjoint_family A" "\ (range A) \ sets X" have [simp]: "(\i. A i \ B) = (\ (range A) \ B)" by blast have "range (\i. A i \ B) \ sets \" "disjoint_family (\i. A i \ B)" using h assms(1,2) by(auto simp: disjoint_family_on_def) from suminf_emeasure[OF this] show " (\i. \ (A i \ B)) = \ (\ (range A) \ B)" by simp qed qed(insert assms, auto simp: positive_def sets.sigma_algebra_axioms) lemma emeasure_marginal_measure: assumes "sets \ = sets (X \\<^sub>M Y)" "A \ sets X" shows "marginal_measure X Y \ A = \ (A \ space Y)" using emeasure_marginal_measure_on[OF assms(1) _ assms(2)] by simp lemma finite_measure_marginal_measure_on_finite: assumes "finite_measure \" "sets \ = sets (X \\<^sub>M Y)" "B \ sets Y" shows "finite_measure (marginal_measure_on X Y \ B)" by (simp add: assms emeasure_marginal_measure_on finite_measure.emeasure_finite finite_measureI space_marginal_measure) lemma finite_measure_marginal_measure_finite: assumes "finite_measure \" "sets \ = sets (X \\<^sub>M Y)" shows "finite_measure (marginal_measure X Y \)" by(rule finite_measure_marginal_measure_on_finite[OF assms sets.top]) lemma marginal_measure_restrict_space: assumes "sets \ = sets (X \\<^sub>M Y)" "B \ sets Y" shows "marginal_measure X (restrict_space Y B) (restrict_space \ (space X \ B)) = marginal_measure_on X Y \ B" proof(rule measure_eqI) fix A assume "A \ sets (marginal_measure X (restrict_space Y B) (restrict_space \ (space X \ B)))" then have "A \ sets X" by(simp add: sets_marginal_measure) have 1:"sets (restrict_space \ (space X \ B)) = sets (X \\<^sub>M restrict_space Y B)" by (metis assms(1) restrict_space_space sets_pair_restrict_space sets_restrict_space_cong) show "emeasure (marginal_measure X (restrict_space Y B) (restrict_space \ (space X \ B))) A = emeasure (marginal_measure_on X Y \ B) A" apply(simp add: emeasure_marginal_measure_on[OF assms(1) assms(2) \A \ sets X\] emeasure_marginal_measure[OF 1 \A \ sets X\]) apply(simp add: space_restrict_space) by (metis Sigma_cong Sigma_mono \A \ sets X\ assms(1) assms(2) emeasure_restrict_space inf_le1 pair_measureI sets.Int_space_eq2 sets.sets_into_space sets.top) qed(simp add: sets_marginal_measure) lemma restrict_space_marginal_measure_on: assumes "sets \ = sets (X \\<^sub>M Y)" "B \ sets Y" "A \ sets X" shows "restrict_space (marginal_measure_on X Y \ B) A = marginal_measure_on (restrict_space X A) Y (restrict_space \ (A \ space Y)) B" proof(rule measure_eqI) fix A' assume "A' \ sets (restrict_space (marginal_measure_on X Y \ B) A)" then have h:"A' \ sets.restricted_space X A" by(simp add: sets_marginal_measure sets_restrict_space) show "emeasure (restrict_space (marginal_measure_on X Y \ B) A) A' = emeasure (marginal_measure_on (restrict_space X A) Y (restrict_space \ (A \ space Y)) B) A'" (is "?lhs = ?rhs") proof - have 1:"sets (restrict_space \ (A \ space Y)) = sets (restrict_space X A \\<^sub>M Y)" by (metis assms(1) restrict_space_space sets_pair_restrict_space sets_restrict_space_cong) have "?lhs = emeasure (marginal_measure_on X Y \ B) A'" using h by(auto intro!: emeasure_restrict_space simp: space_marginal_measure sets_marginal_measure assms) also have "... = \ (A' \ B)" using emeasure_marginal_measure_on[OF assms(1,2),of A'] h assms(3) by auto also have "... = restrict_space \ (A \ space Y) (A' \ B)" using h assms sets.sets_into_space by(auto intro!: emeasure_restrict_space[symmetric]) also have "... = ?rhs" using emeasure_marginal_measure_on[OF 1 assms(2),simplified sets_restrict_space,OF h] .. finally show ?thesis . qed qed(simp add: sets_marginal_measure sets_restrict_space) lemma restrict_space_marginal_measure: assumes "sets \ = sets (X \\<^sub>M Y)" "A \ sets X" shows "restrict_space (marginal_measure X Y \) A = marginal_measure (restrict_space X A) Y (restrict_space \ (A \ space Y))" using restrict_space_marginal_measure_on[OF assms(1) _ assms(2)] by simp lemma marginal_measure_mono: assumes "sets \ = sets (X \\<^sub>M Y)" "A \ sets Y" "B \ sets Y" "A \ B" shows "emeasure (marginal_measure_on X Y \ A) \ emeasure (marginal_measure_on X Y \ B)" proof(rule le_funI) fix U show "emeasure (marginal_measure_on X Y \ A) U \ emeasure (marginal_measure_on X Y \ B) U" proof - have 1:"U \ A \ U \ B" using assms(4) by auto show ?thesis proof(cases "U \ sets X") case True then show ?thesis by (simp add: "1" assms emeasure_marginal_measure_on emeasure_mono) next case False then show ?thesis by (simp add: emeasure_notin_sets sets_marginal_measure) qed qed qed lemma marginal_measure_absolutely_countinuous: assumes "sets \ = sets (X \\<^sub>M Y)" "A \ sets Y" "B \ sets Y" "A \ B" shows "absolutely_continuous (marginal_measure_on X Y \ B) (marginal_measure_on X Y \ A)" using emeasure_marginal_measure[OF assms(1)] assms(2,3) le_funD[OF marginal_measure_mono[OF assms]] by(auto intro!: mono_absolutely_continuous simp: sets_marginal_measure) lemma marginal_measure_absolutely_continuous': assumes "sets \ = sets (X \\<^sub>M Y)" "A \ sets Y" shows "absolutely_continuous (marginal_measure X Y \) (marginal_measure_on X Y \ A)" by(rule marginal_measure_absolutely_countinuous[OF assms sets.top sets.sets_into_space[OF assms(2)]]) subsection \ Lemma 14.D.6. \ locale sigma_finite_measure_on_pair = fixes X :: "'a measure" and Y :: "'b measure" and \ :: "('a \ 'b) measure" assumes nu_sets[measurable_cong]: "sets \ = sets (X \\<^sub>M Y)" and sigma_finite: "sigma_finite_measure \" begin abbreviation "\x \ marginal_measure X Y \" end locale projection_sigma_finite = fixes X :: "'a measure" and Y :: "'b measure" and \ :: "('a \ 'b) measure" assumes nu_sets[measurable_cong]: "sets \ = sets (X \\<^sub>M Y)" and marginal_sigma_finite: "sigma_finite_measure (marginal_measure X Y \)" begin sublocale \x : sigma_finite_measure "marginal_measure X Y \" by(rule marginal_sigma_finite) lemma \_sigma_finite: "sigma_finite_measure \" proof(rule \x.sigma_finite[simplified sets_marginal_measure space_marginal_measure]) fix A :: "nat \ _" assume A: "range A \ sets X" "\ (range A) = space X" "\i. marginal_measure X Y \ (A i) \ \" define C where "C \ range (\n. A n \ space Y)" have 1:"C \ sets \" "countable C" "\ C = space \" using nu_sets A(1,2) by(auto simp: C_def sets_eq_imp_space_eq[OF nu_sets] space_pair_measure) show "sigma_finite_measure \" unfolding sigma_finite_measure_def proof(safe intro!: exI[where x=C,simplified C_def]) fix n assume "\ (A n \ space Y) = \" moreover have "\ (A n \ space Y) \ \" using A(3)[of n] emeasure_marginal_measure[OF nu_sets,of "A n"] A(1) by auto ultimately show False by auto qed (use 1 C_def in auto) qed sublocale sigma_finite_measure_on_pair using \_sigma_finite by(auto simp: sigma_finite_measure_on_pair_def nu_sets) definition \' :: "'a \ 'b set \ ennreal" where "\' x B \ RN_deriv \x (marginal_measure_on X Y \ B) x" (* Notice that \' has the type "'a \ 'b set \ ennreal" not "'a \ 'b measure" because \' x is not a measure in general. *) lemma kernel_measurable[measurable]: "(\x. RN_deriv (marginal_measure X Y \) (marginal_measure_on X Y \ B) x) \ borel_measurable \x" by simp corollary \'_measurable[measurable]: "(\x. \' x B) \ borel_measurable X" using sets_marginal_measure[of X Y \ "space Y"] by(auto simp: \'_def) lemma kernel_RN_deriv: assumes "A \ sets X" "B \ sets Y" shows "\ (A \ B) = (\\<^sup>+x\A. \' x B \\x)" unfolding \'_def proof - have "emeasure \ (A \ B) = emeasure (density \x (RN_deriv \x (marginal_measure_on X Y \ B))) A" by (simp add: \x.density_RN_deriv assms emeasure_marginal_measure_on marginal_measure_absolutely_continuous' nu_sets sets_marginal_measure) then show "emeasure \ (A \ B) = set_nn_integral \x A (RN_deriv \x (marginal_measure_on X Y \ B))" by (simp add: assms(1) emeasure_density sets_marginal_measure) qed lemma empty_Y_bot: assumes "space Y = {}" shows "\ = \" proof - have "sets \ = {{}}" using nu_sets space_empty_iff[of "X \\<^sub>M Y",simplified space_pair_measure] assms by simp thus ?thesis by(simp add: sets_eq_bot) qed lemma empty_Y_nux: assumes "space Y = {}" shows "\x A = 0" proof(cases "A \ sets X") case True from emeasure_marginal_measure[OF nu_sets this] show ?thesis by(simp add: assms) next case False with sets_marginal_measure[of X Y \ "space Y"] show ?thesis by(auto intro!: emeasure_notin_sets) qed lemma kernel_empty0_AE: "AE x in \x. \' x {} = 0" unfolding \'_def by(rule AE_symmetric[OF \x.RN_deriv_unique]) (auto intro!: measure_eqI simp: sets_marginal_measure emeasure_density emeasure_marginal_measure_on[OF nu_sets]) lemma kernel_Y1_AE: "AE x in \x. \' x (space Y) = 1" unfolding \'_def by(rule AE_symmetric[OF \x.RN_deriv_unique]) (auto intro!: measure_eqI simp: emeasure_density) lemma kernel_suminf_AE: assumes "disjoint_family F" and "\i. F i \ sets Y" shows "AE x in \x. (\i. \' x (F i)) = \' x (\ (range F))" unfolding \'_def proof(rule \x.RN_deriv_unique) show "density \x (\x. \i. RN_deriv local.\x (marginal_measure_on X Y \ (F i)) x) = marginal_measure_on X Y \ (\ (range F))" proof(rule measure_eqI) fix A assume [measurable]:"A \ sets (density \x (\x. \i. RN_deriv \x (marginal_measure_on X Y \ (F i)) x))" then have [measurable]:"A \ sets \x" "A \ sets X" by(auto simp: sets_marginal_measure) show "(density \x (\x. \i. RN_deriv \x (marginal_measure_on X Y \ (F i)) x)) A = (marginal_measure_on X Y \ (\ (range F))) A" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+x\A. (\i. RN_deriv \x (marginal_measure_on X Y \ (F i)) x)\\x)" by(auto intro!: emeasure_density) also have "... = (\\<^sup>+x. (\i. RN_deriv \x (marginal_measure_on X Y \ (F i)) x * indicator A x)\\x)" by simp also have "... = (\i. (\\<^sup>+x\A. RN_deriv \x (marginal_measure_on X Y \ (F i)) x \\x))" by(rule nn_integral_suminf) auto also have "... = (\i. \ (A \ F i))" using kernel_RN_deriv[of A "F _"] assms by(auto intro!: suminf_cong simp: \'_def) also have "... = \ (\i. A \ F i)" using assms nu_sets by(fastforce intro!: suminf_emeasure simp: disjoint_family_on_def) also have "... = \ (A \ (\i. F i))" proof - have "(\i. A \ F i) = (A \ (\i. F i))" by blast thus ?thesis by simp qed also have "... = ?rhs" using nu_sets assms by(auto intro!: emeasure_marginal_measure_on[symmetric]) finally show ?thesis . qed qed(simp add: sets_marginal_measure) qed auto lemma kernel_finite_sum_AE: assumes "disjoint_family_on F S" "finite S" and "\i. i \ S \ F i \ sets Y" shows "AE x in \x. (\i\S. \' x (F i)) = \' x (\i\S. F i)" proof - consider "S = {}" | "S \ {}" by auto then show ?thesis proof cases case 1 then show ?thesis by(simp add: kernel_empty0_AE) next case S:2 define F' where "F' \ (\n. if n < card S then F (from_nat_into S n) else {})" have F'[simp]:"\i. F' i \ sets Y" using assms(3) by (metis F'_def bot.extremum_strict bot_nat_def card.empty from_nat_into sets.empty_sets) have F'_disj: "disjoint_family F'" unfolding disjoint_family_on_def proof safe fix m n x assume h:"m \ n" "x \ F' m" "x \ F' n" consider "n < card S" "m < card S" | "n \ card S" | "m \ card S" by arith then show "x \ {}" proof cases case 1 then have "S \ {}" by auto with 1 have "from_nat_into S n \ S" "from_nat_into S m \ S" using from_nat_into[of S ] by blast+ moreover have "from_nat_into S n \ from_nat_into S m" by (metis "1"(1) "1"(2) assms(2) bij_betw_def h(1) lessThan_iff to_nat_on_finite to_nat_on_from_nat_into) ultimately show ?thesis using h assms(1) 1 by(auto simp: disjoint_family_on_def F'_def) qed(use h F'_def in simp_all) qed have 1:"(\i\S. \' x (F i)) = (\i' x (F' i))" for x unfolding F'_def by auto (metis (no_types, lifting) sum.card_from_nat_into sum.cong) have 2: "(\ (range F')) = (\i\S. F i)" proof safe fix x n assume h:"x \ F' n" then have "S \ {}" "n < card S" by(auto simp: F'_def) (meson empty_iff) with h show "x \ \ (F ` S)" by(auto intro!: exI[where x="from_nat_into S n"] simp: F'_def from_nat_into \S \ {}\) next fix x s assume "s \ S" "x \ F s" with bij_betwE[OF to_nat_on_finite[OF assms(2)]] show "x \ \ (range F')" by(auto intro!: exI[where x="to_nat_on S s"] simp: F'_def from_nat_into_to_nat_on[OF countable_finite[OF assms(2)]]) qed have "AE x in \x. (\i' x (F' i)) = (\i. \' x (F' i))" proof - have "AE x in \x. \i\card S. \' x (F' i) = 0" using kernel_empty0_AE by(auto simp: F'_def) hence "AE x in \x. (\i. \' x (F' i)) = (\i' x (F' i))" proof show "AE x in \x. (\i\card S. \' x (F' i) = 0) \ (\i. \' x (F' i)) = (\i' x (F' i))" proof - { fix x assume "\i\card S. \' x (F' i) = 0" then have "(\i. \' x (F' i)) = (\i' x (F' i))" using suminf_offset[of "\i. \' x (F' i)" "card S"] by(auto simp: F'_def) } thus ?thesis by auto qed qed thus ?thesis by auto qed moreover have "AE x in \x. (\i. \' x (F' i)) = \' x (\ (range F'))" using kernel_suminf_AE[OF F'_disj] by simp ultimately show ?thesis by(auto simp: 1 2) qed qed lemma kernel_disjoint_sum_AE: assumes "B \ sets Y" "C \ sets Y" and "B \ C = {}" shows "AE x in \x. \' x (B \ C) = \' x B + \' x C" proof - define F where "F \ \b. if b then B else C" have [simp]:"disjoint_family F" "\i. F i \ sets Y" "\x. (\i\UNIV. \' x (F i)) = \' x B + \' x C" "\ (range F) = B \ C" using assms by(auto simp: F_def disjoint_family_on_def comm_monoid_add_class.sum.Int_Diff[of UNIV _ "{True}"]) show ?thesis using kernel_finite_sum_AE[of F UNIV] by auto qed lemma kernel_mono_AE: assumes "B \ sets Y" "C \ sets Y" and "B \ C" shows "AE x in \x. \' x B \ \' x C" proof - have 1: "B \ (C - B) = C" using assms(3) by auto have "AE x in \x. \' x C = \' x B + \' x (C - B)" using assms by(auto intro!: kernel_disjoint_sum_AE[of B "C - B",simplified 1]) thus ?thesis by auto qed lemma kernel_incseq_AE: assumes "range B \ sets Y" "incseq B" shows "AE x in \x. incseq (\n. \' x (B n))" using assms(1) by(auto simp: incseq_Suc_iff AE_all_countable intro!: kernel_mono_AE[OF _ _ incseq_SucD[OF assms(2)]]) lemma kernel_decseq_AE: assumes "range B \ sets Y" "decseq B" shows "AE x in \x. decseq (\n. \' x (B n))" using assms(1) by(auto simp: decseq_Suc_iff AE_all_countable intro!: kernel_mono_AE[OF _ _ decseq_SucD[OF assms(2)]]) corollary kernel_01_AE: assumes "B \ sets Y" shows "AE x in \x. 0 \ \' x B \ \' x B \ 1" proof - have "{} \ B" "B \ space Y" using assms sets.sets_into_space by auto from kernel_empty0_AE kernel_Y1_AE kernel_mono_AE[OF _ _ this(1)] kernel_mono_AE[OF _ _ this(2)] assms show ?thesis by auto qed lemma kernel_get_0: "0 \ \' x B" by simp lemma kernel_le1_AE: assumes "B \ sets Y" shows "AE x in \x. \' x B \ 1" using kernel_01_AE[OF assms] by auto corollary kernel_n_infty: assumes "B \ sets Y" shows "AE x in \x. \' x B \ \" by(rule AE_mp[OF kernel_le1_AE[OF assms]],standard) (auto simp: neq_top_trans[OF ennreal_one_neq_top]) corollary kernel_le_infty: assumes "B \ sets Y" shows "AE x in \x. \' x B < \" using kernel_n_infty[OF assms] by (simp add: top.not_eq_extremum) lemma kernel_SUP_incseq: assumes "range B \ sets Y" "incseq B" shows "AE x in \x. \' x (\ (range B)) = (\n. \' x (B n))" proof - define Bn where "Bn \ (\n. if n = 0 then {} else B (n - 1))" have "incseq Bn" using assms(2) by(auto simp: Bn_def incseq_def) define Cn where "Cn \ (\n. Bn (Suc n) - Bn n)" have Cn_simp: "Cn 0 = B 0" "Cn (Suc n) = B (Suc n) - B n" for n by(simp_all add: Cn_def Bn_def) have Cn_sets:"Cn n \ sets Y" for n using assms(1) by(induction n) (auto simp: Cn_simp) have Cn_disj: "disjoint_family Cn" by(auto intro!: disjoint_family_Suc[OF ] incseq_SucD[OF \incseq Bn\] simp: Cn_def) have Cn_un: "(\kx. \n. (\i' x (Cn i)) = \' x (B n)" unfolding AE_all_countable using kernel_finite_sum_AE[OF disjoint_family_on_mono[OF _ Cn_disj],of "{.. (range B)) = (\ (range Cn))" (is "?lhs = ?rhs") proof safe fix n x assume "x \ B n" with Cn_un[of n] show "x \ \ (range Cn)" by blast next fix n x assume "x \ Cn n" then show "x \ \ (range B)" by(cases n,auto simp: Cn_simp) qed hence "AE x in \x. \' x (\ (range B)) = \' x (\ (range Cn))" by simp moreover have "AE x in \x. \' x (\ (range Cn)) = (\n. \' x (Cn n))" by(rule AE_symmetric[OF kernel_suminf_AE[OF Cn_disj]]) (use Cn_def Bn_def assms(1) in auto) moreover have "AE x in \x. (\n. \' x (Cn n)) = (\n. \i' x (Cn i))" by(auto simp: suminf_eq_SUP) moreover have "AE x in \x. (\n. \i' x (Cn i)) = (\n. \i' x (Cn i))" proof(intro AE_I2 antisym) fix x show "(\n. \i' x (Cn i)) \ (\n. \i' x (Cn i))" by(rule complete_lattice_class.Sup_mono, auto, use le_iff_add in blast) next fix x show "(\n. \i' x (Cn i)) \ (\n. \i' x (Cn i))" by(rule complete_lattice_class.Sup_mono) blast qed moreover have "AE x in \x. (\n. \i' x (Cn i)) = (\n. \' x (B n))" by(rule AE_mp[OF Cn_sum_Bn]) (standard+, auto) ultimately show ?thesis by auto qed lemma kernel_lim_incseq: assumes "range B \ sets Y" "incseq B" shows "AE x in \x. (\n. \' x (B n)) \ \' x (\ (range B))" by(rule AE_mp[OF AE_conjI[OF kernel_SUP_incseq[OF assms] kernel_incseq_AE[OF assms]]],auto simp: LIMSEQ_SUP) lemma kernel_INF_decseq: assumes "range B \ sets Y" "decseq B" shows "AE x in \x. \' x (\ (range B)) = (\n. \' x (B n))" proof - define C where "C \ (\k. space Y - B k)" have C:"range C \ sets Y" "incseq C" using assms by(auto simp: C_def decseq_def incseq_def) have eq1: "AE x in \x. 1 - \' x (\ (range B)) = \' x (\ (range C))" proof - have "AE x in \x. \' x (\ (range C)) + \' x (\ (range B)) - \' x (\ (range B)) = \' x (\ (range C))" using assms(1) kernel_n_infty[of "\ (range B)"] by auto moreover have "AE x in \x. \' x (\ (range C)) + \' x (\ (range B)) = 1" proof - have [simp]:"(\ (range C)) \ (\ (range B)) = space Y" "(\ (range C)) \ (\ (range B)) = {}" by(auto simp: C_def) (meson assms(1) range_subsetD sets.sets_into_space subsetD) from kernel_disjoint_sum_AE[OF _ _ this(2)] C(1) assms(1) kernel_Y1_AE show ?thesis by auto qed ultimately show ?thesis by auto qed have eq2: "AE x in \x. \' x (\ (range C)) = (\n. \' x (C n))" using kernel_SUP_incseq[OF C] by auto have eq3: "AE x in \x. (\n. \' x (C n)) = (\n. 1 - \' x (B n))" proof - have "AE x in \x. \n. \' x (C n) = 1 - \' x (B n)" unfolding AE_all_countable proof safe fix n have "AE x in \x. \' x (C n) + \' x (B n) - \' x (B n) = \' x (C n)" using assms(1) kernel_n_infty[of "B n"] by auto moreover have "AE x in \x. \' x (C n) + \' x (B n) = 1" proof - have [simp]: "C n \ B n = space Y" "C n \ B n = {}" by(auto simp: C_def) (meson assms(1) range_subsetD sets.sets_into_space subsetD) thus ?thesis using kernel_disjoint_sum_AE[of "C n" "B n"] C(1) assms(1) kernel_Y1_AE by fastforce qed ultimately show "AE x in \x. \' x (C n) = 1 - \' x (B n)" by auto qed thus ?thesis by auto qed have [simp]: "(\n. 1 - \' x (B n)) = 1 - (\n. \' x (B n))" for x by(auto simp: ennreal_INF_const_minus) have eq: "AE x in \x. 1 - \' x (\ (range B)) = 1 - (\n. \' x (B n))" using eq1 eq2 eq3 by auto have le1: "AE x in \x. (\n. \' x (B n)) \ 1" proof - have "AE x in \x. \n. \' x (B n) \ 1" using assms(1) by(auto intro!: kernel_le1_AE simp: AE_all_countable) thus ?thesis by (auto simp: INF_lower2) qed show ?thesis by(rule AE_mp[OF AE_conjI[OF AE_conjI[OF eq le1] kernel_le1_AE[of "\ (range B)"]]]) (insert assms(1),auto simp: ennreal_minus_cancel[OF ennreal_one_neq_top]) qed lemma kernel_lim_decseq: assumes "range B \ sets Y" "decseq B" shows "AE x in \x. (\n. \' x (B n)) \ \' x (\ (range B))" by(rule AE_mp[OF AE_conjI[OF kernel_INF_decseq[OF assms] kernel_decseq_AE[OF assms]]],standard,auto simp: LIMSEQ_INF) end +lemma qlim_eq_lim_mono_at_bot: + fixes g :: "rat \ 'a :: linorder_topology" + assumes "mono f" "(g \ a) at_bot" "\r::rat. f (real_of_rat r) = g r" + shows "(f \ a) at_bot" +proof - + have "mono g" + by(metis assms(1,3) mono_def of_rat_less_eq) + have ga:"\r. g r \ a" + proof(rule ccontr) + fix r + assume "\ a \ g r" + then have "g r < a" by simp + from order_topology_class.order_tendstoD(1)[OF assms(2) this] + obtain Q :: rat where q: "\q. q \ Q \ g r < g q" + by(auto simp: eventually_at_bot_linorder) + define q where "q \ min r Q" + show False + using q[of q] \mono g\ + by(auto simp: q_def mono_def) (meson linorder_not_less min.cobounded1) + qed + show ?thesis + proof(rule decreasing_tendsto) + show "\\<^sub>F n in at_bot. a \ f n" + unfolding eventually_at_bot_linorder + by(rule exI[where x=undefined],auto) (metis Ratreal_def assms(1,3) dual_order.trans ga less_eq_real_def lt_ex monoD of_rat_dense) (*metis assms(1) assms(3) ga less_eq_real_def lfp.leq_trans lt_ex monoD of_rat_dense*) + next + fix x + assume "a < x" + with topological_space_class.topological_tendstoD[OF assms(2),of "{..q. q \ Q \ g q < x" + by(auto simp: eventually_at_bot_linorder) + show "\\<^sub>F n in at_bot. f n < x" + using q assms(1,3) by(auto intro!: exI[where x="real_of_rat Q"] simp: eventually_at_bot_linorder) (metis dual_order.refl monoD order_le_less_trans) + qed +qed + +lemma qlim_eq_lim_mono_at_top: + fixes g :: "rat \ 'a :: linorder_topology" + assumes "mono f" "(g \ a) at_top" "\r::rat. f (real_of_rat r) = g r" + shows "(f \ a) at_top" +proof - + have "mono g" + by(metis assms(1,3) mono_def of_rat_less_eq) + have ga:"\r. g r \ a" + proof(rule ccontr) + fix r + assume "\ g r \ a" + then have "a < g r" by simp + from order_topology_class.order_tendstoD(2)[OF assms(2) this] + obtain Q :: rat where q: "\q. Q \ q \ g q < g r" + by(auto simp: eventually_at_top_linorder) + define q where "q \ max r Q" + show False + using q[of q] \mono g\ by(auto simp: q_def mono_def leD) + qed + show ?thesis + proof(rule increasing_tendsto) + show "\\<^sub>F n in at_top. f n \ a" + unfolding eventually_at_top_linorder + by(rule exI[where x=undefined],auto) (metis (no_types, opaque_lifting) assms(1) assms(3) dual_order.trans ga gt_ex monoD of_rat_dense order_le_less) + next + fix x + assume "x < a" + with topological_space_class.topological_tendstoD[OF assms(2),of "{x<..}"] + obtain Q :: rat where q: "\q. Q \ q \ x < g q" + by(auto simp: eventually_at_top_linorder) + show "\\<^sub>F n in at_top. x < f n" + using q assms(1,3) by(auto simp: eventually_at_top_linorder intro!: exI[where x="real_of_rat Q"]) (metis dual_order.refl monoD order_less_le_trans) + qed +qed + subsection \ Theorem 14.D.10. (Measure Disintegration Theorem) \ locale projection_sigma_finite_standard = projection_sigma_finite + standard_borel_ne Y begin theorem measure_disintegration: "\\. prob_kernel X Y \ \ measure_kernel.disintegration X Y \ \ \x \ (\\''. prob_kernel X Y \'' \ measure_kernel.disintegration X Y \'' \ \x \ (AE x in \x. \ x = \'' x))" proof - have *:"\\. prob_kernel X (borel :: real measure) \ \ measure_kernel.disintegration X borel \ \ (marginal_measure X borel \) \ (\\''. prob_kernel X borel \'' \ measure_kernel.disintegration X borel \'' \ (marginal_measure X borel \) \ (AE x in (marginal_measure X borel \). \ x = \'' x))" if nu_sets': "sets \ = sets (X \\<^sub>M borel)" and marginal_sigma_finite': "sigma_finite_measure (marginal_measure X borel \)" for X :: "'a measure" and \ proof - interpret r: projection_sigma_finite X borel \ using that by(auto simp: projection_sigma_finite_def) define \ :: "'a \ rat \ real" where "\ \ (\x r. enn2real (r.\' x {..real_of_rat r}))" have as1: "AE x in r.\x. \r s. r \ s \ \ x r \ \ x s" unfolding AE_all_countable proof(safe intro!: AE_impI) fix r s :: rat assume "r \ s" have "AE x in r.\x. r.\' x {..real_of_rat k} < top" for k using atMost_borel r.kernel_le_infty by blast from this[of s] r.kernel_mono_AE[of "{..real_of_rat r}" "{..real_of_rat s}"] \r \ s\ show "AE x in r.\x. \ x r \ \ x s" by(auto simp: \_def of_rat_less_eq enn2real_mono) qed have as2: "AE x in r.\x. \r. (\n. \ x (r + 1 / rat_of_nat (Suc n))) \ \ x r" unfolding AE_all_countable proof safe fix r have 1:"(\n. {..real_of_rat (r + 1 / rat_of_nat (Suc n))}) = {..real_of_rat r}" proof safe fix x assume h:" x \ (\n. {..real_of_rat (r + 1 / rat_of_nat (Suc n))})" show "x \ real_of_rat r" proof(rule ccontr) assume "\ x \ real_of_rat r" then have "0 < x - real_of_rat r" by simp then obtain n where "(1 / (real (Suc n))) < x - real_of_rat r" using nat_approx_posE by blast hence "real_of_rat (r + 1 / (1 + rat_of_nat n)) < x" by (simp add: of_rat_add of_rat_divide) with h show False using linorder_not_le by fastforce qed next fix x n assume "x \ real_of_rat r" then show " x \ real_of_rat (r + 1 / rat_of_nat (Suc n))" by (metis le_add_same_cancel1 of_nat_0_le_iff of_rat_less_eq order_trans zero_le_divide_1_iff) qed have "AE x in r.\x. (\n. r.\' x {..real_of_rat (r + 1 / rat_of_nat (Suc n))}) \ r.\' x {..real_of_rat r}" unfolding 1[symmetric] by(rule r.kernel_lim_decseq) (auto simp: decseq_Suc_iff of_rat_less_eq frac_le) - from AE_conjI[OF r.kernel_le_infty[of "{..real_of_rat r}",simplified] this] tendsto_enn2real + from AE_conjI[OF r.kernel_le_infty[of "{..real_of_rat r}",simplified] this] show "AE x in r.\x. (\n. \ x (r + 1 / (rat_of_nat (Suc n)))) \ \ x r" - by(auto simp: \_def) + unfolding \_def by eventually_elim (rule tendsto_enn2real, auto) qed have as3: "AE x in r.\x. (\ x \ 0) at_bot" proof - have 0: "range (\n. {..- real n}) \ sets borel" "decseq (\n. {..- real n})" by(auto simp: decseq_def) show ?thesis proof(safe intro!: AE_I2[THEN AE_mp[OF AE_conjI[OF r.kernel_empty0_AE AE_conjI[OF r.kernel_lim_decseq[OF 0] as1]]]]) fix x assume h: "r.\' x {} = 0" " (\n. r.\' x {..- real n}) \ r.\' x (\n. {..- real n})" "\r s. r \ s \ \ x r \ \ x s" have [simp]: "(\n. {..- real n}) = {}" by auto (meson le_minus_iff linorder_not_less reals_Archimedean2) show "(\ x \ 0) at_bot" proof(rule decreasing_tendsto) fix r :: real assume "0 < r" with h(2) eventually_sequentially obtain N where N:"\n. n \ N \ r.\' x {..- real n} < r" by(fastforce simp: order_tendsto_iff h(1)) show "\\<^sub>F q in at_bot. \ x q < r" unfolding eventually_at_bot_linorder proof(safe intro!: exI[where x="- rat_of_nat N"]) fix q assume "q \ - rat_of_nat N" with h(3) have "\ x q \ \ x (- rat_of_nat N)" by simp also have "... < r" by(auto simp: \_def) (metis N[OF order_refl] \0 < r\ enn2real_less_iff enn2real_top of_rat_minus of_rat_of_nat_eq top.not_eq_extremum) finally show "\ x q < r" . qed qed(simp add: \_def) qed qed have as4: "AE x in r.\x. (\ x \ 1) at_top" proof - have 0: "range (\n. {..real n}) \ sets borel" "incseq (\n. {..real n})" by(auto simp: incseq_def) have [simp]: "(\n. {..real n}) = UNIV" by (auto simp: real_arch_simple) have 1: "AE x in r.\x. \n. r.\' x {..real n} \ 1" "AE x in r.\x. \q. r.\' x {..real_of_rat q} \ 1" by(auto simp: AE_all_countable intro!: r.kernel_le1_AE) show ?thesis proof(safe intro!: AE_I2[THEN AE_mp[OF AE_conjI[OF AE_conjI[OF 1] AE_conjI[OF r.kernel_Y1_AE AE_conjI[OF r.kernel_lim_incseq[OF 0] as1]]],simplified]]) fix x assume h: "\q. r.\' x {..real_of_rat q} \ 1" "\n. r.\' x {..real n} \ 1" "(\n. r.\' x {..real n}) \ r.\' x UNIV" "\r s. r \ s \ \ x r \ \ x s" "r.\' x UNIV = 1" then have h3: "(\n. r.\' x {..real n}) \ 1" by auto show "(\ x \ 1) at_top" proof(rule increasing_tendsto) fix r :: real assume "r < 1" with h3 eventually_sequentially obtain N where N: "\n. n \ N \ r < r.\' x {..real n}" by(fastforce simp: order_tendsto_iff) show "\\<^sub>F n in at_top. r < \ x n" unfolding eventually_at_top_linorder proof(safe intro!: exI[where x="rat_of_nat N"]) fix q assume "rat_of_nat N \ q" have "r < \ x (rat_of_nat N)" by(auto simp: \_def) (metis N[OF order_refl] h(2) enn2real_1 enn2real_ennreal enn2real_positive_iff ennreal_cases ennreal_leI linorder_not_less zero_less_one) also have "... \ \ x q" using h(4) \rat_of_nat N \ q\ by simp finally show "r < \ x q" . qed qed(use h(1) enn2real_leI \_def in auto) qed qed from AE_E3[OF AE_conjI[OF as1 AE_conjI[OF as2 AE_conjI[OF as3 as4]]],simplified space_marginal_measure] obtain N where N: "N \ null_sets r.\x" "\x r s. x \ space X - N \ r \ s \ \ x r \ \ x s" "\x r. x \ space X - N \ (\n. \ x (r + 1 / rat_of_nat (Suc n))) \ \ x r" "\x. x \ space X - N \ (\ x \ 0) at_bot" "\x. x \ space X - N \ (\ x \ 1) at_top" by metis define F where "F \ (\x y. indicat_real (space X - N) x * Inf {\ x r |r. y \ real_of_rat r} + indicat_real N x * indicat_real {0..} y)" have [simp]: "{\ x r |r. y \ real_of_rat r} \ {}" for x y by auto (meson gt_ex less_eq_real_def of_rat_dense) have [simp]: "bdd_below {\ x r |r. y \ real_of_rat r}" if "x \ space X - N" for x y proof - obtain r' where "real_of_rat r' \ y" by (metis less_eq_real_def lt_ex of_rat_dense) from order_trans[OF this] of_rat_less_eq show ?thesis by(auto intro!: bdd_belowI[of _ "\ x r'"] N(2)[OF that]) qed have Feq: "F x (real_of_rat r) = \ x r" if "x \ space X - N" for x r using that N(2)[OF that] by(auto intro!: cInf_eq_minimum simp: of_rat_less_eq F_def) have Fmono: "mono (F x)" if "x \ space X" for x by(auto simp: F_def mono_def indicator_def intro!: cInf_superset_mono) (meson gt_ex less_eq_real_def of_rat_dense) have F1: "(F x \ 0) at_bot" if "x \ space X" for x proof(cases "x \ N") case True with that show ?thesis by(auto simp: F_def tendsto_iff eventually_at_bot_dense indicator_def intro!: exI[where x=0]) next case False with qlim_eq_lim_mono_at_bot[OF Fmono[OF that] N(4)] Feq that show ?thesis by auto qed have F2: "(F x \ 1) at_top" if "x \ space X" for x proof(cases "x \ N") case True with that show ?thesis by(auto simp: F_def tendsto_iff eventually_at_top_dense indicator_def intro!: exI[where x=0]) next case False with qlim_eq_lim_mono_at_top[OF Fmono[OF that] N(5)] Feq that show ?thesis by auto qed have F3: "continuous (at_right a) (F x)" if "x \ space X" for x a proof(cases "x \ N") case x:True { fix e :: real assume e:"0 < e" consider "a \ 0" | "a < 0" by fastforce then have "\d>0. indicat_real {0..} (a + d) - indicat_real {0..} a < e" proof cases case 1 with e show ?thesis by(auto intro!: exI[where x=1]) next case 2 then obtain b where "b > 0" "a + b < 0" by (metis add_less_same_cancel2 of_rat_dense real_add_less_0_iff) with e 2 show ?thesis by(auto intro!: exI[where x=b]) qed } with x show ?thesis unfolding continuous_at_right_real_increasing[of "F x",OF monoD[OF Fmono[OF that]],simplified] by(auto simp: F_def) next case x:False { fix e :: real assume e: "e > 0" have "\k. a \ real_of_rat k \ \ {\ x r |r. a \ real_of_rat r} + e / 2 \ \ x k" proof(rule ccontr) assume "\k. a \ real_of_rat k \ \ x k \ \ {\ x r |r. a \ real_of_rat r} + e / 2" then have cont: "\k. a \ real_of_rat k \ \ x k - e / 2 > \ {\ x r |r. a \ real_of_rat r}" by auto hence "a \ real_of_rat k \ \r. a \ real_of_rat r \ \ x r < \ x k - e / 2" for k using cont \x \ space X\ x cInf_less_iff [of "{\ x r |r. a \ real_of_rat r}" "\ x k - e / 2"] by auto then obtain r where r:"\k. a \ real_of_rat k \ a \ real_of_rat (r k)" "\k. a \ real_of_rat k \ \ x (r k) < \ x k - e / 2" by metis obtain k where k:"a \ real_of_rat k" by (meson gt_ex less_eq_real_def of_rat_dense) define f where "f \ rec_nat k (\n fn. r fn)" have f_simp: "f 0 = k" "f (Suc n) = r (f n)" for n by(auto simp: f_def) have f1: "a \ real_of_rat (f n)" for n using r(1) k by(induction n) (auto simp: f_simp) have f2: "n \ 1 \ \ x (f n) < \ x k - real n * e / 2" for n proof(induction n) case ih:(Suc n) consider "n = 0" | "n \ 1" by fastforce then show ?case proof cases case 1 with r k show ?thesis by(simp add: f_simp) next case 2 show ?thesis using less_trans[OF r(2)[OF f1[of n]] diff_strict_right_mono[OF ih(1)[OF 2],of "e / 2"]] by(auto simp: f_simp ring_distribs(2) add_divide_distrib) qed qed simp have "\ bdd_below {\ x r |r. a \ real_of_rat r}" unfolding bdd_below_def proof safe fix M obtain n where "\ x k - M < real n * e / 2" using f2 e reals_Archimedean3 by fastforce then have "\ x k - M < real (Suc n) * e / 2" using divide_strict_right_mono pos_divide_less_eq e by fastforce thus "Ball {\ x r |r. a \ real_of_rat r} ((\) M) \ False" using f2[of "Suc n"] f1[of "Suc n"] by(auto intro!: exI[where x="\ x (f (Suc n))"]) qed with that x show False by simp qed then obtain k where k: "a \ real_of_rat k" "\ {\ x r |r. a \ real_of_rat r} + e / 2 \ \ x k" by auto obtain no where no:"\n. n\no \ (\ x (k + 1 / rat_of_nat (Suc n))) - (\ x k) < e / 2" using \x \ space X\ x metric_LIMSEQ_D[OF N(3)[of x k],of "e/2"] e N(2)[of x k "k + 1 / rat_of_nat (Suc _)"] by(auto simp: dist_real_def) have "\d>0. \ {\ x r |r. a + d \ real_of_rat r} - \ {\ x r |r. a \ real_of_rat r} < e" proof(safe intro!: exI[where x="real_of_rat (1 / rat_of_nat (Suc no))"]) have "\ x (k + 1 / rat_of_nat (Suc no)) - e < \ x k - e / 2" using no[OF order_refl] by simp also have "... \ \ {\ x r |r. a \ real_of_rat r}" using k by simp finally have "\ x (k + 1 / rat_of_nat (Suc no)) - \ {\ x r |r. a \ real_of_rat r} < e" by simp moreover have "\ {\ x r |r. a + real_of_rat (1 / (1 + rat_of_nat no)) \ real_of_rat r} \ \ x (k + 1 / rat_of_nat (Suc no))" using k that x by(auto intro!: cInf_lower simp: of_rat_add) ultimately show "\ {\ x r |r. a + real_of_rat (1 / (rat_of_nat (Suc no))) \ real_of_rat r} - \ {\ x r |r. a \ real_of_rat r} < e" by simp qed simp } with that x show ?thesis unfolding continuous_at_right_real_increasing[of "F x",OF monoD[OF Fmono[OF that]],simplified] by(auto simp: F_def) qed define \ where "\ \ (\x. interval_measure (F x))" have \: "\x. x \ space X \ \ x UNIV = 1" "\x r. x \ space X \ \ x {..r} = ennreal (F x r)" and[simp]: "\x. sets (\ x) = sets borel" "\x. space (\ x) = UNIV" using emeasure_interval_measure_Iic[OF _ F3 F1] interval_measure_UNIV[OF _ F3 F1 F2] Fmono by(auto simp: mono_def \_def) interpret \: prob_kernel X borel \ unfolding prob_kernel_def' proof(rule measurable_prob_algebra_generated[OF _ atMostq_Int_stable,of _ UNIV]) show "\a. a \ space X \ prob_space (\ a)" by(auto intro!: prob_spaceI \(1)) next fix A assume "A \ {{..r} |r::real. r \ \}" then obtain r where r: "A = {..real_of_rat r}" using Rats_cases by blast have "(\x. ennreal (indicat_real (space X - N) x * \ x r + indicat_real N x * indicat_real {0..} (real_of_rat r))) \ borel_measurable X" proof - have "N \ sets X" using null_setsD2[OF N(1)] by(auto simp: sets_marginal_measure) thus ?thesis by(auto simp: \_def) qed moreover have "indicat_real (space X - N) x * \ x r + indicat_real N x * indicat_real {0..} (real_of_rat r) = emeasure (\ x) A" if "x \ space X" for x using Feq[of x r] \(2)[OF that,of "real_of_rat r"] by(cases "x \ N") (auto simp: r indicator_def F_def) ultimately show " (\x. emeasure (\ x) A) \ borel_measurable X" using measurable_cong[of _ "\x. emeasure (\ x) A" "\x. ennreal (indicat_real (space X - N) x * \ x r + indicat_real N x * indicat_real {0..} (real_of_rat r))"] by simp qed(auto simp: rborel_eq_atMostq) have \_AE:"AE x in r.\x. \ x {..real_of_rat r} = r.\' x {..real_of_rat r}" for r proof - have "AE x in r.\x. \ x {..real_of_rat r} = ennreal (F x (real_of_rat r))" by(auto simp: space_marginal_measure \(2)) moreover have "AE x in r.\x. ennreal (F x (real_of_rat r))= ennreal (\ x r)" using Feq[of _ r] by(auto simp add: space_marginal_measure intro!: AE_I''[OF N(1)]) moreover have "AE x in r.\x. ennreal (\ x r) = ennreal (enn2real (r.\' x {..real_of_rat r}))" by(simp add: \_def) moreover have "AE x in r.\x. ennreal (enn2real (r.\' x {..real_of_rat r})) = r.\' x {..real_of_rat r}" using r.kernel_le_infty[of "{..real_of_rat r}",simplified] by(auto simp: ennreal_enn2real_if) ultimately show ?thesis by auto qed have \_dis: "\.disintegration \ r.\x" proof - interpret D: Dynkin_system UNIV "{B \ sets borel. \A\ sets X. \ (A \ B) = (\\<^sup>+x\A. (\ x) B\r.\x)}" proof { fix A assume h:"A\ sets X" then have "\ (A \ UNIV) = (\\<^sup>+x\A. 1 \r.\x)" using emeasure_marginal_measure[OF nu_sets' h] sets_marginal_measure[of X borel \ "space borel"] by auto also have "... = (\\<^sup>+x\A. (\ x) UNIV\r.\x)" by(auto intro!: nn_integral_cong simp: \ space_marginal_measure) finally have "\ (A \ UNIV) = (\\<^sup>+x\A. emeasure (\ x) UNIV\r.\x)" . } thus "UNIV \ {B \ sets borel. \A\sets X. emeasure \ (A \ B) = \\<^sup>+x\A. emeasure (\ x) B\r.\x}" by auto hence univ:"\A. A \ sets X \ \ (A \ UNIV) = (\\<^sup>+x\A. emeasure (\ x) UNIV\r.\x)" by auto show "\B. B \ {B \ sets borel. \A\sets X. emeasure \ (A \ B) = \\<^sup>+x\A. emeasure (\ x) B\r.\x} \ UNIV - B \ {B \ sets borel. \A\sets X. emeasure \ (A \ B) = \\<^sup>+x\A. emeasure (\ x) B\r.\x}" proof(rule r.\x.sigma_finite_disjoint) fix B and J :: "nat \ _" assume "B \ {B \ sets borel. \A\sets X. emeasure \ (A \ B) = (\\<^sup>+x\A. emeasure (\ x) B \r.\x)}" "range J \ sets r.\x" "\ (range J) = space r.\x" "(\i. emeasure r.\x (J i) \ \)" "disjoint_family J" then have B: "B \ sets borel" " \A\sets X. \ (A \ B) = (\\<^sup>+x\A. (\ x) B\r.\x)" and J: "range J \ sets X" "\ (range J) = space X" "\i. emeasure r.\x (J i) \ \" "disjoint_family J" by (auto simp: sets_marginal_measure space_marginal_measure) { fix A assume A: "A \ sets X" have "\ (A \ (UNIV - B)) = (\\<^sup>+x\A. (\ x) (UNIV - B)\r.\x)" (is "?lhs = ?rhs") proof - have AJi1: "disjoint_family (\i. (A \ J i) \ (UNIV - B))" using B(1) J(4) by(fastforce simp: disjoint_family_on_def) have AJi2[simp]: "(\i. ((A \ J i) \ (UNIV - B))) = A \ (UNIV - B)" using J(2) sets.sets_into_space[OF A] by blast have AJi3: "(range (\i. (A \ J i) \ (UNIV - B))) \ sets \" using B(1) J(1) A by(auto simp: nu_sets') have "?lhs = (\i. \ ((A \ J i) \ (UNIV - B)))" by(simp add: suminf_emeasure[OF AJi3 AJi1]) also have "... = (\i. (\\<^sup>+x\ A \ J i. (\ x) (UNIV - B) \r.\x))" proof(safe intro!: suminf_cong) fix n have Jn: "J n \ sets X" using J by auto have fin: "\ ((A \ J n) \ C) \ \" for C proof(cases "(A \ J n) \ C \ sets \") case True then have "\ ((A \ J n) \ C) \ \ ((A \ J n) \ UNIV)" using Jn nu_sets' A by(intro emeasure_mono) auto also have "\ ((A \ J n) \ UNIV) \ \ (J n \ UNIV)" using Jn nu_sets' by(intro emeasure_mono) auto also have "... = r.\x (J n)" using emeasure_marginal_measure[OF nu_sets' Jn] by simp finally show ?thesis by (metis J(3)[of n] infinity_ennreal_def neq_top_trans) qed(simp add: emeasure_notin_sets) show "\ ((A \ J n) \ (UNIV - B)) = (\\<^sup>+x\ A \ J n. (\ x) (UNIV - B) \r.\x)" (is "?lhs = ?rhs") proof - have "?lhs = \ ((A \ J n) \ UNIV) - \ ((A \ J n) \ B)" proof - have [simp]: "?lhs + \ ((A \ J n) \ B) = \ ((A \ J n) \ UNIV)" proof - have [simp]:"((A \ J n) \ (UNIV - B)) \ ((A \ J n) \ B) = ((A \ J n) \ UNIV)" by blast show ?thesis using B(1) A Jn nu_sets' by(intro plus_emeasure[of "(A \ J n) \ (UNIV - B)" _ "(A \ J n) \ B",simplified]) auto qed have "?lhs = ?lhs + \ ((A \ J n) \ B) - \ ((A \ J n) \ B)" by(simp only: ennreal_add_diff_cancel[OF fin[of B]]) also have "... = \ ((A \ J n) \ UNIV) - \ ((A \ J n) \ B)" by simp finally show ?thesis . qed also have "... = (\\<^sup>+x\ A \ J n. (\ x) UNIV \r.\x) - (\\<^sup>+x\ A \ J n. (\ x) B \r.\x)" using B(2) A Jn univ by auto also have "... = (\\<^sup>+x. ((\ x) UNIV * indicator (A \ J n) x - (\ x) B * indicator (A \ J n) x) \r.\x)" proof(rule nn_integral_diff[symmetric]) show "(\x. (\ x) UNIV * indicator (A \ J n) x) \ borel_measurable r.\x" "(\x. (\ x) B * indicator (A \ J n) x) \ borel_measurable r.\x" using sets_marginal_measure[of X borel \ "space borel"] \.emeasure_measurable[OF B(1)] \.emeasure_measurable[of UNIV] A Jn by(auto simp del: space_borel) next show "\\<^sup>+x\A \ J n. (\ x) B\r.\x \ \" using B(2) A Jn univ fin[of B] by auto next show "AE x in r.\x. (\ x) B * indicator (A \ J n) x \ (\ x) UNIV * indicator (A \ J n) x" by(standard, auto simp: space_marginal_measure indicator_def intro!: emeasure_mono) qed also have "... = (\\<^sup>+x\ A \ J n. ((\ x) UNIV - (\ x) B) \r.\x)" by(auto intro!: nn_integral_cong simp: indicator_def) also have "... = ?rhs" proof(safe intro!: nn_integral_cong) fix x assume "x \ space r.\x" then have "x \ space X" by(simp add: space_marginal_measure) show "((\ x) UNIV - (\ x) B) * indicator (A \ J n) x = (\ x) (UNIV - B) * indicator (A \ J n) x" by(auto intro!: emeasure_compl[of B "\ x",simplified,symmetric] simp: B \.prob_spaces \x \ space X\ prob_space_imp_subprob_space subprob_space.emeasure_subprob_space_less_top indicator_def) qed finally show ?thesis . qed qed also have "... = (\\<^sup>+x. (\i. (\ x) (UNIV - B) * indicator (A \ J i) x)\r.\x)" using \.emeasure_measurable[of "UNIV - B"] B(1) sets_marginal_measure[of X borel \ "space borel"] A J by(intro nn_integral_suminf[symmetric]) (auto simp del: space_borel) also have "... = (\\<^sup>+x. (\ x) (UNIV - B) * indicator A x * (\i. indicator (A \ J i) x) \r.\x)" by(auto simp: indicator_def intro!: nn_integral_cong) also have "... = (\\<^sup>+x. (\ x) (UNIV - B) * indicator A x * (indicator (\i. A \ J i) x) \r.\x)" proof - have "(\i. indicator (A \ J i) x) = (indicator (\i. A \ J i) x :: ennreal)" for x using J(4) by(intro suminf_indicator) (auto simp: disjoint_family_on_def) thus ?thesis by(auto intro!: nn_integral_cong) qed also have "... = ?rhs" using J(2) by(auto simp: indicator_def space_marginal_measure intro!: nn_integral_cong) finally show ?thesis . qed } thus "UNIV - B \ {B \ sets borel. \A\sets X. emeasure \ (A \ B) = (\\<^sup>+x\A. emeasure (\ x) B \r.\x)}" using B by auto qed next fix J :: "nat \ _" assume J1: "disjoint_family J" "range J \ {B \ sets borel. \A\sets X. \ (A \ B) = \\<^sup>+x\A. (\ x) B\r.\x}" then have J2: "range J \ sets borel" "\ (range J) \ sets borel" "\n A. A \ sets X \ \ (A \ (J n)) = (\\<^sup>+x\A. (\ x) (J n) \r.\x)" by auto show "\ (range J) \ {B \ sets borel. \A\sets X. \ (A \ B) = \\<^sup>+x\A. (\ x) B\r.\x}" proof - { fix A assume A:"A \ sets X" have "\ (A \ \ (range J)) = (\\<^sup>+x\A. (\ x) (\ (range J)) \r.\x)" (is "?lhs = ?rhs") proof - have "?lhs = \ (\n. A \ J n)" proof - have "(A \ \ (range J)) = (\n. A \ J n)" by blast thus ?thesis by simp qed also have "... = (\n. \ (A \ J n))" using J1(1) J2(1) A nu_sets' by(fastforce intro!: suminf_emeasure[symmetric] simp: disjoint_family_on_def) also have "... = (\n. (\\<^sup>+x\A. (\ x) (J n) \r.\x))" by(simp add: J2(3)[OF A]) also have "... = (\\<^sup>+x. (\n. (\ x) (J n) * indicator A x) \r.\x)" using \.emeasure_measurable J2(1) A sets_marginal_measure[of X borel \ "space borel"] by(intro nn_integral_suminf[symmetric]) auto also have "... = (\\<^sup>+x\A. (\n. (\ x) (J n)) \r.\x)" by auto also have "... = (\\<^sup>+x\A. (\ x) (\ (range J)) \r.\x)" using J1 J2 by(auto intro!: nn_integral_cong suminf_emeasure simp: space_marginal_measure indicator_def) finally show ?thesis . qed } thus ?thesis using J2(2) by auto qed qed auto have "{ {..r} | r::real. r \ \} \ {B \ sets borel. \A\ sets X. \ (A \ B) = (\\<^sup>+x\A. (\ x) B\r.\x)}" proof - { fix r ::real and A assume h: "r \ \" "A \ sets X" then obtain r' where r':"r = real_of_rat r'" using Rats_cases by blast have "\ (A \ {..r}) = (\\<^sup>+x\A. (\ x) {..r} \r.\x)" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+x\A. r.\' x {..r}\r.\x)" using h by(simp add: r.kernel_RN_deriv) also have "... = ?rhs" using \_AE[of r'] by(auto intro!: nn_integral_cong_AE simp: r' simp del: space_borel) finally show ?thesis . qed } thus ?thesis by auto qed from D.Dynkin_subset[OF this] rborel_eq_atMostq[symmetric] show ?thesis by(auto simp: \.disintegration_def sets_marginal_measure nu_sets' sigma_eq_Dynkin[OF _ atMostq_Int_stable,of UNIV,simplified,symmetric] rborel_eq_atMostq_sets simp del: space_borel) qed show ?thesis proof(intro exI conjI strip) fix \'' assume "prob_kernel X (borel :: real measure) \''" interpret \'': prob_kernel X borel \'' by fact assume disi: "\''.disintegration \ r.\x" have eq_atMostr_AE:"AE x in r.\x. \r. \ x {..real_of_rat r} = \'' x {..real_of_rat r}" unfolding AE_all_countable proof safe fix r have "AE x in r.\x. (\'' x) {..real_of_rat r} = r.\' x {..real_of_rat r}" proof(safe intro!: r.\x.RN_deriv_unique[of "\x. \'' x {..real_of_rat r}" "marginal_measure_on X borel \ {..real_of_rat r}",simplified r.\'_def[of _ "{..real_of_rat r}",symmetric]]) show 1:"(\x. emeasure (\'' x) {..real_of_rat r}) \ borel_measurable r.\x" using \''.emeasure_measurable[of "{..real_of_rat r}"] sets_marginal_measure[of X borel \ "space borel"] by simp show "density r.\x (\x. emeasure (\'' x) {..real_of_rat r}) = marginal_measure_on X borel \ {..real_of_rat r}" proof(rule measure_eqI) fix A assume "A \ sets (density r.\x (\x. (\'' x) {..real_of_rat r}))" then have A [measurable]:"A \ sets X" by(simp add: sets_marginal_measure) show "emeasure (density r.\x (\x. emeasure (\'' x) {..real_of_rat r})) A = emeasure (marginal_measure_on X borel \ {..real_of_rat r}) A" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+x\A. (\'' x) {..real_of_rat r} \r.\x)" using emeasure_density[OF 1,of A] A by(simp add: sets_marginal_measure) also have "... = \ (A \ {..real_of_rat r})" using disi A by(auto simp: \''.disintegration_def) also have "... = ?rhs" by(simp add: emeasure_marginal_measure_on[OF nu_sets' _ A]) finally show ?thesis . qed qed(simp add: sets_marginal_measure) qed with \_AE[of r] show "AE x in r.\x. \ x {..real_of_rat r} = \'' x {..real_of_rat r}" by auto qed { fix x assume h:"x \ space r.\x" " \r. (\ x) {..real_of_rat r} = (\'' x) {..real_of_rat r}" then have x: "x \ space X" by(simp add: space_marginal_measure) have "\ x = \'' x" proof(rule measure_eqI_generator_eq[OF atMostq_Int_stable,of UNIV _ _ "\n. {..real n}"]) show "\A. A \ {{..r} |r. r \ \} \ (\ x) A = (\'' x) A" using h(2) Rats_cases by auto next show "(\n. {..real n}) = UNIV" by (simp add: real_arch_simple subsetI subset_antisym) next fix n have "(\ x) {..real n} \ \ x UNIV" by(auto intro!: emeasure_mono) also have "... = 1" by(rule \(1)[OF x]) finally show "(\ x) {..real n} \ \" using linorder_not_le by fastforce next show "range (\n. {..real n}) \ {{..r} |r. r \ \}" using Rats_of_nat by blast qed(auto simp: \.kernel_sets[OF x] \''.kernel_sets[OF x] rborel_eq_atMostq_sets) } then show "AE x in r.\x. \ x = \'' x" using eq_atMostr_AE by fastforce qed(auto simp del: space_borel simp add: \_dis \.prob_kernel_axioms) qed show ?thesis proof - define \' where "\' = distr \ (X \\<^sub>M borel) (\(x,y). (x, to_real y))" have \_distr:"\ = distr \' (X \\<^sub>M Y) (\(x,y). (x, from_real y))" using nu_sets sets_eq_imp_space_eq[OF nu_sets] from_real_to_real by(auto simp: \'_def distr_distr space_pair_measure intro!: distr_id'[symmetric]) have \x_eq:"(marginal_measure X borel \') = \x" using emeasure_marginal_measure[of \' X borel] emeasure_marginal_measure[OF nu_sets] sets_eq_imp_space_eq[OF nu_sets] by(auto intro!: measure_eqI simp: sets_marginal_measure \'_def emeasure_distr map_prod_vimage[of id to_real,simplified map_prod_def id_def] space_pair_measure Times_Int_Times) interpret \' : projection_sigma_finite X borel \' by(auto simp: projection_sigma_finite_def \x_eq \x.sigma_finite_measure_axioms simp del: space_borel,auto simp add: \'_def) obtain \' where \': "prob_kernel X borel \'" "measure_kernel.disintegration X borel \' \' \'.\x" "\\''. prob_kernel X borel \'' \ measure_kernel.disintegration X borel \'' \' \'.\x \ (AE x in \'.\x. \' x = \'' x)" using *[of \' X] \'.nu_sets \'.\x.sigma_finite_measure_axioms by blast interpret \': prob_kernel X borel \' by fact define \ where "\ \ (\x. distr (\' x) Y from_real)" interpret \: prob_kernel X Y \ by(auto simp: prob_kernel_def' \_def) have disi: "\.disintegration \ \x" proof(rule \.disintegrationI) fix A B assume A[measurable]:"A \ sets X" and B[measurable]: "B \ sets Y" have [measurable]: "from_real -` B \ sets borel" by(simp add: measurable_sets_borel[OF _ B]) show "\ (A \ B) = (\\<^sup>+x\A. \ x B\\x)" (is "?lhs = ?rhs") proof - have "?lhs = \' (A \ (from_real -` B))" by(auto simp: \_distr emeasure_distr map_prod_vimage[of id from_real,simplified map_prod_def id_def]) also have "... = (\\<^sup>+x\A. \' x (from_real -` B) \\x)" using \'.disintegrationD[OF \'(2),of A "from_real -` B"] by(auto simp add: \x_eq simp del: space_borel) also have "... = ?rhs" by(auto intro!: nn_integral_cong simp: space_marginal_measure \_def emeasure_distr) finally show ?thesis . qed qed(simp_all add: sets_marginal_measure nu_sets) show ?thesis proof(safe intro!: exI[where x=\]) fix \'' assume h:"prob_kernel X Y \''" "measure_kernel.disintegration X Y \'' \ \x" interpret \'': prob_kernel X Y \'' by fact show "AE x in \x. \ x = \'' x" proof - define \''' where "\''' \ (\x. distr (\'' x) borel to_real)" interpret \''': prob_kernel X borel \''' by(auto simp: prob_kernel_def' \'''_def) have \''_def: "\'' x = distr (\''' x) Y from_real" if "x \ space X" for x using distr_distr[of from_real borel Y to_real "\'' x",simplified measurable_cong_sets[OF \''.kernel_sets[OF that] refl,of borel]] by(auto simp: \'''_def comp_def \''.kernel_sets[OF that] measurable_cong_sets[OF \''.kernel_sets[OF that] \''.kernel_sets[OF that]] sets_eq_imp_space_eq[OF \''.kernel_sets[OF that]] intro!: distr_id'[symmetric]) have \'''_disi: "\'''.disintegration \' \'.\x" proof(rule \'''.disintegrationI) fix A and B :: "real set" assume A[measurable]:"A \ sets X" and B[measurable]:"B \ sets borel" show "\' (A \ B) = (\\<^sup>+x\A. (\''' x) B \\'.\x)" (is "?lhs = ?rhs") proof - have "?lhs = \ (A \ (to_real -` B \ space Y))" by(auto simp: \'_def emeasure_distr map_prod_vimage[of id to_real,simplified map_prod_def id_def] sets_eq_imp_space_eq[OF nu_sets] space_pair_measure Times_Int_Times) also have "... = (\\<^sup>+x\A. (\'' x) (to_real -` B \ space Y) \\x)" using \''.disintegrationD[OF h(2) A,of "to_real -` B \ space Y"] by auto also have "... = ?rhs" by(auto simp: \x_eq[symmetric] space_marginal_measure \'''_def emeasure_distr sets_eq_imp_space_eq[OF \''.kernel_sets] intro!: nn_integral_cong) finally show ?thesis . qed qed(auto simp: \'_def sets_marginal_measure) show ?thesis by(rule AE_mp[OF \'(3)[OF \'''.prob_kernel_axioms \'''_disi,simplified \x_eq]],standard) (auto simp: space_marginal_measure \''_def \_def) qed qed(simp_all add: disi \.prob_kernel_axioms) qed qed end subsection \ Lemma 14.D.12. \ lemma ex_finite_density_measure: fixes A :: "nat \ _" assumes A: "range A \ sets M" "\ (range A) = space M" "\i. emeasure M (A i) \ \" "disjoint_family A" defines "h \ (\x. (\n. (1/2)^(Suc n) * (1 / (1 + M (A n))) * indicator (A n) x))" shows "h \ borel_measurable M" "\x. x \ space M \ 0 < h x" "\x. x \ space M \ h x < 1" "finite_measure (density M h)" proof - have less1:"0 < 1 / (1 + M (A n))" "1 / (1 + M (A n)) \ 1" for n using A(3)[of n] ennreal_zero_less_divide[of 1 "1 + M (A n)"] by (auto intro!: divide_le_posI_ennreal simp: add_pos_nonneg) show [measurable]:"h \ borel_measurable M" using A by(simp add: h_def) { fix x assume x:"x \ space M" then obtain i where i: "x \ A i" using A(2) by auto show "0 < h x" using A(3)[of i] less1[of i] by(auto simp: h_def suminf_pos_iff i ennreal_divide_times ennreal_zero_less_divide power_divide_distrib_ennreal power_less_top_ennreal intro!: exI[where x=i]) have "h x = (\n. (1/2)^(Suc n + 2) * (1 / (1 + M (A (n + 2)))) * indicator (A (n + 2)) x) + (1/2) * (1 / (1 + M (A 0))) * indicator (A 0) x + (1/2)^2 * (1 / (1 + M (A 1))) * indicator (A 1) x" by(auto simp: h_def suminf_split_head suminf_offset[of "\n. (1/2)^(Suc n) * (1 / (1 + M (A n))) * indicator (A n) x" 2] simp del: power_Suc sum_mult_indicator) (auto simp: numeral_2_eq_2) also have "... \ 1/4 + (1/2) * (1 / (1 + M (A 0))) * indicator (A 0) x + (1/2)^2 * (1 / (1 + M (A 1))) * indicator (A 1) x" proof - have "(\n. (1/2)^(Suc n + 2) * (1 / (1 + M (A (n + 2)))) * indicator (A (n + 2)) x) \ (\n. (1/2)^(Suc n + 2))" using less1(2)[of "Suc (Suc _)"] by(intro suminf_le,auto simp: indicator_def) (metis mult.right_neutral mult_left_mono zero_le) also have "... = (\n. ennreal ((1 / 2) ^ (Suc n + 2)))" by(simp only: ennreal_power[of "1/2",symmetric]) (metis divide_ennreal ennreal_1 ennreal_numeral linorder_not_le not_one_less_zero zero_less_numeral) also have "... = ennreal (\n. (1 / 2) ^ (Suc n + 2))" by(rule suminf_ennreal2) auto also have "... = ennreal (1/4)" using nsum_of_r'[of "1/2" "Suc (Suc (Suc 0))" 1] by auto also have "... = 1 / 4" by (metis ennreal_divide_numeral ennreal_numeral numeral_One zero_less_one_class.zero_le_one) finally show ?thesis by simp qed also have "... < 1" (is "?lhs < _") proof(cases "x \ A 0") case True then have "x \ A 1" using A(4) by (auto simp: disjoint_family_on_def) hence "?lhs = 1 / 4 + 1 / 2 * (1 / (1 + emeasure M (A 0)))" by(simp add: True) also have "... \ 1 / 4 + 1 / 2" using less1(2)[of 0] by (simp add: divide_right_mono_ennreal ennreal_divide_times) also have "... = 1 / 4 + 2 / 4" using divide_mult_eq[of 2 1 2] by simp also have "... = 3 / 4" by(simp add: add_divide_distrib_ennreal[symmetric]) also have "... < 1" by(simp add: divide_less_ennreal) finally show ?thesis . next case False then have "?lhs = 1 / 4 + (1 / 2)\<^sup>2 * (1 / (1 + emeasure M (A 1))) * indicator (A 1) x" by simp also have "... \ 1 / 4 + (1 / 2)\<^sup>2" by (metis less1(2)[of 1] add_left_mono indicator_eq_0_iff indicator_eq_1_iff mult.right_neutral mult_eq_0_iff mult_left_mono zero_le) also have "... = 2 / 4" by(simp add: power_divide_distrib_ennreal add_divide_distrib_ennreal[symmetric]) also have "... < 1" by(simp add: divide_less_ennreal) finally show ?thesis . qed finally show "h x < 1" . } show "finite_measure (density M h)" proof show "emeasure (density M h) (space (density M h)) \ \" proof - have "integral\<^sup>N M h \ \" (is "?lhs \ _") proof - have "?lhs = (\n. (\\<^sup>+ x\A n. ((1/2)^(Suc n) * (1 / (1 + M (A n)))) \M))" using A by(simp add: h_def nn_integral_suminf) also have "... = (\n. (1/2)^(Suc n) * (1 / (1 + M (A n))) * M (A n))" by(rule suminf_cong,rule nn_integral_cmult_indicator) (use A in auto) also have "... = (\n. (1/2)^(Suc n) * ((1 / (1 + M (A n))) * M (A n)))" by (simp add: mult.assoc) also have "... \ (\n. (1/2)^(Suc n))" proof - have "(1 / (1 + M (A n))) * M (A n) \ 1" for n using A(3)[of n] by (simp add: add_pos_nonneg divide_le_posI_ennreal ennreal_divide_times) thus ?thesis by(intro suminf_le) (metis mult.right_neutral mult_left_mono zero_le,auto) qed also have "... = (\n. ennreal ((1/2)^(Suc n)))" by(simp only: ennreal_power[of "1/2",symmetric]) (metis divide_ennreal ennreal_1 ennreal_numeral linorder_not_le not_one_less_zero zero_less_numeral) also have "... = ennreal (\n. (1/2)^(Suc n))" by(rule suminf_ennreal2) auto also have "... = 1" using nsum_of_r'[of "1/2" 1 1] by auto finally show ?thesis using nle_le by fastforce qed thus ?thesis by(simp add: emeasure_density) qed qed qed lemma(in sigma_finite_measure) finite_density_measure: obtains h where "h \ borel_measurable M" "\x. x \ space M \ 0 < h x" "\x. x \ space M \ h x < 1" "finite_measure (density M h)" by (metis (no_types, lifting) sigma_finite_disjoint ex_finite_density_measure) subsection \ Lemma 14.D.13. \ lemma (in measure_kernel) assumes "disintegration \ \" defines "\x \ marginal_measure X Y \" shows disintegration_absolutely_continuous: "absolutely_continuous \ \x" and disintegration_density: "\x = density \ (\x. \ x (space Y))" and disintegration_absolutely_continuous_iff: "absolutely_continuous \x \ \ (AE x in \. \ x (space Y) > 0)" proof - note sets_eq[measurable_cong] = disintegration_sets_eq[OF assms(1)] note [measurable] = emeasure_measurable[OF sets.top] have \x_eq: "\x A = (\\<^sup>+x\A. (\ x (space Y)) \\)" if A:"A \ sets X" for A by(simp add: disintegrationD[OF assms(1) A sets.top] emeasure_marginal_measure[OF sets_eq(1) A] \x_def) thus 1:"\x = density \ (\x. \ x (space Y))" by(auto intro!: measure_eqI simp: sets_marginal_measure \x_def sets_eq emeasure_density) hence sets_\x:"sets \x = sets X" using sets_eq by simp show "absolutely_continuous \ \x" unfolding absolutely_continuous_def proof safe fix A assume A: "A \ null_sets \" have "0 = (\\<^sup>+x\A. (\ x (space Y)) \\)" by(simp add: A nn_integral_null_set) also have "... = \x A" using A \x_eq[of A,simplified sets_eq(2)[symmetric]] by auto finally show "A \ null_sets \x" using A by(auto simp: null_sets_def \x_def sets_marginal_measure sets_eq) qed show "absolutely_continuous \x \ \ (AE x in \. \ x (space Y) > 0)" proof assume h:"absolutely_continuous \x \" define N where "N = {x \ space \. (\ x) (space Y) = 0}" have "N \ null_sets \" proof - have "\x N = (\\<^sup>+x\N. (\ x (space Y)) \\)" using \x_eq[of N] by(simp add: N_def sets_eq_imp_space_eq[OF sets_eq(2)]) also have "... = (\\<^sup>+x\N. 0 \\)" by(rule nn_integral_cong) (auto simp: N_def indicator_def) also have "... = 0" by simp finally have "N \ null_sets \x" by(auto simp: null_sets_def 1 N_def) thus ?thesis using h by(auto simp: absolutely_continuous_def) qed then show "AE x in \. 0 < (\ x) (space Y)" by(auto intro!: AE_I'[OF _ subset_refl] simp: N_def) next assume "AE x in \. 0 < (\ x) (space Y)" then show "absolutely_continuous \x \" using \x_eq by(auto simp: absolutely_continuous_def intro!: null_if_pos_func_has_zero_nn_int[where f="\x. emeasure (\ x) (space Y)"]) (auto simp: null_sets_def sets_\x) qed qed subsection \ Theorem 14.D.14. \ locale sigma_finite_measure_on_pair_standard = sigma_finite_measure_on_pair + standard_borel_ne Y sublocale projection_sigma_finite_standard \ sigma_finite_measure_on_pair_standard by (simp add: sigma_finite_measure_on_pair_axioms sigma_finite_measure_on_pair_standard_def standard_borel_ne_axioms) context sigma_finite_measure_on_pair_standard begin lemma measure_disintegration_extension: "\\ \. finite_measure \ \ measure_kernel X Y \ \ measure_kernel.disintegration X Y \ \ \ \ (\x\space X. sigma_finite_measure (\ x)) \ (\x\space X. \ x (space Y) > 0) \ \ ~\<^sub>M \x" (is "?goal") proof(rule sigma_finite_measure.sigma_finite_disjoint[OF sigma_finite]) fix A :: "nat \ _" assume A:"range A \ sets \" "\ (range A) = space \" "\i. emeasure \ (A i) \ \" "disjoint_family A" define h where "h \ (\x. \n. (1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))) * indicator (A n) x)" have h: "h \ borel_measurable \" "\x y. x \ space X \ y \ space Y \ 0 < h (x,y)" "\x y. x \ space X \ y \ space Y \ h (x,y) < 1" "finite_measure (density \ h)" using ex_finite_density_measure[OF A] by(auto simp: sets_eq_imp_space_eq[OF nu_sets] h_def space_pair_measure) interpret psfs_\x: finite_measure "marginal_measure X Y (density \ h)" by(rule finite_measure_marginal_measure_finite[OF h(4),simplified,OF nu_sets]) interpret psfs: projection_sigma_finite_standard X Y "density \ h" by(auto simp: projection_sigma_finite_standard_def projection_sigma_finite_def standard_borel_ne_axioms nu_sets finite_measure.sigma_finite_measure[OF finite_measure_marginal_measure_finite[OF h(4),simplified,OF nu_sets]]) from psfs.measure_disintegration obtain \' where \': "prob_kernel X Y \'" "measure_kernel.disintegration X Y \' (density \ h) psfs.\x" by auto interpret pk: prob_kernel X Y \' by fact define \ where "\ \ (\x. density (\' x) (\y. 1 / h (x,y)))" have \B: "\ x B = (\\<^sup>+y\B. (1 / h (x, y))\\' x)" if "x \ space X" and [measurable]:"B \ sets Y" for x B using nu_sets pk.kernel_sets[OF that(1)] that h(1) by(auto simp: \_def emeasure_density) interpret mk: measure_kernel X Y \ proof fix B assume [measurable]:"B \ sets Y" have 1:"(\x. \\<^sup>+y\B. (1 / h (x, y))\\' x) \ borel_measurable X" using h(1) nu_sets by(auto intro!: pk.nn_integral_measurable_f'[of "\z. (1 / h z) * indicator B (snd z)",simplified]) show "(\x. (\ x) B) \ borel_measurable X" by(rule measurable_cong[THEN iffD1,OF _ 1],simp add: \B) qed(simp_all add: \_def pk.kernel_sets space_ne) have disi: "mk.disintegration \ psfs.\x" proof(rule mk.disintegrationI) fix A B assume A[measurable]:"A \ sets X" and B[measurable]:"B \ sets Y" show "\ (A \ B) = (\\<^sup>+x\A. (\ x) B\psfs.\x)" (is "?lhs = ?rhs") proof - have "?lhs = (\\<^sup>+z\A \ B. 1 \\)" by auto also have "... = (\\<^sup>+z\A \ B. (1 / h z * h z) \\)" proof - have 1: "a * (1 / a) = 1" if "0 < a" "a < 1" for a :: ennreal proof - have "a * (1 / a) = ennreal (enn2real a * 1 / (enn2real a))" by (simp add: divide_eq_1_ennreal enn2real_eq_0_iff ennreal_times_divide) also have "... = ennreal 1" using enn2real_eq_0_iff that by fastforce finally show ?thesis using ennreal_1 by simp qed show ?thesis by(rule nn_integral_cong,auto simp add: sets_eq_imp_space_eq[OF nu_sets] space_pair_measure ennreal_divide_times indicator_def 1[OF h(2,3)]) qed also have "... = (\\<^sup>+z. h z * ((1 / h z) * indicator (A \ B) z) \\)" by(auto intro!: nn_integral_cong simp: indicator_def mult.commute) also have "... = (\\<^sup>+z\A \ B. (1 / h z) \(density \ h))" using h(1) by(simp add: nn_integral_density) also have "... = (\\<^sup>+ x. \\<^sup>+ y. (1 / h (x,y) * indicator (A \ B) (x,y)) \\' x \psfs.\x)" using h(1) by(simp add: pk.nn_integral_fst_finite'[OF _ \'(2) psfs_\x.finite_measure_axioms]) also have "... = (\\<^sup>+ x\A. (\\<^sup>+ y\B. (1 / h (x,y)) \\' x) \psfs.\x)" by(auto intro!: nn_integral_cong simp: indicator_def) also have "... = ?rhs" by(auto intro!: nn_integral_cong simp: \B[OF _ B] space_marginal_measure) finally show ?thesis . qed qed(simp_all add: nu_sets sets_marginal_measure) have geq0: "0 < (\ x) (space Y)" if "x \ space X" for x proof - have "0 = (\\<^sup>+ y. 0 \\' x)" by simp also have "... < (\\<^sup>+ y. (1 / h (x,y)) \\' x)" proof(rule nn_integral_less) show "\ (AE y in \' x. 1 / h (x, y) \ 0)" proof assume "AE y in \' x. 1 / h (x, y) \ 0" moreover have "h (x,y) \ \" if "y \ space (\' x)" for y using h(3)[OF \x \ space X\ that[simplified sets_eq_imp_space_eq[OF pk.kernel_sets[OF \x \ space X\]]]] top.not_eq_extremum by fastforce ultimately show False using prob_space.AE_False[OF pk.prob_spaces[OF that]] by simp qed qed(use h(1) pk.kernel_sets[OF that] that in auto) also have "... = (\ x) (space Y)" by(simp add: \B[OF that sets.top]) (simp add: sets_eq_imp_space_eq[OF pk.kernel_sets[OF that],symmetric]) finally show ?thesis . qed show ?goal proof(safe intro!: exI[where x=psfs.\x] exI[where x=\] disi) show "absolutely_continuous \x psfs.\x" unfolding mk.disintegration_absolutely_continuous_iff[OF disi] by standard (simp add: space_marginal_measure geq0) next fix x assume x:"x \ space X" define C where "C \ range (\n. Pair x -` (A n) \ space Y)" have 1:"countable C" "C \ sets Y" using A(1,2) x by (auto simp: nu_sets sets_eq_imp_space_eq[OF nu_sets] space_pair_measure C_def) have 2: "\ C = space Y" using A(1,2) by(auto simp: sets_eq_imp_space_eq[OF nu_sets] space_pair_measure C_def) (use x in auto) show "sigma_finite_measure (\ x)" unfolding sigma_finite_measure_def proof(safe intro!: exI[where x=C]) fix c assume "c \ C" "(\ x) c = \" then obtain n where c:"c = Pair x -` (A n) \ space Y" by(auto simp: C_def) have "(\ x) c = (\\<^sup>+y\c. (1 / h (x, y))\\' x)" using \B[OF x,of c] 1 \c \ C\ by auto also have "... = (\\<^sup>+y\Pair x -` (A n). (1 / h (x, y))\\' x)" by(auto intro!: nn_integral_cong simp: c indicator_def sets_eq_imp_space_eq[OF pk.kernel_sets[OF x]]) also have "... = (\\<^sup>+y\Pair x -` (A n). (1 / ((1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))))) \\' x)" proof - { fix y assume xy:"(x, y) \ A n" have "1 / h (x, y) = 1 / ((1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))))" proof - have "h (x, y) = (1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n)))" (is "?lhs = ?rhs") proof - have "?lhs = (\m. (1 / 2) ^ Suc m * (1 / (1 + emeasure \ (A m))) * indicator (A m) (x,y))" by(simp add: h_def) also have "... = (\m. if m = n then (1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))) else 0)" using xy A(4) by(fastforce intro!: suminf_cong simp: disjoint_family_on_def indicator_def) also have "... = (\j. if j + Suc n = n then (1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))) else 0) + (\j (A n))) else 0)" by(auto simp: suminf_offset[of "\m. if m = n then (1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))) else 0" "Suc n"] simp del: power_Suc) also have "... = ?rhs" by simp finally show ?thesis . qed thus ?thesis by simp qed } thus ?thesis by(intro nn_integral_cong) (auto simp: sets_eq_imp_space_eq[OF pk.kernel_sets[OF x]] indicator_def simp del: power_Suc) qed also have "... \ (\\<^sup>+y. (1 / ((1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n))))) \\' x)" by(rule nn_integral_mono) (auto simp: indicator_def) also have "... = (1 / ((1 / 2) ^ Suc n * (1 / (1 + emeasure \ (A n)))))" by(simp add: prob_space.emeasure_space_1[OF pk.prob_spaces[OF x]]) also have "... < \" by (metis A(3) ennreal_add_eq_top ennreal_divide_eq_0_iff ennreal_divide_eq_top_iff ennreal_top_neq_one infinity_ennreal_def mult_eq_0_iff power_eq_0_iff top.not_eq_extremum top_neq_numeral) finally show False using \(\ x) c = \\ by simp qed(insert 1 2, auto simp: mk.kernel_sets[OF x] sets_eq_imp_space_eq[OF mk.kernel_sets[OF x]]) qed(auto simp: psfs_\x.finite_measure_axioms geq0 mk.measure_kernel_axioms mk.disintegration_absolutely_continuous[OF disi]) qed end (* TODO: \AE x in \. \B \ sets Y. ... = ...\ for a standard Borel Y. *) lemma(in sigma_finite_measure_on_pair) measure_disintegration_extension_AE_unique: assumes "sigma_finite_measure \" "sigma_finite_measure \'" "measure_kernel X Y \" "measure_kernel X Y \'" "measure_kernel.disintegration X Y \ \ \" "measure_kernel.disintegration X Y \' \ \'" and "absolutely_continuous \ \'" "B \ sets Y" shows "AE x in \. \' x B * RN_deriv \ \' x = \ x B" proof - interpret s1: sigma_finite_measure \ by fact interpret s2: sigma_finite_measure \' by fact interpret mk1: measure_kernel X Y \ by fact interpret mk2: measure_kernel X Y \' by fact have sets[measurable_cong]:"sets \ = sets X" "sets \' = sets X" using assms(5,6) by(auto dest: mk1.disintegration_sets_eq mk2.disintegration_sets_eq) have 1:"AE x in \. \ x B = RN_deriv \ (marginal_measure_on X Y \ B) x" using sets mk1.emeasure_measurable[OF assms(8)] mk1.disintegrationD[OF assms(5) _ assms(8)] by(auto intro!: measure_eqI s1.RN_deriv_unique simp: emeasure_density emeasure_marginal_measure_on[OF nu_sets assms(8)] sets sets_marginal_measure) have 2:"AE x in \. \' x B * RN_deriv \ \' x = RN_deriv \ (marginal_measure_on X Y \ B) x" proof - { fix A assume A: "A \ sets X" have "(\\<^sup>+x\A. ((\' x) B * RN_deriv \ \' x) \\) = (\\<^sup>+x. RN_deriv \ \' x * (\' x B * indicator A x)\\)" by(auto intro!: nn_integral_cong simp: indicator_def mult.commute) also have "... = (\\<^sup>+x\A. \' x B \\')" using mk2.emeasure_measurable[OF assms(8)] sets A by(auto intro!: s1.RN_deriv_nn_integral[OF assms(7),symmetric]) also have "... = \ (A \ B)" by(simp add: mk2.disintegrationD[OF assms(6) A assms(8)]) finally have "(\\<^sup>+x\A. ((\' x) B * RN_deriv \ \' x) \\) = \ (A \ B)" . } thus ?thesis using sets mk2.emeasure_measurable[OF assms(8)] by(auto intro!: measure_eqI s1.RN_deriv_unique simp: emeasure_density emeasure_marginal_measure_on[OF nu_sets assms(8)]sets sets_marginal_measure) qed show ?thesis using 1 2 by auto qed end \ No newline at end of file