src/HOL/Probability/Nonnegative_Lebesgue_Integration.thy
changeset 62390 842917225d56
parent 62343 24106dc44def
child 62975 1d066f6ab25d
equal deleted inserted replaced
62380:29800666e526 62390:842917225d56
    53 proof safe
    53 proof safe
    54   fix A assume "finite (f ` space M)" "\<forall>x\<in>f ` space M. f -` {x} \<inter> space M \<in> sets M"
    54   fix A assume "finite (f ` space M)" "\<forall>x\<in>f ` space M. f -` {x} \<inter> space M \<in> sets M"
    55   then have "(\<Union>x\<in>f ` space M. if x \<in> A then f -` {x} \<inter> space M else {}) \<in> sets M"
    55   then have "(\<Union>x\<in>f ` space M. if x \<in> A then f -` {x} \<inter> space M else {}) \<in> sets M"
    56     by (intro sets.finite_UN) auto
    56     by (intro sets.finite_UN) auto
    57   also have "(\<Union>x\<in>f ` space M. if x \<in> A then f -` {x} \<inter> space M else {}) = f -` A \<inter> space M"
    57   also have "(\<Union>x\<in>f ` space M. if x \<in> A then f -` {x} \<inter> space M else {}) = f -` A \<inter> space M"
    58     by (auto split: split_if_asm)
    58     by (auto split: if_split_asm)
    59   finally show "f -` A \<inter> space M \<in> sets M" .
    59   finally show "f -` A \<inter> space M \<in> sets M" .
    60 qed simp
    60 qed simp
    61 
    61 
    62 lemma borel_measurable_simple_function:
    62 lemma borel_measurable_simple_function:
    63   "simple_function M f \<Longrightarrow> f \<in> borel_measurable M"
    63   "simple_function M f \<Longrightarrow> f \<in> borel_measurable M"
   220   shows "\<exists>f. incseq f \<and> (\<forall>i. \<infinity> \<notin> range (f i) \<and> simple_function M (f i)) \<and>
   220   shows "\<exists>f. incseq f \<and> (\<forall>i. \<infinity> \<notin> range (f i) \<and> simple_function M (f i)) \<and>
   221              (\<forall>x. (SUP i. f i x) = max 0 (u x)) \<and> (\<forall>i x. 0 \<le> f i x)"
   221              (\<forall>x. (SUP i. f i x) = max 0 (u x)) \<and> (\<forall>i x. 0 \<le> f i x)"
   222 proof -
   222 proof -
   223   def f \<equiv> "\<lambda>x i. if real i \<le> u x then i * 2 ^ i else nat \<lfloor>real_of_ereal (u x) * 2 ^ i\<rfloor>"
   223   def f \<equiv> "\<lambda>x i. if real i \<le> u x then i * 2 ^ i else nat \<lfloor>real_of_ereal (u x) * 2 ^ i\<rfloor>"
   224   { fix x j have "f x j \<le> j * 2 ^ j" unfolding f_def
   224   { fix x j have "f x j \<le> j * 2 ^ j" unfolding f_def
   225     proof (split split_if, intro conjI impI)
   225     proof (split if_split, intro conjI impI)
   226       assume "\<not> real j \<le> u x"
   226       assume "\<not> real j \<le> u x"
   227       then have "nat \<lfloor>real_of_ereal (u x) * 2 ^ j\<rfloor> \<le> nat \<lfloor>j * 2 ^ j\<rfloor>"
   227       then have "nat \<lfloor>real_of_ereal (u x) * 2 ^ j\<rfloor> \<le> nat \<lfloor>j * 2 ^ j\<rfloor>"
   228          by (cases "u x") (auto intro!: nat_mono floor_mono)
   228          by (cases "u x") (auto intro!: nat_mono floor_mono)
   229       moreover have "real (nat \<lfloor>j * 2 ^ j\<rfloor>) \<le> j * 2^j"
   229       moreover have "real (nat \<lfloor>j * 2 ^ j\<rfloor>) \<le> j * 2^j"
   230         by linarith
   230         by linarith
   256   next
   256   next
   257     show "incseq ?g"
   257     show "incseq ?g"
   258     proof (intro incseq_ereal incseq_SucI le_funI)
   258     proof (intro incseq_ereal incseq_SucI le_funI)
   259       fix x and i :: nat
   259       fix x and i :: nat
   260       have "f x i * 2 \<le> f x (Suc i)" unfolding f_def
   260       have "f x i * 2 \<le> f x (Suc i)" unfolding f_def
   261       proof ((split split_if)+, intro conjI impI)
   261       proof ((split if_split)+, intro conjI impI)
   262         assume "ereal (real i) \<le> u x" "\<not> ereal (real (Suc i)) \<le> u x"
   262         assume "ereal (real i) \<le> u x" "\<not> ereal (real (Suc i)) \<le> u x"
   263         then show "i * 2 ^ i * 2 \<le> nat \<lfloor>real_of_ereal (u x) * 2 ^ Suc i\<rfloor>"
   263         then show "i * 2 ^ i * 2 \<le> nat \<lfloor>real_of_ereal (u x) * 2 ^ Suc i\<rfloor>"
   264           by (cases "u x") (auto intro!: le_nat_floor)
   264           by (cases "u x") (auto intro!: le_nat_floor)
   265       next
   265       next
   266         assume "\<not> ereal (real i) \<le> u x" "ereal (real (Suc i)) \<le> u x"
   266         assume "\<not> ereal (real i) \<le> u x" "ereal (real (Suc i)) \<le> u x"
   309           obtain N where "\<forall>n\<ge>N. r * 2^n < p * 2^n - 1" by (auto simp: field_simps)
   309           obtain N where "\<forall>n\<ge>N. r * 2^n < p * 2^n - 1" by (auto simp: field_simps)
   310           then have "r * 2^max N m < p * 2^max N m - 1" by simp
   310           then have "r * 2^max N m < p * 2^max N m - 1" by simp
   311           moreover
   311           moreover
   312           have "real (nat \<lfloor>p * 2 ^ max N m\<rfloor>) \<le> r * 2 ^ max N m"
   312           have "real (nat \<lfloor>p * 2 ^ max N m\<rfloor>) \<le> r * 2 ^ max N m"
   313             using *[of "max N m"] m unfolding real_f using ux
   313             using *[of "max N m"] m unfolding real_f using ux
   314             by (cases "0 \<le> u x") (simp_all add: max_def split: split_if_asm)
   314             by (cases "0 \<le> u x") (simp_all add: max_def split: if_split_asm)
   315           then have "p * 2 ^ max N m - 1 < r * 2 ^ max N m"
   315           then have "p * 2 ^ max N m - 1 < r * 2 ^ max N m"
   316             by linarith
   316             by linarith
   317           ultimately show False by auto
   317           ultimately show False by auto
   318         qed
   318         qed
   319         then show "max 0 (u x) \<le> y" using real ux by simp
   319         then show "max 0 (u x) \<le> y" using real ux by simp
   465   next
   465   next
   466     fix x assume "x \<in> space M"
   466     fix x assume "x \<in> space M"
   467     then have *: "?IF -` {?IF x} \<inter> space M = (if x \<in> A
   467     then have *: "?IF -` {?IF x} \<inter> space M = (if x \<in> A
   468       then ((F (f x) \<inter> (A \<inter> space M)) \<union> (G (f x) - (G (f x) \<inter> (A \<inter> space M))))
   468       then ((F (f x) \<inter> (A \<inter> space M)) \<union> (G (f x) - (G (f x) \<inter> (A \<inter> space M))))
   469       else ((F (g x) \<inter> (A \<inter> space M)) \<union> (G (g x) - (G (g x) \<inter> (A \<inter> space M)))))"
   469       else ((F (g x) \<inter> (A \<inter> space M)) \<union> (G (g x) - (G (g x) \<inter> (A \<inter> space M)))))"
   470       using sets.sets_into_space[OF A] by (auto split: split_if_asm simp: G_def F_def)
   470       using sets.sets_into_space[OF A] by (auto split: if_split_asm simp: G_def F_def)
   471     have [intro]: "\<And>x. F x \<in> sets M" "\<And>x. G x \<in> sets M"
   471     have [intro]: "\<And>x. F x \<in> sets M" "\<And>x. G x \<in> sets M"
   472       unfolding F_def G_def using sf[THEN simple_functionD(2)] by auto
   472       unfolding F_def G_def using sf[THEN simple_functionD(2)] by auto
   473     show "?IF -` {?IF x} \<inter> space M \<in> sets M" unfolding * using A by auto
   473     show "?IF -` {?IF x} \<inter> space M \<in> sets M" unfolding * using A by auto
   474   qed
   474   qed
   475 qed
   475 qed
   683   assumes f: "simple_function M f"
   683   assumes f: "simple_function M f"
   684   shows "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
   684   shows "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
   685     (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M \<inter> A))"
   685     (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M \<inter> A))"
   686 proof -
   686 proof -
   687   have eq: "(\<lambda>x. (f x, indicator A x)) ` space M \<inter> {x. snd x = 1} = (\<lambda>x. (f x, 1::ereal))`A"
   687   have eq: "(\<lambda>x. (f x, indicator A x)) ` space M \<inter> {x. snd x = 1} = (\<lambda>x. (f x, 1::ereal))`A"
   688     using A[THEN sets.sets_into_space] by (auto simp: indicator_def image_iff split: split_if_asm)
   688     using A[THEN sets.sets_into_space] by (auto simp: indicator_def image_iff split: if_split_asm)
   689   have eq2: "\<And>x. f x \<notin> f ` A \<Longrightarrow> f -` {f x} \<inter> space M \<inter> A = {}"
   689   have eq2: "\<And>x. f x \<notin> f ` A \<Longrightarrow> f -` {f x} \<inter> space M \<inter> A = {}"
   690     by (auto simp: image_iff)
   690     by (auto simp: image_iff)
   691 
   691 
   692   have "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
   692   have "(\<integral>\<^sup>Sx. f x * indicator A x \<partial>M) =
   693     (\<Sum>y\<in>(\<lambda>x. (f x, indicator A x))`space M. (fst y * snd y) * emeasure M {x\<in>space M. (f x, indicator A x) = y})"
   693     (\<Sum>y\<in>(\<lambda>x. (f x, indicator A x))`space M. (fst y * snd y) * emeasure M {x\<in>space M. (f x, indicator A x) = y})"
   694     using assms by (intro simple_function_partition) auto
   694     using assms by (intro simple_function_partition) auto
   695   also have "\<dots> = (\<Sum>y\<in>(\<lambda>x. (f x, indicator A x::ereal))`space M.
   695   also have "\<dots> = (\<Sum>y\<in>(\<lambda>x. (f x, indicator A x::ereal))`space M.
   696     if snd y = 1 then fst y * emeasure M (f -` {fst y} \<inter> space M \<inter> A) else 0)"
   696     if snd y = 1 then fst y * emeasure M (f -` {fst y} \<inter> space M \<inter> A) else 0)"
   697     by (auto simp: indicator_def split: split_if_asm intro!: arg_cong2[where f="op *"] arg_cong2[where f=emeasure] setsum.cong)
   697     by (auto simp: indicator_def split: if_split_asm intro!: arg_cong2[where f="op *"] arg_cong2[where f=emeasure] setsum.cong)
   698   also have "\<dots> = (\<Sum>y\<in>(\<lambda>x. (f x, 1::ereal))`A. fst y * emeasure M (f -` {fst y} \<inter> space M \<inter> A))"
   698   also have "\<dots> = (\<Sum>y\<in>(\<lambda>x. (f x, 1::ereal))`A. fst y * emeasure M (f -` {fst y} \<inter> space M \<inter> A))"
   699     using assms by (subst setsum.If_cases) (auto intro!: simple_functionD(1) simp: eq)
   699     using assms by (subst setsum.If_cases) (auto intro!: simple_functionD(1) simp: eq)
   700   also have "\<dots> = (\<Sum>y\<in>fst`(\<lambda>x. (f x, 1::ereal))`A. y * emeasure M (f -` {y} \<inter> space M \<inter> A))"
   700   also have "\<dots> = (\<Sum>y\<in>fst`(\<lambda>x. (f x, 1::ereal))`A. y * emeasure M (f -` {y} \<inter> space M \<inter> A))"
   701     by (subst setsum.reindex [of fst]) (auto simp: inj_on_def)
   701     by (subst setsum.reindex [of fst]) (auto simp: inj_on_def)
   702   also have "\<dots> = (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M \<inter> A))"
   702   also have "\<dots> = (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M \<inter> A))"
   707 
   707 
   708 lemma simple_integral_indicator_only[simp]:
   708 lemma simple_integral_indicator_only[simp]:
   709   assumes "A \<in> sets M"
   709   assumes "A \<in> sets M"
   710   shows "integral\<^sup>S M (indicator A) = emeasure M A"
   710   shows "integral\<^sup>S M (indicator A) = emeasure M A"
   711   using simple_integral_indicator[OF assms, of "\<lambda>x. 1"] sets.sets_into_space[OF assms]
   711   using simple_integral_indicator[OF assms, of "\<lambda>x. 1"] sets.sets_into_space[OF assms]
   712   by (simp_all add: image_constant_conv Int_absorb1 split: split_if_asm)
   712   by (simp_all add: image_constant_conv Int_absorb1 split: if_split_asm)
   713 
   713 
   714 lemma simple_integral_null_set:
   714 lemma simple_integral_null_set:
   715   assumes "simple_function M u" "\<And>x. 0 \<le> u x" and "N \<in> null_sets M"
   715   assumes "simple_function M u" "\<And>x. 0 \<le> u x" and "N \<in> null_sets M"
   716   shows "(\<integral>\<^sup>Sx. u x * indicator N x \<partial>M) = 0"
   716   shows "(\<integral>\<^sup>Sx. u x * indicator N x \<partial>M) = 0"
   717 proof -
   717 proof -
   775   note gM = g(1)[THEN borel_measurable_simple_function]
   775   note gM = g(1)[THEN borel_measurable_simple_function]
   776   have \<mu>_G_pos: "0 \<le> (emeasure M) ?G" using gM by auto
   776   have \<mu>_G_pos: "0 \<le> (emeasure M) ?G" using gM by auto
   777   let ?g = "\<lambda>y x. if g x = \<infinity> then y else max 0 (g x)"
   777   let ?g = "\<lambda>y x. if g x = \<infinity> then y else max 0 (g x)"
   778   from g gM have g_in_A: "\<And>y. 0 \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> ?g y \<in> ?A"
   778   from g gM have g_in_A: "\<And>y. 0 \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> ?g y \<in> ?A"
   779     apply (safe intro!: simple_function_max simple_function_If)
   779     apply (safe intro!: simple_function_max simple_function_If)
   780     apply (force simp: max_def le_fun_def split: split_if_asm)+
   780     apply (force simp: max_def le_fun_def split: if_split_asm)+
   781     done
   781     done
   782   show "integral\<^sup>S M g \<le> SUPREMUM ?A ?f"
   782   show "integral\<^sup>S M g \<le> SUPREMUM ?A ?f"
   783   proof cases
   783   proof cases
   784     have g0: "?g 0 \<in> ?A" by (intro g_in_A) auto
   784     have g0: "?g 0 \<in> ?A" by (intro g_in_A) auto
   785     assume "(emeasure M) ?G = 0"
   785     assume "(emeasure M) ?G = 0"
   824   { fix x have "?n x \<le> max 0 (v x)"
   824   { fix x have "?n x \<le> max 0 (v x)"
   825     proof cases
   825     proof cases
   826       assume x: "x \<in> space M - N"
   826       assume x: "x \<in> space M - N"
   827       with N have "u x \<le> v x" by auto
   827       with N have "u x \<le> v x" by auto
   828       with n(2)[THEN le_funD, of x] x show ?thesis
   828       with n(2)[THEN le_funD, of x] x show ?thesis
   829         by (auto simp: max_def split: split_if_asm)
   829         by (auto simp: max_def split: if_split_asm)
   830     qed simp }
   830     qed simp }
   831   then have "?n \<le> max 0 \<circ> v" by (auto simp: le_funI)
   831   then have "?n \<le> max 0 \<circ> v" by (auto simp: le_funI)
   832   moreover have "integral\<^sup>S M n \<le> integral\<^sup>S M ?n"
   832   moreover have "integral\<^sup>S M n \<le> integral\<^sup>S M ?n"
   833     using ae_N N n by (auto intro!: simple_integral_mono_AE)
   833     using ae_N N n by (auto intro!: simple_integral_mono_AE)
   834   ultimately show "\<exists>m\<in>{g. simple_function M g \<and> g \<le> max 0 \<circ> v}. integral\<^sup>S M n \<le> integral\<^sup>S M m"
   834   ultimately show "\<exists>m\<in>{g. simple_function M g \<and> g \<le> max 0 \<circ> v}. integral\<^sup>S M n \<le> integral\<^sup>S M m"
  1084 lemma nn_integral_const[simp]:
  1084 lemma nn_integral_const[simp]:
  1085   "0 \<le> c \<Longrightarrow> (\<integral>\<^sup>+ x. c \<partial>M) = c * (emeasure M) (space M)"
  1085   "0 \<le> c \<Longrightarrow> (\<integral>\<^sup>+ x. c \<partial>M) = c * (emeasure M) (space M)"
  1086   by (subst nn_integral_eq_simple_integral) auto
  1086   by (subst nn_integral_eq_simple_integral) auto
  1087 
  1087 
  1088 lemma nn_integral_const_nonpos: "c \<le> 0 \<Longrightarrow> nn_integral M (\<lambda>x. c) = 0"
  1088 lemma nn_integral_const_nonpos: "c \<le> 0 \<Longrightarrow> nn_integral M (\<lambda>x. c) = 0"
  1089   using nn_integral_max_0[of M "\<lambda>x. c"] by (simp add: max_def split: split_if_asm)
  1089   using nn_integral_max_0[of M "\<lambda>x. c"] by (simp add: max_def split: if_split_asm)
  1090 
  1090 
  1091 lemma nn_integral_linear:
  1091 lemma nn_integral_linear:
  1092   assumes f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" and "0 \<le> a"
  1092   assumes f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" and "0 \<le> a"
  1093   and g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g x"
  1093   and g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g x"
  1094   shows "(\<integral>\<^sup>+ x. a * f x + g x \<partial>M) = a * integral\<^sup>N M f + integral\<^sup>N M g"
  1094   shows "(\<integral>\<^sup>+ x. a * f x + g x \<partial>M) = a * integral\<^sup>N M f + integral\<^sup>N M g"
  1109     by (auto simp: incseq_Suc_iff le_fun_def
  1109     by (auto simp: incseq_Suc_iff le_fun_def
  1110              intro!: add_mono ereal_mult_left_mono simple_integral_mono)
  1110              intro!: add_mono ereal_mult_left_mono simple_integral_mono)
  1111   have pos: "\<And>i. 0 \<le> integral\<^sup>S M (u i)" "\<And>i. 0 \<le> integral\<^sup>S M (v i)" "\<And>i. 0 \<le> a * integral\<^sup>S M (u i)"
  1111   have pos: "\<And>i. 0 \<le> integral\<^sup>S M (u i)" "\<And>i. 0 \<le> integral\<^sup>S M (v i)" "\<And>i. 0 \<le> a * integral\<^sup>S M (u i)"
  1112     using u v \<open>0 \<le> a\<close> by (auto simp: simple_integral_nonneg)
  1112     using u v \<open>0 \<le> a\<close> by (auto simp: simple_integral_nonneg)
  1113   { fix i from pos[of i] have "a * integral\<^sup>S M (u i) \<noteq> -\<infinity>" "integral\<^sup>S M (v i) \<noteq> -\<infinity>"
  1113   { fix i from pos[of i] have "a * integral\<^sup>S M (u i) \<noteq> -\<infinity>" "integral\<^sup>S M (v i) \<noteq> -\<infinity>"
  1114       by (auto split: split_if_asm) }
  1114       by (auto split: if_split_asm) }
  1115   note not_MInf = this
  1115   note not_MInf = this
  1116 
  1116 
  1117   have l': "(SUP i. integral\<^sup>S M (l i)) = (SUP i. integral\<^sup>S M (?L' i))"
  1117   have l': "(SUP i. integral\<^sup>S M (l i)) = (SUP i. integral\<^sup>S M (?L' i))"
  1118   proof (rule SUP_simple_integral_sequences[OF l(3,6,2)])
  1118   proof (rule SUP_simple_integral_sequences[OF l(3,6,2)])
  1119     show "incseq ?L'" "\<And>i x. 0 \<le> ?L' i x" "\<And>i. simple_function M (?L' i)"
  1119     show "incseq ?L'" "\<And>i x. 0 \<le> ?L' i x" "\<And>i. simple_function M (?L' i)"
  1314   finally have "\<infinity> * (emeasure M) (f -` {\<infinity>} \<inter> space M) \<le> integral\<^sup>N M f"
  1314   finally have "\<infinity> * (emeasure M) (f -` {\<infinity>} \<inter> space M) \<le> integral\<^sup>N M f"
  1315     by (simp add: nn_integral_max_0)
  1315     by (simp add: nn_integral_max_0)
  1316   moreover have "0 \<le> (emeasure M) (f -` {\<infinity>} \<inter> space M)"
  1316   moreover have "0 \<le> (emeasure M) (f -` {\<infinity>} \<inter> space M)"
  1317     by (rule emeasure_nonneg)
  1317     by (rule emeasure_nonneg)
  1318   ultimately show ?thesis
  1318   ultimately show ?thesis
  1319     using assms by (auto split: split_if_asm)
  1319     using assms by (auto split: if_split_asm)
  1320 qed
  1320 qed
  1321 
  1321 
  1322 lemma nn_integral_PInf_AE:
  1322 lemma nn_integral_PInf_AE:
  1323   assumes "f \<in> borel_measurable M" "integral\<^sup>N M f \<noteq> \<infinity>" shows "AE x in M. f x \<noteq> \<infinity>"
  1323   assumes "f \<in> borel_measurable M" "integral\<^sup>N M f \<noteq> \<infinity>" shows "AE x in M. f x \<noteq> \<infinity>"
  1324 proof (rule AE_I)
  1324 proof (rule AE_I)
  1618     assume "(emeasure M) ?A = 0"
  1618     assume "(emeasure M) ?A = 0"
  1619     with nn_integral_null_set[of ?A M u] u
  1619     with nn_integral_null_set[of ?A M u] u
  1620     show "integral\<^sup>N M u = 0" by (simp add: u_eq null_sets_def)
  1620     show "integral\<^sup>N M u = 0" by (simp add: u_eq null_sets_def)
  1621   next
  1621   next
  1622     { fix r :: ereal and n :: nat assume gt_1: "1 \<le> real n * r"
  1622     { fix r :: ereal and n :: nat assume gt_1: "1 \<le> real n * r"
  1623       then have "0 < real n * r" by (cases r) (auto split: split_if_asm simp: one_ereal_def)
  1623       then have "0 < real n * r" by (cases r) (auto split: if_split_asm simp: one_ereal_def)
  1624       then have "0 \<le> r" by (auto simp add: ereal_zero_less_0_iff) }
  1624       then have "0 \<le> r" by (auto simp add: ereal_zero_less_0_iff) }
  1625     note gt_1 = this
  1625     note gt_1 = this
  1626     assume *: "integral\<^sup>N M u = 0"
  1626     assume *: "integral\<^sup>N M u = 0"
  1627     let ?M = "\<lambda>n. {x \<in> space M. 1 \<le> real (n::nat) * u x}"
  1627     let ?M = "\<lambda>n. {x \<in> space M. 1 \<le> real (n::nat) * u x}"
  1628     have "0 = (SUP n. (emeasure M) (?M n \<inter> ?A))"
  1628     have "0 = (SUP n. (emeasure M) (?M n \<inter> ?A))"
  2375       by (intro nn_integral_0_iff) auto
  2375       by (intro nn_integral_0_iff) auto
  2376     also have "\<dots> \<longleftrightarrow> (AE x in M. max 0 (f x) * indicator A x = 0)"
  2376     also have "\<dots> \<longleftrightarrow> (AE x in M. max 0 (f x) * indicator A x = 0)"
  2377       using f \<open>A \<in> sets M\<close>
  2377       using f \<open>A \<in> sets M\<close>
  2378       by (intro AE_iff_measurable[OF _ refl, symmetric]) auto
  2378       by (intro AE_iff_measurable[OF _ refl, symmetric]) auto
  2379     also have "(AE x in M. max 0 (f x) * indicator A x = 0) \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)"
  2379     also have "(AE x in M. max 0 (f x) * indicator A x = 0) \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)"
  2380       by (auto simp add: indicator_def max_def split: split_if_asm)
  2380       by (auto simp add: indicator_def max_def split: if_split_asm)
  2381     finally have "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = 0 \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)" . }
  2381     finally have "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = 0 \<longleftrightarrow> (AE x in M. x \<in> A \<longrightarrow> f x \<le> 0)" . }
  2382   with f show ?thesis
  2382   with f show ?thesis
  2383     by (simp add: null_sets_def emeasure_density cong: conj_cong)
  2383     by (simp add: null_sets_def emeasure_density cong: conj_cong)
  2384 qed
  2384 qed
  2385 
  2385