src/HOL/Probability/Bochner_Integration.thy
changeset 56996 891e992e510f
parent 56994 8d5e5ec1cac3
child 57025 e7fd64f82876
equal deleted inserted replaced
56995:61855ade6c7e 56996:891e992e510f
   282   then have m: "0 < m"
   282   then have m: "0 < m"
   283     using nn by (auto simp: less_le)
   283     using nn by (auto simp: less_le)
   284 
   284 
   285   from m have "m * emeasure M {x\<in>space M. 0 \<noteq> f x} = 
   285   from m have "m * emeasure M {x\<in>space M. 0 \<noteq> f x} = 
   286     (\<integral>\<^sup>+x. m * indicator {x\<in>space M. 0 \<noteq> f x} x \<partial>M)"
   286     (\<integral>\<^sup>+x. m * indicator {x\<in>space M. 0 \<noteq> f x} x \<partial>M)"
   287     using f by (intro positive_integral_cmult_indicator[symmetric]) auto
   287     using f by (intro nn_integral_cmult_indicator[symmetric]) auto
   288   also have "\<dots> \<le> (\<integral>\<^sup>+x. f x \<partial>M)"
   288   also have "\<dots> \<le> (\<integral>\<^sup>+x. f x \<partial>M)"
   289     using AE_space
   289     using AE_space
   290   proof (intro positive_integral_mono_AE, eventually_elim)
   290   proof (intro nn_integral_mono_AE, eventually_elim)
   291     fix x assume "x \<in> space M"
   291     fix x assume "x \<in> space M"
   292     with nn show "m * indicator {x \<in> space M. 0 \<noteq> f x} x \<le> f x"
   292     with nn show "m * indicator {x \<in> space M. 0 \<noteq> f x} x \<le> f x"
   293       using f by (auto split: split_indicator simp: simple_function_def m_def)
   293       using f by (auto split: split_indicator simp: simple_function_def m_def)
   294   qed
   294   qed
   295   also note `\<dots> < \<infinity>`
   295   also note `\<dots> < \<infinity>`
   445     by (intro simple_bochner_integral_partition[symmetric])
   445     by (intro simple_bochner_integral_partition[symmetric])
   446        (auto intro: f simple_bochner_integrable_compose2 elim: simple_bochner_integrable.cases)
   446        (auto intro: f simple_bochner_integrable_compose2 elim: simple_bochner_integrable.cases)
   447   finally show ?thesis .
   447   finally show ?thesis .
   448 qed
   448 qed
   449 
   449 
   450 lemma simple_bochner_integral_eq_positive_integral:
   450 lemma simple_bochner_integral_eq_nn_integral:
   451   assumes f: "simple_bochner_integrable M f" "\<And>x. 0 \<le> f x"
   451   assumes f: "simple_bochner_integrable M f" "\<And>x. 0 \<le> f x"
   452   shows "simple_bochner_integral M f = (\<integral>\<^sup>+x. f x \<partial>M)"
   452   shows "simple_bochner_integral M f = (\<integral>\<^sup>+x. f x \<partial>M)"
   453 proof -
   453 proof -
   454   { fix x y z have "(x \<noteq> 0 \<Longrightarrow> y = z) \<Longrightarrow> ereal x * y = ereal x * z"
   454   { fix x y z have "(x \<noteq> 0 \<Longrightarrow> y = z) \<Longrightarrow> ereal x * y = ereal x * z"
   455       by (cases "x = 0") (auto simp: zero_ereal_def[symmetric]) }
   455       by (cases "x = 0") (auto simp: zero_ereal_def[symmetric]) }
   477              intro!: setsum_cong ereal_cong_mult
   477              intro!: setsum_cong ereal_cong_mult
   478              simp: setsum_ereal[symmetric] times_ereal.simps(1)[symmetric] mult_ac
   478              simp: setsum_ereal[symmetric] times_ereal.simps(1)[symmetric] mult_ac
   479              simp del: setsum_ereal times_ereal.simps(1))
   479              simp del: setsum_ereal times_ereal.simps(1))
   480   also have "\<dots> = (\<integral>\<^sup>+x. f x \<partial>M)"
   480   also have "\<dots> = (\<integral>\<^sup>+x. f x \<partial>M)"
   481     using f
   481     using f
   482     by (intro positive_integral_eq_simple_integral[symmetric])
   482     by (intro nn_integral_eq_simple_integral[symmetric])
   483        (auto simp: simple_function_compose1 simple_bochner_integrable.simps)
   483        (auto simp: simple_function_compose1 simple_bochner_integrable.simps)
   484   finally show ?thesis .
   484   finally show ?thesis .
   485 qed
   485 qed
   486 
   486 
   487 lemma simple_bochner_integral_bounded:
   487 lemma simple_bochner_integral_bounded:
   500   also have "\<dots> \<le> simple_bochner_integral M (\<lambda>x. norm (s x - t x))"
   500   also have "\<dots> \<le> simple_bochner_integral M (\<lambda>x. norm (s x - t x))"
   501     using simple_bochner_integrable_compose2[of "op -" M "s" "t"] s t
   501     using simple_bochner_integrable_compose2[of "op -" M "s" "t"] s t
   502     by (auto intro!: simple_bochner_integral_norm_bound)
   502     by (auto intro!: simple_bochner_integral_norm_bound)
   503   also have "\<dots> = (\<integral>\<^sup>+x. norm (s x - t x) \<partial>M)"
   503   also have "\<dots> = (\<integral>\<^sup>+x. norm (s x - t x) \<partial>M)"
   504     using simple_bochner_integrable_compose2[of "\<lambda>x y. norm (x - y)" M "s" "t"] s t
   504     using simple_bochner_integrable_compose2[of "\<lambda>x y. norm (x - y)" M "s" "t"] s t
   505     by (auto intro!: simple_bochner_integral_eq_positive_integral)
   505     by (auto intro!: simple_bochner_integral_eq_nn_integral)
   506   also have "\<dots> \<le> (\<integral>\<^sup>+x. ereal (norm (f x - s x)) + ereal (norm (f x - t x)) \<partial>M)"
   506   also have "\<dots> \<le> (\<integral>\<^sup>+x. ereal (norm (f x - s x)) + ereal (norm (f x - t x)) \<partial>M)"
   507     by (auto intro!: positive_integral_mono)
   507     by (auto intro!: nn_integral_mono)
   508        (metis (erased, hide_lams) add_diff_cancel_left add_diff_eq diff_add_eq order_trans
   508        (metis (erased, hide_lams) add_diff_cancel_left add_diff_eq diff_add_eq order_trans
   509               norm_minus_commute norm_triangle_ineq4 order_refl)
   509               norm_minus_commute norm_triangle_ineq4 order_refl)
   510   also have "\<dots> = ?S + ?T"
   510   also have "\<dots> = ?S + ?T"
   511    by (rule positive_integral_add) auto
   511    by (rule nn_integral_add) auto
   512   finally show ?thesis .
   512   finally show ?thesis .
   513 qed
   513 qed
   514 
   514 
   515 inductive has_bochner_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b::{real_normed_vector, second_countable_topology} \<Rightarrow> bool"
   515 inductive has_bochner_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b::{real_normed_vector, second_countable_topology} \<Rightarrow> bool"
   516   for M f x where
   516   for M f x where
   522 
   522 
   523 lemma has_bochner_integral_cong:
   523 lemma has_bochner_integral_cong:
   524   assumes "M = N" "\<And>x. x \<in> space N \<Longrightarrow> f x = g x" "x = y"
   524   assumes "M = N" "\<And>x. x \<in> space N \<Longrightarrow> f x = g x" "x = y"
   525   shows "has_bochner_integral M f x \<longleftrightarrow> has_bochner_integral N g y"
   525   shows "has_bochner_integral M f x \<longleftrightarrow> has_bochner_integral N g y"
   526   unfolding has_bochner_integral.simps assms(1,3)
   526   unfolding has_bochner_integral.simps assms(1,3)
   527   using assms(2) by (simp cong: measurable_cong_strong positive_integral_cong_strong)
   527   using assms(2) by (simp cong: measurable_cong_strong nn_integral_cong_strong)
   528 
   528 
   529 lemma has_bochner_integral_cong_AE:
   529 lemma has_bochner_integral_cong_AE:
   530   "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> (AE x in M. f x = g x) \<Longrightarrow>
   530   "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> (AE x in M. f x = g x) \<Longrightarrow>
   531     has_bochner_integral M f x \<longleftrightarrow> has_bochner_integral M g x"
   531     has_bochner_integral M f x \<longleftrightarrow> has_bochner_integral M g x"
   532   unfolding has_bochner_integral.simps
   532   unfolding has_bochner_integral.simps
   533   by (intro arg_cong[where f=Ex] ext conj_cong rev_conj_cong refl arg_cong[where f="\<lambda>x. x ----> 0"]
   533   by (intro arg_cong[where f=Ex] ext conj_cong rev_conj_cong refl arg_cong[where f="\<lambda>x. x ----> 0"]
   534             positive_integral_cong_AE)
   534             nn_integral_cong_AE)
   535      auto
   535      auto
   536 
   536 
   537 lemma borel_measurable_has_bochner_integral[measurable_dest]:
   537 lemma borel_measurable_has_bochner_integral[measurable_dest]:
   538   "has_bochner_integral M f x \<Longrightarrow> f \<in> borel_measurable M"
   538   "has_bochner_integral M f x \<Longrightarrow> f \<in> borel_measurable M"
   539   by (auto elim: has_bochner_integral.cases)
   539   by (auto elim: has_bochner_integral.cases)
   555       using sets.sets_into_space[OF `A\<in>sets M`] by (auto split: split_indicator)
   555       using sets.sets_into_space[OF `A\<in>sets M`] by (auto split: split_indicator)
   556     then show "emeasure M {y \<in> space M. (indicator A y::real) \<noteq> 0} \<noteq> \<infinity>"
   556     then show "emeasure M {y \<in> space M. (indicator A y::real) \<noteq> 0} \<noteq> \<infinity>"
   557       using A by auto
   557       using A by auto
   558   qed (rule simple_function_indicator assms)+
   558   qed (rule simple_function_indicator assms)+
   559   moreover have "simple_bochner_integral M (indicator A) = measure M A"
   559   moreover have "simple_bochner_integral M (indicator A) = measure M A"
   560     using simple_bochner_integral_eq_positive_integral[OF sbi] A
   560     using simple_bochner_integral_eq_nn_integral[OF sbi] A
   561     by (simp add: ereal_indicator emeasure_eq_ereal_measure)
   561     by (simp add: ereal_indicator emeasure_eq_ereal_measure)
   562   ultimately show ?thesis
   562   ultimately show ?thesis
   563     by (metis has_bochner_integral_simple_bochner_integrable)
   563     by (metis has_bochner_integral_simple_bochner_integrable)
   564 qed
   564 qed
   565 
   565 
   582 
   582 
   583   show "(\<lambda>i. \<integral>\<^sup>+ x. (norm (f x + g x - (sf i x + sg i x))) \<partial>M) ----> 0"
   583   show "(\<lambda>i. \<integral>\<^sup>+ x. (norm (f x + g x - (sf i x + sg i x))) \<partial>M) ----> 0"
   584     (is "?f ----> 0")
   584     (is "?f ----> 0")
   585   proof (rule tendsto_sandwich)
   585   proof (rule tendsto_sandwich)
   586     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   586     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   587       by (auto simp: positive_integral_positive)
   587       by (auto simp: nn_integral_nonneg)
   588     show "eventually (\<lambda>i. ?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) \<partial>M) + \<integral>\<^sup>+ x. (norm (g x - sg i x)) \<partial>M) sequentially"
   588     show "eventually (\<lambda>i. ?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) \<partial>M) + \<integral>\<^sup>+ x. (norm (g x - sg i x)) \<partial>M) sequentially"
   589       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   589       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   590     proof (intro always_eventually allI)
   590     proof (intro always_eventually allI)
   591       fix i have "?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) + ereal (norm (g x - sg i x)) \<partial>M)"
   591       fix i have "?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) + ereal (norm (g x - sg i x)) \<partial>M)"
   592         by (auto intro!: positive_integral_mono norm_diff_triangle_ineq)
   592         by (auto intro!: nn_integral_mono norm_diff_triangle_ineq)
   593       also have "\<dots> = ?g i"
   593       also have "\<dots> = ?g i"
   594         by (intro positive_integral_add) auto
   594         by (intro nn_integral_add) auto
   595       finally show "?f i \<le> ?g i" .
   595       finally show "?f i \<le> ?g i" .
   596     qed
   596     qed
   597     show "?g ----> 0"
   597     show "?g ----> 0"
   598       using tendsto_add_ereal[OF _ _ f_sf g_sg] by simp
   598       using tendsto_add_ereal[OF _ _ f_sf g_sg] by simp
   599   qed
   599   qed
   623 
   623 
   624   show "(\<lambda>i. \<integral>\<^sup>+ x. norm (T (f x) - T (s i x)) \<partial>M) ----> 0"
   624   show "(\<lambda>i. \<integral>\<^sup>+ x. norm (T (f x) - T (s i x)) \<partial>M) ----> 0"
   625     (is "?f ----> 0")
   625     (is "?f ----> 0")
   626   proof (rule tendsto_sandwich)
   626   proof (rule tendsto_sandwich)
   627     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   627     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   628       by (auto simp: positive_integral_positive)
   628       by (auto simp: nn_integral_nonneg)
   629 
   629 
   630     show "eventually (\<lambda>i. ?f i \<le> K * (\<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M)) sequentially"
   630     show "eventually (\<lambda>i. ?f i \<le> K * (\<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M)) sequentially"
   631       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   631       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   632     proof (intro always_eventually allI)
   632     proof (intro always_eventually allI)
   633       fix i have "?f i \<le> (\<integral>\<^sup>+ x. ereal K * norm (f x - s i x) \<partial>M)"
   633       fix i have "?f i \<le> (\<integral>\<^sup>+ x. ereal K * norm (f x - s i x) \<partial>M)"
   634         using K by (intro positive_integral_mono) (auto simp: mult_ac)
   634         using K by (intro nn_integral_mono) (auto simp: mult_ac)
   635       also have "\<dots> = ?g i"
   635       also have "\<dots> = ?g i"
   636         using K by (intro positive_integral_cmult) auto
   636         using K by (intro nn_integral_cmult) auto
   637       finally show "?f i \<le> ?g i" .
   637       finally show "?f i \<le> ?g i" .
   638     qed
   638     qed
   639     show "?g ----> 0"
   639     show "?g ----> 0"
   640       using ereal_lim_mult[OF f_s, of "ereal K"] by simp
   640       using ereal_lim_mult[OF f_s, of "ereal K"] by simp
   641   qed
   641   qed
   736   then have "finite (norm ` s i ` space M)"
   736   then have "finite (norm ` s i ` space M)"
   737     by (rule finite_imageI)
   737     by (rule finite_imageI)
   738   then have "\<And>x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> m" "0 \<le> m"
   738   then have "\<And>x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> m" "0 \<le> m"
   739     by (auto simp: m_def image_comp comp_def Max_ge_iff)
   739     by (auto simp: m_def image_comp comp_def Max_ge_iff)
   740   then have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) \<le> (\<integral>\<^sup>+x. ereal m * indicator {x\<in>space M. s i x \<noteq> 0} x \<partial>M)"
   740   then have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) \<le> (\<integral>\<^sup>+x. ereal m * indicator {x\<in>space M. s i x \<noteq> 0} x \<partial>M)"
   741     by (auto split: split_indicator intro!: Max_ge positive_integral_mono simp:)
   741     by (auto split: split_indicator intro!: Max_ge nn_integral_mono simp:)
   742   also have "\<dots> < \<infinity>"
   742   also have "\<dots> < \<infinity>"
   743     using s by (subst positive_integral_cmult_indicator) (auto simp: `0 \<le> m` simple_bochner_integrable.simps)
   743     using s by (subst nn_integral_cmult_indicator) (auto simp: `0 \<le> m` simple_bochner_integrable.simps)
   744   finally have s_fin: "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) < \<infinity>" .
   744   finally have s_fin: "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) < \<infinity>" .
   745 
   745 
   746   have "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x - s i x)) + ereal (norm (s i x)) \<partial>M)"
   746   have "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x - s i x)) + ereal (norm (s i x)) \<partial>M)"
   747     by (auto intro!: positive_integral_mono) (metis add_commute norm_triangle_sub)
   747     by (auto intro!: nn_integral_mono) (metis add_commute norm_triangle_sub)
   748   also have "\<dots> = (\<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) + (\<integral>\<^sup>+x. norm (s i x) \<partial>M)"
   748   also have "\<dots> = (\<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) + (\<integral>\<^sup>+x. norm (s i x) \<partial>M)"
   749     by (rule positive_integral_add) auto
   749     by (rule nn_integral_add) auto
   750   also have "\<dots> < \<infinity>"
   750   also have "\<dots> < \<infinity>"
   751     using s_fin f_s_fin by auto
   751     using s_fin f_s_fin by auto
   752   finally show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" .
   752   finally show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" .
   753 qed
   753 qed
   754 
   754 
   774     proof (intro exI allI impI)
   774     proof (intro exI allI impI)
   775       fix n
   775       fix n
   776       have "ereal (norm (?s n)) \<le> simple_bochner_integral M (\<lambda>x. norm (s n x))"
   776       have "ereal (norm (?s n)) \<le> simple_bochner_integral M (\<lambda>x. norm (s n x))"
   777         by (auto intro!: simple_bochner_integral_norm_bound)
   777         by (auto intro!: simple_bochner_integral_norm_bound)
   778       also have "\<dots> = (\<integral>\<^sup>+x. norm (s n x) \<partial>M)"
   778       also have "\<dots> = (\<integral>\<^sup>+x. norm (s n x) \<partial>M)"
   779         by (intro simple_bochner_integral_eq_positive_integral)
   779         by (intro simple_bochner_integral_eq_nn_integral)
   780            (auto intro: s simple_bochner_integrable_compose2)
   780            (auto intro: s simple_bochner_integrable_compose2)
   781       also have "\<dots> \<le> (\<integral>\<^sup>+x. ereal (norm (f x - s n x)) + norm (f x) \<partial>M)"
   781       also have "\<dots> \<le> (\<integral>\<^sup>+x. ereal (norm (f x - s n x)) + norm (f x) \<partial>M)"
   782         by (auto intro!: positive_integral_mono)
   782         by (auto intro!: nn_integral_mono)
   783            (metis add_commute norm_minus_commute norm_triangle_sub)
   783            (metis add_commute norm_minus_commute norm_triangle_sub)
   784       also have "\<dots> = ?t n" 
   784       also have "\<dots> = ?t n" 
   785         by (rule positive_integral_add) auto
   785         by (rule nn_integral_add) auto
   786       finally show "norm (?s n) \<le> ?t n" .
   786       finally show "norm (?s n) \<le> ?t n" .
   787     qed
   787     qed
   788     have "?t ----> 0 + (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
   788     have "?t ----> 0 + (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
   789       using has_bochner_integral_implies_finite_norm[OF i]
   789       using has_bochner_integral_implies_finite_norm[OF i]
   790       by (intro tendsto_add_ereal tendsto_const lim) auto
   790       by (intro tendsto_add_ereal tendsto_const lim) auto
   814     by (intro tendsto_intros)
   814     by (intro tendsto_intros)
   815   moreover
   815   moreover
   816   have "(\<lambda>i. ereal (norm (?s i - ?t i))) ----> ereal 0"
   816   have "(\<lambda>i. ereal (norm (?s i - ?t i))) ----> ereal 0"
   817   proof (rule tendsto_sandwich)
   817   proof (rule tendsto_sandwich)
   818     show "eventually (\<lambda>i. 0 \<le> ereal (norm (?s i - ?t i))) sequentially" "(\<lambda>_. 0) ----> ereal 0"
   818     show "eventually (\<lambda>i. 0 \<le> ereal (norm (?s i - ?t i))) sequentially" "(\<lambda>_. 0) ----> ereal 0"
   819       by (auto simp: positive_integral_positive zero_ereal_def[symmetric])
   819       by (auto simp: nn_integral_nonneg zero_ereal_def[symmetric])
   820 
   820 
   821     show "eventually (\<lambda>i. norm (?s i - ?t i) \<le> ?S i + ?T i) sequentially"
   821     show "eventually (\<lambda>i. norm (?s i - ?t i) \<le> ?S i + ?T i) sequentially"
   822       by (intro always_eventually allI simple_bochner_integral_bounded s t f)
   822       by (intro always_eventually allI simple_bochner_integral_bounded s t f)
   823     show "(\<lambda>i. ?S i + ?T i) ----> ereal 0"
   823     show "(\<lambda>i. ?S i + ?T i) ----> ereal 0"
   824       using tendsto_add_ereal[OF _ _ `?S ----> 0` `?T ----> 0`]
   824       using tendsto_add_ereal[OF _ _ `?S ----> 0` `?T ----> 0`]
   839   using f
   839   using f
   840 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   840 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   841   fix s assume "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
   841   fix s assume "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
   842   also have "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) = (\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M)"
   842   also have "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) = (\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M)"
   843     using ae
   843     using ae
   844     by (intro ext positive_integral_cong_AE, eventually_elim) simp
   844     by (intro ext nn_integral_cong_AE, eventually_elim) simp
   845   finally show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M) ----> 0" .
   845   finally show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M) ----> 0" .
   846 qed (auto intro: g)
   846 qed (auto intro: g)
   847 
   847 
   848 lemma has_bochner_integral_eq_AE:
   848 lemma has_bochner_integral_eq_AE:
   849   assumes f: "has_bochner_integral M f x"
   849   assumes f: "has_bochner_integral M f x"
  1085         using M[OF n] by auto
  1085         using M[OF n] by auto
  1086       have "norm (?s n - ?s m) \<le> ?S n + ?S m"
  1086       have "norm (?s n - ?s m) \<le> ?S n + ?S m"
  1087         by (intro simple_bochner_integral_bounded s f)
  1087         by (intro simple_bochner_integral_bounded s f)
  1088       also have "\<dots> < ereal (e / 2) + e / 2"
  1088       also have "\<dots> < ereal (e / 2) + e / 2"
  1089         using ereal_add_strict_mono[OF less_imp_le[OF M[OF n]] _ `?S n \<noteq> \<infinity>` M[OF m]]
  1089         using ereal_add_strict_mono[OF less_imp_le[OF M[OF n]] _ `?S n \<noteq> \<infinity>` M[OF m]]
  1090         by (auto simp: positive_integral_positive)
  1090         by (auto simp: nn_integral_nonneg)
  1091       also have "\<dots> = e" by simp
  1091       also have "\<dots> = e" by simp
  1092       finally show "dist (?s n) (?s m) < e"
  1092       finally show "dist (?s n) (?s m) < e"
  1093         by (simp add: dist_norm)
  1093         by (simp add: dist_norm)
  1094     qed
  1094     qed
  1095   qed
  1095   qed
  1096   then obtain x where "?s ----> x" ..
  1096   then obtain x where "?s ----> x" ..
  1097   show ?thesis
  1097   show ?thesis
  1098     by (rule, rule) fact+
  1098     by (rule, rule) fact+
  1099 qed
  1099 qed
  1100 
  1100 
  1101 lemma positive_integral_dominated_convergence_norm:
  1101 lemma nn_integral_dominated_convergence_norm:
  1102   fixes u' :: "_ \<Rightarrow> _::{real_normed_vector, second_countable_topology}"
  1102   fixes u' :: "_ \<Rightarrow> _::{real_normed_vector, second_countable_topology}"
  1103   assumes [measurable]:
  1103   assumes [measurable]:
  1104        "\<And>i. u i \<in> borel_measurable M" "u' \<in> borel_measurable M" "w \<in> borel_measurable M"
  1104        "\<And>i. u i \<in> borel_measurable M" "u' \<in> borel_measurable M" "w \<in> borel_measurable M"
  1105     and bound: "\<And>j. AE x in M. norm (u j x) \<le> w x"
  1105     and bound: "\<And>j. AE x in M. norm (u j x) \<le> w x"
  1106     and w: "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1106     and w: "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1120       by (rule norm_triangle_ineq4)
  1120       by (rule norm_triangle_ineq4)
  1121     finally (xtrans) show "norm (u' x - u i x) \<le> 2 * w x" .
  1121     finally (xtrans) show "norm (u' x - u i x) \<le> 2 * w x" .
  1122   qed
  1122   qed
  1123   
  1123   
  1124   have "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) ----> (\<integral>\<^sup>+x. 0 \<partial>M)"
  1124   have "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) ----> (\<integral>\<^sup>+x. 0 \<partial>M)"
  1125   proof (rule positive_integral_dominated_convergence)  
  1125   proof (rule nn_integral_dominated_convergence)  
  1126     show "(\<integral>\<^sup>+x. 2 * w x \<partial>M) < \<infinity>"
  1126     show "(\<integral>\<^sup>+x. 2 * w x \<partial>M) < \<infinity>"
  1127       by (rule positive_integral_mult_bounded_inf[OF _ w, of 2]) auto
  1127       by (rule nn_integral_mult_bounded_inf[OF _ w, of 2]) auto
  1128     show "AE x in M. (\<lambda>i. ereal (norm (u' x - u i x))) ----> 0"
  1128     show "AE x in M. (\<lambda>i. ereal (norm (u' x - u i x))) ----> 0"
  1129       using u' 
  1129       using u' 
  1130     proof eventually_elim
  1130     proof eventually_elim
  1131       fix x assume "(\<lambda>i. u i x) ----> u' x"
  1131       fix x assume "(\<lambda>i. u i x) ----> u' x"
  1132       from tendsto_diff[OF tendsto_const[of "u' x"] this]
  1132       from tendsto_diff[OF tendsto_const[of "u' x"] this]
  1150   
  1150   
  1151   show ?thesis
  1151   show ?thesis
  1152   proof (rule integrableI_sequence)
  1152   proof (rule integrableI_sequence)
  1153     { fix i
  1153     { fix i
  1154       have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) \<le> (\<integral>\<^sup>+x. 2 * ereal (norm (f x)) \<partial>M)"
  1154       have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) \<le> (\<integral>\<^sup>+x. 2 * ereal (norm (f x)) \<partial>M)"
  1155         by (intro positive_integral_mono) (simp add: bound)
  1155         by (intro nn_integral_mono) (simp add: bound)
  1156       also have "\<dots> = 2 * (\<integral>\<^sup>+x. ereal (norm (f x)) \<partial>M)"
  1156       also have "\<dots> = 2 * (\<integral>\<^sup>+x. ereal (norm (f x)) \<partial>M)"
  1157         by (rule positive_integral_cmult) auto
  1157         by (rule nn_integral_cmult) auto
  1158       finally have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) < \<infinity>"
  1158       finally have "(\<integral>\<^sup>+x. norm (s i x) \<partial>M) < \<infinity>"
  1159         using fin by auto }
  1159         using fin by auto }
  1160     note fin_s = this
  1160     note fin_s = this
  1161 
  1161 
  1162     show "\<And>i. simple_bochner_integrable M (s i)"
  1162     show "\<And>i. simple_bochner_integrable M (s i)"
  1163       by (rule simple_bochner_integrableI_bounded) fact+
  1163       by (rule simple_bochner_integrableI_bounded) fact+
  1164 
  1164 
  1165     show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
  1165     show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
  1166     proof (rule positive_integral_dominated_convergence_norm)
  1166     proof (rule nn_integral_dominated_convergence_norm)
  1167       show "\<And>j. AE x in M. norm (s j x) \<le> 2 * norm (f x)"
  1167       show "\<And>j. AE x in M. norm (s j x) \<le> 2 * norm (f x)"
  1168         using bound by auto
  1168         using bound by auto
  1169       show "\<And>i. s i \<in> borel_measurable M" "(\<lambda>x. 2 * norm (f x)) \<in> borel_measurable M"
  1169       show "\<And>i. s i \<in> borel_measurable M" "(\<lambda>x. 2 * norm (f x)) \<in> borel_measurable M"
  1170         using s by (auto intro: borel_measurable_simple_function)
  1170         using s by (auto intro: borel_measurable_simple_function)
  1171       show "(\<integral>\<^sup>+ x. ereal (2 * norm (f x)) \<partial>M) < \<infinity>"
  1171       show "(\<integral>\<^sup>+ x. ereal (2 * norm (f x)) \<partial>M) < \<infinity>"
  1172         using fin unfolding times_ereal.simps(1)[symmetric] by (subst positive_integral_cmult) auto
  1172         using fin unfolding times_ereal.simps(1)[symmetric] by (subst nn_integral_cmult) auto
  1173       show "AE x in M. (\<lambda>i. s i x) ----> f x"
  1173       show "AE x in M. (\<lambda>i. s i x) ----> f x"
  1174         using pointwise by auto
  1174         using pointwise by auto
  1175     qed fact
  1175     qed fact
  1176   qed fact
  1176   qed fact
  1177 qed
  1177 qed
  1180   fixes f :: "'a \<Rightarrow> real"
  1180   fixes f :: "'a \<Rightarrow> real"
  1181   assumes "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" "(\<integral>\<^sup>+x. f x \<partial>M) < \<infinity>"
  1181   assumes "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" "(\<integral>\<^sup>+x. f x \<partial>M) < \<infinity>"
  1182   shows "integrable M f"
  1182   shows "integrable M f"
  1183 proof -
  1183 proof -
  1184   have "(\<integral>\<^sup>+x. norm (f x) \<partial>M) = (\<integral>\<^sup>+x. f x \<partial>M)"
  1184   have "(\<integral>\<^sup>+x. norm (f x) \<partial>M) = (\<integral>\<^sup>+x. f x \<partial>M)"
  1185     using assms by (intro positive_integral_cong_AE) auto
  1185     using assms by (intro nn_integral_cong_AE) auto
  1186   then show ?thesis
  1186   then show ?thesis
  1187     using assms by (intro integrableI_bounded) auto
  1187     using assms by (intro integrableI_bounded) auto
  1188 qed
  1188 qed
  1189 
  1189 
  1190 lemma integrable_iff_bounded:
  1190 lemma integrable_iff_bounded:
  1201   unfolding integrable_iff_bounded
  1201   unfolding integrable_iff_bounded
  1202 proof safe
  1202 proof safe
  1203   assume "f \<in> borel_measurable M" "g \<in> borel_measurable M"
  1203   assume "f \<in> borel_measurable M" "g \<in> borel_measurable M"
  1204   assume "AE x in M. norm (g x) \<le> norm (f x)"
  1204   assume "AE x in M. norm (g x) \<le> norm (f x)"
  1205   then have "(\<integral>\<^sup>+ x. ereal (norm (g x)) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1205   then have "(\<integral>\<^sup>+ x. ereal (norm (g x)) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1206     by  (intro positive_integral_mono_AE) auto
  1206     by  (intro nn_integral_mono_AE) auto
  1207   also assume "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>"
  1207   also assume "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>"
  1208   finally show "(\<integral>\<^sup>+ x. ereal (norm (g x)) \<partial>M) < \<infinity>" .
  1208   finally show "(\<integral>\<^sup>+ x. ereal (norm (g x)) \<partial>M) < \<infinity>" .
  1209 qed 
  1209 qed 
  1210 
  1210 
  1211 lemma integrable_abs[simp, intro]:
  1211 lemma integrable_abs[simp, intro]:
  1247   unfolding integrable_iff_bounded
  1247   unfolding integrable_iff_bounded
  1248   by (auto intro: borel_measurable_uminus[of "\<lambda>x. - f x" M, simplified])
  1248   by (auto intro: borel_measurable_uminus[of "\<lambda>x. - f x" M, simplified])
  1249 
  1249 
  1250 lemma integrable_indicator_iff:
  1250 lemma integrable_indicator_iff:
  1251   "integrable M (indicator A::_ \<Rightarrow> real) \<longleftrightarrow> A \<inter> space M \<in> sets M \<and> emeasure M (A \<inter> space M) < \<infinity>"
  1251   "integrable M (indicator A::_ \<Rightarrow> real) \<longleftrightarrow> A \<inter> space M \<in> sets M \<and> emeasure M (A \<inter> space M) < \<infinity>"
  1252   by (simp add: integrable_iff_bounded borel_measurable_indicator_iff ereal_indicator positive_integral_indicator'
  1252   by (simp add: integrable_iff_bounded borel_measurable_indicator_iff ereal_indicator nn_integral_indicator'
  1253            cong: conj_cong)
  1253            cong: conj_cong)
  1254 
  1254 
  1255 lemma integral_dominated_convergence:
  1255 lemma integral_dominated_convergence:
  1256   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1256   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1257   assumes "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M" "integrable M w"
  1257   assumes "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M" "integrable M w"
  1262     and "(\<lambda>i. integral\<^sup>L M (s i)) ----> integral\<^sup>L M f"
  1262     and "(\<lambda>i. integral\<^sup>L M (s i)) ----> integral\<^sup>L M f"
  1263 proof -
  1263 proof -
  1264   have "AE x in M. 0 \<le> w x"
  1264   have "AE x in M. 0 \<le> w x"
  1265     using bound[of 0] by eventually_elim (auto intro: norm_ge_zero order_trans)
  1265     using bound[of 0] by eventually_elim (auto intro: norm_ge_zero order_trans)
  1266   then have "(\<integral>\<^sup>+x. w x \<partial>M) = (\<integral>\<^sup>+x. norm (w x) \<partial>M)"
  1266   then have "(\<integral>\<^sup>+x. w x \<partial>M) = (\<integral>\<^sup>+x. norm (w x) \<partial>M)"
  1267     by (intro positive_integral_cong_AE) auto
  1267     by (intro nn_integral_cong_AE) auto
  1268   with `integrable M w` have w: "w \<in> borel_measurable M" "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1268   with `integrable M w` have w: "w \<in> borel_measurable M" "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1269     unfolding integrable_iff_bounded by auto
  1269     unfolding integrable_iff_bounded by auto
  1270 
  1270 
  1271   show int_s: "\<And>i. integrable M (s i)"
  1271   show int_s: "\<And>i. integrable M (s i)"
  1272     unfolding integrable_iff_bounded
  1272     unfolding integrable_iff_bounded
  1273   proof
  1273   proof
  1274     fix i 
  1274     fix i 
  1275     have "(\<integral>\<^sup>+ x. ereal (norm (s i x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1275     have "(\<integral>\<^sup>+ x. ereal (norm (s i x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1276       using bound by (intro positive_integral_mono_AE) auto
  1276       using bound by (intro nn_integral_mono_AE) auto
  1277     with w show "(\<integral>\<^sup>+ x. ereal (norm (s i x)) \<partial>M) < \<infinity>" by auto
  1277     with w show "(\<integral>\<^sup>+ x. ereal (norm (s i x)) \<partial>M) < \<infinity>" by auto
  1278   qed fact
  1278   qed fact
  1279 
  1279 
  1280   have all_bound: "AE x in M. \<forall>i. norm (s i x) \<le> w x"
  1280   have all_bound: "AE x in M. \<forall>i. norm (s i x) \<le> w x"
  1281     using bound unfolding AE_all_countable by auto
  1281     using bound unfolding AE_all_countable by auto
  1283   show int_f: "integrable M f"
  1283   show int_f: "integrable M f"
  1284     unfolding integrable_iff_bounded
  1284     unfolding integrable_iff_bounded
  1285   proof
  1285   proof
  1286     have "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1286     have "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1287       using all_bound lim
  1287       using all_bound lim
  1288     proof (intro positive_integral_mono_AE, eventually_elim)
  1288     proof (intro nn_integral_mono_AE, eventually_elim)
  1289       fix x assume "\<forall>i. norm (s i x) \<le> w x" "(\<lambda>i. s i x) ----> f x"
  1289       fix x assume "\<forall>i. norm (s i x) \<le> w x" "(\<lambda>i. s i x) ----> f x"
  1290       then show "ereal (norm (f x)) \<le> ereal (w x)"
  1290       then show "ereal (norm (f x)) \<le> ereal (w x)"
  1291         by (intro LIMSEQ_le_const2[where X="\<lambda>i. ereal (norm (s i x))"] tendsto_intros lim_ereal[THEN iffD2]) auto
  1291         by (intro LIMSEQ_le_const2[where X="\<lambda>i. ereal (norm (s i x))"] tendsto_intros lim_ereal[THEN iffD2]) auto
  1292     qed
  1292     qed
  1293     with w show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" by auto
  1293     with w show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" by auto
  1306       finally show "?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)" .
  1306       finally show "?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)" .
  1307     qed
  1307     qed
  1308     show "(\<lambda>n. \<integral>\<^sup>+x. norm (s n x - f x) \<partial>M) ----> ereal 0"
  1308     show "(\<lambda>n. \<integral>\<^sup>+x. norm (s n x - f x) \<partial>M) ----> ereal 0"
  1309       unfolding zero_ereal_def[symmetric]
  1309       unfolding zero_ereal_def[symmetric]
  1310       apply (subst norm_minus_commute)
  1310       apply (subst norm_minus_commute)
  1311     proof (rule positive_integral_dominated_convergence_norm[where w=w])
  1311     proof (rule nn_integral_dominated_convergence_norm[where w=w])
  1312       show "\<And>n. s n \<in> borel_measurable M"
  1312       show "\<And>n. s n \<in> borel_measurable M"
  1313         using int_s unfolding integrable_iff_bounded by auto
  1313         using int_s unfolding integrable_iff_bounded by auto
  1314     qed fact+
  1314     qed fact+
  1315   qed
  1315   qed
  1316   then have "(\<lambda>n. integral\<^sup>L M (s n) - integral\<^sup>L M f) ----> 0"
  1316   then have "(\<lambda>n. integral\<^sup>L M (s n) - integral\<^sup>L M f) ----> 0"
  1323   fixes f :: "'a \<Rightarrow> real"
  1323   fixes f :: "'a \<Rightarrow> real"
  1324   shows "integrable M (\<lambda>x. c * f x) \<longleftrightarrow> c = 0 \<or> integrable M f"
  1324   shows "integrable M (\<lambda>x. c * f x) \<longleftrightarrow> c = 0 \<or> integrable M f"
  1325   using integrable_mult_left[of c M f] integrable_mult_left[of "1 / c" M "\<lambda>x. c * f x"]
  1325   using integrable_mult_left[of c M f] integrable_mult_left[of "1 / c" M "\<lambda>x. c * f x"]
  1326   by (cases "c = 0") auto
  1326   by (cases "c = 0") auto
  1327 
  1327 
  1328 lemma positive_integral_eq_integral:
  1328 lemma nn_integral_eq_integral:
  1329   assumes f: "integrable M f"
  1329   assumes f: "integrable M f"
  1330   assumes nonneg: "AE x in M. 0 \<le> f x" 
  1330   assumes nonneg: "AE x in M. 0 \<le> f x" 
  1331   shows "(\<integral>\<^sup>+ x. f x \<partial>M) = integral\<^sup>L M f"
  1331   shows "(\<integral>\<^sup>+ x. f x \<partial>M) = integral\<^sup>L M f"
  1332 proof -
  1332 proof -
  1333   { fix f :: "'a \<Rightarrow> real" assume f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "integrable M f"
  1333   { fix f :: "'a \<Rightarrow> real" assume f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "integrable M f"
  1336       case (set A) then show ?case
  1336       case (set A) then show ?case
  1337         by (simp add: integrable_indicator_iff ereal_indicator emeasure_eq_ereal_measure)
  1337         by (simp add: integrable_indicator_iff ereal_indicator emeasure_eq_ereal_measure)
  1338     next
  1338     next
  1339       case (mult f c) then show ?case
  1339       case (mult f c) then show ?case
  1340         unfolding times_ereal.simps(1)[symmetric]
  1340         unfolding times_ereal.simps(1)[symmetric]
  1341         by (subst positive_integral_cmult)
  1341         by (subst nn_integral_cmult)
  1342            (auto simp add: integrable_mult_left_iff zero_ereal_def[symmetric])
  1342            (auto simp add: integrable_mult_left_iff zero_ereal_def[symmetric])
  1343     next
  1343     next
  1344       case (add g f)
  1344       case (add g f)
  1345       then have "integrable M f" "integrable M g"
  1345       then have "integrable M f" "integrable M g"
  1346         by (auto intro!: integrable_bound[OF add(8)])
  1346         by (auto intro!: integrable_bound[OF add(8)])
  1347       with add show ?case
  1347       with add show ?case
  1348         unfolding plus_ereal.simps(1)[symmetric]
  1348         unfolding plus_ereal.simps(1)[symmetric]
  1349         by (subst positive_integral_add) auto
  1349         by (subst nn_integral_add) auto
  1350     next
  1350     next
  1351       case (seq s)
  1351       case (seq s)
  1352       { fix i x assume "x \<in> space M" with seq(4) have "s i x \<le> f x"
  1352       { fix i x assume "x \<in> space M" with seq(4) have "s i x \<le> f x"
  1353           by (intro LIMSEQ_le_const[OF seq(5)] exI[of _ i]) (auto simp: incseq_def le_fun_def) }
  1353           by (intro LIMSEQ_le_const[OF seq(5)] exI[of _ i]) (auto simp: incseq_def le_fun_def) }
  1354       note s_le_f = this
  1354       note s_le_f = this
  1364         qed (insert seq, auto)
  1364         qed (insert seq, auto)
  1365         have int_s: "\<And>i. integrable M (s i)"
  1365         have int_s: "\<And>i. integrable M (s i)"
  1366           using seq f s_le_f by (intro integrable_bound[OF f(3)]) auto
  1366           using seq f s_le_f by (intro integrable_bound[OF f(3)]) auto
  1367         have "(\<lambda>i. \<integral>\<^sup>+ x. s i x \<partial>M) ----> \<integral>\<^sup>+ x. f x \<partial>M"
  1367         have "(\<lambda>i. \<integral>\<^sup>+ x. s i x \<partial>M) ----> \<integral>\<^sup>+ x. f x \<partial>M"
  1368           using seq s_le_f f
  1368           using seq s_le_f f
  1369           by (intro positive_integral_dominated_convergence[where w=f])
  1369           by (intro nn_integral_dominated_convergence[where w=f])
  1370              (auto simp: integrable_iff_bounded)
  1370              (auto simp: integrable_iff_bounded)
  1371         also have "(\<lambda>i. \<integral>\<^sup>+x. s i x \<partial>M) = (\<lambda>i. \<integral>x. s i x \<partial>M)"
  1371         also have "(\<lambda>i. \<integral>\<^sup>+x. s i x \<partial>M) = (\<lambda>i. \<integral>x. s i x \<partial>M)"
  1372           using seq int_s by simp
  1372           using seq int_s by simp
  1373         finally show "(\<lambda>i. \<integral>x. s i x \<partial>M) ----> \<integral>\<^sup>+x. f x \<partial>M"
  1373         finally show "(\<lambda>i. \<integral>x. s i x \<partial>M) ----> \<integral>\<^sup>+x. f x \<partial>M"
  1374           by simp
  1374           by simp
  1377   from this[of "\<lambda>x. max 0 (f x)"] assms have "(\<integral>\<^sup>+ x. max 0 (f x) \<partial>M) = integral\<^sup>L M (\<lambda>x. max 0 (f x))"
  1377   from this[of "\<lambda>x. max 0 (f x)"] assms have "(\<integral>\<^sup>+ x. max 0 (f x) \<partial>M) = integral\<^sup>L M (\<lambda>x. max 0 (f x))"
  1378     by simp
  1378     by simp
  1379   also have "\<dots> = integral\<^sup>L M f"
  1379   also have "\<dots> = integral\<^sup>L M f"
  1380     using assms by (auto intro!: integral_cong_AE)
  1380     using assms by (auto intro!: integral_cong_AE)
  1381   also have "(\<integral>\<^sup>+ x. max 0 (f x) \<partial>M) = (\<integral>\<^sup>+ x. f x \<partial>M)"
  1381   also have "(\<integral>\<^sup>+ x. max 0 (f x) \<partial>M) = (\<integral>\<^sup>+ x. f x \<partial>M)"
  1382     using assms by (auto intro!: positive_integral_cong_AE simp: max_def)
  1382     using assms by (auto intro!: nn_integral_cong_AE simp: max_def)
  1383   finally show ?thesis .
  1383   finally show ?thesis .
  1384 qed
  1384 qed
  1385 
  1385 
  1386 lemma integral_norm_bound:
  1386 lemma integral_norm_bound:
  1387   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
  1387   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
  1388   shows "integrable M f \<Longrightarrow> norm (integral\<^sup>L M f) \<le> (\<integral>x. norm (f x) \<partial>M)"
  1388   shows "integrable M f \<Longrightarrow> norm (integral\<^sup>L M f) \<le> (\<integral>x. norm (f x) \<partial>M)"
  1389   using positive_integral_eq_integral[of M "\<lambda>x. norm (f x)"]
  1389   using nn_integral_eq_integral[of M "\<lambda>x. norm (f x)"]
  1390   using integral_norm_bound_ereal[of M f] by simp
  1390   using integral_norm_bound_ereal[of M f] by simp
  1391   
  1391   
  1392 lemma integral_eq_positive_integral:
  1392 lemma integral_eq_nn_integral:
  1393   "integrable M f \<Longrightarrow> (\<And>x. 0 \<le> f x) \<Longrightarrow> integral\<^sup>L M f = real (\<integral>\<^sup>+ x. ereal (f x) \<partial>M)"
  1393   "integrable M f \<Longrightarrow> (\<And>x. 0 \<le> f x) \<Longrightarrow> integral\<^sup>L M f = real (\<integral>\<^sup>+ x. ereal (f x) \<partial>M)"
  1394   by (subst positive_integral_eq_integral) auto
  1394   by (subst nn_integral_eq_integral) auto
  1395   
  1395   
  1396 lemma integrableI_simple_bochner_integrable:
  1396 lemma integrableI_simple_bochner_integrable:
  1397   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1397   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1398   shows "simple_bochner_integrable M f \<Longrightarrow> integrable M f"
  1398   shows "simple_bochner_integrable M f \<Longrightarrow> integrable M f"
  1399   by (intro integrableI_sequence[where s="\<lambda>_. f"] borel_measurable_simple_function)
  1399   by (intro integrableI_sequence[where s="\<lambda>_. f"] borel_measurable_simple_function)
  1443   show "P f"
  1443   show "P f"
  1444   proof (rule lim)
  1444   proof (rule lim)
  1445     fix i
  1445     fix i
  1446 
  1446 
  1447     have "(\<integral>\<^sup>+x. norm (s' i x) \<partial>M) \<le> (\<integral>\<^sup>+x. 2 * ereal (norm (f x)) \<partial>M)"
  1447     have "(\<integral>\<^sup>+x. norm (s' i x) \<partial>M) \<le> (\<integral>\<^sup>+x. 2 * ereal (norm (f x)) \<partial>M)"
  1448       using s by (intro positive_integral_mono) (auto simp: s'_eq_s)
  1448       using s by (intro nn_integral_mono) (auto simp: s'_eq_s)
  1449     also have "\<dots> < \<infinity>"
  1449     also have "\<dots> < \<infinity>"
  1450       using f by (subst positive_integral_cmult) auto
  1450       using f by (subst nn_integral_cmult) auto
  1451     finally have sbi: "simple_bochner_integrable M (s' i)"
  1451     finally have sbi: "simple_bochner_integrable M (s' i)"
  1452       using sf by (intro simple_bochner_integrableI_bounded) auto
  1452       using sf by (intro simple_bochner_integrableI_bounded) auto
  1453     then show "integrable M (s' i)"
  1453     then show "integrable M (s' i)"
  1454       by (rule integrableI_simple_bochner_integrable)
  1454       by (rule integrableI_simple_bochner_integrable)
  1455 
  1455 
  1473   fixes f :: "'a \<Rightarrow> real"
  1473   fixes f :: "'a \<Rightarrow> real"
  1474   assumes [measurable]: "integrable M f" "AE x in M. 0 \<le> f x"
  1474   assumes [measurable]: "integrable M f" "AE x in M. 0 \<le> f x"
  1475   shows "0 \<le> integral\<^sup>L M f"
  1475   shows "0 \<le> integral\<^sup>L M f"
  1476 proof -
  1476 proof -
  1477   have "0 \<le> ereal (integral\<^sup>L M (\<lambda>x. max 0 (f x)))"
  1477   have "0 \<le> ereal (integral\<^sup>L M (\<lambda>x. max 0 (f x)))"
  1478     by (subst integral_eq_positive_integral)
  1478     by (subst integral_eq_nn_integral)
  1479        (auto intro: real_of_ereal_pos positive_integral_positive integrable_max assms)
  1479        (auto intro: real_of_ereal_pos nn_integral_nonneg integrable_max assms)
  1480   also have "integral\<^sup>L M (\<lambda>x. max 0 (f x)) = integral\<^sup>L M f"
  1480   also have "integral\<^sup>L M (\<lambda>x. max 0 (f x)) = integral\<^sup>L M f"
  1481     using assms(2) by (intro integral_cong_AE assms integrable_max) auto
  1481     using assms(2) by (intro integral_cong_AE assms integrable_max) auto
  1482   finally show ?thesis
  1482   finally show ?thesis
  1483     by simp
  1483     by simp
  1484 qed
  1484 qed
  1491   fixes f :: "_ \<Rightarrow> real"
  1491   fixes f :: "_ \<Rightarrow> real"
  1492   assumes f[measurable]: "integrable M f" and nonneg: "AE x in M. 0 \<le> f x"
  1492   assumes f[measurable]: "integrable M f" and nonneg: "AE x in M. 0 \<le> f x"
  1493   shows "integral\<^sup>L M f = 0 \<longleftrightarrow> (AE x in M. f x = 0)"
  1493   shows "integral\<^sup>L M f = 0 \<longleftrightarrow> (AE x in M. f x = 0)"
  1494 proof
  1494 proof
  1495   assume "integral\<^sup>L M f = 0"
  1495   assume "integral\<^sup>L M f = 0"
  1496   then have "integral\<^sup>P M f = 0"
  1496   then have "integral\<^sup>N M f = 0"
  1497     using positive_integral_eq_integral[OF f nonneg] by simp
  1497     using nn_integral_eq_integral[OF f nonneg] by simp
  1498   then have "AE x in M. ereal (f x) \<le> 0"
  1498   then have "AE x in M. ereal (f x) \<le> 0"
  1499     by (simp add: positive_integral_0_iff_AE)
  1499     by (simp add: nn_integral_0_iff_AE)
  1500   with nonneg show "AE x in M. f x = 0"
  1500   with nonneg show "AE x in M. f x = 0"
  1501     by auto
  1501     by auto
  1502 qed (auto simp add: integral_eq_zero_AE)
  1502 qed (auto simp add: integral_eq_zero_AE)
  1503 
  1503 
  1504 lemma integral_mono_AE:
  1504 lemma integral_mono_AE:
  1525   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and g :: "'a \<Rightarrow> real"
  1525   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and g :: "'a \<Rightarrow> real"
  1526   assumes [measurable]: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
  1526   assumes [measurable]: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
  1527     and nn: "AE x in M. 0 \<le> g x"
  1527     and nn: "AE x in M. 0 \<le> g x"
  1528   shows "integrable (density M g) f \<longleftrightarrow> integrable M (\<lambda>x. g x *\<^sub>R f x)"
  1528   shows "integrable (density M g) f \<longleftrightarrow> integrable M (\<lambda>x. g x *\<^sub>R f x)"
  1529   unfolding integrable_iff_bounded using nn
  1529   unfolding integrable_iff_bounded using nn
  1530   apply (simp add: positive_integral_density )
  1530   apply (simp add: nn_integral_density )
  1531   apply (intro arg_cong2[where f="op ="] refl positive_integral_cong_AE)
  1531   apply (intro arg_cong2[where f="op ="] refl nn_integral_cong_AE)
  1532   apply auto
  1532   apply auto
  1533   done
  1533   done
  1534 
  1534 
  1535 lemma integral_density:
  1535 lemma integral_density:
  1536   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and g :: "'a \<Rightarrow> real"
  1536   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and g :: "'a \<Rightarrow> real"
  1545     then have [measurable]: "A \<in> sets M" by auto
  1545     then have [measurable]: "A \<in> sets M" by auto
  1546   
  1546   
  1547     have int: "integrable M (\<lambda>x. g x * indicator A x)"
  1547     have int: "integrable M (\<lambda>x. g x * indicator A x)"
  1548       using g base integrable_density[of "indicator A :: 'a \<Rightarrow> real" M g] by simp
  1548       using g base integrable_density[of "indicator A :: 'a \<Rightarrow> real" M g] by simp
  1549     then have "integral\<^sup>L M (\<lambda>x. g x * indicator A x) = (\<integral>\<^sup>+ x. ereal (g x * indicator A x) \<partial>M)"
  1549     then have "integral\<^sup>L M (\<lambda>x. g x * indicator A x) = (\<integral>\<^sup>+ x. ereal (g x * indicator A x) \<partial>M)"
  1550       using g by (subst positive_integral_eq_integral) auto
  1550       using g by (subst nn_integral_eq_integral) auto
  1551     also have "\<dots> = (\<integral>\<^sup>+ x. ereal (g x) * indicator A x \<partial>M)"
  1551     also have "\<dots> = (\<integral>\<^sup>+ x. ereal (g x) * indicator A x \<partial>M)"
  1552       by (intro positive_integral_cong) (auto split: split_indicator)
  1552       by (intro nn_integral_cong) (auto split: split_indicator)
  1553     also have "\<dots> = emeasure (density M g) A"
  1553     also have "\<dots> = emeasure (density M g) A"
  1554       by (rule emeasure_density[symmetric]) auto
  1554       by (rule emeasure_density[symmetric]) auto
  1555     also have "\<dots> = ereal (measure (density M g) A)"
  1555     also have "\<dots> = ereal (measure (density M g) A)"
  1556       using base by (auto intro: emeasure_eq_ereal_measure)
  1556       using base by (auto intro: emeasure_eq_ereal_measure)
  1557     also have "\<dots> = integral\<^sup>L (density M g) (indicator A)"
  1557     also have "\<dots> = integral\<^sup>L (density M g) (indicator A)"
  1605 
  1605 
  1606 lemma integrable_distr_eq:
  1606 lemma integrable_distr_eq:
  1607   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1607   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1608   assumes [measurable]: "g \<in> measurable M N" "f \<in> borel_measurable N"
  1608   assumes [measurable]: "g \<in> measurable M N" "f \<in> borel_measurable N"
  1609   shows "integrable (distr M N g) f \<longleftrightarrow> integrable M (\<lambda>x. f (g x))"
  1609   shows "integrable (distr M N g) f \<longleftrightarrow> integrable M (\<lambda>x. f (g x))"
  1610   unfolding integrable_iff_bounded by (simp_all add: positive_integral_distr)
  1610   unfolding integrable_iff_bounded by (simp_all add: nn_integral_distr)
  1611 
  1611 
  1612 lemma integrable_distr:
  1612 lemma integrable_distr:
  1613   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1613   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1614   shows "T \<in> measurable M M' \<Longrightarrow> integrable (distr M M' T) f \<Longrightarrow> integrable M (\<lambda>x. f (T x))"
  1614   shows "T \<in> measurable M M' \<Longrightarrow> integrable (distr M M' T) f \<Longrightarrow> integrable M (\<lambda>x. f (T x))"
  1615   by (subst integrable_distr_eq[symmetric, where g=T])
  1615   by (subst integrable_distr_eq[symmetric, where g=T])
  1676 subsection {* Lebesgue integration on @{const count_space} *}
  1676 subsection {* Lebesgue integration on @{const count_space} *}
  1677 
  1677 
  1678 lemma integrable_count_space:
  1678 lemma integrable_count_space:
  1679   fixes f :: "'a \<Rightarrow> 'b::{banach,second_countable_topology}"
  1679   fixes f :: "'a \<Rightarrow> 'b::{banach,second_countable_topology}"
  1680   shows "finite X \<Longrightarrow> integrable (count_space X) f"
  1680   shows "finite X \<Longrightarrow> integrable (count_space X) f"
  1681   by (auto simp: positive_integral_count_space integrable_iff_bounded)
  1681   by (auto simp: nn_integral_count_space integrable_iff_bounded)
  1682 
  1682 
  1683 lemma measure_count_space[simp]:
  1683 lemma measure_count_space[simp]:
  1684   "B \<subseteq> A \<Longrightarrow> finite B \<Longrightarrow> measure (count_space A) B = card B"
  1684   "B \<subseteq> A \<Longrightarrow> finite B \<Longrightarrow> measure (count_space A) B = card B"
  1685   unfolding measure_def by (subst emeasure_count_space ) auto
  1685   unfolding measure_def by (subst emeasure_count_space ) auto
  1686 
  1686 
  1729   have "integral\<^sup>L M f = integral\<^sup>L M (\<lambda>x. max 0 (f x) - max 0 (- f x))"
  1729   have "integral\<^sup>L M f = integral\<^sup>L M (\<lambda>x. max 0 (f x) - max 0 (- f x))"
  1730     by (auto intro!: arg_cong[where f="integral\<^sup>L M"])
  1730     by (auto intro!: arg_cong[where f="integral\<^sup>L M"])
  1731   also have "\<dots> = integral\<^sup>L M (\<lambda>x. max 0 (f x)) - integral\<^sup>L M (\<lambda>x. max 0 (- f x))"
  1731   also have "\<dots> = integral\<^sup>L M (\<lambda>x. max 0 (f x)) - integral\<^sup>L M (\<lambda>x. max 0 (- f x))"
  1732     by (intro integral_diff integrable_max integrable_minus integrable_zero f)
  1732     by (intro integral_diff integrable_max integrable_minus integrable_zero f)
  1733   also have "integral\<^sup>L M (\<lambda>x. max 0 (f x)) = real (\<integral>\<^sup>+x. max 0 (f x) \<partial>M)"
  1733   also have "integral\<^sup>L M (\<lambda>x. max 0 (f x)) = real (\<integral>\<^sup>+x. max 0 (f x) \<partial>M)"
  1734     by (subst integral_eq_positive_integral[symmetric]) (auto intro!: integrable_max f)
  1734     by (subst integral_eq_nn_integral[symmetric]) (auto intro!: integrable_max f)
  1735   also have "integral\<^sup>L M (\<lambda>x. max 0 (- f x)) = real (\<integral>\<^sup>+x. max 0 (- f x) \<partial>M)"
  1735   also have "integral\<^sup>L M (\<lambda>x. max 0 (- f x)) = real (\<integral>\<^sup>+x. max 0 (- f x) \<partial>M)"
  1736     by (subst integral_eq_positive_integral[symmetric]) (auto intro!: integrable_max f)
  1736     by (subst integral_eq_nn_integral[symmetric]) (auto intro!: integrable_max f)
  1737   also have "(\<lambda>x. ereal (max 0 (f x))) = (\<lambda>x. max 0 (ereal (f x)))"
  1737   also have "(\<lambda>x. ereal (max 0 (f x))) = (\<lambda>x. max 0 (ereal (f x)))"
  1738     by (auto simp: max_def)
  1738     by (auto simp: max_def)
  1739   also have "(\<lambda>x. ereal (max 0 (- f x))) = (\<lambda>x. max 0 (- ereal (f x)))"
  1739   also have "(\<lambda>x. ereal (max 0 (- f x))) = (\<lambda>x. max 0 (- ereal (f x)))"
  1740     by (auto simp: max_def)
  1740     by (auto simp: max_def)
  1741   finally show ?thesis
  1741   finally show ?thesis
  1742     unfolding positive_integral_max_0 .
  1742     unfolding nn_integral_max_0 .
  1743 qed
  1743 qed
  1744 
  1744 
  1745 lemma real_integrable_def:
  1745 lemma real_integrable_def:
  1746   "integrable M f \<longleftrightarrow> f \<in> borel_measurable M \<and>
  1746   "integrable M f \<longleftrightarrow> f \<in> borel_measurable M \<and>
  1747     (\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity> \<and> (\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1747     (\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity> \<and> (\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1748   unfolding integrable_iff_bounded
  1748   unfolding integrable_iff_bounded
  1749 proof (safe del: notI)
  1749 proof (safe del: notI)
  1750   assume *: "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>"
  1750   assume *: "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>"
  1751   have "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1751   have "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1752     by (intro positive_integral_mono) auto
  1752     by (intro nn_integral_mono) auto
  1753   also note *
  1753   also note *
  1754   finally show "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity>"
  1754   finally show "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity>"
  1755     by simp
  1755     by simp
  1756   have "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1756   have "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<le> (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
  1757     by (intro positive_integral_mono) auto
  1757     by (intro nn_integral_mono) auto
  1758   also note *
  1758   also note *
  1759   finally show "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1759   finally show "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1760     by simp
  1760     by simp
  1761 next
  1761 next
  1762   assume [measurable]: "f \<in> borel_measurable M"
  1762   assume [measurable]: "f \<in> borel_measurable M"
  1763   assume fin: "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity>" "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1763   assume fin: "(\<integral>\<^sup>+ x. ereal (f x) \<partial>M) \<noteq> \<infinity>" "(\<integral>\<^sup>+ x. ereal (- f x) \<partial>M) \<noteq> \<infinity>"
  1764   have "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) = (\<integral>\<^sup>+ x. max 0 (ereal (f x)) + max 0 (ereal (- f x)) \<partial>M)"
  1764   have "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) = (\<integral>\<^sup>+ x. max 0 (ereal (f x)) + max 0 (ereal (- f x)) \<partial>M)"
  1765     by (intro positive_integral_cong) (auto simp: max_def)
  1765     by (intro nn_integral_cong) (auto simp: max_def)
  1766   also have"\<dots> = (\<integral>\<^sup>+ x. max 0 (ereal (f x)) \<partial>M) + (\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>M)"
  1766   also have"\<dots> = (\<integral>\<^sup>+ x. max 0 (ereal (f x)) \<partial>M) + (\<integral>\<^sup>+ x. max 0 (ereal (- f x)) \<partial>M)"
  1767     by (intro positive_integral_add) auto
  1767     by (intro nn_integral_add) auto
  1768   also have "\<dots> < \<infinity>"
  1768   also have "\<dots> < \<infinity>"
  1769     using fin by (auto simp: positive_integral_max_0)
  1769     using fin by (auto simp: nn_integral_max_0)
  1770   finally show "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) < \<infinity>" .
  1770   finally show "(\<integral>\<^sup>+ x. norm (f x) \<partial>M) < \<infinity>" .
  1771 qed
  1771 qed
  1772 
  1772 
  1773 lemma integrableD[dest]:
  1773 lemma integrableD[dest]:
  1774   assumes "integrable M f"
  1774   assumes "integrable M f"
  1780   obtains r q where
  1780   obtains r q where
  1781     "(\<integral>\<^sup>+x. ereal (f x)\<partial>M) = ereal r"
  1781     "(\<integral>\<^sup>+x. ereal (f x)\<partial>M) = ereal r"
  1782     "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M) = ereal q"
  1782     "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M) = ereal q"
  1783     "f \<in> borel_measurable M" "integral\<^sup>L M f = r - q"
  1783     "f \<in> borel_measurable M" "integral\<^sup>L M f = r - q"
  1784   using assms unfolding real_integrable_def real_lebesgue_integral_def[OF assms]
  1784   using assms unfolding real_integrable_def real_lebesgue_integral_def[OF assms]
  1785   using positive_integral_positive[of M "\<lambda>x. ereal (f x)"]
  1785   using nn_integral_nonneg[of M "\<lambda>x. ereal (f x)"]
  1786   using positive_integral_positive[of M "\<lambda>x. ereal (-f x)"]
  1786   using nn_integral_nonneg[of M "\<lambda>x. ereal (-f x)"]
  1787   by (cases rule: ereal2_cases[of "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M)" "(\<integral>\<^sup>+x. ereal (f x)\<partial>M)"]) auto
  1787   by (cases rule: ereal2_cases[of "(\<integral>\<^sup>+x. ereal (-f x)\<partial>M)" "(\<integral>\<^sup>+x. ereal (f x)\<partial>M)"]) auto
  1788 
  1788 
  1789 lemma integral_monotone_convergence_nonneg:
  1789 lemma integral_monotone_convergence_nonneg:
  1790   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  1790   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  1791   assumes i: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  1791   assumes i: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  1795     and u: "u \<in> borel_measurable M"
  1795     and u: "u \<in> borel_measurable M"
  1796   shows "integrable M u"
  1796   shows "integrable M u"
  1797   and "integral\<^sup>L M u = x"
  1797   and "integral\<^sup>L M u = x"
  1798 proof -
  1798 proof -
  1799   have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = (SUP n. (\<integral>\<^sup>+ x. ereal (f n x) \<partial>M))"
  1799   have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = (SUP n. (\<integral>\<^sup>+ x. ereal (f n x) \<partial>M))"
  1800   proof (subst positive_integral_monotone_convergence_SUP_AE[symmetric])
  1800   proof (subst nn_integral_monotone_convergence_SUP_AE[symmetric])
  1801     fix i
  1801     fix i
  1802     from mono pos show "AE x in M. ereal (f i x) \<le> ereal (f (Suc i) x) \<and> 0 \<le> ereal (f i x)"
  1802     from mono pos show "AE x in M. ereal (f i x) \<le> ereal (f (Suc i) x) \<and> 0 \<le> ereal (f i x)"
  1803       by eventually_elim (auto simp: mono_def)
  1803       by eventually_elim (auto simp: mono_def)
  1804     show "(\<lambda>x. ereal (f i x)) \<in> borel_measurable M"
  1804     show "(\<lambda>x. ereal (f i x)) \<in> borel_measurable M"
  1805       using i by auto
  1805       using i by auto
  1806   next
  1806   next
  1807     show "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = \<integral>\<^sup>+ x. (SUP i. ereal (f i x)) \<partial>M"
  1807     show "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = \<integral>\<^sup>+ x. (SUP i. ereal (f i x)) \<partial>M"
  1808       apply (rule positive_integral_cong_AE)
  1808       apply (rule nn_integral_cong_AE)
  1809       using lim mono
  1809       using lim mono
  1810       by eventually_elim (simp add: SUP_eq_LIMSEQ[THEN iffD2])
  1810       by eventually_elim (simp add: SUP_eq_LIMSEQ[THEN iffD2])
  1811   qed
  1811   qed
  1812   also have "\<dots> = ereal x"
  1812   also have "\<dots> = ereal x"
  1813     using mono i unfolding positive_integral_eq_integral[OF i pos]
  1813     using mono i unfolding nn_integral_eq_integral[OF i pos]
  1814     by (subst SUP_eq_LIMSEQ) (auto simp: mono_def intro!: integral_mono_AE ilim)
  1814     by (subst SUP_eq_LIMSEQ) (auto simp: mono_def intro!: integral_mono_AE ilim)
  1815   finally have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = ereal x" .
  1815   finally have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = ereal x" .
  1816   moreover have "(\<integral>\<^sup>+ x. ereal (- u x) \<partial>M) = 0"
  1816   moreover have "(\<integral>\<^sup>+ x. ereal (- u x) \<partial>M) = 0"
  1817   proof (subst positive_integral_0_iff_AE)
  1817   proof (subst nn_integral_0_iff_AE)
  1818     show "(\<lambda>x. ereal (- u x)) \<in> borel_measurable M"
  1818     show "(\<lambda>x. ereal (- u x)) \<in> borel_measurable M"
  1819       using u by auto
  1819       using u by auto
  1820     from mono pos[of 0] lim show "AE x in M. ereal (- u x) \<le> 0"
  1820     from mono pos[of 0] lim show "AE x in M. ereal (- u x) \<le> 0"
  1821     proof eventually_elim
  1821     proof eventually_elim
  1822       fix x assume "mono (\<lambda>n. f n x)" "0 \<le> f 0 x" "(\<lambda>i. f i x) ----> u x"
  1822       fix x assume "mono (\<lambda>n. f n x)" "0 \<le> f 0 x" "(\<lambda>i. f i x) ----> u x"
  1863   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1863   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1864   assumes f[measurable]: "integrable M f"
  1864   assumes f[measurable]: "integrable M f"
  1865   shows "(\<integral>x. norm (f x) \<partial>M) = 0 \<longleftrightarrow> emeasure M {x\<in>space M. f x \<noteq> 0} = 0"
  1865   shows "(\<integral>x. norm (f x) \<partial>M) = 0 \<longleftrightarrow> emeasure M {x\<in>space M. f x \<noteq> 0} = 0"
  1866 proof -
  1866 proof -
  1867   have "(\<integral>\<^sup>+x. norm (f x) \<partial>M) = (\<integral>x. norm (f x) \<partial>M)"
  1867   have "(\<integral>\<^sup>+x. norm (f x) \<partial>M) = (\<integral>x. norm (f x) \<partial>M)"
  1868     using f by (intro positive_integral_eq_integral integrable_norm) auto
  1868     using f by (intro nn_integral_eq_integral integrable_norm) auto
  1869   then have "(\<integral>x. norm (f x) \<partial>M) = 0 \<longleftrightarrow> (\<integral>\<^sup>+x. norm (f x) \<partial>M) = 0"
  1869   then have "(\<integral>x. norm (f x) \<partial>M) = 0 \<longleftrightarrow> (\<integral>\<^sup>+x. norm (f x) \<partial>M) = 0"
  1870     by simp
  1870     by simp
  1871   also have "\<dots> \<longleftrightarrow> emeasure M {x\<in>space M. ereal (norm (f x)) \<noteq> 0} = 0"
  1871   also have "\<dots> \<longleftrightarrow> emeasure M {x\<in>space M. ereal (norm (f x)) \<noteq> 0} = 0"
  1872     by (intro positive_integral_0_iff) auto
  1872     by (intro nn_integral_0_iff) auto
  1873   finally show ?thesis
  1873   finally show ?thesis
  1874     by simp
  1874     by simp
  1875 qed
  1875 qed
  1876 
  1876 
  1877 lemma integral_0_iff:
  1877 lemma integral_0_iff:
  1915       using eq int by simp
  1915       using eq int by simp
  1916     finally have "(emeasure M) {x \<in> space M. Y x - X x \<noteq> 0} = 0"
  1916     finally have "(emeasure M) {x \<in> space M. Y x - X x \<noteq> 0} = 0"
  1917       using int by (simp add: integral_0_iff)
  1917       using int by (simp add: integral_0_iff)
  1918     moreover
  1918     moreover
  1919     have "(\<integral>\<^sup>+x. indicator A x \<partial>M) \<le> (\<integral>\<^sup>+x. indicator {x \<in> space M. Y x - X x \<noteq> 0} x \<partial>M)"
  1919     have "(\<integral>\<^sup>+x. indicator A x \<partial>M) \<le> (\<integral>\<^sup>+x. indicator {x \<in> space M. Y x - X x \<noteq> 0} x \<partial>M)"
  1920       using A by (intro positive_integral_mono_AE) auto
  1920       using A by (intro nn_integral_mono_AE) auto
  1921     then have "(emeasure M) A \<le> (emeasure M) {x \<in> space M. Y x - X x \<noteq> 0}"
  1921     then have "(emeasure M) A \<le> (emeasure M) {x \<in> space M. Y x - X x \<noteq> 0}"
  1922       using int A by (simp add: integrable_def)
  1922       using int A by (simp add: integrable_def)
  1923     ultimately have "emeasure M A = 0"
  1923     ultimately have "emeasure M A = 0"
  1924       using emeasure_nonneg[of M A] by simp
  1924       using emeasure_nonneg[of M A] by simp
  1925     with `(emeasure M) A \<noteq> 0` show False by auto
  1925     with `(emeasure M) A \<noteq> 0` show False by auto
  2219           then show "simple_function M (\<lambda>y. s i (x, y))"
  2219           then show "simple_function M (\<lambda>y. s i (x, y))"
  2220             using simple_functionD(1)[OF s(1), of i] x
  2220             using simple_functionD(1)[OF s(1), of i] x
  2221             by (intro simple_function_borel_measurable)
  2221             by (intro simple_function_borel_measurable)
  2222                (auto simp: space_pair_measure dest: finite_subset)
  2222                (auto simp: space_pair_measure dest: finite_subset)
  2223           have "(\<integral>\<^sup>+ y. ereal (norm (s i (x, y))) \<partial>M) \<le> (\<integral>\<^sup>+ y. 2 * norm (f x y) \<partial>M)"
  2223           have "(\<integral>\<^sup>+ y. ereal (norm (s i (x, y))) \<partial>M) \<le> (\<integral>\<^sup>+ y. 2 * norm (f x y) \<partial>M)"
  2224             using x s by (intro positive_integral_mono) auto
  2224             using x s by (intro nn_integral_mono) auto
  2225           also have "(\<integral>\<^sup>+ y. 2 * norm (f x y) \<partial>M) < \<infinity>"
  2225           also have "(\<integral>\<^sup>+ y. 2 * norm (f x y) \<partial>M) < \<infinity>"
  2226             using int_2f by (simp add: integrable_iff_bounded)
  2226             using int_2f by (simp add: integrable_iff_bounded)
  2227           finally show "(\<integral>\<^sup>+ xa. ereal (norm (s i (x, xa))) \<partial>M) < \<infinity>" .
  2227           finally show "(\<integral>\<^sup>+ xa. ereal (norm (s i (x, xa))) \<partial>M) < \<infinity>" .
  2228         qed
  2228         qed
  2229         then have "integral\<^sup>L M (\<lambda>y. s i (x, y)) = simple_bochner_integral M (\<lambda>y. s i (x, y))"
  2229         then have "integral\<^sup>L M (\<lambda>y. s i (x, y)) = simple_bochner_integral M (\<lambda>y. s i (x, y))"
  2274 proof -
  2274 proof -
  2275   from M2.emeasure_pair_measure_alt[OF A] finite
  2275   from M2.emeasure_pair_measure_alt[OF A] finite
  2276   have "(\<integral>\<^sup>+ x. emeasure M2 (Pair x -` A) \<partial>M1) \<noteq> \<infinity>"
  2276   have "(\<integral>\<^sup>+ x. emeasure M2 (Pair x -` A) \<partial>M1) \<noteq> \<infinity>"
  2277     by simp
  2277     by simp
  2278   then have "AE x in M1. emeasure M2 (Pair x -` A) \<noteq> \<infinity>"
  2278   then have "AE x in M1. emeasure M2 (Pair x -` A) \<noteq> \<infinity>"
  2279     by (rule positive_integral_PInf_AE[rotated]) (intro M2.measurable_emeasure_Pair A)
  2279     by (rule nn_integral_PInf_AE[rotated]) (intro M2.measurable_emeasure_Pair A)
  2280   moreover have "\<And>x. x \<in> space M1 \<Longrightarrow> Pair x -` A = {y\<in>space M2. (x, y) \<in> A}"
  2280   moreover have "\<And>x. x \<in> space M1 \<Longrightarrow> Pair x -` A = {y\<in>space M2. (x, y) \<in> A}"
  2281     using sets.sets_into_space[OF A] by (auto simp: space_pair_measure)
  2281     using sets.sets_into_space[OF A] by (auto simp: space_pair_measure)
  2282   ultimately show ?thesis by auto
  2282   ultimately show ?thesis by auto
  2283 qed
  2283 qed
  2284 
  2284 
  2286   fixes f :: "_ \<Rightarrow> _::{banach, second_countable_topology}"
  2286   fixes f :: "_ \<Rightarrow> _::{banach, second_countable_topology}"
  2287   assumes f[measurable]: "integrable (M1 \<Otimes>\<^sub>M M2) f"
  2287   assumes f[measurable]: "integrable (M1 \<Otimes>\<^sub>M M2) f"
  2288   shows "AE x in M1. integrable M2 (\<lambda>y. f (x, y))"
  2288   shows "AE x in M1. integrable M2 (\<lambda>y. f (x, y))"
  2289 proof -
  2289 proof -
  2290   have "(\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1) = (\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2290   have "(\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1) = (\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2291     by (rule M2.positive_integral_fst) simp
  2291     by (rule M2.nn_integral_fst) simp
  2292   also have "(\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2)) \<noteq> \<infinity>"
  2292   also have "(\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2)) \<noteq> \<infinity>"
  2293     using f unfolding integrable_iff_bounded by simp
  2293     using f unfolding integrable_iff_bounded by simp
  2294   finally have "AE x in M1. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<noteq> \<infinity>"
  2294   finally have "AE x in M1. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<noteq> \<infinity>"
  2295     by (intro positive_integral_PInf_AE M2.borel_measurable_positive_integral )
  2295     by (intro nn_integral_PInf_AE M2.borel_measurable_nn_integral )
  2296        (auto simp: measurable_split_conv)
  2296        (auto simp: measurable_split_conv)
  2297   with AE_space show ?thesis
  2297   with AE_space show ?thesis
  2298     by eventually_elim
  2298     by eventually_elim
  2299        (auto simp: integrable_iff_bounded measurable_compose[OF _ borel_measurable_integrable[OF f]])
  2299        (auto simp: integrable_iff_bounded measurable_compose[OF _ borel_measurable_integrable[OF f]])
  2300 qed
  2300 qed
  2306   unfolding integrable_iff_bounded
  2306   unfolding integrable_iff_bounded
  2307 proof
  2307 proof
  2308   show "(\<lambda>x. \<integral> y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
  2308   show "(\<lambda>x. \<integral> y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
  2309     by (rule M2.borel_measurable_lebesgue_integral) simp
  2309     by (rule M2.borel_measurable_lebesgue_integral) simp
  2310   have "(\<integral>\<^sup>+ x. ereal (norm (\<integral> y. f (x, y) \<partial>M2)) \<partial>M1) \<le> (\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1)"
  2310   have "(\<integral>\<^sup>+ x. ereal (norm (\<integral> y. f (x, y) \<partial>M2)) \<partial>M1) \<le> (\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1)"
  2311     using AE_integrable_fst'[OF f] by (auto intro!: positive_integral_mono_AE integral_norm_bound_ereal)
  2311     using AE_integrable_fst'[OF f] by (auto intro!: nn_integral_mono_AE integral_norm_bound_ereal)
  2312   also have "(\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1) = (\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2312   also have "(\<integral>\<^sup>+x. (\<integral>\<^sup>+y. norm (f (x, y)) \<partial>M2) \<partial>M1) = (\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2313     by (rule M2.positive_integral_fst) simp
  2313     by (rule M2.nn_integral_fst) simp
  2314   also have "(\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2)) < \<infinity>"
  2314   also have "(\<integral>\<^sup>+x. norm (f x) \<partial>(M1 \<Otimes>\<^sub>M M2)) < \<infinity>"
  2315     using f unfolding integrable_iff_bounded by simp
  2315     using f unfolding integrable_iff_bounded by simp
  2316   finally show "(\<integral>\<^sup>+ x. ereal (norm (\<integral> y. f (x, y) \<partial>M2)) \<partial>M1) < \<infinity>" .
  2316   finally show "(\<integral>\<^sup>+ x. ereal (norm (\<integral> y. f (x, y) \<partial>M2)) \<partial>M1) < \<infinity>" .
  2317 qed
  2317 qed
  2318 
  2318 
  2339   also have "\<dots> = measure (M1 \<Otimes>\<^sub>M M2) A *\<^sub>R c"
  2339   also have "\<dots> = measure (M1 \<Otimes>\<^sub>M M2) A *\<^sub>R c"
  2340   proof (subst integral_scaleR_left)
  2340   proof (subst integral_scaleR_left)
  2341     have "(\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1) =
  2341     have "(\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1) =
  2342       (\<integral>\<^sup>+x. emeasure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1)"
  2342       (\<integral>\<^sup>+x. emeasure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1)"
  2343       using emeasure_pair_measure_finite[OF base]
  2343       using emeasure_pair_measure_finite[OF base]
  2344       by (intro positive_integral_cong_AE, eventually_elim) (simp add: emeasure_eq_ereal_measure)
  2344       by (intro nn_integral_cong_AE, eventually_elim) (simp add: emeasure_eq_ereal_measure)
  2345     also have "\<dots> = emeasure (M1 \<Otimes>\<^sub>M M2) A"
  2345     also have "\<dots> = emeasure (M1 \<Otimes>\<^sub>M M2) A"
  2346       using sets.sets_into_space[OF A]
  2346       using sets.sets_into_space[OF A]
  2347       by (subst M2.emeasure_pair_measure_alt)
  2347       by (subst M2.emeasure_pair_measure_alt)
  2348          (auto intro!: positive_integral_cong arg_cong[where f="emeasure M2"] simp: space_pair_measure)
  2348          (auto intro!: nn_integral_cong arg_cong[where f="emeasure M2"] simp: space_pair_measure)
  2349     finally have *: "(\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1) = emeasure (M1 \<Otimes>\<^sub>M M2) A" .
  2349     finally have *: "(\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1) = emeasure (M1 \<Otimes>\<^sub>M M2) A" .
  2350 
  2350 
  2351     from base * show "integrable M1 (\<lambda>x. measure M2 {y \<in> space M2. (x, y) \<in> A})"
  2351     from base * show "integrable M1 (\<lambda>x. measure M2 {y \<in> space M2. (x, y) \<in> A})"
  2352       by (simp add: measure_nonneg integrable_iff_bounded)
  2352       by (simp add: measure_nonneg integrable_iff_bounded)
  2353     then have "(\<integral>x. measure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1) = 
  2353     then have "(\<integral>x. measure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1) = 
  2354       (\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1)"
  2354       (\<integral>\<^sup>+x. ereal (measure M2 {y \<in> space M2. (x, y) \<in> A}) \<partial>M1)"
  2355       by (rule positive_integral_eq_integral[symmetric]) (simp add: measure_nonneg)
  2355       by (rule nn_integral_eq_integral[symmetric]) (simp add: measure_nonneg)
  2356     also note *
  2356     also note *
  2357     finally show "(\<integral>x. measure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1) *\<^sub>R c = measure (M1 \<Otimes>\<^sub>M M2) A *\<^sub>R c"
  2357     finally show "(\<integral>x. measure M2 {y \<in> space M2. (x, y) \<in> A} \<partial>M1) *\<^sub>R c = measure (M1 \<Otimes>\<^sub>M M2) A *\<^sub>R c"
  2358       using base by (simp add: emeasure_eq_ereal_measure)
  2358       using base by (simp add: emeasure_eq_ereal_measure)
  2359   qed
  2359   qed
  2360   also have "\<dots> = (\<integral> a. indicator A a *\<^sub>R c \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2360   also have "\<dots> = (\<integral> a. indicator A a *\<^sub>R c \<partial>(M1 \<Otimes>\<^sub>M M2))"
  2415         fix x assume x: "x \<in> space M1"
  2415         fix x assume x: "x \<in> space M1"
  2416           and s: "integrable M2 (\<lambda>y. s i (x, y))" and f: "integrable M2 (\<lambda>y. f (x, y))"
  2416           and s: "integrable M2 (\<lambda>y. s i (x, y))" and f: "integrable M2 (\<lambda>y. f (x, y))"
  2417         from s have "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral>\<^sup>+y. norm (s i (x, y)) \<partial>M2)"
  2417         from s have "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral>\<^sup>+y. norm (s i (x, y)) \<partial>M2)"
  2418           by (rule integral_norm_bound_ereal)
  2418           by (rule integral_norm_bound_ereal)
  2419         also have "\<dots> \<le> (\<integral>\<^sup>+y. 2 * norm (f (x, y)) \<partial>M2)"
  2419         also have "\<dots> \<le> (\<integral>\<^sup>+y. 2 * norm (f (x, y)) \<partial>M2)"
  2420           using x lim by (auto intro!: positive_integral_mono simp: space_pair_measure)
  2420           using x lim by (auto intro!: nn_integral_mono simp: space_pair_measure)
  2421         also have "\<dots> = (\<integral>y. 2 * norm (f (x, y)) \<partial>M2)"
  2421         also have "\<dots> = (\<integral>y. 2 * norm (f (x, y)) \<partial>M2)"
  2422           using f by (intro positive_integral_eq_integral) auto
  2422           using f by (intro nn_integral_eq_integral) auto
  2423         finally show "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral> y. 2 * norm (f (x, y)) \<partial>M2)"
  2423         finally show "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral> y. 2 * norm (f (x, y)) \<partial>M2)"
  2424           by simp
  2424           by simp
  2425       qed
  2425       qed
  2426     qed simp_all
  2426     qed simp_all
  2427     then show "(\<lambda>i. integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) (s i)) ----> \<integral> x. \<integral> y. f (x, y) \<partial>M2 \<partial>M1"
  2427     then show "(\<lambda>i. integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) (s i)) ----> \<integral> x. \<integral> y. f (x, y) \<partial>M2 \<partial>M1"
  2528     using assms by simp
  2528     using assms by simp
  2529   have "(\<integral>\<^sup>+ x. ereal (norm (\<Prod>i\<in>I. f i (x i))) \<partial>Pi\<^sub>M I M) = 
  2529   have "(\<integral>\<^sup>+ x. ereal (norm (\<Prod>i\<in>I. f i (x i))) \<partial>Pi\<^sub>M I M) = 
  2530       (\<integral>\<^sup>+ x. (\<Prod>i\<in>I. ereal (norm (f i (x i)))) \<partial>Pi\<^sub>M I M)"
  2530       (\<integral>\<^sup>+ x. (\<Prod>i\<in>I. ereal (norm (f i (x i)))) \<partial>Pi\<^sub>M I M)"
  2531     by (simp add: setprod_norm setprod_ereal)
  2531     by (simp add: setprod_norm setprod_ereal)
  2532   also have "\<dots> = (\<Prod>i\<in>I. \<integral>\<^sup>+ x. ereal (norm (f i x)) \<partial>M i)"
  2532   also have "\<dots> = (\<Prod>i\<in>I. \<integral>\<^sup>+ x. ereal (norm (f i x)) \<partial>M i)"
  2533     using assms by (intro product_positive_integral_setprod) auto
  2533     using assms by (intro product_nn_integral_setprod) auto
  2534   also have "\<dots> < \<infinity>"
  2534   also have "\<dots> < \<infinity>"
  2535     using integrable by (simp add: setprod_PInf positive_integral_positive integrable_iff_bounded)
  2535     using integrable by (simp add: setprod_PInf nn_integral_nonneg integrable_iff_bounded)
  2536   finally show "(\<integral>\<^sup>+ x. ereal (norm (\<Prod>i\<in>I. f i (x i))) \<partial>Pi\<^sub>M I M) < \<infinity>" .
  2536   finally show "(\<integral>\<^sup>+ x. ereal (norm (\<Prod>i\<in>I. f i (x i))) \<partial>Pi\<^sub>M I M) < \<infinity>" .
  2537 qed
  2537 qed
  2538 
  2538 
  2539 lemma (in product_sigma_finite) product_integral_setprod:
  2539 lemma (in product_sigma_finite) product_integral_setprod:
  2540   fixes f :: "'i \<Rightarrow> 'a \<Rightarrow> _::{real_normed_field,banach,second_countable_topology}"
  2540   fixes f :: "'i \<Rightarrow> 'a \<Rightarrow> _::{real_normed_field,banach,second_countable_topology}"
  2566   shows "integrable N f \<longleftrightarrow> integrable M f" (is ?P)
  2566   shows "integrable N f \<longleftrightarrow> integrable M f" (is ?P)
  2567 proof -
  2567 proof -
  2568   have "f \<in> borel_measurable M"
  2568   have "f \<in> borel_measurable M"
  2569     using assms by (auto simp: measurable_def)
  2569     using assms by (auto simp: measurable_def)
  2570   with assms show ?thesis
  2570   with assms show ?thesis
  2571     using assms by (auto simp: integrable_iff_bounded positive_integral_subalgebra)
  2571     using assms by (auto simp: integrable_iff_bounded nn_integral_subalgebra)
  2572 qed
  2572 qed
  2573 
  2573 
  2574 lemma integral_subalgebra:
  2574 lemma integral_subalgebra:
  2575   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  2575   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  2576   assumes borel: "f \<in> borel_measurable N"
  2576   assumes borel: "f \<in> borel_measurable N"