src/HOL/Probability/Bochner_Integration.thy
changeset 61969 e01015e49041
parent 61945 1135b8de26c3
child 61973 0c7e865fa7cb
equal deleted inserted replaced
61968:e13e70f32407 61969:e01015e49041
    16 \<close>
    16 \<close>
    17 
    17 
    18 lemma borel_measurable_implies_sequence_metric:
    18 lemma borel_measurable_implies_sequence_metric:
    19   fixes f :: "'a \<Rightarrow> 'b :: {metric_space, second_countable_topology}"
    19   fixes f :: "'a \<Rightarrow> 'b :: {metric_space, second_countable_topology}"
    20   assumes [measurable]: "f \<in> borel_measurable M"
    20   assumes [measurable]: "f \<in> borel_measurable M"
    21   shows "\<exists>F. (\<forall>i. simple_function M (F i)) \<and> (\<forall>x\<in>space M. (\<lambda>i. F i x) ----> f x) \<and>
    21   shows "\<exists>F. (\<forall>i. simple_function M (F i)) \<and> (\<forall>x\<in>space M. (\<lambda>i. F i x) \<longlonglongrightarrow> f x) \<and>
    22     (\<forall>i. \<forall>x\<in>space M. dist (F i x) z \<le> 2 * dist (f x) z)"
    22     (\<forall>i. \<forall>x\<in>space M. dist (F i x) z \<le> 2 * dist (f x) z)"
    23 proof -
    23 proof -
    24   obtain D :: "'b set" where "countable D" and D: "\<And>X. open X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> \<exists>d\<in>D. d \<in> X"
    24   obtain D :: "'b set" where "countable D" and D: "\<And>X. open X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> \<exists>d\<in>D. d \<in> X"
    25     by (erule countable_dense_setE)
    25     by (erule countable_dense_setE)
    26 
    26 
    99       ultimately have "dist (f x) (F N x) < 1 / Suc (m N x)"
    99       ultimately have "dist (f x) (F N x) < 1 / Suc (m N x)"
   100         by (auto simp add: F_def L_def) }
   100         by (auto simp add: F_def L_def) }
   101     note * = this
   101     note * = this
   102 
   102 
   103     fix x assume "x \<in> space M"
   103     fix x assume "x \<in> space M"
   104     show "(\<lambda>i. F i x) ----> f x"
   104     show "(\<lambda>i. F i x) \<longlonglongrightarrow> f x"
   105     proof cases
   105     proof cases
   106       assume "f x = z"
   106       assume "f x = z"
   107       then have "\<And>i n. x \<notin> A i n"
   107       then have "\<And>i n. x \<notin> A i n"
   108         unfolding A_def by auto
   108         unfolding A_def by auto
   109       then have "\<And>i. F i x = z"
   109       then have "\<And>i. F i x = z"
   171   fixes P :: "('a \<Rightarrow> real) \<Rightarrow> bool"
   171   fixes P :: "('a \<Rightarrow> real) \<Rightarrow> bool"
   172   assumes u: "u \<in> borel_measurable M" "\<And>x. 0 \<le> u x"
   172   assumes u: "u \<in> borel_measurable M" "\<And>x. 0 \<le> u x"
   173   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   173   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   174   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   174   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   175   assumes add: "\<And>u v. u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> v \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> u x = 0 \<or> v x = 0) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   175   assumes add: "\<And>u v. u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> v \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> u x = 0 \<or> v x = 0) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   176   assumes seq: "\<And>U. (\<And>i. U i \<in> borel_measurable M) \<Longrightarrow> (\<And>i x. 0 \<le> U i x) \<Longrightarrow> (\<And>i. P (U i)) \<Longrightarrow> incseq U \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. U i x) ----> u x) \<Longrightarrow> P u"
   176   assumes seq: "\<And>U. (\<And>i. U i \<in> borel_measurable M) \<Longrightarrow> (\<And>i x. 0 \<le> U i x) \<Longrightarrow> (\<And>i. P (U i)) \<Longrightarrow> incseq U \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. U i x) \<longlonglongrightarrow> u x) \<Longrightarrow> P u"
   177   shows "P u"
   177   shows "P u"
   178 proof -
   178 proof -
   179   have "(\<lambda>x. ereal (u x)) \<in> borel_measurable M" using u by auto
   179   have "(\<lambda>x. ereal (u x)) \<in> borel_measurable M" using u by auto
   180   from borel_measurable_implies_simple_function_sequence'[OF this]
   180   from borel_measurable_implies_simple_function_sequence'[OF this]
   181   obtain U where U: "\<And>i. simple_function M (U i)" "incseq U" "\<And>i. \<infinity> \<notin> range (U i)" and
   181   obtain U where U: "\<And>i. simple_function M (U i)" "incseq U" "\<And>i. \<infinity> \<notin> range (U i)" and
   197       using U(2,3) nn
   197       using U(2,3) nn
   198       by (auto simp: incseq_def le_fun_def image_iff eq_commute U'_def indicator_def
   198       by (auto simp: incseq_def le_fun_def image_iff eq_commute U'_def indicator_def
   199                intro!: real_of_ereal_positive_mono)
   199                intro!: real_of_ereal_positive_mono)
   200   next
   200   next
   201     fix x assume x: "x \<in> space M"
   201     fix x assume x: "x \<in> space M"
   202     have "(\<lambda>i. U i x) ----> (SUP i. U i x)"
   202     have "(\<lambda>i. U i x) \<longlonglongrightarrow> (SUP i. U i x)"
   203       using U(2) by (intro LIMSEQ_SUP) (auto simp: incseq_def le_fun_def)
   203       using U(2) by (intro LIMSEQ_SUP) (auto simp: incseq_def le_fun_def)
   204     moreover have "(\<lambda>i. U i x) = (\<lambda>i. ereal (U' i x))"
   204     moreover have "(\<lambda>i. U i x) = (\<lambda>i. ereal (U' i x))"
   205       using x nn U(3) by (auto simp: fun_eq_iff U'_def ereal_real image_iff eq_commute)
   205       using x nn U(3) by (auto simp: fun_eq_iff U'_def ereal_real image_iff eq_commute)
   206     moreover have "(SUP i. U i x) = ereal (u x)"
   206     moreover have "(SUP i. U i x) = ereal (u x)"
   207       using sup u(2) by (simp add: max_def)
   207       using sup u(2) by (simp add: max_def)
   208     ultimately show "(\<lambda>i. U' i x) ----> u x" 
   208     ultimately show "(\<lambda>i. U' i x) \<longlonglongrightarrow> u x" 
   209       by simp
   209       by simp
   210   next
   210   next
   211     fix i
   211     fix i
   212     have "U' i ` space M \<subseteq> real_of_ereal ` (U i ` space M)" "finite (U i ` space M)"
   212     have "U' i ` space M \<subseteq> real_of_ereal ` (U i ` space M)" "finite (U i ` space M)"
   213       unfolding U'_def using U(1) by (auto dest: simple_functionD)
   213       unfolding U'_def using U(1) by (auto dest: simple_functionD)
   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
   517   "f \<in> borel_measurable M \<Longrightarrow>
   517   "f \<in> borel_measurable M \<Longrightarrow>
   518     (\<And>i. simple_bochner_integrable M (s i)) \<Longrightarrow>
   518     (\<And>i. simple_bochner_integrable M (s i)) \<Longrightarrow>
   519     (\<lambda>i. \<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) ----> 0 \<Longrightarrow>
   519     (\<lambda>i. \<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) \<longlonglongrightarrow> 0 \<Longrightarrow>
   520     (\<lambda>i. simple_bochner_integral M (s i)) ----> x \<Longrightarrow>
   520     (\<lambda>i. simple_bochner_integral M (s i)) \<longlonglongrightarrow> x \<Longrightarrow>
   521     has_bochner_integral M f x"
   521     has_bochner_integral M f x"
   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"
   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 \<longlonglongrightarrow> 0"]
   534             nn_integral_cong_AE)
   534             nn_integral_cong_AE)
   535      auto
   535      auto
   536 
   536 
   537 lemma borel_measurable_has_bochner_integral:
   537 lemma borel_measurable_has_bochner_integral:
   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"
   570 lemma has_bochner_integral_add[intro]:
   570 lemma has_bochner_integral_add[intro]:
   571   "has_bochner_integral M f x \<Longrightarrow> has_bochner_integral M g y \<Longrightarrow>
   571   "has_bochner_integral M f x \<Longrightarrow> has_bochner_integral M g y \<Longrightarrow>
   572     has_bochner_integral M (\<lambda>x. f x + g x) (x + y)"
   572     has_bochner_integral M (\<lambda>x. f x + g x) (x + y)"
   573 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   573 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   574   fix sf sg
   574   fix sf sg
   575   assume f_sf: "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - sf i x) \<partial>M) ----> 0"
   575   assume f_sf: "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - sf i x) \<partial>M) \<longlonglongrightarrow> 0"
   576   assume g_sg: "(\<lambda>i. \<integral>\<^sup>+ x. norm (g x - sg i x) \<partial>M) ----> 0"
   576   assume g_sg: "(\<lambda>i. \<integral>\<^sup>+ x. norm (g x - sg i x) \<partial>M) \<longlonglongrightarrow> 0"
   577 
   577 
   578   assume sf: "\<forall>i. simple_bochner_integrable M (sf i)"
   578   assume sf: "\<forall>i. simple_bochner_integrable M (sf i)"
   579     and sg: "\<forall>i. simple_bochner_integrable M (sg i)"
   579     and sg: "\<forall>i. simple_bochner_integrable M (sg i)"
   580   then have [measurable]: "\<And>i. sf i \<in> borel_measurable M" "\<And>i. sg i \<in> borel_measurable M"
   580   then have [measurable]: "\<And>i. sf i \<in> borel_measurable M" "\<And>i. sg i \<in> borel_measurable M"
   581     by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   581     by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   582   assume [measurable]: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
   582   assume [measurable]: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
   583 
   583 
   584   show "\<And>i. simple_bochner_integrable M (\<lambda>x. sf i x + sg i x)"
   584   show "\<And>i. simple_bochner_integrable M (\<lambda>x. sf i x + sg i x)"
   585     using sf sg by (simp add: simple_bochner_integrable_compose2)
   585     using sf sg by (simp add: simple_bochner_integrable_compose2)
   586 
   586 
   587   show "(\<lambda>i. \<integral>\<^sup>+ x. (norm (f x + g x - (sf i x + sg i x))) \<partial>M) ----> 0"
   587   show "(\<lambda>i. \<integral>\<^sup>+ x. (norm (f x + g x - (sf i x + sg i x))) \<partial>M) \<longlonglongrightarrow> 0"
   588     (is "?f ----> 0")
   588     (is "?f \<longlonglongrightarrow> 0")
   589   proof (rule tendsto_sandwich)
   589   proof (rule tendsto_sandwich)
   590     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   590     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) \<longlonglongrightarrow> 0"
   591       by (auto simp: nn_integral_nonneg)
   591       by (auto simp: nn_integral_nonneg)
   592     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"
   592     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"
   593       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   593       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   594     proof (intro always_eventually allI)
   594     proof (intro always_eventually allI)
   595       fix i have "?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) + ereal (norm (g x - sg i x)) \<partial>M)"
   595       fix i have "?f i \<le> (\<integral>\<^sup>+ x. (norm (f x - sf i x)) + ereal (norm (g x - sg i x)) \<partial>M)"
   596         by (auto intro!: nn_integral_mono norm_diff_triangle_ineq)
   596         by (auto intro!: nn_integral_mono norm_diff_triangle_ineq)
   597       also have "\<dots> = ?g i"
   597       also have "\<dots> = ?g i"
   598         by (intro nn_integral_add) auto
   598         by (intro nn_integral_add) auto
   599       finally show "?f i \<le> ?g i" .
   599       finally show "?f i \<le> ?g i" .
   600     qed
   600     qed
   601     show "?g ----> 0"
   601     show "?g \<longlonglongrightarrow> 0"
   602       using tendsto_add_ereal[OF _ _ f_sf g_sg] by simp
   602       using tendsto_add_ereal[OF _ _ f_sf g_sg] by simp
   603   qed
   603   qed
   604 qed (auto simp: simple_bochner_integral_add tendsto_add)
   604 qed (auto simp: simple_bochner_integral_add tendsto_add)
   605 
   605 
   606 lemma has_bochner_integral_bounded_linear:
   606 lemma has_bochner_integral_bounded_linear:
   612     by (intro borel_measurable_continuous_on1 T.continuous_on continuous_on_id)
   612     by (intro borel_measurable_continuous_on1 T.continuous_on continuous_on_id)
   613   assume [measurable]: "f \<in> borel_measurable M"
   613   assume [measurable]: "f \<in> borel_measurable M"
   614   then show "(\<lambda>x. T (f x)) \<in> borel_measurable M"
   614   then show "(\<lambda>x. T (f x)) \<in> borel_measurable M"
   615     by auto
   615     by auto
   616 
   616 
   617   fix s assume f_s: "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M) ----> 0"
   617   fix s assume f_s: "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M) \<longlonglongrightarrow> 0"
   618   assume s: "\<forall>i. simple_bochner_integrable M (s i)"
   618   assume s: "\<forall>i. simple_bochner_integrable M (s i)"
   619   then show "\<And>i. simple_bochner_integrable M (\<lambda>x. T (s i x))"
   619   then show "\<And>i. simple_bochner_integrable M (\<lambda>x. T (s i x))"
   620     by (auto intro: simple_bochner_integrable_compose2 T.zero)
   620     by (auto intro: simple_bochner_integrable_compose2 T.zero)
   621 
   621 
   622   have [measurable]: "\<And>i. s i \<in> borel_measurable M"
   622   have [measurable]: "\<And>i. s i \<in> borel_measurable M"
   623     using s by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   623     using s by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   624 
   624 
   625   obtain K where K: "K > 0" "\<And>x i. norm (T (f x) - T (s i x)) \<le> norm (f x - s i x) * K"
   625   obtain K where K: "K > 0" "\<And>x i. norm (T (f x) - T (s i x)) \<le> norm (f x - s i x) * K"
   626     using T.pos_bounded by (auto simp: T.diff[symmetric])
   626     using T.pos_bounded by (auto simp: T.diff[symmetric])
   627 
   627 
   628   show "(\<lambda>i. \<integral>\<^sup>+ x. norm (T (f x) - T (s i x)) \<partial>M) ----> 0"
   628   show "(\<lambda>i. \<integral>\<^sup>+ x. norm (T (f x) - T (s i x)) \<partial>M) \<longlonglongrightarrow> 0"
   629     (is "?f ----> 0")
   629     (is "?f \<longlonglongrightarrow> 0")
   630   proof (rule tendsto_sandwich)
   630   proof (rule tendsto_sandwich)
   631     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) ----> 0"
   631     show "eventually (\<lambda>n. 0 \<le> ?f n) sequentially" "(\<lambda>_. 0) \<longlonglongrightarrow> 0"
   632       by (auto simp: nn_integral_nonneg)
   632       by (auto simp: nn_integral_nonneg)
   633 
   633 
   634     show "eventually (\<lambda>i. ?f i \<le> K * (\<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M)) sequentially"
   634     show "eventually (\<lambda>i. ?f i \<le> K * (\<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M)) sequentially"
   635       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   635       (is "eventually (\<lambda>i. ?f i \<le> ?g i) sequentially")
   636     proof (intro always_eventually allI)
   636     proof (intro always_eventually allI)
   638         using K by (intro nn_integral_mono) (auto simp: ac_simps)
   638         using K by (intro nn_integral_mono) (auto simp: ac_simps)
   639       also have "\<dots> = ?g i"
   639       also have "\<dots> = ?g i"
   640         using K by (intro nn_integral_cmult) auto
   640         using K by (intro nn_integral_cmult) auto
   641       finally show "?f i \<le> ?g i" .
   641       finally show "?f i \<le> ?g i" .
   642     qed
   642     qed
   643     show "?g ----> 0"
   643     show "?g \<longlonglongrightarrow> 0"
   644       using tendsto_cmult_ereal[OF _ f_s, of "ereal K"] by simp
   644       using tendsto_cmult_ereal[OF _ f_s, of "ereal K"] by simp
   645   qed
   645   qed
   646 
   646 
   647   assume "(\<lambda>i. simple_bochner_integral M (s i)) ----> x"
   647   assume "(\<lambda>i. simple_bochner_integral M (s i)) \<longlonglongrightarrow> x"
   648   with s show "(\<lambda>i. simple_bochner_integral M (\<lambda>x. T (s i x))) ----> T x"
   648   with s show "(\<lambda>i. simple_bochner_integral M (\<lambda>x. T (s i x))) \<longlonglongrightarrow> T x"
   649     by (auto intro!: T.tendsto simp: T.simple_bochner_integral_linear)
   649     by (auto intro!: T.tendsto simp: T.simple_bochner_integral_linear)
   650 qed
   650 qed
   651 
   651 
   652 lemma has_bochner_integral_zero[intro]: "has_bochner_integral M (\<lambda>x. 0) 0"
   652 lemma has_bochner_integral_zero[intro]: "has_bochner_integral M (\<lambda>x. 0) 0"
   653   by (auto intro!: has_bochner_integral.intros[where s="\<lambda>_ _. 0"]
   653   by (auto intro!: has_bochner_integral.intros[where s="\<lambda>_ _. 0"]
   722 lemma has_bochner_integral_implies_finite_norm:
   722 lemma has_bochner_integral_implies_finite_norm:
   723   "has_bochner_integral M f x \<Longrightarrow> (\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
   723   "has_bochner_integral M f x \<Longrightarrow> (\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
   724 proof (elim has_bochner_integral.cases)
   724 proof (elim has_bochner_integral.cases)
   725   fix s v
   725   fix s v
   726   assume [measurable]: "f \<in> borel_measurable M" and s: "\<And>i. simple_bochner_integrable M (s i)" and
   726   assume [measurable]: "f \<in> borel_measurable M" and s: "\<And>i. simple_bochner_integrable M (s i)" and
   727     lim_0: "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
   727     lim_0: "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) \<longlonglongrightarrow> 0"
   728   from order_tendstoD[OF lim_0, of "\<infinity>"]
   728   from order_tendstoD[OF lim_0, of "\<infinity>"]
   729   obtain i where f_s_fin: "(\<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) < \<infinity>"
   729   obtain i where f_s_fin: "(\<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) < \<infinity>"
   730     by (metis (mono_tags, lifting) eventually_False_sequentially eventually_mono
   730     by (metis (mono_tags, lifting) eventually_False_sequentially eventually_mono
   731               less_ereal.simps(4) zero_ereal_def)
   731               less_ereal.simps(4) zero_ereal_def)
   732 
   732 
   758 lemma has_bochner_integral_norm_bound:
   758 lemma has_bochner_integral_norm_bound:
   759   assumes i: "has_bochner_integral M f x"
   759   assumes i: "has_bochner_integral M f x"
   760   shows "norm x \<le> (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   760   shows "norm x \<le> (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   761 using assms proof
   761 using assms proof
   762   fix s assume
   762   fix s assume
   763     x: "(\<lambda>i. simple_bochner_integral M (s i)) ----> x" (is "?s ----> x") and
   763     x: "(\<lambda>i. simple_bochner_integral M (s i)) \<longlonglongrightarrow> x" (is "?s \<longlonglongrightarrow> x") and
   764     s[simp]: "\<And>i. simple_bochner_integrable M (s i)" and
   764     s[simp]: "\<And>i. simple_bochner_integrable M (s i)" and
   765     lim: "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0" and
   765     lim: "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) \<longlonglongrightarrow> 0" and
   766     f[measurable]: "f \<in> borel_measurable M"
   766     f[measurable]: "f \<in> borel_measurable M"
   767 
   767 
   768   have [measurable]: "\<And>i. s i \<in> borel_measurable M"
   768   have [measurable]: "\<And>i. s i \<in> borel_measurable M"
   769     using s by (auto simp: simple_bochner_integrable.simps intro: borel_measurable_simple_function)
   769     using s by (auto simp: simple_bochner_integrable.simps intro: borel_measurable_simple_function)
   770 
   770 
   771   show "norm x \<le> (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   771   show "norm x \<le> (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   772   proof (rule LIMSEQ_le)
   772   proof (rule LIMSEQ_le)
   773     show "(\<lambda>i. ereal (norm (?s i))) ----> norm x"
   773     show "(\<lambda>i. ereal (norm (?s i))) \<longlonglongrightarrow> norm x"
   774       using x by (intro tendsto_intros lim_ereal[THEN iffD2])
   774       using x by (intro tendsto_intros lim_ereal[THEN iffD2])
   775     show "\<exists>N. \<forall>n\<ge>N. norm (?s n) \<le> (\<integral>\<^sup>+x. norm (f x - s n x) \<partial>M) + (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   775     show "\<exists>N. \<forall>n\<ge>N. norm (?s n) \<le> (\<integral>\<^sup>+x. norm (f x - s n x) \<partial>M) + (\<integral>\<^sup>+x. norm (f x) \<partial>M)"
   776       (is "\<exists>N. \<forall>n\<ge>N. _ \<le> ?t n")
   776       (is "\<exists>N. \<forall>n\<ge>N. _ \<le> ?t n")
   777     proof (intro exI allI impI)
   777     proof (intro exI allI impI)
   778       fix n
   778       fix n
   786            (metis add.commute norm_minus_commute norm_triangle_sub)
   786            (metis add.commute norm_minus_commute norm_triangle_sub)
   787       also have "\<dots> = ?t n" 
   787       also have "\<dots> = ?t n" 
   788         by (rule nn_integral_add) auto
   788         by (rule nn_integral_add) auto
   789       finally show "norm (?s n) \<le> ?t n" .
   789       finally show "norm (?s n) \<le> ?t n" .
   790     qed
   790     qed
   791     have "?t ----> 0 + (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
   791     have "?t \<longlonglongrightarrow> 0 + (\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M)"
   792       using has_bochner_integral_implies_finite_norm[OF i]
   792       using has_bochner_integral_implies_finite_norm[OF i]
   793       by (intro tendsto_add_ereal tendsto_const lim) auto
   793       by (intro tendsto_add_ereal tendsto_const lim) auto
   794     then show "?t ----> \<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M"
   794     then show "?t \<longlonglongrightarrow> \<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M"
   795       by simp
   795       by simp
   796   qed
   796   qed
   797 qed
   797 qed
   798 
   798 
   799 lemma has_bochner_integral_eq:
   799 lemma has_bochner_integral_eq:
   800   "has_bochner_integral M f x \<Longrightarrow> has_bochner_integral M f y \<Longrightarrow> x = y"
   800   "has_bochner_integral M f x \<Longrightarrow> has_bochner_integral M f y \<Longrightarrow> x = y"
   801 proof (elim has_bochner_integral.cases)
   801 proof (elim has_bochner_integral.cases)
   802   assume f[measurable]: "f \<in> borel_measurable M"
   802   assume f[measurable]: "f \<in> borel_measurable M"
   803 
   803 
   804   fix s t
   804   fix s t
   805   assume "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M) ----> 0" (is "?S ----> 0")
   805   assume "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - s i x) \<partial>M) \<longlonglongrightarrow> 0" (is "?S \<longlonglongrightarrow> 0")
   806   assume "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - t i x) \<partial>M) ----> 0" (is "?T ----> 0")
   806   assume "(\<lambda>i. \<integral>\<^sup>+ x. norm (f x - t i x) \<partial>M) \<longlonglongrightarrow> 0" (is "?T \<longlonglongrightarrow> 0")
   807   assume s: "\<And>i. simple_bochner_integrable M (s i)"
   807   assume s: "\<And>i. simple_bochner_integrable M (s i)"
   808   assume t: "\<And>i. simple_bochner_integrable M (t i)"
   808   assume t: "\<And>i. simple_bochner_integrable M (t i)"
   809 
   809 
   810   have [measurable]: "\<And>i. s i \<in> borel_measurable M" "\<And>i. t i \<in> borel_measurable M"
   810   have [measurable]: "\<And>i. s i \<in> borel_measurable M" "\<And>i. t i \<in> borel_measurable M"
   811     using s t by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   811     using s t by (auto intro: borel_measurable_simple_function elim: simple_bochner_integrable.cases)
   812 
   812 
   813   let ?s = "\<lambda>i. simple_bochner_integral M (s i)"
   813   let ?s = "\<lambda>i. simple_bochner_integral M (s i)"
   814   let ?t = "\<lambda>i. simple_bochner_integral M (t i)"
   814   let ?t = "\<lambda>i. simple_bochner_integral M (t i)"
   815   assume "?s ----> x" "?t ----> y"
   815   assume "?s \<longlonglongrightarrow> x" "?t \<longlonglongrightarrow> y"
   816   then have "(\<lambda>i. norm (?s i - ?t i)) ----> norm (x - y)"
   816   then have "(\<lambda>i. norm (?s i - ?t i)) \<longlonglongrightarrow> norm (x - y)"
   817     by (intro tendsto_intros)
   817     by (intro tendsto_intros)
   818   moreover
   818   moreover
   819   have "(\<lambda>i. ereal (norm (?s i - ?t i))) ----> ereal 0"
   819   have "(\<lambda>i. ereal (norm (?s i - ?t i))) \<longlonglongrightarrow> ereal 0"
   820   proof (rule tendsto_sandwich)
   820   proof (rule tendsto_sandwich)
   821     show "eventually (\<lambda>i. 0 \<le> ereal (norm (?s i - ?t i))) sequentially" "(\<lambda>_. 0) ----> ereal 0"
   821     show "eventually (\<lambda>i. 0 \<le> ereal (norm (?s i - ?t i))) sequentially" "(\<lambda>_. 0) \<longlonglongrightarrow> ereal 0"
   822       by (auto simp: nn_integral_nonneg zero_ereal_def[symmetric])
   822       by (auto simp: nn_integral_nonneg zero_ereal_def[symmetric])
   823 
   823 
   824     show "eventually (\<lambda>i. norm (?s i - ?t i) \<le> ?S i + ?T i) sequentially"
   824     show "eventually (\<lambda>i. norm (?s i - ?t i) \<le> ?S i + ?T i) sequentially"
   825       by (intro always_eventually allI simple_bochner_integral_bounded s t f)
   825       by (intro always_eventually allI simple_bochner_integral_bounded s t f)
   826     show "(\<lambda>i. ?S i + ?T i) ----> ereal 0"
   826     show "(\<lambda>i. ?S i + ?T i) \<longlonglongrightarrow> ereal 0"
   827       using tendsto_add_ereal[OF _ _ \<open>?S ----> 0\<close> \<open>?T ----> 0\<close>]
   827       using tendsto_add_ereal[OF _ _ \<open>?S \<longlonglongrightarrow> 0\<close> \<open>?T \<longlonglongrightarrow> 0\<close>]
   828       by (simp add: zero_ereal_def[symmetric])
   828       by (simp add: zero_ereal_def[symmetric])
   829   qed
   829   qed
   830   then have "(\<lambda>i. norm (?s i - ?t i)) ----> 0"
   830   then have "(\<lambda>i. norm (?s i - ?t i)) \<longlonglongrightarrow> 0"
   831     by simp
   831     by simp
   832   ultimately have "norm (x - y) = 0"
   832   ultimately have "norm (x - y) = 0"
   833     by (rule LIMSEQ_unique)
   833     by (rule LIMSEQ_unique)
   834   then show "x = y" by simp
   834   then show "x = y" by simp
   835 qed
   835 qed
   839     and g: "g \<in> borel_measurable M"
   839     and g: "g \<in> borel_measurable M"
   840     and ae: "AE x in M. f x = g x"
   840     and ae: "AE x in M. f x = g x"
   841   shows "has_bochner_integral M g x"
   841   shows "has_bochner_integral M g x"
   842   using f
   842   using f
   843 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   843 proof (safe intro!: has_bochner_integral.intros elim!: has_bochner_integral.cases)
   844   fix s assume "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
   844   fix s assume "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) \<longlonglongrightarrow> 0"
   845   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)"
   845   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)"
   846     using ae
   846     using ae
   847     by (intro ext nn_integral_cong_AE, eventually_elim) simp
   847     by (intro ext nn_integral_cong_AE, eventually_elim) simp
   848   finally show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M) ----> 0" .
   848   finally show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (g x - s i x)) \<partial>M) \<longlonglongrightarrow> 0" .
   849 qed (auto intro: g)
   849 qed (auto intro: g)
   850 
   850 
   851 lemma has_bochner_integral_eq_AE:
   851 lemma has_bochner_integral_eq_AE:
   852   assumes f: "has_bochner_integral M f x"
   852   assumes f: "has_bochner_integral M f x"
   853     and g: "has_bochner_integral M g y"
   853     and g: "has_bochner_integral M g y"
  1142 
  1142 
  1143 lemma integrableI_sequence:
  1143 lemma integrableI_sequence:
  1144   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1144   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1145   assumes f[measurable]: "f \<in> borel_measurable M"
  1145   assumes f[measurable]: "f \<in> borel_measurable M"
  1146   assumes s: "\<And>i. simple_bochner_integrable M (s i)"
  1146   assumes s: "\<And>i. simple_bochner_integrable M (s i)"
  1147   assumes lim: "(\<lambda>i. \<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) ----> 0" (is "?S ----> 0")
  1147   assumes lim: "(\<lambda>i. \<integral>\<^sup>+x. norm (f x - s i x) \<partial>M) \<longlonglongrightarrow> 0" (is "?S \<longlonglongrightarrow> 0")
  1148   shows "integrable M f"
  1148   shows "integrable M f"
  1149 proof -
  1149 proof -
  1150   let ?s = "\<lambda>n. simple_bochner_integral M (s n)"
  1150   let ?s = "\<lambda>n. simple_bochner_integral M (s n)"
  1151 
  1151 
  1152   have "\<exists>x. ?s ----> x"
  1152   have "\<exists>x. ?s \<longlonglongrightarrow> x"
  1153     unfolding convergent_eq_cauchy
  1153     unfolding convergent_eq_cauchy
  1154   proof (rule metric_CauchyI)
  1154   proof (rule metric_CauchyI)
  1155     fix e :: real assume "0 < e"
  1155     fix e :: real assume "0 < e"
  1156     then have "0 < ereal (e / 2)" by auto
  1156     then have "0 < ereal (e / 2)" by auto
  1157     from order_tendstoD(2)[OF lim this]
  1157     from order_tendstoD(2)[OF lim this]
  1170       also have "\<dots> = e" by simp
  1170       also have "\<dots> = e" by simp
  1171       finally show "dist (?s n) (?s m) < e"
  1171       finally show "dist (?s n) (?s m) < e"
  1172         by (simp add: dist_norm)
  1172         by (simp add: dist_norm)
  1173     qed
  1173     qed
  1174   qed
  1174   qed
  1175   then obtain x where "?s ----> x" ..
  1175   then obtain x where "?s \<longlonglongrightarrow> x" ..
  1176   show ?thesis
  1176   show ?thesis
  1177     by (rule, rule) fact+
  1177     by (rule, rule) fact+
  1178 qed
  1178 qed
  1179 
  1179 
  1180 lemma nn_integral_dominated_convergence_norm:
  1180 lemma nn_integral_dominated_convergence_norm:
  1181   fixes u' :: "_ \<Rightarrow> _::{real_normed_vector, second_countable_topology}"
  1181   fixes u' :: "_ \<Rightarrow> _::{real_normed_vector, second_countable_topology}"
  1182   assumes [measurable]:
  1182   assumes [measurable]:
  1183        "\<And>i. u i \<in> borel_measurable M" "u' \<in> borel_measurable M" "w \<in> borel_measurable M"
  1183        "\<And>i. u i \<in> borel_measurable M" "u' \<in> borel_measurable M" "w \<in> borel_measurable M"
  1184     and bound: "\<And>j. AE x in M. norm (u j x) \<le> w x"
  1184     and bound: "\<And>j. AE x in M. norm (u j x) \<le> w x"
  1185     and w: "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1185     and w: "(\<integral>\<^sup>+x. w x \<partial>M) < \<infinity>"
  1186     and u': "AE x in M. (\<lambda>i. u i x) ----> u' x"
  1186     and u': "AE x in M. (\<lambda>i. u i x) \<longlonglongrightarrow> u' x"
  1187   shows "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) ----> 0"
  1187   shows "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) \<longlonglongrightarrow> 0"
  1188 proof -
  1188 proof -
  1189   have "AE x in M. \<forall>j. norm (u j x) \<le> w x"
  1189   have "AE x in M. \<forall>j. norm (u j x) \<le> w x"
  1190     unfolding AE_all_countable by rule fact
  1190     unfolding AE_all_countable by rule fact
  1191   with u' have bnd: "AE x in M. \<forall>j. norm (u' x - u j x) \<le> 2 * w x"
  1191   with u' have bnd: "AE x in M. \<forall>j. norm (u' x - u j x) \<le> 2 * w x"
  1192   proof (eventually_elim, intro allI)
  1192   proof (eventually_elim, intro allI)
  1193     fix i x assume "(\<lambda>i. u i x) ----> u' x" "\<forall>j. norm (u j x) \<le> w x" "\<forall>j. norm (u j x) \<le> w x"
  1193     fix i x assume "(\<lambda>i. u i x) \<longlonglongrightarrow> u' x" "\<forall>j. norm (u j x) \<le> w x" "\<forall>j. norm (u j x) \<le> w x"
  1194     then have "norm (u' x) \<le> w x" "norm (u i x) \<le> w x"
  1194     then have "norm (u' x) \<le> w x" "norm (u i x) \<le> w x"
  1195       by (auto intro: LIMSEQ_le_const2 tendsto_norm)
  1195       by (auto intro: LIMSEQ_le_const2 tendsto_norm)
  1196     then have "norm (u' x) + norm (u i x) \<le> 2 * w x"
  1196     then have "norm (u' x) + norm (u i x) \<le> 2 * w x"
  1197       by simp
  1197       by simp
  1198     also have "norm (u' x - u i x) \<le> norm (u' x) + norm (u i x)"
  1198     also have "norm (u' x - u i x) \<le> norm (u' x) + norm (u i x)"
  1199       by (rule norm_triangle_ineq4)
  1199       by (rule norm_triangle_ineq4)
  1200     finally (xtrans) show "norm (u' x - u i x) \<le> 2 * w x" .
  1200     finally (xtrans) show "norm (u' x - u i x) \<le> 2 * w x" .
  1201   qed
  1201   qed
  1202   
  1202   
  1203   have "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) ----> (\<integral>\<^sup>+x. 0 \<partial>M)"
  1203   have "(\<lambda>i. (\<integral>\<^sup>+x. norm (u' x - u i x) \<partial>M)) \<longlonglongrightarrow> (\<integral>\<^sup>+x. 0 \<partial>M)"
  1204   proof (rule nn_integral_dominated_convergence)  
  1204   proof (rule nn_integral_dominated_convergence)  
  1205     show "(\<integral>\<^sup>+x. 2 * w x \<partial>M) < \<infinity>"
  1205     show "(\<integral>\<^sup>+x. 2 * w x \<partial>M) < \<infinity>"
  1206       by (rule nn_integral_mult_bounded_inf[OF _ w, of 2]) auto
  1206       by (rule nn_integral_mult_bounded_inf[OF _ w, of 2]) auto
  1207     show "AE x in M. (\<lambda>i. ereal (norm (u' x - u i x))) ----> 0"
  1207     show "AE x in M. (\<lambda>i. ereal (norm (u' x - u i x))) \<longlonglongrightarrow> 0"
  1208       using u' 
  1208       using u' 
  1209     proof eventually_elim
  1209     proof eventually_elim
  1210       fix x assume "(\<lambda>i. u i x) ----> u' x"
  1210       fix x assume "(\<lambda>i. u i x) \<longlonglongrightarrow> u' x"
  1211       from tendsto_diff[OF tendsto_const[of "u' x"] this]
  1211       from tendsto_diff[OF tendsto_const[of "u' x"] this]
  1212       show "(\<lambda>i. ereal (norm (u' x - u i x))) ----> 0"
  1212       show "(\<lambda>i. ereal (norm (u' x - u i x))) \<longlonglongrightarrow> 0"
  1213         by (simp add: zero_ereal_def tendsto_norm_zero_iff)
  1213         by (simp add: zero_ereal_def tendsto_norm_zero_iff)
  1214     qed
  1214     qed
  1215   qed (insert bnd, auto)
  1215   qed (insert bnd, auto)
  1216   then show ?thesis by simp
  1216   then show ?thesis by simp
  1217 qed
  1217 qed
  1221   assumes f[measurable]: "f \<in> borel_measurable M" and fin: "(\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
  1221   assumes f[measurable]: "f \<in> borel_measurable M" and fin: "(\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
  1222   shows "integrable M f"
  1222   shows "integrable M f"
  1223 proof -
  1223 proof -
  1224   from borel_measurable_implies_sequence_metric[OF f, of 0] obtain s where
  1224   from borel_measurable_implies_sequence_metric[OF f, of 0] obtain s where
  1225     s: "\<And>i. simple_function M (s i)" and
  1225     s: "\<And>i. simple_function M (s i)" and
  1226     pointwise: "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) ----> f x" and
  1226     pointwise: "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) \<longlonglongrightarrow> f x" and
  1227     bound: "\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)"
  1227     bound: "\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)"
  1228     by (simp add: norm_conv_dist) metis
  1228     by (simp add: norm_conv_dist) metis
  1229   
  1229   
  1230   show ?thesis
  1230   show ?thesis
  1231   proof (rule integrableI_sequence)
  1231   proof (rule integrableI_sequence)
  1239     note fin_s = this
  1239     note fin_s = this
  1240 
  1240 
  1241     show "\<And>i. simple_bochner_integrable M (s i)"
  1241     show "\<And>i. simple_bochner_integrable M (s i)"
  1242       by (rule simple_bochner_integrableI_bounded) fact+
  1242       by (rule simple_bochner_integrableI_bounded) fact+
  1243 
  1243 
  1244     show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) ----> 0"
  1244     show "(\<lambda>i. \<integral>\<^sup>+ x. ereal (norm (f x - s i x)) \<partial>M) \<longlonglongrightarrow> 0"
  1245     proof (rule nn_integral_dominated_convergence_norm)
  1245     proof (rule nn_integral_dominated_convergence_norm)
  1246       show "\<And>j. AE x in M. norm (s j x) \<le> 2 * norm (f x)"
  1246       show "\<And>j. AE x in M. norm (s j x) \<le> 2 * norm (f x)"
  1247         using bound by auto
  1247         using bound by auto
  1248       show "\<And>i. s i \<in> borel_measurable M" "(\<lambda>x. 2 * norm (f x)) \<in> borel_measurable M"
  1248       show "\<And>i. s i \<in> borel_measurable M" "(\<lambda>x. 2 * norm (f x)) \<in> borel_measurable M"
  1249         using s by (auto intro: borel_measurable_simple_function)
  1249         using s by (auto intro: borel_measurable_simple_function)
  1250       show "(\<integral>\<^sup>+ x. ereal (2 * norm (f x)) \<partial>M) < \<infinity>"
  1250       show "(\<integral>\<^sup>+ x. ereal (2 * norm (f x)) \<partial>M) < \<infinity>"
  1251         using fin unfolding times_ereal.simps(1)[symmetric] by (subst nn_integral_cmult) auto
  1251         using fin unfolding times_ereal.simps(1)[symmetric] by (subst nn_integral_cmult) auto
  1252       show "AE x in M. (\<lambda>i. s i x) ----> f x"
  1252       show "AE x in M. (\<lambda>i. s i x) \<longlonglongrightarrow> f x"
  1253         using pointwise by auto
  1253         using pointwise by auto
  1254     qed fact
  1254     qed fact
  1255   qed fact
  1255   qed fact
  1256 qed
  1256 qed
  1257 
  1257 
  1454   by (metis has_bochner_integral_iff)
  1454   by (metis has_bochner_integral_iff)
  1455 
  1455 
  1456 lemma
  1456 lemma
  1457   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1457   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1458   assumes "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M" "integrable M w"
  1458   assumes "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M" "integrable M w"
  1459   assumes lim: "AE x in M. (\<lambda>i. s i x) ----> f x"
  1459   assumes lim: "AE x in M. (\<lambda>i. s i x) \<longlonglongrightarrow> f x"
  1460   assumes bound: "\<And>i. AE x in M. norm (s i x) \<le> w x"
  1460   assumes bound: "\<And>i. AE x in M. norm (s i x) \<le> w x"
  1461   shows integrable_dominated_convergence: "integrable M f"
  1461   shows integrable_dominated_convergence: "integrable M f"
  1462     and integrable_dominated_convergence2: "\<And>i. integrable M (s i)"
  1462     and integrable_dominated_convergence2: "\<And>i. integrable M (s i)"
  1463     and integral_dominated_convergence: "(\<lambda>i. integral\<^sup>L M (s i)) ----> integral\<^sup>L M f"
  1463     and integral_dominated_convergence: "(\<lambda>i. integral\<^sup>L M (s i)) \<longlonglongrightarrow> integral\<^sup>L M f"
  1464 proof -
  1464 proof -
  1465   have "AE x in M. 0 \<le> w x"
  1465   have "AE x in M. 0 \<le> w x"
  1466     using bound[of 0] by eventually_elim (auto intro: norm_ge_zero order_trans)
  1466     using bound[of 0] by eventually_elim (auto intro: norm_ge_zero order_trans)
  1467   then have "(\<integral>\<^sup>+x. w x \<partial>M) = (\<integral>\<^sup>+x. norm (w x) \<partial>M)"
  1467   then have "(\<integral>\<^sup>+x. w x \<partial>M) = (\<integral>\<^sup>+x. norm (w x) \<partial>M)"
  1468     by (intro nn_integral_cong_AE) auto
  1468     by (intro nn_integral_cong_AE) auto
  1485     unfolding integrable_iff_bounded
  1485     unfolding integrable_iff_bounded
  1486   proof
  1486   proof
  1487     have "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1487     have "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) \<le> (\<integral>\<^sup>+x. w x \<partial>M)"
  1488       using all_bound lim
  1488       using all_bound lim
  1489     proof (intro nn_integral_mono_AE, eventually_elim)
  1489     proof (intro nn_integral_mono_AE, eventually_elim)
  1490       fix x assume "\<forall>i. norm (s i x) \<le> w x" "(\<lambda>i. s i x) ----> f x"
  1490       fix x assume "\<forall>i. norm (s i x) \<le> w x" "(\<lambda>i. s i x) \<longlonglongrightarrow> f x"
  1491       then show "ereal (norm (f x)) \<le> ereal (w x)"
  1491       then show "ereal (norm (f x)) \<le> ereal (w x)"
  1492         by (intro LIMSEQ_le_const2[where X="\<lambda>i. ereal (norm (s i x))"] tendsto_intros lim_ereal[THEN iffD2]) auto
  1492         by (intro LIMSEQ_le_const2[where X="\<lambda>i. ereal (norm (s i x))"] tendsto_intros lim_ereal[THEN iffD2]) auto
  1493     qed
  1493     qed
  1494     with w show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" by auto
  1494     with w show "(\<integral>\<^sup>+ x. ereal (norm (f x)) \<partial>M) < \<infinity>" by auto
  1495   qed fact
  1495   qed fact
  1496 
  1496 
  1497   have "(\<lambda>n. ereal (norm (integral\<^sup>L M (s n) - integral\<^sup>L M f))) ----> ereal 0" (is "?d ----> ereal 0")
  1497   have "(\<lambda>n. ereal (norm (integral\<^sup>L M (s n) - integral\<^sup>L M f))) \<longlonglongrightarrow> ereal 0" (is "?d \<longlonglongrightarrow> ereal 0")
  1498   proof (rule tendsto_sandwich)
  1498   proof (rule tendsto_sandwich)
  1499     show "eventually (\<lambda>n. ereal 0 \<le> ?d n) sequentially" "(\<lambda>_. ereal 0) ----> ereal 0" by auto
  1499     show "eventually (\<lambda>n. ereal 0 \<le> ?d n) sequentially" "(\<lambda>_. ereal 0) \<longlonglongrightarrow> ereal 0" by auto
  1500     show "eventually (\<lambda>n. ?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)) sequentially"
  1500     show "eventually (\<lambda>n. ?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)) sequentially"
  1501     proof (intro always_eventually allI)
  1501     proof (intro always_eventually allI)
  1502       fix n
  1502       fix n
  1503       have "?d n = norm (integral\<^sup>L M (\<lambda>x. s n x - f x))"
  1503       have "?d n = norm (integral\<^sup>L M (\<lambda>x. s n x - f x))"
  1504         using int_f int_s by simp
  1504         using int_f int_s by simp
  1505       also have "\<dots> \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)"
  1505       also have "\<dots> \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)"
  1506         by (intro int_f int_s integrable_diff integral_norm_bound_ereal)
  1506         by (intro int_f int_s integrable_diff integral_norm_bound_ereal)
  1507       finally show "?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)" .
  1507       finally show "?d n \<le> (\<integral>\<^sup>+x. norm (s n x - f x) \<partial>M)" .
  1508     qed
  1508     qed
  1509     show "(\<lambda>n. \<integral>\<^sup>+x. norm (s n x - f x) \<partial>M) ----> ereal 0"
  1509     show "(\<lambda>n. \<integral>\<^sup>+x. norm (s n x - f x) \<partial>M) \<longlonglongrightarrow> ereal 0"
  1510       unfolding zero_ereal_def[symmetric]
  1510       unfolding zero_ereal_def[symmetric]
  1511       apply (subst norm_minus_commute)
  1511       apply (subst norm_minus_commute)
  1512     proof (rule nn_integral_dominated_convergence_norm[where w=w])
  1512     proof (rule nn_integral_dominated_convergence_norm[where w=w])
  1513       show "\<And>n. s n \<in> borel_measurable M"
  1513       show "\<And>n. s n \<in> borel_measurable M"
  1514         using int_s unfolding integrable_iff_bounded by auto
  1514         using int_s unfolding integrable_iff_bounded by auto
  1515     qed fact+
  1515     qed fact+
  1516   qed
  1516   qed
  1517   then have "(\<lambda>n. integral\<^sup>L M (s n) - integral\<^sup>L M f) ----> 0"
  1517   then have "(\<lambda>n. integral\<^sup>L M (s n) - integral\<^sup>L M f) \<longlonglongrightarrow> 0"
  1518     unfolding lim_ereal tendsto_norm_zero_iff .
  1518     unfolding lim_ereal tendsto_norm_zero_iff .
  1519   from tendsto_add[OF this tendsto_const[of "integral\<^sup>L M f"]]
  1519   from tendsto_add[OF this tendsto_const[of "integral\<^sup>L M f"]]
  1520   show "(\<lambda>i. integral\<^sup>L M (s i)) ----> integral\<^sup>L M f"  by simp
  1520   show "(\<lambda>i. integral\<^sup>L M (s i)) \<longlonglongrightarrow> integral\<^sup>L M f"  by simp
  1521 qed
  1521 qed
  1522 
  1522 
  1523 context
  1523 context
  1524   fixes s :: "real \<Rightarrow> 'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1524   fixes s :: "real \<Rightarrow> 'a \<Rightarrow> 'b::{banach, second_countable_topology}" and w :: "'a \<Rightarrow> real"
  1525     and f :: "'a \<Rightarrow> 'b" and M
  1525     and f :: "'a \<Rightarrow> 'b" and M
  1533   fix X :: "nat \<Rightarrow> real" assume X: "filterlim X at_top sequentially"
  1533   fix X :: "nat \<Rightarrow> real" assume X: "filterlim X at_top sequentially"
  1534   from filterlim_iff[THEN iffD1, OF this, rule_format, OF bound]
  1534   from filterlim_iff[THEN iffD1, OF this, rule_format, OF bound]
  1535   obtain N where w: "\<And>n. N \<le> n \<Longrightarrow> AE x in M. norm (s (X n) x) \<le> w x"
  1535   obtain N where w: "\<And>n. N \<le> n \<Longrightarrow> AE x in M. norm (s (X n) x) \<le> w x"
  1536     by (auto simp: eventually_sequentially)
  1536     by (auto simp: eventually_sequentially)
  1537 
  1537 
  1538   show "(\<lambda>n. integral\<^sup>L M (s (X n))) ----> integral\<^sup>L M f"
  1538   show "(\<lambda>n. integral\<^sup>L M (s (X n))) \<longlonglongrightarrow> integral\<^sup>L M f"
  1539   proof (rule LIMSEQ_offset, rule integral_dominated_convergence)
  1539   proof (rule LIMSEQ_offset, rule integral_dominated_convergence)
  1540     show "AE x in M. norm (s (X (n + N)) x) \<le> w x" for n
  1540     show "AE x in M. norm (s (X (n + N)) x) \<le> w x" for n
  1541       by (rule w) auto
  1541       by (rule w) auto
  1542     show "AE x in M. (\<lambda>n. s (X (n + N)) x) ----> f x"
  1542     show "AE x in M. (\<lambda>n. s (X (n + N)) x) \<longlonglongrightarrow> f x"
  1543       using lim
  1543       using lim
  1544     proof eventually_elim
  1544     proof eventually_elim
  1545       fix x assume "((\<lambda>i. s i x) ---> f x) at_top"
  1545       fix x assume "((\<lambda>i. s i x) ---> f x) at_top"
  1546       then show "(\<lambda>n. s (X (n + N)) x) ----> f x"
  1546       then show "(\<lambda>n. s (X (n + N)) x) \<longlonglongrightarrow> f x"
  1547         by (intro LIMSEQ_ignore_initial_segment filterlim_compose[OF _ X])
  1547         by (intro LIMSEQ_ignore_initial_segment filterlim_compose[OF _ X])
  1548     qed
  1548     qed
  1549   qed fact+
  1549   qed fact+
  1550 qed
  1550 qed
  1551 
  1551 
  1555     by (auto simp: eventually_at_top_linorder)
  1555     by (auto simp: eventually_at_top_linorder)
  1556   show ?thesis
  1556   show ?thesis
  1557   proof (rule integrable_dominated_convergence)
  1557   proof (rule integrable_dominated_convergence)
  1558     show "AE x in M. norm (s (N + i) x) \<le> w x" for i :: nat
  1558     show "AE x in M. norm (s (N + i) x) \<le> w x" for i :: nat
  1559       by (intro w) auto
  1559       by (intro w) auto
  1560     show "AE x in M. (\<lambda>i. s (N + real i) x) ----> f x"
  1560     show "AE x in M. (\<lambda>i. s (N + real i) x) \<longlonglongrightarrow> f x"
  1561       using lim
  1561       using lim
  1562     proof eventually_elim
  1562     proof eventually_elim
  1563       fix x assume "((\<lambda>i. s i x) ---> f x) at_top"
  1563       fix x assume "((\<lambda>i. s i x) ---> f x) at_top"
  1564       then show "(\<lambda>n. s (N + n) x) ----> f x"
  1564       then show "(\<lambda>n. s (N + n) x) \<longlonglongrightarrow> f x"
  1565         by (rule filterlim_compose)
  1565         by (rule filterlim_compose)
  1566            (auto intro!: filterlim_tendsto_add_at_top filterlim_real_sequentially)
  1566            (auto intro!: filterlim_tendsto_add_at_top filterlim_real_sequentially)
  1567     qed
  1567     qed
  1568   qed fact+
  1568   qed fact+
  1569 qed
  1569 qed
  1604           by (intro LIMSEQ_le_const[OF seq(5)] exI[of _ i]) (auto simp: incseq_def le_fun_def) }
  1604           by (intro LIMSEQ_le_const[OF seq(5)] exI[of _ i]) (auto simp: incseq_def le_fun_def) }
  1605       note s_le_f = this
  1605       note s_le_f = this
  1606 
  1606 
  1607       show ?case
  1607       show ?case
  1608       proof (rule LIMSEQ_unique)
  1608       proof (rule LIMSEQ_unique)
  1609         show "(\<lambda>i. ereal (integral\<^sup>L M (s i))) ----> ereal (integral\<^sup>L M f)"
  1609         show "(\<lambda>i. ereal (integral\<^sup>L M (s i))) \<longlonglongrightarrow> ereal (integral\<^sup>L M f)"
  1610           unfolding lim_ereal
  1610           unfolding lim_ereal
  1611         proof (rule integral_dominated_convergence[where w=f])
  1611         proof (rule integral_dominated_convergence[where w=f])
  1612           show "integrable M f" by fact
  1612           show "integrable M f" by fact
  1613           from s_le_f seq show "\<And>i. AE x in M. norm (s i x) \<le> f x"
  1613           from s_le_f seq show "\<And>i. AE x in M. norm (s i x) \<le> f x"
  1614             by auto
  1614             by auto
  1615         qed (insert seq, auto)
  1615         qed (insert seq, auto)
  1616         have int_s: "\<And>i. integrable M (s i)"
  1616         have int_s: "\<And>i. integrable M (s i)"
  1617           using seq f s_le_f by (intro integrable_bound[OF f(3)]) auto
  1617           using seq f s_le_f by (intro integrable_bound[OF f(3)]) auto
  1618         have "(\<lambda>i. \<integral>\<^sup>+ x. s i x \<partial>M) ----> \<integral>\<^sup>+ x. f x \<partial>M"
  1618         have "(\<lambda>i. \<integral>\<^sup>+ x. s i x \<partial>M) \<longlonglongrightarrow> \<integral>\<^sup>+ x. f x \<partial>M"
  1619           using seq s_le_f f
  1619           using seq s_le_f f
  1620           by (intro nn_integral_dominated_convergence[where w=f])
  1620           by (intro nn_integral_dominated_convergence[where w=f])
  1621              (auto simp: integrable_iff_bounded)
  1621              (auto simp: integrable_iff_bounded)
  1622         also have "(\<lambda>i. \<integral>\<^sup>+x. s i x \<partial>M) = (\<lambda>i. \<integral>x. s i x \<partial>M)"
  1622         also have "(\<lambda>i. \<integral>\<^sup>+x. s i x \<partial>M) = (\<lambda>i. \<integral>x. s i x \<partial>M)"
  1623           using seq int_s by simp
  1623           using seq int_s by simp
  1624         finally show "(\<lambda>i. \<integral>x. s i x \<partial>M) ----> \<integral>\<^sup>+x. f x \<partial>M"
  1624         finally show "(\<lambda>i. \<integral>x. s i x \<partial>M) \<longlonglongrightarrow> \<integral>\<^sup>+x. f x \<partial>M"
  1625           by simp
  1625           by simp
  1626       qed
  1626       qed
  1627     qed }
  1627     qed }
  1628   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))"
  1628   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))"
  1629     by simp
  1629     by simp
  1658       by (intro arg_cong[where f=suminf] ext nn_integral_eq_integral integrable_norm integrable) auto
  1658       by (intro arg_cong[where f=suminf] ext nn_integral_eq_integral integrable_norm integrable) auto
  1659     finally show "(\<integral>\<^sup>+ x. ereal (norm (\<Sum>i. norm (f i x))) \<partial>M) < \<infinity>"
  1659     finally show "(\<integral>\<^sup>+ x. ereal (norm (\<Sum>i. norm (f i x))) \<partial>M) < \<infinity>"
  1660       by (simp add: suminf_ereal' sums)
  1660       by (simp add: suminf_ereal' sums)
  1661   qed simp
  1661   qed simp
  1662 
  1662 
  1663   have 2: "AE x in M. (\<lambda>n. \<Sum>i<n. f i x) ----> (\<Sum>i. f i x)"
  1663   have 2: "AE x in M. (\<lambda>n. \<Sum>i<n. f i x) \<longlonglongrightarrow> (\<Sum>i. f i x)"
  1664     using summable by eventually_elim (auto intro: summable_LIMSEQ summable_norm_cancel)
  1664     using summable by eventually_elim (auto intro: summable_LIMSEQ summable_norm_cancel)
  1665 
  1665 
  1666   have 3: "\<And>j. AE x in M. norm (\<Sum>i<j. f i x) \<le> (\<Sum>i. norm (f i x))"
  1666   have 3: "\<And>j. AE x in M. norm (\<Sum>i<j. f i x) \<le> (\<Sum>i. norm (f i x))"
  1667     using summable
  1667     using summable
  1668   proof eventually_elim
  1668   proof eventually_elim
  1740   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1740   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
  1741   assumes "integrable M f"
  1741   assumes "integrable M f"
  1742   assumes base: "\<And>A c. A \<in> sets M \<Longrightarrow> emeasure M A < \<infinity> \<Longrightarrow> P (\<lambda>x. indicator A x *\<^sub>R c)"
  1742   assumes base: "\<And>A c. A \<in> sets M \<Longrightarrow> emeasure M A < \<infinity> \<Longrightarrow> P (\<lambda>x. indicator A x *\<^sub>R c)"
  1743   assumes add: "\<And>f g. integrable M f \<Longrightarrow> P f \<Longrightarrow> integrable M g \<Longrightarrow> P g \<Longrightarrow> P (\<lambda>x. f x + g x)"
  1743   assumes add: "\<And>f g. integrable M f \<Longrightarrow> P f \<Longrightarrow> integrable M g \<Longrightarrow> P g \<Longrightarrow> P (\<lambda>x. f x + g x)"
  1744   assumes lim: "\<And>f s. (\<And>i. integrable M (s i)) \<Longrightarrow> (\<And>i. P (s i)) \<Longrightarrow>
  1744   assumes lim: "\<And>f s. (\<And>i. integrable M (s i)) \<Longrightarrow> (\<And>i. P (s i)) \<Longrightarrow>
  1745    (\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) ----> f x) \<Longrightarrow>
  1745    (\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) \<longlonglongrightarrow> f x) \<Longrightarrow>
  1746    (\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)) \<Longrightarrow> integrable M f \<Longrightarrow> P f"
  1746    (\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)) \<Longrightarrow> integrable M f \<Longrightarrow> P f"
  1747   shows "P f"
  1747   shows "P f"
  1748 proof -
  1748 proof -
  1749   from \<open>integrable M f\<close> have f: "f \<in> borel_measurable M" "(\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
  1749   from \<open>integrable M f\<close> have f: "f \<in> borel_measurable M" "(\<integral>\<^sup>+x. norm (f x) \<partial>M) < \<infinity>"
  1750     unfolding integrable_iff_bounded by auto
  1750     unfolding integrable_iff_bounded by auto
  1751   from borel_measurable_implies_sequence_metric[OF f(1)]
  1751   from borel_measurable_implies_sequence_metric[OF f(1)]
  1752   obtain s where s: "\<And>i. simple_function M (s i)" "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) ----> f x"
  1752   obtain s where s: "\<And>i. simple_function M (s i)" "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. s i x) \<longlonglongrightarrow> f x"
  1753     "\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)"
  1753     "\<And>i x. x \<in> space M \<Longrightarrow> norm (s i x) \<le> 2 * norm (f x)"
  1754     unfolding norm_conv_dist by metis
  1754     unfolding norm_conv_dist by metis
  1755 
  1755 
  1756   { fix f A 
  1756   { fix f A 
  1757     have [simp]: "P (\<lambda>x. 0)"
  1757     have [simp]: "P (\<lambda>x. 0)"
  1797         using sbi by (auto elim: simple_bochner_integrable.cases)
  1797         using sbi by (auto elim: simple_bochner_integrable.cases)
  1798       finally have "emeasure M {y \<in> space M. s' i y = s' i x} \<noteq> \<infinity>" by simp }
  1798       finally have "emeasure M {y \<in> space M. s' i y = s' i x} \<noteq> \<infinity>" by simp }
  1799     then show "P (s' i)"
  1799     then show "P (s' i)"
  1800       by (subst s'_eq) (auto intro!: setsum base)
  1800       by (subst s'_eq) (auto intro!: setsum base)
  1801 
  1801 
  1802     fix x assume "x \<in> space M" with s show "(\<lambda>i. s' i x) ----> f x"
  1802     fix x assume "x \<in> space M" with s show "(\<lambda>i. s' i x) \<longlonglongrightarrow> f x"
  1803       by (simp add: s'_eq_s)
  1803       by (simp add: s'_eq_s)
  1804     show "norm (s' i x) \<le> 2 * norm (f x)"
  1804     show "norm (s' i x) \<le> 2 * norm (f x)"
  1805       using \<open>x \<in> space M\<close> s by (simp add: s'_eq_s)
  1805       using \<open>x \<in> space M\<close> s by (simp add: s'_eq_s)
  1806   qed fact
  1806   qed fact
  1807 qed
  1807 qed
  1921       by (simp add: scaleR_add_right integrable_restrict_space)
  1921       by (simp add: scaleR_add_right integrable_restrict_space)
  1922   next
  1922   next
  1923     case (lim f s)
  1923     case (lim f s)
  1924     show ?case
  1924     show ?case
  1925     proof (rule LIMSEQ_unique)
  1925     proof (rule LIMSEQ_unique)
  1926       show "(\<lambda>i. integral\<^sup>L (restrict_space M \<Omega>) (s i)) ----> integral\<^sup>L (restrict_space M \<Omega>) f"
  1926       show "(\<lambda>i. integral\<^sup>L (restrict_space M \<Omega>) (s i)) \<longlonglongrightarrow> integral\<^sup>L (restrict_space M \<Omega>) f"
  1927         using lim by (intro integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"]) simp_all
  1927         using lim by (intro integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"]) simp_all
  1928       
  1928       
  1929       show "(\<lambda>i. integral\<^sup>L (restrict_space M \<Omega>) (s i)) ----> (\<integral> x. indicator \<Omega> x *\<^sub>R f x \<partial>M)"
  1929       show "(\<lambda>i. integral\<^sup>L (restrict_space M \<Omega>) (s i)) \<longlonglongrightarrow> (\<integral> x. indicator \<Omega> x *\<^sub>R f x \<partial>M)"
  1930         unfolding lim
  1930         unfolding lim
  1931         using lim
  1931         using lim
  1932         by (intro integral_dominated_convergence[where w="\<lambda>x. 2 * norm (indicator \<Omega> x *\<^sub>R f x)"])
  1932         by (intro integral_dominated_convergence[where w="\<lambda>x. 2 * norm (indicator \<Omega> x *\<^sub>R f x)"])
  1933            (auto simp add: space_restrict_space integrable_restrict_space
  1933            (auto simp add: space_restrict_space integrable_restrict_space
  1934                  simp del: norm_scaleR
  1934                  simp del: norm_scaleR
  1996     have [measurable]: "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M"
  1996     have [measurable]: "f \<in> borel_measurable M" "\<And>i. s i \<in> borel_measurable M"
  1997       using lim(1,5)[THEN borel_measurable_integrable] by auto
  1997       using lim(1,5)[THEN borel_measurable_integrable] by auto
  1998   
  1998   
  1999     show ?case
  1999     show ?case
  2000     proof (rule LIMSEQ_unique)
  2000     proof (rule LIMSEQ_unique)
  2001       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. g x *\<^sub>R s i x)) ----> integral\<^sup>L M (\<lambda>x. g x *\<^sub>R f x)"
  2001       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. g x *\<^sub>R s i x)) \<longlonglongrightarrow> integral\<^sup>L M (\<lambda>x. g x *\<^sub>R f x)"
  2002       proof (rule integral_dominated_convergence)
  2002       proof (rule integral_dominated_convergence)
  2003         show "integrable M (\<lambda>x. 2 * norm (g x *\<^sub>R f x))"
  2003         show "integrable M (\<lambda>x. 2 * norm (g x *\<^sub>R f x))"
  2004           by (intro integrable_mult_right integrable_norm integrable_density[THEN iffD1] lim g) auto
  2004           by (intro integrable_mult_right integrable_norm integrable_density[THEN iffD1] lim g) auto
  2005         show "AE x in M. (\<lambda>i. g x *\<^sub>R s i x) ----> g x *\<^sub>R f x"
  2005         show "AE x in M. (\<lambda>i. g x *\<^sub>R s i x) \<longlonglongrightarrow> g x *\<^sub>R f x"
  2006           using lim(3) by (auto intro!: tendsto_scaleR AE_I2[of M])
  2006           using lim(3) by (auto intro!: tendsto_scaleR AE_I2[of M])
  2007         show "\<And>i. AE x in M. norm (g x *\<^sub>R s i x) \<le> 2 * norm (g x *\<^sub>R f x)"
  2007         show "\<And>i. AE x in M. norm (g x *\<^sub>R s i x) \<le> 2 * norm (g x *\<^sub>R f x)"
  2008           using lim(4) g by (auto intro!: AE_I2[of M] mult_left_mono simp: field_simps)
  2008           using lim(4) g by (auto intro!: AE_I2[of M] mult_left_mono simp: field_simps)
  2009       qed auto
  2009       qed auto
  2010       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. g x *\<^sub>R s i x)) ----> integral\<^sup>L (density M g) f"
  2010       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. g x *\<^sub>R s i x)) \<longlonglongrightarrow> integral\<^sup>L (density M g) f"
  2011         unfolding lim(2)[symmetric]
  2011         unfolding lim(2)[symmetric]
  2012         by (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2012         by (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2013            (insert lim(3-5), auto)
  2013            (insert lim(3-5), auto)
  2014     qed
  2014     qed
  2015   qed
  2015   qed
  2075     have [measurable]: "f \<in> borel_measurable N" "\<And>i. s i \<in> borel_measurable N"
  2075     have [measurable]: "f \<in> borel_measurable N" "\<And>i. s i \<in> borel_measurable N"
  2076       using lim(1,5)[THEN borel_measurable_integrable] by auto
  2076       using lim(1,5)[THEN borel_measurable_integrable] by auto
  2077   
  2077   
  2078     show ?case
  2078     show ?case
  2079     proof (rule LIMSEQ_unique)
  2079     proof (rule LIMSEQ_unique)
  2080       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. s i (g x))) ----> integral\<^sup>L M (\<lambda>x. f (g x))"
  2080       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. s i (g x))) \<longlonglongrightarrow> integral\<^sup>L M (\<lambda>x. f (g x))"
  2081       proof (rule integral_dominated_convergence)
  2081       proof (rule integral_dominated_convergence)
  2082         show "integrable M (\<lambda>x. 2 * norm (f (g x)))"
  2082         show "integrable M (\<lambda>x. 2 * norm (f (g x)))"
  2083           using lim by (auto simp: integrable_distr_eq) 
  2083           using lim by (auto simp: integrable_distr_eq) 
  2084         show "AE x in M. (\<lambda>i. s i (g x)) ----> f (g x)"
  2084         show "AE x in M. (\<lambda>i. s i (g x)) \<longlonglongrightarrow> f (g x)"
  2085           using lim(3) g[THEN measurable_space] by auto
  2085           using lim(3) g[THEN measurable_space] by auto
  2086         show "\<And>i. AE x in M. norm (s i (g x)) \<le> 2 * norm (f (g x))"
  2086         show "\<And>i. AE x in M. norm (s i (g x)) \<le> 2 * norm (f (g x))"
  2087           using lim(4) g[THEN measurable_space] by auto
  2087           using lim(4) g[THEN measurable_space] by auto
  2088       qed auto
  2088       qed auto
  2089       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. s i (g x))) ----> integral\<^sup>L (distr M N g) f"
  2089       show "(\<lambda>i. integral\<^sup>L M (\<lambda>x. s i (g x))) \<longlonglongrightarrow> integral\<^sup>L (distr M N g) f"
  2090         unfolding lim(2)[symmetric]
  2090         unfolding lim(2)[symmetric]
  2091         by (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2091         by (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2092            (insert lim(3-5), auto)
  2092            (insert lim(3-5), auto)
  2093     qed
  2093     qed
  2094   qed
  2094   qed
  2264 
  2264 
  2265 lemma integral_monotone_convergence_nonneg:
  2265 lemma integral_monotone_convergence_nonneg:
  2266   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  2266   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  2267   assumes i: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  2267   assumes i: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  2268     and pos: "\<And>i. AE x in M. 0 \<le> f i x"
  2268     and pos: "\<And>i. AE x in M. 0 \<le> f i x"
  2269     and lim: "AE x in M. (\<lambda>i. f i x) ----> u x"
  2269     and lim: "AE x in M. (\<lambda>i. f i x) \<longlonglongrightarrow> u x"
  2270     and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) ----> x"
  2270     and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) \<longlonglongrightarrow> x"
  2271     and u: "u \<in> borel_measurable M"
  2271     and u: "u \<in> borel_measurable M"
  2272   shows "integrable M u"
  2272   shows "integrable M u"
  2273   and "integral\<^sup>L M u = x"
  2273   and "integral\<^sup>L M u = x"
  2274 proof -
  2274 proof -
  2275   have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = (SUP n. (\<integral>\<^sup>+ x. ereal (f n x) \<partial>M))"
  2275   have "(\<integral>\<^sup>+ x. ereal (u x) \<partial>M) = (SUP n. (\<integral>\<^sup>+ x. ereal (f n x) \<partial>M))"
  2293   proof (subst nn_integral_0_iff_AE)
  2293   proof (subst nn_integral_0_iff_AE)
  2294     show "(\<lambda>x. ereal (- u x)) \<in> borel_measurable M"
  2294     show "(\<lambda>x. ereal (- u x)) \<in> borel_measurable M"
  2295       using u by auto
  2295       using u by auto
  2296     from mono pos[of 0] lim show "AE x in M. ereal (- u x) \<le> 0"
  2296     from mono pos[of 0] lim show "AE x in M. ereal (- u x) \<le> 0"
  2297     proof eventually_elim
  2297     proof eventually_elim
  2298       fix x assume "mono (\<lambda>n. f n x)" "0 \<le> f 0 x" "(\<lambda>i. f i x) ----> u x"
  2298       fix x assume "mono (\<lambda>n. f n x)" "0 \<le> f 0 x" "(\<lambda>i. f i x) \<longlonglongrightarrow> u x"
  2299       then show "ereal (- u x) \<le> 0"
  2299       then show "ereal (- u x) \<le> 0"
  2300         using incseq_le[of "\<lambda>n. f n x" "u x" 0] by (simp add: mono_def incseq_def)
  2300         using incseq_le[of "\<lambda>n. f n x" "u x" 0] by (simp add: mono_def incseq_def)
  2301     qed
  2301     qed
  2302   qed
  2302   qed
  2303   ultimately show "integrable M u" "integral\<^sup>L M u = x"
  2303   ultimately show "integrable M u" "integral\<^sup>L M u = x"
  2305 qed
  2305 qed
  2306 
  2306 
  2307 lemma
  2307 lemma
  2308   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  2308   fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> real"
  2309   assumes f: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  2309   assumes f: "\<And>i. integrable M (f i)" and mono: "AE x in M. mono (\<lambda>n. f n x)"
  2310   and lim: "AE x in M. (\<lambda>i. f i x) ----> u x"
  2310   and lim: "AE x in M. (\<lambda>i. f i x) \<longlonglongrightarrow> u x"
  2311   and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) ----> x"
  2311   and ilim: "(\<lambda>i. integral\<^sup>L M (f i)) \<longlonglongrightarrow> x"
  2312   and u: "u \<in> borel_measurable M"
  2312   and u: "u \<in> borel_measurable M"
  2313   shows integrable_monotone_convergence: "integrable M u"
  2313   shows integrable_monotone_convergence: "integrable M u"
  2314     and integral_monotone_convergence: "integral\<^sup>L M u = x"
  2314     and integral_monotone_convergence: "integral\<^sup>L M u = x"
  2315     and has_bochner_integral_monotone_convergence: "has_bochner_integral M u x"
  2315     and has_bochner_integral_monotone_convergence: "has_bochner_integral M u x"
  2316 proof -
  2316 proof -
  2318     using f by auto
  2318     using f by auto
  2319   have 2: "AE x in M. mono (\<lambda>n. f n x - f 0 x)"
  2319   have 2: "AE x in M. mono (\<lambda>n. f n x - f 0 x)"
  2320     using mono by (auto simp: mono_def le_fun_def)
  2320     using mono by (auto simp: mono_def le_fun_def)
  2321   have 3: "\<And>n. AE x in M. 0 \<le> f n x - f 0 x"
  2321   have 3: "\<And>n. AE x in M. 0 \<le> f n x - f 0 x"
  2322     using mono by (auto simp: field_simps mono_def le_fun_def)
  2322     using mono by (auto simp: field_simps mono_def le_fun_def)
  2323   have 4: "AE x in M. (\<lambda>i. f i x - f 0 x) ----> u x - f 0 x"
  2323   have 4: "AE x in M. (\<lambda>i. f i x - f 0 x) \<longlonglongrightarrow> u x - f 0 x"
  2324     using lim by (auto intro!: tendsto_diff)
  2324     using lim by (auto intro!: tendsto_diff)
  2325   have 5: "(\<lambda>i. (\<integral>x. f i x - f 0 x \<partial>M)) ----> x - integral\<^sup>L M (f 0)"
  2325   have 5: "(\<lambda>i. (\<integral>x. f i x - f 0 x \<partial>M)) \<longlonglongrightarrow> x - integral\<^sup>L M (f 0)"
  2326     using f ilim by (auto intro!: tendsto_diff)
  2326     using f ilim by (auto intro!: tendsto_diff)
  2327   have 6: "(\<lambda>x. u x - f 0 x) \<in> borel_measurable M"
  2327   have 6: "(\<lambda>x. u x - f 0 x) \<in> borel_measurable M"
  2328     using f[of 0] u by auto
  2328     using f[of 0] u by auto
  2329   note diff = integral_monotone_convergence_nonneg[OF 1 2 3 4 5 6]
  2329   note diff = integral_monotone_convergence_nonneg[OF 1 2 3 4 5 6]
  2330   have "integrable M (\<lambda>x. (u x - f 0 x) + f 0 x)"
  2330   have "integrable M (\<lambda>x. (u x - f 0 x) + f 0 x)"
  2460   fixes f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
  2460   fixes f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
  2461   assumes [measurable_cong]: "sets M = sets borel" and f[measurable]: "integrable M f"
  2461   assumes [measurable_cong]: "sets M = sets borel" and f[measurable]: "integrable M f"
  2462   shows "((\<lambda>y. \<integral> x. indicator {.. y} x *\<^sub>R f x \<partial>M) ---> \<integral> x. f x \<partial>M) at_top"
  2462   shows "((\<lambda>y. \<integral> x. indicator {.. y} x *\<^sub>R f x \<partial>M) ---> \<integral> x. f x \<partial>M) at_top"
  2463 proof (rule tendsto_at_topI_sequentially)
  2463 proof (rule tendsto_at_topI_sequentially)
  2464   fix X :: "nat \<Rightarrow> real" assume "filterlim X at_top sequentially"
  2464   fix X :: "nat \<Rightarrow> real" assume "filterlim X at_top sequentially"
  2465   show "(\<lambda>n. \<integral>x. indicator {..X n} x *\<^sub>R f x \<partial>M) ----> integral\<^sup>L M f"
  2465   show "(\<lambda>n. \<integral>x. indicator {..X n} x *\<^sub>R f x \<partial>M) \<longlonglongrightarrow> integral\<^sup>L M f"
  2466   proof (rule integral_dominated_convergence)
  2466   proof (rule integral_dominated_convergence)
  2467     show "integrable M (\<lambda>x. norm (f x))"
  2467     show "integrable M (\<lambda>x. norm (f x))"
  2468       by (rule integrable_norm) fact
  2468       by (rule integrable_norm) fact
  2469     show "AE x in M. (\<lambda>n. indicator {..X n} x *\<^sub>R f x) ----> f x"
  2469     show "AE x in M. (\<lambda>n. indicator {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x"
  2470     proof
  2470     proof
  2471       fix x
  2471       fix x
  2472       from \<open>filterlim X at_top sequentially\<close> 
  2472       from \<open>filterlim X at_top sequentially\<close> 
  2473       have "eventually (\<lambda>n. x \<le> X n) sequentially"
  2473       have "eventually (\<lambda>n. x \<le> X n) sequentially"
  2474         unfolding filterlim_at_top_ge[where c=x] by auto
  2474         unfolding filterlim_at_top_ge[where c=x] by auto
  2475       then show "(\<lambda>n. indicator {..X n} x *\<^sub>R f x) ----> f x"
  2475       then show "(\<lambda>n. indicator {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x"
  2476         by (intro Lim_eventually) (auto split: split_indicator elim!: eventually_mono)
  2476         by (intro Lim_eventually) (auto split: split_indicator elim!: eventually_mono)
  2477     qed
  2477     qed
  2478     fix n show "AE x in M. norm (indicator {..X n} x *\<^sub>R f x) \<le> norm (f x)"
  2478     fix n show "AE x in M. norm (indicator {..X n} x *\<^sub>R f x) \<le> norm (f x)"
  2479       by (auto split: split_indicator)
  2479       by (auto split: split_indicator)
  2480   qed auto
  2480   qed auto
  2495     by (auto split: split_indicator intro!: monoI)
  2495     by (auto split: split_indicator intro!: monoI)
  2496   { fix x have "eventually (\<lambda>n. f x * indicator {..real n} x = f x) sequentially"
  2496   { fix x have "eventually (\<lambda>n. f x * indicator {..real n} x = f x) sequentially"
  2497       by (rule eventually_sequentiallyI[of "nat \<lceil>x\<rceil>"])
  2497       by (rule eventually_sequentiallyI[of "nat \<lceil>x\<rceil>"])
  2498          (auto split: split_indicator simp: nat_le_iff ceiling_le_iff) }
  2498          (auto split: split_indicator simp: nat_le_iff ceiling_le_iff) }
  2499   from filterlim_cong[OF refl refl this]
  2499   from filterlim_cong[OF refl refl this]
  2500   have "AE x in M. (\<lambda>i. f x * indicator {..real i} x) ----> f x"
  2500   have "AE x in M. (\<lambda>i. f x * indicator {..real i} x) \<longlonglongrightarrow> f x"
  2501     by simp
  2501     by simp
  2502   have "(\<lambda>i. \<integral> x. f x * indicator {..real i} x \<partial>M) ----> x"
  2502   have "(\<lambda>i. \<integral> x. f x * indicator {..real i} x \<partial>M) \<longlonglongrightarrow> x"
  2503     using conv filterlim_real_sequentially by (rule filterlim_compose)
  2503     using conv filterlim_real_sequentially by (rule filterlim_compose)
  2504   have M_measure[simp]: "borel_measurable M = borel_measurable borel"
  2504   have M_measure[simp]: "borel_measurable M = borel_measurable borel"
  2505     using M by (simp add: sets_eq_imp_space_eq measurable_def)
  2505     using M by (simp add: sets_eq_imp_space_eq measurable_def)
  2506   have "f \<in> borel_measurable M"
  2506   have "f \<in> borel_measurable M"
  2507     using borel by simp
  2507     using borel by simp
  2537   assumes f[measurable]: "case_prod f \<in> borel_measurable (N \<Otimes>\<^sub>M M)"
  2537   assumes f[measurable]: "case_prod f \<in> borel_measurable (N \<Otimes>\<^sub>M M)"
  2538   shows "(\<lambda>x. \<integral>y. f x y \<partial>M) \<in> borel_measurable N"
  2538   shows "(\<lambda>x. \<integral>y. f x y \<partial>M) \<in> borel_measurable N"
  2539 proof -
  2539 proof -
  2540   from borel_measurable_implies_sequence_metric[OF f, of 0] guess s ..
  2540   from borel_measurable_implies_sequence_metric[OF f, of 0] guess s ..
  2541   then have s: "\<And>i. simple_function (N \<Otimes>\<^sub>M M) (s i)"
  2541   then have s: "\<And>i. simple_function (N \<Otimes>\<^sub>M M) (s i)"
  2542     "\<And>x y. x \<in> space N \<Longrightarrow> y \<in> space M \<Longrightarrow> (\<lambda>i. s i (x, y)) ----> f x y"
  2542     "\<And>x y. x \<in> space N \<Longrightarrow> y \<in> space M \<Longrightarrow> (\<lambda>i. s i (x, y)) \<longlonglongrightarrow> f x y"
  2543     "\<And>i x y. x \<in> space N \<Longrightarrow> y \<in> space M \<Longrightarrow> norm (s i (x, y)) \<le> 2 * norm (f x y)"
  2543     "\<And>i x y. x \<in> space N \<Longrightarrow> y \<in> space M \<Longrightarrow> norm (s i (x, y)) \<le> 2 * norm (f x y)"
  2544     by (auto simp: space_pair_measure norm_conv_dist)
  2544     by (auto simp: space_pair_measure norm_conv_dist)
  2545 
  2545 
  2546   have [measurable]: "\<And>i. s i \<in> borel_measurable (N \<Otimes>\<^sub>M M)"
  2546   have [measurable]: "\<And>i. s i \<in> borel_measurable (N \<Otimes>\<^sub>M M)"
  2547     by (rule borel_measurable_simple_function) fact
  2547     by (rule borel_measurable_simple_function) fact
  2567   next
  2567   next
  2568     fix x assume x: "x \<in> space N"
  2568     fix x assume x: "x \<in> space N"
  2569     { assume int_f: "integrable M (f x)"
  2569     { assume int_f: "integrable M (f x)"
  2570       have int_2f: "integrable M (\<lambda>y. 2 * norm (f x y))"
  2570       have int_2f: "integrable M (\<lambda>y. 2 * norm (f x y))"
  2571         by (intro integrable_norm integrable_mult_right int_f)
  2571         by (intro integrable_norm integrable_mult_right int_f)
  2572       have "(\<lambda>i. integral\<^sup>L M (\<lambda>y. s i (x, y))) ----> integral\<^sup>L M (f x)"
  2572       have "(\<lambda>i. integral\<^sup>L M (\<lambda>y. s i (x, y))) \<longlonglongrightarrow> integral\<^sup>L M (f x)"
  2573       proof (rule integral_dominated_convergence)
  2573       proof (rule integral_dominated_convergence)
  2574         from int_f show "f x \<in> borel_measurable M" by auto
  2574         from int_f show "f x \<in> borel_measurable M" by auto
  2575         show "\<And>i. (\<lambda>y. s i (x, y)) \<in> borel_measurable M"
  2575         show "\<And>i. (\<lambda>y. s i (x, y)) \<in> borel_measurable M"
  2576           using x by simp
  2576           using x by simp
  2577         show "AE xa in M. (\<lambda>i. s i (x, xa)) ----> f x xa"
  2577         show "AE xa in M. (\<lambda>i. s i (x, xa)) \<longlonglongrightarrow> f x xa"
  2578           using x s(2) by auto
  2578           using x s(2) by auto
  2579         show "\<And>i. AE xa in M. norm (s i (x, xa)) \<le> 2 * norm (f x xa)"
  2579         show "\<And>i. AE xa in M. norm (s i (x, xa)) \<le> 2 * norm (f x xa)"
  2580           using x s(3) by auto
  2580           using x s(3) by auto
  2581       qed fact
  2581       qed fact
  2582       moreover
  2582       moreover
  2595             using int_2f by (simp add: integrable_iff_bounded)
  2595             using int_2f by (simp add: integrable_iff_bounded)
  2596           finally show "(\<integral>\<^sup>+ xa. ereal (norm (s i (x, xa))) \<partial>M) < \<infinity>" .
  2596           finally show "(\<integral>\<^sup>+ xa. ereal (norm (s i (x, xa))) \<partial>M) < \<infinity>" .
  2597         qed
  2597         qed
  2598         then have "integral\<^sup>L M (\<lambda>y. s i (x, y)) = simple_bochner_integral M (\<lambda>y. s i (x, y))"
  2598         then have "integral\<^sup>L M (\<lambda>y. s i (x, y)) = simple_bochner_integral M (\<lambda>y. s i (x, y))"
  2599           by (rule simple_bochner_integrable_eq_integral[symmetric]) }
  2599           by (rule simple_bochner_integrable_eq_integral[symmetric]) }
  2600       ultimately have "(\<lambda>i. simple_bochner_integral M (\<lambda>y. s i (x, y))) ----> integral\<^sup>L M (f x)"
  2600       ultimately have "(\<lambda>i. simple_bochner_integral M (\<lambda>y. s i (x, y))) \<longlonglongrightarrow> integral\<^sup>L M (f x)"
  2601         by simp }
  2601         by simp }
  2602     then 
  2602     then 
  2603     show "(\<lambda>i. f' i x) ----> integral\<^sup>L M (f x)"
  2603     show "(\<lambda>i. f' i x) \<longlonglongrightarrow> integral\<^sup>L M (f x)"
  2604       unfolding f'_def
  2604       unfolding f'_def
  2605       by (cases "integrable M (f x)") (simp_all add: not_integrable_integral_eq)
  2605       by (cases "integrable M (f x)") (simp_all add: not_integrable_integral_eq)
  2606   qed
  2606   qed
  2607 qed
  2607 qed
  2608 
  2608 
  2777   then have [measurable]: "f \<in> borel_measurable (M1 \<Otimes>\<^sub>M M2)" "\<And>i. s i \<in> borel_measurable (M1 \<Otimes>\<^sub>M M2)"
  2777   then have [measurable]: "f \<in> borel_measurable (M1 \<Otimes>\<^sub>M M2)" "\<And>i. s i \<in> borel_measurable (M1 \<Otimes>\<^sub>M M2)"
  2778     by auto
  2778     by auto
  2779   
  2779   
  2780   show ?case
  2780   show ?case
  2781   proof (rule LIMSEQ_unique)
  2781   proof (rule LIMSEQ_unique)
  2782     show "(\<lambda>i. integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) (s i)) ----> integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) f"
  2782     show "(\<lambda>i. integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) (s i)) \<longlonglongrightarrow> integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) f"
  2783     proof (rule integral_dominated_convergence)
  2783     proof (rule integral_dominated_convergence)
  2784       show "integrable (M1 \<Otimes>\<^sub>M M2) (\<lambda>x. 2 * norm (f x))"
  2784       show "integrable (M1 \<Otimes>\<^sub>M M2) (\<lambda>x. 2 * norm (f x))"
  2785         using lim(5) by auto
  2785         using lim(5) by auto
  2786     qed (insert lim, auto)
  2786     qed (insert lim, auto)
  2787     have "(\<lambda>i. \<integral> x. \<integral> y. s i (x, y) \<partial>M2 \<partial>M1) ----> \<integral> x. \<integral> y. f (x, y) \<partial>M2 \<partial>M1"
  2787     have "(\<lambda>i. \<integral> x. \<integral> y. s i (x, y) \<partial>M2 \<partial>M1) \<longlonglongrightarrow> \<integral> x. \<integral> y. f (x, y) \<partial>M2 \<partial>M1"
  2788     proof (rule integral_dominated_convergence)
  2788     proof (rule integral_dominated_convergence)
  2789       have "AE x in M1. \<forall>i. integrable M2 (\<lambda>y. s i (x, y))"
  2789       have "AE x in M1. \<forall>i. integrable M2 (\<lambda>y. s i (x, y))"
  2790         unfolding AE_all_countable using AE_integrable_fst'[OF lim(1)] ..
  2790         unfolding AE_all_countable using AE_integrable_fst'[OF lim(1)] ..
  2791       with AE_space AE_integrable_fst'[OF lim(5)]
  2791       with AE_space AE_integrable_fst'[OF lim(5)]
  2792       show "AE x in M1. (\<lambda>i. \<integral> y. s i (x, y) \<partial>M2) ----> \<integral> y. f (x, y) \<partial>M2"
  2792       show "AE x in M1. (\<lambda>i. \<integral> y. s i (x, y) \<partial>M2) \<longlonglongrightarrow> \<integral> y. f (x, y) \<partial>M2"
  2793       proof eventually_elim
  2793       proof eventually_elim
  2794         fix x assume x: "x \<in> space M1" and
  2794         fix x assume x: "x \<in> space M1" and
  2795           s: "\<forall>i. integrable M2 (\<lambda>y. s i (x, y))" and f: "integrable M2 (\<lambda>y. f (x, y))"
  2795           s: "\<forall>i. integrable M2 (\<lambda>y. s i (x, y))" and f: "integrable M2 (\<lambda>y. f (x, y))"
  2796         show "(\<lambda>i. \<integral> y. s i (x, y) \<partial>M2) ----> \<integral> y. f (x, y) \<partial>M2"
  2796         show "(\<lambda>i. \<integral> y. s i (x, y) \<partial>M2) \<longlonglongrightarrow> \<integral> y. f (x, y) \<partial>M2"
  2797         proof (rule integral_dominated_convergence)
  2797         proof (rule integral_dominated_convergence)
  2798           show "integrable M2 (\<lambda>y. 2 * norm (f (x, y)))"
  2798           show "integrable M2 (\<lambda>y. 2 * norm (f (x, y)))"
  2799              using f by auto
  2799              using f by auto
  2800           show "AE xa in M2. (\<lambda>i. s i (x, xa)) ----> f (x, xa)"
  2800           show "AE xa in M2. (\<lambda>i. s i (x, xa)) \<longlonglongrightarrow> f (x, xa)"
  2801             using x lim(3) by (auto simp: space_pair_measure)
  2801             using x lim(3) by (auto simp: space_pair_measure)
  2802           show "\<And>i. AE xa in M2. norm (s i (x, xa)) \<le> 2 * norm (f (x, xa))"
  2802           show "\<And>i. AE xa in M2. norm (s i (x, xa)) \<le> 2 * norm (f (x, xa))"
  2803             using x lim(4) by (auto simp: space_pair_measure)
  2803             using x lim(4) by (auto simp: space_pair_measure)
  2804         qed (insert x, measurable)
  2804         qed (insert x, measurable)
  2805       qed
  2805       qed
  2818           using f by (intro nn_integral_eq_integral) auto
  2818           using f by (intro nn_integral_eq_integral) auto
  2819         finally show "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral> y. 2 * norm (f (x, y)) \<partial>M2)"
  2819         finally show "norm (\<integral> y. s i (x, y) \<partial>M2) \<le> (\<integral> y. 2 * norm (f (x, y)) \<partial>M2)"
  2820           by simp
  2820           by simp
  2821       qed
  2821       qed
  2822     qed simp_all
  2822     qed simp_all
  2823     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"
  2823     then show "(\<lambda>i. integral\<^sup>L (M1 \<Otimes>\<^sub>M M2) (s i)) \<longlonglongrightarrow> \<integral> x. \<integral> y. f (x, y) \<partial>M2 \<partial>M1"
  2824       using lim by simp
  2824       using lim by simp
  2825   qed
  2825   qed
  2826 qed
  2826 qed
  2827 
  2827 
  2828 lemma (in pair_sigma_finite)
  2828 lemma (in pair_sigma_finite)
  2989     case (lim f s)
  2989     case (lim f s)
  2990     then have M: "\<And>i. integrable M (s i)" "integrable M f"
  2990     then have M: "\<And>i. integrable M (s i)" "integrable M f"
  2991       using integrable_subalgebra[OF _ N, of f] integrable_subalgebra[OF _ N, of "s i" for i] by simp_all
  2991       using integrable_subalgebra[OF _ N, of f] integrable_subalgebra[OF _ N, of "s i" for i] by simp_all
  2992     show ?case
  2992     show ?case
  2993     proof (intro LIMSEQ_unique)
  2993     proof (intro LIMSEQ_unique)
  2994       show "(\<lambda>i. integral\<^sup>L N (s i)) ----> integral\<^sup>L N f"
  2994       show "(\<lambda>i. integral\<^sup>L N (s i)) \<longlonglongrightarrow> integral\<^sup>L N f"
  2995         apply (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2995         apply (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  2996         using lim
  2996         using lim
  2997         apply auto
  2997         apply auto
  2998         done
  2998         done
  2999       show "(\<lambda>i. integral\<^sup>L N (s i)) ----> integral\<^sup>L M f"
  2999       show "(\<lambda>i. integral\<^sup>L N (s i)) \<longlonglongrightarrow> integral\<^sup>L M f"
  3000         unfolding lim
  3000         unfolding lim
  3001         apply (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  3001         apply (rule integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"])
  3002         using lim M N(2)
  3002         using lim M N(2)
  3003         apply auto
  3003         apply auto
  3004         done
  3004         done