src/HOL/Analysis/Set_Integral.thy
changeset 67974 3f352a91b45a
parent 67399 eab6ce8368fa
child 67977 557ea2740125
equal deleted inserted replaced
67971:e9f66b35d636 67974:3f352a91b45a
    13 
    13 
    14 (*
    14 (*
    15     Notation
    15     Notation
    16 *)
    16 *)
    17 
    17 
    18 abbreviation "set_borel_measurable M A f \<equiv> (\<lambda>x. indicator A x *\<^sub>R f x) \<in> borel_measurable M"
    18 definition "set_borel_measurable M A f \<equiv> (\<lambda>x. indicator A x *\<^sub>R f x) \<in> borel_measurable M"
    19 
    19 
    20 abbreviation "set_integrable M A f \<equiv> integrable M (\<lambda>x. indicator A x *\<^sub>R f x)"
    20 definition "set_integrable M A f \<equiv> integrable M (\<lambda>x. indicator A x *\<^sub>R f x)"
    21 
    21 
    22 abbreviation "set_lebesgue_integral M A f \<equiv> lebesgue_integral M (\<lambda>x. indicator A x *\<^sub>R f x)"
    22 definition "set_lebesgue_integral M A f \<equiv> lebesgue_integral M (\<lambda>x. indicator A x *\<^sub>R f x)"
    23 
    23 
    24 syntax
    24 syntax
    25 "_ascii_set_lebesgue_integral" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a measure \<Rightarrow> real \<Rightarrow> real"
    25   "_ascii_set_lebesgue_integral" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a measure \<Rightarrow> real \<Rightarrow> real"
    26 ("(4LINT (_):(_)/|(_)./ _)" [0,60,110,61] 60)
    26   ("(4LINT (_):(_)/|(_)./ _)" [0,60,110,61] 60)
    27 
    27 
    28 translations
    28 translations
    29 "LINT x:A|M. f" == "CONST set_lebesgue_integral M A (\<lambda>x. f)"
    29   "LINT x:A|M. f" == "CONST set_lebesgue_integral M A (\<lambda>x. f)"
    30 
    30 
    31 (*
    31 (*
    32     Notation for integration wrt lebesgue measure on the reals:
    32     Notation for integration wrt lebesgue measure on the reals:
    33 
    33 
    34       LBINT x. f
    34       LBINT x. f
    36 
    36 
    37     TODO: keep all these? Need unicode.
    37     TODO: keep all these? Need unicode.
    38 *)
    38 *)
    39 
    39 
    40 syntax
    40 syntax
    41 "_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real \<Rightarrow> real"
    41   "_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real \<Rightarrow> real"
    42 ("(2LBINT _./ _)" [0,60] 60)
    42   ("(2LBINT _./ _)" [0,60] 60)
    43 
    43 
    44 syntax
    44 syntax
    45 "_set_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real set \<Rightarrow> real \<Rightarrow> real"
    45   "_set_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real set \<Rightarrow> real \<Rightarrow> real"
    46 ("(3LBINT _:_./ _)" [0,60,61] 60)
    46   ("(3LBINT _:_./ _)" [0,60,61] 60)
    47 
    47 
    48 (*
    48 (*
    49     Basic properties
    49     Basic properties
    50 *)
    50 *)
    51 
    51 
    58   fixes f :: "_ \<Rightarrow> _::real_normed_vector"
    58   fixes f :: "_ \<Rightarrow> _::real_normed_vector"
    59   assumes "set_borel_measurable M X f" "B \<in> sets borel" "X \<in> sets M"
    59   assumes "set_borel_measurable M X f" "B \<in> sets borel" "X \<in> sets M"
    60   shows "f -` B \<inter> X \<in> sets M"
    60   shows "f -` B \<inter> X \<in> sets M"
    61 proof -
    61 proof -
    62   have "f \<in> borel_measurable (restrict_space M X)"
    62   have "f \<in> borel_measurable (restrict_space M X)"
    63     using assms by (subst borel_measurable_restrict_space_iff) auto
    63     using assms unfolding set_borel_measurable_def by (subst borel_measurable_restrict_space_iff) auto
    64   then have "f -` B \<inter> space (restrict_space M X) \<in> sets (restrict_space M X)"
    64   then have "f -` B \<inter> space (restrict_space M X) \<in> sets (restrict_space M X)"
    65     by (rule measurable_sets) fact
    65     by (rule measurable_sets) fact
    66   with \<open>X \<in> sets M\<close> show ?thesis
    66   with \<open>X \<in> sets M\<close> show ?thesis
    67     by (subst (asm) sets_restrict_space_iff) (auto simp: space_restrict_space)
    67     by (subst (asm) sets_restrict_space_iff) (auto simp: space_restrict_space)
    68 qed
    68 qed
    69 
    69 
    70 lemma set_lebesgue_integral_cong:
    70 lemma set_lebesgue_integral_cong:
    71   assumes "A \<in> sets M" and "\<forall>x. x \<in> A \<longrightarrow> f x = g x"
    71   assumes "A \<in> sets M" and "\<forall>x. x \<in> A \<longrightarrow> f x = g x"
    72   shows "(LINT x:A|M. f x) = (LINT x:A|M. g x)"
    72   shows "(LINT x:A|M. f x) = (LINT x:A|M. g x)"
    73   using assms by (auto intro!: Bochner_Integration.integral_cong split: split_indicator simp add: sets.sets_into_space)
    73   unfolding set_lebesgue_integral_def
       
    74   using assms
       
    75   by (metis indicator_simps(2) real_vector.scale_zero_left)
    74 
    76 
    75 lemma set_lebesgue_integral_cong_AE:
    77 lemma set_lebesgue_integral_cong_AE:
    76   assumes [measurable]: "A \<in> sets M" "f \<in> borel_measurable M" "g \<in> borel_measurable M"
    78   assumes [measurable]: "A \<in> sets M" "f \<in> borel_measurable M" "g \<in> borel_measurable M"
    77   assumes "AE x \<in> A in M. f x = g x"
    79   assumes "AE x \<in> A in M. f x = g x"
    78   shows "LINT x:A|M. f x = LINT x:A|M. g x"
    80   shows "LINT x:A|M. f x = LINT x:A|M. g x"
    79 proof-
    81 proof-
    80   have "AE x in M. indicator A x *\<^sub>R f x = indicator A x *\<^sub>R g x"
    82   have "AE x in M. indicator A x *\<^sub>R f x = indicator A x *\<^sub>R g x"
    81     using assms by auto
    83     using assms by auto
    82   thus ?thesis by (intro integral_cong_AE) auto
    84   thus ?thesis
       
    85   unfolding set_lebesgue_integral_def by (intro integral_cong_AE) auto
    83 qed
    86 qed
    84 
    87 
    85 lemma set_integrable_cong_AE:
    88 lemma set_integrable_cong_AE:
    86     "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow>
    89     "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow>
    87     AE x \<in> A in M. f x = g x \<Longrightarrow> A \<in> sets M \<Longrightarrow>
    90     AE x \<in> A in M. f x = g x \<Longrightarrow> A \<in> sets M \<Longrightarrow>
    88     set_integrable M A f = set_integrable M A g"
    91     set_integrable M A f = set_integrable M A g"
       
    92   unfolding set_integrable_def
    89   by (rule integrable_cong_AE) auto
    93   by (rule integrable_cong_AE) auto
    90 
    94 
    91 lemma set_integrable_subset:
    95 lemma set_integrable_subset:
    92   fixes M A B and f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
    96   fixes M A B and f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
    93   assumes "set_integrable M A f" "B \<in> sets M" "B \<subseteq> A"
    97   assumes "set_integrable M A f" "B \<in> sets M" "B \<subseteq> A"
    94   shows "set_integrable M B f"
    98   shows "set_integrable M B f"
    95 proof -
    99 proof -
    96   have "set_integrable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
   100   have "set_integrable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
    97     by (rule integrable_mult_indicator) fact+
   101     using assms integrable_mult_indicator set_integrable_def by blast
    98   with \<open>B \<subseteq> A\<close> show ?thesis
   102   with \<open>B \<subseteq> A\<close> show ?thesis
       
   103     unfolding set_integrable_def
    99     by (simp add: indicator_inter_arith[symmetric] Int_absorb2)
   104     by (simp add: indicator_inter_arith[symmetric] Int_absorb2)
   100 qed
   105 qed
   101 
   106 
   102 lemma set_integrable_restrict_space:
   107 lemma set_integrable_restrict_space:
   103   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   108   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   104   assumes f: "set_integrable M S f" and T: "T \<in> sets (restrict_space M S)"
   109   assumes f: "set_integrable M S f" and T: "T \<in> sets (restrict_space M S)"
   105   shows "set_integrable M T f"
   110   shows "set_integrable M T f"
   106 proof -
   111 proof -
   107   obtain T' where T_eq: "T = S \<inter> T'" and "T' \<in> sets M" using T by (auto simp: sets_restrict_space)
   112   obtain T' where T_eq: "T = S \<inter> T'" and "T' \<in> sets M" 
   108 
   113     using T by (auto simp: sets_restrict_space)
   109   have \<open>integrable M (\<lambda>x. indicator T' x *\<^sub>R (indicator S x *\<^sub>R f x))\<close>
   114   have \<open>integrable M (\<lambda>x. indicator T' x *\<^sub>R (indicator S x *\<^sub>R f x))\<close>
   110     by (rule integrable_mult_indicator; fact)
   115     using \<open>T' \<in> sets M\<close> f integrable_mult_indicator set_integrable_def by blast
   111   then show ?thesis
   116   then show ?thesis
       
   117     unfolding set_integrable_def
   112     unfolding T_eq indicator_inter_arith by (simp add: ac_simps)
   118     unfolding T_eq indicator_inter_arith by (simp add: ac_simps)
   113 qed
   119 qed
   114 
   120 
   115 (* TODO: integral_cmul_indicator should be named set_integral_const *)
   121 (* TODO: integral_cmul_indicator should be named set_integral_const *)
   116 (* TODO: borel_integrable_atLeastAtMost should be named something like set_integrable_Icc_isCont *)
   122 (* TODO: borel_integrable_atLeastAtMost should be named something like set_integrable_Icc_isCont *)
   117 
   123 
   118 lemma set_integral_scaleR_right [simp]: "LINT t:A|M. a *\<^sub>R f t = a *\<^sub>R (LINT t:A|M. f t)"
   124 lemma set_integral_scaleR_right [simp]: "LINT t:A|M. a *\<^sub>R f t = a *\<^sub>R (LINT t:A|M. f t)"
       
   125   unfolding set_lebesgue_integral_def
   119   by (subst integral_scaleR_right[symmetric]) (auto intro!: Bochner_Integration.integral_cong)
   126   by (subst integral_scaleR_right[symmetric]) (auto intro!: Bochner_Integration.integral_cong)
   120 
   127 
   121 lemma set_integral_mult_right [simp]:
   128 lemma set_integral_mult_right [simp]:
   122   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   129   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   123   shows "LINT t:A|M. a * f t = a * (LINT t:A|M. f t)"
   130   shows "LINT t:A|M. a * f t = a * (LINT t:A|M. f t)"
       
   131   unfolding set_lebesgue_integral_def
   124   by (subst integral_mult_right_zero[symmetric]) auto
   132   by (subst integral_mult_right_zero[symmetric]) auto
   125 
   133 
   126 lemma set_integral_mult_left [simp]:
   134 lemma set_integral_mult_left [simp]:
   127   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   135   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   128   shows "LINT t:A|M. f t * a = (LINT t:A|M. f t) * a"
   136   shows "LINT t:A|M. f t * a = (LINT t:A|M. f t) * a"
       
   137   unfolding set_lebesgue_integral_def
   129   by (subst integral_mult_left_zero[symmetric]) auto
   138   by (subst integral_mult_left_zero[symmetric]) auto
   130 
   139 
   131 lemma set_integral_divide_zero [simp]:
   140 lemma set_integral_divide_zero [simp]:
   132   fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
   141   fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
   133   shows "LINT t:A|M. f t / a = (LINT t:A|M. f t) / a"
   142   shows "LINT t:A|M. f t / a = (LINT t:A|M. f t) / a"
       
   143   unfolding set_lebesgue_integral_def
   134   by (subst integral_divide_zero[symmetric], intro Bochner_Integration.integral_cong)
   144   by (subst integral_divide_zero[symmetric], intro Bochner_Integration.integral_cong)
   135      (auto split: split_indicator)
   145      (auto split: split_indicator)
   136 
   146 
   137 lemma set_integrable_scaleR_right [simp, intro]:
   147 lemma set_integrable_scaleR_right [simp, intro]:
   138   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a *\<^sub>R f t)"
   148   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a *\<^sub>R f t)"
       
   149   unfolding set_integrable_def
   139   unfolding scaleR_left_commute by (rule integrable_scaleR_right)
   150   unfolding scaleR_left_commute by (rule integrable_scaleR_right)
   140 
   151 
   141 lemma set_integrable_scaleR_left [simp, intro]:
   152 lemma set_integrable_scaleR_left [simp, intro]:
   142   fixes a :: "_ :: {banach, second_countable_topology}"
   153   fixes a :: "_ :: {banach, second_countable_topology}"
   143   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t *\<^sub>R a)"
   154   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t *\<^sub>R a)"
       
   155   unfolding set_integrable_def
   144   using integrable_scaleR_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   156   using integrable_scaleR_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   145 
   157 
   146 lemma set_integrable_mult_right [simp, intro]:
   158 lemma set_integrable_mult_right [simp, intro]:
   147   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   159   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   148   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a * f t)"
   160   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a * f t)"
       
   161   unfolding set_integrable_def
   149   using integrable_mult_right[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   162   using integrable_mult_right[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   150 
   163 
   151 lemma set_integrable_mult_left [simp, intro]:
   164 lemma set_integrable_mult_left [simp, intro]:
   152   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   165   fixes a :: "'a::{real_normed_field, second_countable_topology}"
   153   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t * a)"
   166   shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t * a)"
       
   167   unfolding set_integrable_def
   154   using integrable_mult_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   168   using integrable_mult_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
   155 
   169 
   156 lemma set_integrable_divide [simp, intro]:
   170 lemma set_integrable_divide [simp, intro]:
   157   fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
   171   fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
   158   assumes "a \<noteq> 0 \<Longrightarrow> set_integrable M A f"
   172   assumes "a \<noteq> 0 \<Longrightarrow> set_integrable M A f"
   159   shows "set_integrable M A (\<lambda>t. f t / a)"
   173   shows "set_integrable M A (\<lambda>t. f t / a)"
   160 proof -
   174 proof -
   161   have "integrable M (\<lambda>x. indicator A x *\<^sub>R f x / a)"
   175   have "integrable M (\<lambda>x. indicator A x *\<^sub>R f x / a)"
   162     using assms by (rule integrable_divide_zero)
   176     using assms unfolding set_integrable_def by (rule integrable_divide_zero)
   163   also have "(\<lambda>x. indicator A x *\<^sub>R f x / a) = (\<lambda>x. indicator A x *\<^sub>R (f x / a))"
   177   also have "(\<lambda>x. indicator A x *\<^sub>R f x / a) = (\<lambda>x. indicator A x *\<^sub>R (f x / a))"
   164     by (auto split: split_indicator)
   178     by (auto split: split_indicator)
   165   finally show ?thesis .
   179   finally show ?thesis 
       
   180     unfolding set_integrable_def .
   166 qed
   181 qed
   167 
   182 
   168 lemma set_integral_add [simp, intro]:
   183 lemma set_integral_add [simp, intro]:
   169   fixes f g :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   184   fixes f g :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   170   assumes "set_integrable M A f" "set_integrable M A g"
   185   assumes "set_integrable M A f" "set_integrable M A g"
   171   shows "set_integrable M A (\<lambda>x. f x + g x)"
   186   shows "set_integrable M A (\<lambda>x. f x + g x)"
   172     and "LINT x:A|M. f x + g x = (LINT x:A|M. f x) + (LINT x:A|M. g x)"
   187     and "LINT x:A|M. f x + g x = (LINT x:A|M. f x) + (LINT x:A|M. g x)"
   173   using assms by (simp_all add: scaleR_add_right)
   188   using assms unfolding set_integrable_def set_lebesgue_integral_def by (simp_all add: scaleR_add_right)
   174 
   189 
   175 lemma set_integral_diff [simp, intro]:
   190 lemma set_integral_diff [simp, intro]:
   176   assumes "set_integrable M A f" "set_integrable M A g"
   191   assumes "set_integrable M A f" "set_integrable M A g"
   177   shows "set_integrable M A (\<lambda>x. f x - g x)" and "LINT x:A|M. f x - g x =
   192   shows "set_integrable M A (\<lambda>x. f x - g x)" and "LINT x:A|M. f x - g x =
   178     (LINT x:A|M. f x) - (LINT x:A|M. g x)"
   193     (LINT x:A|M. f x) - (LINT x:A|M. g x)"
   179   using assms by (simp_all add: scaleR_diff_right)
   194   using assms unfolding set_integrable_def set_lebesgue_integral_def by (simp_all add: scaleR_diff_right)
   180 
   195 
   181 (* question: why do we have this for negation, but multiplication by a constant
   196 (* question: why do we have this for negation, but multiplication by a constant
   182    requires an integrability assumption? *)
   197    requires an integrability assumption? *)
   183 lemma set_integral_uminus: "set_integrable M A f \<Longrightarrow> LINT x:A|M. - f x = - (LINT x:A|M. f x)"
   198 lemma set_integral_uminus: "set_integrable M A f \<Longrightarrow> LINT x:A|M. - f x = - (LINT x:A|M. f x)"
       
   199   unfolding set_integrable_def set_lebesgue_integral_def
   184   by (subst integral_minus[symmetric]) simp_all
   200   by (subst integral_minus[symmetric]) simp_all
   185 
   201 
   186 lemma set_integral_complex_of_real:
   202 lemma set_integral_complex_of_real:
   187   "LINT x:A|M. complex_of_real (f x) = of_real (LINT x:A|M. f x)"
   203   "LINT x:A|M. complex_of_real (f x) = of_real (LINT x:A|M. f x)"
       
   204   unfolding set_lebesgue_integral_def
   188   by (subst integral_complex_of_real[symmetric])
   205   by (subst integral_complex_of_real[symmetric])
   189      (auto intro!: Bochner_Integration.integral_cong split: split_indicator)
   206      (auto intro!: Bochner_Integration.integral_cong split: split_indicator)
   190 
   207 
   191 lemma set_integral_mono:
   208 lemma set_integral_mono:
   192   fixes f g :: "_ \<Rightarrow> real"
   209   fixes f g :: "_ \<Rightarrow> real"
   193   assumes "set_integrable M A f" "set_integrable M A g"
   210   assumes "set_integrable M A f" "set_integrable M A g"
   194     "\<And>x. x \<in> A \<Longrightarrow> f x \<le> g x"
   211     "\<And>x. x \<in> A \<Longrightarrow> f x \<le> g x"
   195   shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
   212   shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
   196 using assms by (auto intro: integral_mono split: split_indicator)
   213   using assms unfolding set_integrable_def set_lebesgue_integral_def
       
   214   by (auto intro: integral_mono split: split_indicator)
   197 
   215 
   198 lemma set_integral_mono_AE:
   216 lemma set_integral_mono_AE:
   199   fixes f g :: "_ \<Rightarrow> real"
   217   fixes f g :: "_ \<Rightarrow> real"
   200   assumes "set_integrable M A f" "set_integrable M A g"
   218   assumes "set_integrable M A f" "set_integrable M A g"
   201     "AE x \<in> A in M. f x \<le> g x"
   219     "AE x \<in> A in M. f x \<le> g x"
   202   shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
   220   shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
   203 using assms by (auto intro: integral_mono_AE split: split_indicator)
   221   using assms unfolding set_integrable_def set_lebesgue_integral_def
       
   222   by (auto intro: integral_mono_AE split: split_indicator)
   204 
   223 
   205 lemma set_integrable_abs: "set_integrable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar> :: real)"
   224 lemma set_integrable_abs: "set_integrable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar> :: real)"
   206   using integrable_abs[of M "\<lambda>x. f x * indicator A x"] by (simp add: abs_mult ac_simps)
   225   using integrable_abs[of M "\<lambda>x. f x * indicator A x"]unfolding set_integrable_def by (simp add: abs_mult ac_simps)
   207 
   226 
   208 lemma set_integrable_abs_iff:
   227 lemma set_integrable_abs_iff:
   209   fixes f :: "_ \<Rightarrow> real"
   228   fixes f :: "_ \<Rightarrow> real"
   210   shows "set_borel_measurable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
   229   shows "set_borel_measurable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
       
   230   unfolding set_integrable_def set_borel_measurable_def
   211   by (subst (2) integrable_abs_iff[symmetric]) (simp_all add: abs_mult ac_simps)
   231   by (subst (2) integrable_abs_iff[symmetric]) (simp_all add: abs_mult ac_simps)
   212 
   232 
   213 lemma set_integrable_abs_iff':
   233 lemma set_integrable_abs_iff':
   214   fixes f :: "_ \<Rightarrow> real"
   234   fixes f :: "_ \<Rightarrow> real"
   215   shows "f \<in> borel_measurable M \<Longrightarrow> A \<in> sets M \<Longrightarrow>
   235   shows "f \<in> borel_measurable M \<Longrightarrow> A \<in> sets M \<Longrightarrow>
   216     set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
   236     set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
   217 by (intro set_integrable_abs_iff) auto
   237   by (simp add: set_borel_measurable_def set_integrable_abs_iff)
   218 
   238 
   219 lemma set_integrable_discrete_difference:
   239 lemma set_integrable_discrete_difference:
   220   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   240   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   221   assumes "countable X"
   241   assumes "countable X"
   222   assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
   242   assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
   223   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   243   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   224   shows "set_integrable M A f \<longleftrightarrow> set_integrable M B f"
   244   shows "set_integrable M A f \<longleftrightarrow> set_integrable M B f"
       
   245   unfolding set_integrable_def
   225 proof (rule integrable_discrete_difference[where X=X])
   246 proof (rule integrable_discrete_difference[where X=X])
   226   show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
   247   show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
   227     using diff by (auto split: split_indicator)
   248     using diff by (auto split: split_indicator)
   228 qed fact+
   249 qed fact+
   229 
   250 
   231   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   252   fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
   232   assumes "countable X"
   253   assumes "countable X"
   233   assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
   254   assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
   234   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   255   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   235   shows "set_lebesgue_integral M A f = set_lebesgue_integral M B f"
   256   shows "set_lebesgue_integral M A f = set_lebesgue_integral M B f"
       
   257   unfolding set_lebesgue_integral_def
   236 proof (rule integral_discrete_difference[where X=X])
   258 proof (rule integral_discrete_difference[where X=X])
   237   show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
   259   show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
   238     using diff by (auto split: split_indicator)
   260     using diff by (auto split: split_indicator)
   239 qed fact+
   261 qed fact+
   240 
   262 
   244     and [measurable]: "A \<in> sets M" "B \<in> sets M"
   266     and [measurable]: "A \<in> sets M" "B \<in> sets M"
   245   shows "set_integrable M (A \<union> B) f"
   267   shows "set_integrable M (A \<union> B) f"
   246 proof -
   268 proof -
   247   have "set_integrable M (A - B) f"
   269   have "set_integrable M (A - B) f"
   248     using f_A by (rule set_integrable_subset) auto
   270     using f_A by (rule set_integrable_subset) auto
   249   from Bochner_Integration.integrable_add[OF this f_B] show ?thesis
   271   with f_B have "integrable M (\<lambda>x. indicator (A - B) x *\<^sub>R f x + indicator B x *\<^sub>R f x)"
       
   272     unfolding set_integrable_def using integrable_add by blast
       
   273   then show ?thesis
       
   274     unfolding set_integrable_def
   250     by (rule integrable_cong[THEN iffD1, rotated 2]) (auto split: split_indicator)
   275     by (rule integrable_cong[THEN iffD1, rotated 2]) (auto split: split_indicator)
   251 qed
   276 qed
       
   277 
       
   278 lemma set_integrable_empty [simp]: "set_integrable M {} f"
       
   279   by (auto simp: set_integrable_def)
   252 
   280 
   253 lemma set_integrable_UN:
   281 lemma set_integrable_UN:
   254   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   282   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   255   assumes "finite I" "\<And>i. i\<in>I \<Longrightarrow> set_integrable M (A i) f"
   283   assumes "finite I" "\<And>i. i\<in>I \<Longrightarrow> set_integrable M (A i) f"
   256     "\<And>i. i\<in>I \<Longrightarrow> A i \<in> sets M"
   284     "\<And>i. i\<in>I \<Longrightarrow> A i \<in> sets M"
   257   shows "set_integrable M (\<Union>i\<in>I. A i) f"
   285   shows "set_integrable M (\<Union>i\<in>I. A i) f"
   258 using assms by (induct I) (auto intro!: set_integrable_Un)
   286   using assms
       
   287   by (induct I) (auto simp: set_integrable_Un sets.finite_UN)
   259 
   288 
   260 lemma set_integral_Un:
   289 lemma set_integral_Un:
   261   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   290   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   262   assumes "A \<inter> B = {}"
   291   assumes "A \<inter> B = {}"
   263   and "set_integrable M A f"
   292   and "set_integrable M A f"
   264   and "set_integrable M B f"
   293   and "set_integrable M B f"
   265   shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
   294 shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
   266 by (auto simp add: indicator_union_arith indicator_inter_arith[symmetric]
   295   using assms
   267       scaleR_add_left assms)
   296   unfolding set_integrable_def set_lebesgue_integral_def
       
   297   by (auto simp add: indicator_union_arith indicator_inter_arith[symmetric] scaleR_add_left)
   268 
   298 
   269 lemma set_integral_cong_set:
   299 lemma set_integral_cong_set:
   270   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   300   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   271   assumes [measurable]: "set_borel_measurable M A f" "set_borel_measurable M B f"
   301   assumes "set_borel_measurable M A f" "set_borel_measurable M B f"
   272     and ae: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
   302     and ae: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
   273   shows "LINT x:B|M. f x = LINT x:A|M. f x"
   303   shows "LINT x:B|M. f x = LINT x:A|M. f x"
       
   304   unfolding set_lebesgue_integral_def
   274 proof (rule integral_cong_AE)
   305 proof (rule integral_cong_AE)
   275   show "AE x in M. indicator B x *\<^sub>R f x = indicator A x *\<^sub>R f x"
   306   show "AE x in M. indicator B x *\<^sub>R f x = indicator A x *\<^sub>R f x"
   276     using ae by (auto simp: subset_eq split: split_indicator)
   307     using ae by (auto simp: subset_eq split: split_indicator)
   277 qed fact+
   308 qed (use assms in \<open>auto simp: set_borel_measurable_def\<close>)
   278 
   309 
   279 lemma set_borel_measurable_subset:
   310 lemma set_borel_measurable_subset:
   280   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   311   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   281   assumes [measurable]: "set_borel_measurable M A f" "B \<in> sets M" and "B \<subseteq> A"
   312   assumes [measurable]: "set_borel_measurable M A f" "B \<in> sets M" and "B \<subseteq> A"
   282   shows "set_borel_measurable M B f"
   313   shows "set_borel_measurable M B f"
   283 proof -
   314 proof -
   284   have "set_borel_measurable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
   315   have "set_borel_measurable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
   285     by measurable
   316     using assms unfolding set_borel_measurable_def
   286   also have "(\<lambda>x. indicator B x *\<^sub>R indicator A x *\<^sub>R f x) = (\<lambda>x. indicator B x *\<^sub>R f x)"
   317     using borel_measurable_indicator borel_measurable_scaleR by blast 
       
   318   moreover have "(\<lambda>x. indicator B x *\<^sub>R indicator A x *\<^sub>R f x) = (\<lambda>x. indicator B x *\<^sub>R f x)"
   287     using \<open>B \<subseteq> A\<close> by (auto simp: fun_eq_iff split: split_indicator)
   319     using \<open>B \<subseteq> A\<close> by (auto simp: fun_eq_iff split: split_indicator)
   288   finally show ?thesis .
   320   ultimately show ?thesis 
       
   321     unfolding set_borel_measurable_def by simp
   289 qed
   322 qed
   290 
   323 
   291 lemma set_integral_Un_AE:
   324 lemma set_integral_Un_AE:
   292   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   325   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   293   assumes ae: "AE x in M. \<not> (x \<in> A \<and> x \<in> B)" and [measurable]: "A \<in> sets M" "B \<in> sets M"
   326   assumes ae: "AE x in M. \<not> (x \<in> A \<and> x \<in> B)" and [measurable]: "A \<in> sets M" "B \<in> sets M"
   296   shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
   329   shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
   297 proof -
   330 proof -
   298   have f: "set_integrable M (A \<union> B) f"
   331   have f: "set_integrable M (A \<union> B) f"
   299     by (intro set_integrable_Un assms)
   332     by (intro set_integrable_Un assms)
   300   then have f': "set_borel_measurable M (A \<union> B) f"
   333   then have f': "set_borel_measurable M (A \<union> B) f"
   301     by (rule borel_measurable_integrable)
   334     using integrable_iff_bounded set_borel_measurable_def set_integrable_def by blast
   302   have "LINT x:A\<union>B|M. f x = LINT x:(A - A \<inter> B) \<union> (B - A \<inter> B)|M. f x"
   335   have "LINT x:A\<union>B|M. f x = LINT x:(A - A \<inter> B) \<union> (B - A \<inter> B)|M. f x"
   303   proof (rule set_integral_cong_set)
   336   proof (rule set_integral_cong_set)
   304     show "AE x in M. (x \<in> A - A \<inter> B \<union> (B - A \<inter> B)) = (x \<in> A \<union> B)"
   337     show "AE x in M. (x \<in> A - A \<inter> B \<union> (B - A \<inter> B)) = (x \<in> A \<union> B)"
   305       using ae by auto
   338       using ae by auto
   306     show "set_borel_measurable M (A - A \<inter> B \<union> (B - A \<inter> B)) f"
   339     show "set_borel_measurable M (A - A \<inter> B \<union> (B - A \<inter> B)) f"
   319   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   352   fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   320   assumes "finite I" "disjoint_family_on A I"
   353   assumes "finite I" "disjoint_family_on A I"
   321     and "\<And>i. i \<in> I \<Longrightarrow> set_integrable M (A i) f" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets M"
   354     and "\<And>i. i \<in> I \<Longrightarrow> set_integrable M (A i) f" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets M"
   322   shows "(LINT x:(\<Union>i\<in>I. A i)|M. f x) = (\<Sum>i\<in>I. LINT x:A i|M. f x)"
   355   shows "(LINT x:(\<Union>i\<in>I. A i)|M. f x) = (\<Sum>i\<in>I. LINT x:A i|M. f x)"
   323   using assms
   356   using assms
   324   apply induct
   357 proof induction
   325   apply (auto intro!: set_integral_Un set_integrable_Un set_integrable_UN simp: disjoint_family_on_def)
   358   case (insert x F)
   326 by (subst set_integral_Un, auto intro: set_integrable_UN)
   359   then have "A x \<inter> UNION F A = {}"
       
   360     by (meson disjoint_family_on_insert)
       
   361   with insert show ?case
       
   362     by (simp add: set_integral_Un set_integrable_Un set_integrable_UN disjoint_family_on_insert)
       
   363 qed (simp add: set_lebesgue_integral_def)
   327 
   364 
   328 (* TODO: find a better name? *)
   365 (* TODO: find a better name? *)
   329 lemma pos_integrable_to_top:
   366 lemma pos_integrable_to_top:
   330   fixes l::real
   367   fixes l::real
   331   assumes "\<And>i. A i \<in> sets M" "mono A"
   368   assumes "\<And>i. A i \<in> sets M" "mono A"
   332   assumes nneg: "\<And>x i. x \<in> A i \<Longrightarrow> 0 \<le> f x"
   369   assumes nneg: "\<And>x i. x \<in> A i \<Longrightarrow> 0 \<le> f x"
   333   and intgbl: "\<And>i::nat. set_integrable M (A i) f"
   370   and intgbl: "\<And>i::nat. set_integrable M (A i) f"
   334   and lim: "(\<lambda>i::nat. LINT x:A i|M. f x) \<longlonglongrightarrow> l"
   371   and lim: "(\<lambda>i::nat. LINT x:A i|M. f x) \<longlonglongrightarrow> l"
   335   shows "set_integrable M (\<Union>i. A i) f"
   372 shows "set_integrable M (\<Union>i. A i) f"
       
   373     unfolding set_integrable_def
   336   apply (rule integrable_monotone_convergence[where f = "\<lambda>i::nat. \<lambda>x. indicator (A i) x *\<^sub>R f x" and x = l])
   374   apply (rule integrable_monotone_convergence[where f = "\<lambda>i::nat. \<lambda>x. indicator (A i) x *\<^sub>R f x" and x = l])
   337   apply (rule intgbl)
   375   apply (rule intgbl [unfolded set_integrable_def])
   338   prefer 3 apply (rule lim)
   376   prefer 3 apply (rule lim [unfolded set_lebesgue_integral_def])
   339   apply (rule AE_I2)
   377   apply (rule AE_I2)
   340   using \<open>mono A\<close> apply (auto simp: mono_def nneg split: split_indicator) []
   378   using \<open>mono A\<close> apply (auto simp: mono_def nneg split: split_indicator) []
   341 proof (rule AE_I2)
   379 proof (rule AE_I2)
   342   { fix x assume "x \<in> space M"
   380   { fix x assume "x \<in> space M"
   343     show "(\<lambda>i. indicator (A i) x *\<^sub>R f x) \<longlonglongrightarrow> indicator (\<Union>i. A i) x *\<^sub>R f x"
   381     show "(\<lambda>i. indicator (A i) x *\<^sub>R f x) \<longlonglongrightarrow> indicator (\<Union>i. A i) x *\<^sub>R f x"
   354         done
   392         done
   355     qed auto }
   393     qed auto }
   356   then show "(\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R f x) \<in> borel_measurable M"
   394   then show "(\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R f x) \<in> borel_measurable M"
   357     apply (rule borel_measurable_LIMSEQ_real)
   395     apply (rule borel_measurable_LIMSEQ_real)
   358     apply assumption
   396     apply assumption
   359     apply (intro borel_measurable_integrable intgbl)
   397     using intgbl set_integrable_def by blast
   360     done
       
   361 qed
   398 qed
   362 
   399 
   363 (* Proof from Royden Real Analysis, p. 91. *)
   400 (* Proof from Royden Real Analysis, p. 91. *)
   364 lemma lebesgue_integral_countable_add:
   401 lemma lebesgue_integral_countable_add:
   365   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   402   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   366   assumes meas[intro]: "\<And>i::nat. A i \<in> sets M"
   403   assumes meas[intro]: "\<And>i::nat. A i \<in> sets M"
   367     and disj: "\<And>i j. i \<noteq> j \<Longrightarrow> A i \<inter> A j = {}"
   404     and disj: "\<And>i j. i \<noteq> j \<Longrightarrow> A i \<inter> A j = {}"
   368     and intgbl: "set_integrable M (\<Union>i. A i) f"
   405     and intgbl: "set_integrable M (\<Union>i. A i) f"
   369   shows "LINT x:(\<Union>i. A i)|M. f x = (\<Sum>i. (LINT x:(A i)|M. f x))"
   406   shows "LINT x:(\<Union>i. A i)|M. f x = (\<Sum>i. (LINT x:(A i)|M. f x))"
       
   407     unfolding set_lebesgue_integral_def
   370 proof (subst integral_suminf[symmetric])
   408 proof (subst integral_suminf[symmetric])
   371   show int_A: "\<And>i. set_integrable M (A i) f"
   409   show int_A: "integrable M (\<lambda>x. indicat_real (A i) x *\<^sub>R f x)" for i
   372     using intgbl by (rule set_integrable_subset) auto
   410     using intgbl unfolding set_integrable_def [symmetric]
       
   411     by (rule set_integrable_subset) auto
   373   { fix x assume "x \<in> space M"
   412   { fix x assume "x \<in> space M"
   374     have "(\<lambda>i. indicator (A i) x *\<^sub>R f x) sums (indicator (\<Union>i. A i) x *\<^sub>R f x)"
   413     have "(\<lambda>i. indicator (A i) x *\<^sub>R f x) sums (indicator (\<Union>i. A i) x *\<^sub>R f x)"
   375       by (intro sums_scaleR_left indicator_sums) fact }
   414       by (intro sums_scaleR_left indicator_sums) fact }
   376   note sums = this
   415   note sums = this
   377 
   416 
   378   have norm_f: "\<And>i. set_integrable M (A i) (\<lambda>x. norm (f x))"
   417   have norm_f: "\<And>i. set_integrable M (A i) (\<lambda>x. norm (f x))"
   379     using int_A[THEN integrable_norm] by auto
   418     using int_A[THEN integrable_norm] unfolding set_integrable_def by auto
   380 
   419 
   381   show "AE x in M. summable (\<lambda>i. norm (indicator (A i) x *\<^sub>R f x))"
   420   show "AE x in M. summable (\<lambda>i. norm (indicator (A i) x *\<^sub>R f x))"
   382     using disj by (intro AE_I2) (auto intro!: summable_mult2 sums_summable[OF indicator_sums])
   421     using disj by (intro AE_I2) (auto intro!: summable_mult2 sums_summable[OF indicator_sums])
   383 
   422 
   384   show "summable (\<lambda>i. LINT x|M. norm (indicator (A i) x *\<^sub>R f x))"
   423   show "summable (\<lambda>i. LINT x|M. norm (indicator (A i) x *\<^sub>R f x))"
   385   proof (rule summableI_nonneg_bounded)
   424   proof (rule summableI_nonneg_bounded)
   386     fix n
   425     fix n
   387     show "0 \<le> LINT x|M. norm (indicator (A n) x *\<^sub>R f x)"
   426     show "0 \<le> LINT x|M. norm (indicator (A n) x *\<^sub>R f x)"
   388       using norm_f by (auto intro!: integral_nonneg_AE)
   427       using norm_f by (auto intro!: integral_nonneg_AE)
   389 
   428 
   390     have "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) =
   429     have "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) = (\<Sum>i<n. LINT x:A i|M. norm (f x))"
   391       (\<Sum>i<n. set_lebesgue_integral M (A i) (\<lambda>x. norm (f x)))"
   430       by (simp add: abs_mult set_lebesgue_integral_def)
   392       by (simp add: abs_mult)
       
   393     also have "\<dots> = set_lebesgue_integral M (\<Union>i<n. A i) (\<lambda>x. norm (f x))"
   431     also have "\<dots> = set_lebesgue_integral M (\<Union>i<n. A i) (\<lambda>x. norm (f x))"
   394       using norm_f
   432       using norm_f
   395       by (subst set_integral_finite_Union) (auto simp: disjoint_family_on_def disj)
   433       by (subst set_integral_finite_Union) (auto simp: disjoint_family_on_def disj)
   396     also have "\<dots> \<le> set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
   434     also have "\<dots> \<le> set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
   397       using intgbl[THEN integrable_norm]
   435       using intgbl[unfolded set_integrable_def, THEN integrable_norm] norm_f
   398       by (intro integral_mono set_integrable_UN[of "{..<n}"] norm_f)
   436       unfolding set_lebesgue_integral_def set_integrable_def
   399          (auto split: split_indicator)
   437       apply (intro integral_mono set_integrable_UN[of "{..<n}", unfolded set_integrable_def])
       
   438           apply (auto split: split_indicator)
       
   439       done
   400     finally show "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) \<le>
   440     finally show "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) \<le>
   401       set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
   441       set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
   402       by simp
   442       by simp
   403   qed
   443   qed
   404   show "set_lebesgue_integral M (UNION UNIV A) f = LINT x|M. (\<Sum>i. indicator (A i) x *\<^sub>R f x)"
   444   show "LINT x|M. indicator (UNION UNIV A) x *\<^sub>R f x = LINT x|M. (\<Sum>i. indicator (A i) x *\<^sub>R f x)"
   405     apply (rule Bochner_Integration.integral_cong[OF refl])
   445     apply (rule Bochner_Integration.integral_cong[OF refl])
   406     apply (subst suminf_scaleR_left[OF sums_summable[OF indicator_sums, OF disj], symmetric])
   446     apply (subst suminf_scaleR_left[OF sums_summable[OF indicator_sums, OF disj], symmetric])
   407     using sums_unique[OF indicator_sums[OF disj]]
   447     using sums_unique[OF indicator_sums[OF disj]]
   408     apply auto
   448     apply auto
   409     done
   449     done
   411 
   451 
   412 lemma set_integral_cont_up:
   452 lemma set_integral_cont_up:
   413   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   453   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   414   assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "incseq A"
   454   assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "incseq A"
   415   and intgbl: "set_integrable M (\<Union>i. A i) f"
   455   and intgbl: "set_integrable M (\<Union>i. A i) f"
   416   shows "(\<lambda>i. LINT x:(A i)|M. f x) \<longlonglongrightarrow> LINT x:(\<Union>i. A i)|M. f x"
   456 shows "(\<lambda>i. LINT x:(A i)|M. f x) \<longlonglongrightarrow> LINT x:(\<Union>i. A i)|M. f x"
       
   457   unfolding set_lebesgue_integral_def
   417 proof (intro integral_dominated_convergence[where w="\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R norm (f x)"])
   458 proof (intro integral_dominated_convergence[where w="\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R norm (f x)"])
   418   have int_A: "\<And>i. set_integrable M (A i) f"
   459   have int_A: "\<And>i. set_integrable M (A i) f"
   419     using intgbl by (rule set_integrable_subset) auto
   460     using intgbl by (rule set_integrable_subset) auto
   420   then show "\<And>i. set_borel_measurable M (A i) f" "set_borel_measurable M (\<Union>i. A i) f"
   461   show "\<And>i. (\<lambda>x. indicator (A i) x *\<^sub>R f x) \<in> borel_measurable M"
   421     "set_integrable M (\<Union>i. A i) (\<lambda>x. norm (f x))"
   462     using int_A integrable_iff_bounded set_integrable_def by blast
   422     using intgbl integrable_norm[OF intgbl] by auto
   463   show "(\<lambda>x. indicator (UNION UNIV A) x *\<^sub>R f x) \<in> borel_measurable M"
   423 
   464     using integrable_iff_bounded intgbl set_integrable_def by blast
       
   465   show "integrable M (\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R norm (f x))"
       
   466     using int_A intgbl integrable_norm unfolding set_integrable_def 
       
   467     by fastforce
   424   { fix x i assume "x \<in> A i"
   468   { fix x i assume "x \<in> A i"
   425     with A have "(\<lambda>xa. indicator (A xa) x::real) \<longlonglongrightarrow> 1 \<longleftrightarrow> (\<lambda>xa. 1::real) \<longlonglongrightarrow> 1"
   469     with A have "(\<lambda>xa. indicator (A xa) x::real) \<longlonglongrightarrow> 1 \<longleftrightarrow> (\<lambda>xa. 1::real) \<longlonglongrightarrow> 1"
   426       by (intro filterlim_cong refl)
   470       by (intro filterlim_cong refl)
   427          (fastforce simp: eventually_sequentially incseq_def subset_eq intro!: exI[of _ i]) }
   471          (fastforce simp: eventually_sequentially incseq_def subset_eq intro!: exI[of _ i]) }
   428   then show "AE x in M. (\<lambda>i. indicator (A i) x *\<^sub>R f x) \<longlonglongrightarrow> indicator (\<Union>i. A i) x *\<^sub>R f x"
   472   then show "AE x in M. (\<lambda>i. indicator (A i) x *\<^sub>R f x) \<longlonglongrightarrow> indicator (\<Union>i. A i) x *\<^sub>R f x"
   433 lemma set_integral_cont_down:
   477 lemma set_integral_cont_down:
   434   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   478   fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
   435   assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "decseq A"
   479   assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "decseq A"
   436   and int0: "set_integrable M (A 0) f"
   480   and int0: "set_integrable M (A 0) f"
   437   shows "(\<lambda>i::nat. LINT x:(A i)|M. f x) \<longlonglongrightarrow> LINT x:(\<Inter>i. A i)|M. f x"
   481   shows "(\<lambda>i::nat. LINT x:(A i)|M. f x) \<longlonglongrightarrow> LINT x:(\<Inter>i. A i)|M. f x"
       
   482   unfolding set_lebesgue_integral_def
   438 proof (rule integral_dominated_convergence)
   483 proof (rule integral_dominated_convergence)
   439   have int_A: "\<And>i. set_integrable M (A i) f"
   484   have int_A: "\<And>i. set_integrable M (A i) f"
   440     using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
   485     using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
   441   show "set_integrable M (A 0) (\<lambda>x. norm (f x))"
   486   have "integrable M (\<lambda>c. norm (indicat_real (A 0) c *\<^sub>R f c))"
   442     using int0[THEN integrable_norm] by simp
   487     by (metis (no_types) int0 integrable_norm set_integrable_def)
       
   488   then show "integrable M (\<lambda>x. indicator (A 0) x *\<^sub>R norm (f x))"
       
   489     by force
   443   have "set_integrable M (\<Inter>i. A i) f"
   490   have "set_integrable M (\<Inter>i. A i) f"
   444     using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
   491     using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
   445   with int_A show "set_borel_measurable M (\<Inter>i. A i) f" "\<And>i. set_borel_measurable M (A i) f"
   492   with int_A show "(\<lambda>x. indicat_real (INTER UNIV A) x *\<^sub>R f x) \<in> borel_measurable M"
   446     by auto
   493                   "\<And>i. (\<lambda>x. indicat_real (A i) x *\<^sub>R f x) \<in> borel_measurable M"
       
   494     by (auto simp: set_integrable_def)
   447   show "\<And>i. AE x in M. norm (indicator (A i) x *\<^sub>R f x) \<le> indicator (A 0) x *\<^sub>R norm (f x)"
   495   show "\<And>i. AE x in M. norm (indicator (A i) x *\<^sub>R f x) \<le> indicator (A 0) x *\<^sub>R norm (f x)"
   448     using A by (auto split: split_indicator simp: decseq_def)
   496     using A by (auto split: split_indicator simp: decseq_def)
   449   { fix x i assume "x \<in> space M" "x \<notin> A i"
   497   { fix x i assume "x \<in> space M" "x \<notin> A i"
   450     with A have "(\<lambda>i. indicator (A i) x::real) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<lambda>i. 0::real) \<longlonglongrightarrow> 0"
   498     with A have "(\<lambda>i. indicator (A i) x::real) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<lambda>i. 0::real) \<longlonglongrightarrow> 0"
   451       by (intro filterlim_cong refl)
   499       by (intro filterlim_cong refl)
   460   and [simp]: "{a} \<in> sets M" and "(emeasure M) {a} \<noteq> \<infinity>"
   508   and [simp]: "{a} \<in> sets M" and "(emeasure M) {a} \<noteq> \<infinity>"
   461   shows "(LINT x:{a} | M. f x) = f a * measure M {a}"
   509   shows "(LINT x:{a} | M. f x) = f a * measure M {a}"
   462 proof-
   510 proof-
   463   have "set_lebesgue_integral M {a} f = set_lebesgue_integral M {a} (%x. f a)"
   511   have "set_lebesgue_integral M {a} f = set_lebesgue_integral M {a} (%x. f a)"
   464     by (intro set_lebesgue_integral_cong) simp_all
   512     by (intro set_lebesgue_integral_cong) simp_all
   465   then show ?thesis using assms by simp
   513   then show ?thesis using assms
       
   514     unfolding set_lebesgue_integral_def by simp
   466 qed
   515 qed
   467 
   516 
   468 
   517 
   469 abbreviation complex_integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> bool" where
   518 abbreviation complex_integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> bool" where
   470   "complex_integrable M f \<equiv> integrable M f"
   519   "complex_integrable M f \<equiv> integrable M f"
   521 "CLINT x:A|M. f" == "CONST complex_set_lebesgue_integral M A (\<lambda>x. f)"
   570 "CLINT x:A|M. f" == "CONST complex_set_lebesgue_integral M A (\<lambda>x. f)"
   522 
   571 
   523 lemma set_measurable_continuous_on_ivl:
   572 lemma set_measurable_continuous_on_ivl:
   524   assumes "continuous_on {a..b} (f :: real \<Rightarrow> real)"
   573   assumes "continuous_on {a..b} (f :: real \<Rightarrow> real)"
   525   shows "set_borel_measurable borel {a..b} f"
   574   shows "set_borel_measurable borel {a..b} f"
       
   575   unfolding set_borel_measurable_def
   526   by (rule borel_measurable_continuous_on_indicator[OF _ assms]) simp
   576   by (rule borel_measurable_continuous_on_indicator[OF _ assms]) simp
   527 
   577 
   528 
   578 
   529 text\<open>This notation is from Sébastien Gouëzel: His use is not directly in line with the
   579 text\<open>This notation is from Sébastien Gouëzel: His use is not directly in line with the
   530 notations in this file, they are more in line with sum, and more readable he thinks.\<close>
   580 notations in this file, they are more in line with sum, and more readable he thinks.\<close>
   668 qed
   718 qed
   669 
   719 
   670 lemma set_integral_null_delta:
   720 lemma set_integral_null_delta:
   671   fixes f::"_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   721   fixes f::"_ \<Rightarrow> _ :: {banach, second_countable_topology}"
   672   assumes [measurable]: "integrable M f" "A \<in> sets M" "B \<in> sets M"
   722   assumes [measurable]: "integrable M f" "A \<in> sets M" "B \<in> sets M"
   673     and "(A - B) \<union> (B - A) \<in> null_sets M"
   723     and null: "(A - B) \<union> (B - A) \<in> null_sets M"
   674   shows "(\<integral>x \<in> A. f x \<partial>M) = (\<integral>x \<in> B. f x \<partial>M)"
   724   shows "(\<integral>x \<in> A. f x \<partial>M) = (\<integral>x \<in> B. f x \<partial>M)"
   675 proof (rule set_integral_cong_set, auto)
   725 proof (rule set_integral_cong_set)
   676   have *: "AE a in M. a \<notin> (A - B) \<union> (B - A)"
   726   have *: "AE a in M. a \<notin> (A - B) \<union> (B - A)"
   677     using assms(4) AE_not_in by blast
   727     using null AE_not_in by blast
   678   then show "AE x in M. (x \<in> B) = (x \<in> A)"
   728   then show "AE x in M. (x \<in> B) = (x \<in> A)"
   679     by auto
   729     by auto
   680 qed
   730 qed (simp_all add: set_borel_measurable_def)
   681 
   731 
   682 lemma set_integral_space:
   732 lemma set_integral_space:
   683   assumes "integrable M f"
   733   assumes "integrable M f"
   684   shows "(\<integral>x \<in> space M. f x \<partial>M) = (\<integral>x. f x \<partial>M)"
   734   shows "(\<integral>x \<in> space M. f x \<partial>M) = (\<integral>x. f x \<partial>M)"
   685 by (metis (mono_tags, lifting) indicator_simps(1) Bochner_Integration.integral_cong real_vector.scale_one)
   735   by (metis (no_types, lifting) indicator_simps(1) integral_cong scaleR_one set_lebesgue_integral_def)
   686 
   736 
   687 lemma null_if_pos_func_has_zero_nn_int:
   737 lemma null_if_pos_func_has_zero_nn_int:
   688   fixes f::"'a \<Rightarrow> ennreal"
   738   fixes f::"'a \<Rightarrow> ennreal"
   689   assumes [measurable]: "f \<in> borel_measurable M" "A \<in> sets M"
   739   assumes [measurable]: "f \<in> borel_measurable M" "A \<in> sets M"
   690     and "AE x\<in>A in M. f x > 0" "(\<integral>\<^sup>+x\<in>A. f x \<partial>M) = 0"
   740     and "AE x\<in>A in M. f x > 0" "(\<integral>\<^sup>+x\<in>A. f x \<partial>M) = 0"
   701       and "AE x\<in>A in M. f x > 0" "(\<integral>x\<in>A. f x \<partial>M) = (0::real)"
   751       and "AE x\<in>A in M. f x > 0" "(\<integral>x\<in>A. f x \<partial>M) = (0::real)"
   702   shows "A \<in> null_sets M"
   752   shows "A \<in> null_sets M"
   703 proof -
   753 proof -
   704   have "AE x in M. indicator A x * f x = 0"
   754   have "AE x in M. indicator A x * f x = 0"
   705     apply (subst integral_nonneg_eq_0_iff_AE[symmetric])
   755     apply (subst integral_nonneg_eq_0_iff_AE[symmetric])
   706     using assms integrable_mult_indicator[OF \<open>A \<in> sets M\<close> assms(1)] by auto
   756     using assms integrable_mult_indicator[OF \<open>A \<in> sets M\<close> assms(1)]
       
   757     by (auto simp: set_lebesgue_integral_def)
   707   then have "AE x\<in>A in M. f x = 0" by auto
   758   then have "AE x\<in>A in M. f x = 0" by auto
   708   then have "AE x\<in>A in M. False" using assms(3) by auto
   759   then have "AE x\<in>A in M. False" using assms(3) by auto
   709   then show "A \<in> null_sets M" using assms(2) by (simp add: AE_iff_null_sets)
   760   then show "A \<in> null_sets M" using assms(2) by (simp add: AE_iff_null_sets)
   710 qed
   761 qed
   711 
   762 
   726 using Hahn-Banach theorem and linear forms. Since they are not yet easily available, I
   777 using Hahn-Banach theorem and linear forms. Since they are not yet easily available, I
   727 only formulate it for real-valued functions.\<close>
   778 only formulate it for real-valued functions.\<close>
   728 
   779 
   729 lemma density_unique_real:
   780 lemma density_unique_real:
   730   fixes f f'::"_ \<Rightarrow> real"
   781   fixes f f'::"_ \<Rightarrow> real"
   731   assumes [measurable]: "integrable M f" "integrable M f'"
   782   assumes M[measurable]: "integrable M f" "integrable M f'"
   732   assumes density_eq: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>x \<in> A. f x \<partial>M) = (\<integral>x \<in> A. f' x \<partial>M)"
   783   assumes density_eq: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>x \<in> A. f x \<partial>M) = (\<integral>x \<in> A. f' x \<partial>M)"
   733   shows "AE x in M. f x = f' x"
   784   shows "AE x in M. f x = f' x"
   734 proof -
   785 proof -
   735   define A where "A = {x \<in> space M. f x < f' x}"
   786   define A where "A = {x \<in> space M. f x < f' x}"
   736   then have [measurable]: "A \<in> sets M" by simp
   787   then have [measurable]: "A \<in> sets M" by simp
   737   have "(\<integral>x \<in> A. (f' x - f x) \<partial>M) = (\<integral>x \<in> A. f' x \<partial>M) - (\<integral>x \<in> A. f x \<partial>M)"
   788   have "(\<integral>x \<in> A. (f' x - f x) \<partial>M) = (\<integral>x \<in> A. f' x \<partial>M) - (\<integral>x \<in> A. f x \<partial>M)"
   738     using \<open>A \<in> sets M\<close> assms(1) assms(2) integrable_mult_indicator by blast
   789     using \<open>A \<in> sets M\<close> M integrable_mult_indicator set_integrable_def by blast
   739   then have "(\<integral>x \<in> A. (f' x - f x) \<partial>M) = 0" using assms(3) by simp
   790   then have "(\<integral>x \<in> A. (f' x - f x) \<partial>M) = 0" using assms(3) by simp
   740   then have "A \<in> null_sets M"
   791   then have "A \<in> null_sets M"
   741     using A_def null_if_pos_func_has_zero_int[where ?f = "\<lambda>x. f' x - f x" and ?A = A] assms by auto
   792     using A_def null_if_pos_func_has_zero_int[where ?f = "\<lambda>x. f' x - f x" and ?A = A] assms by auto
   742   then have "AE x in M. x \<notin> A" by (simp add: AE_not_in)
   793   then have "AE x in M. x \<notin> A" by (simp add: AE_not_in)
   743   then have *: "AE x in M. f' x \<le> f x" unfolding A_def by auto
   794   then have *: "AE x in M. f' x \<le> f x" unfolding A_def by auto
   744 
   795 
   745 
       
   746   define B where "B = {x \<in> space M. f' x < f x}"
   796   define B where "B = {x \<in> space M. f' x < f x}"
   747   then have [measurable]: "B \<in> sets M" by simp
   797   then have [measurable]: "B \<in> sets M" by simp
   748   have "(\<integral>x \<in> B. (f x - f' x) \<partial>M) = (\<integral>x \<in> B. f x \<partial>M) - (\<integral>x \<in> B. f' x \<partial>M)"
   798   have "(\<integral>x \<in> B. (f x - f' x) \<partial>M) = (\<integral>x \<in> B. f x \<partial>M) - (\<integral>x \<in> B. f' x \<partial>M)"
   749     using \<open>B \<in> sets M\<close> assms(1) assms(2) integrable_mult_indicator by blast
   799     using \<open>B \<in> sets M\<close> M integrable_mult_indicator set_integrable_def by blast
   750   then have "(\<integral>x \<in> B. (f x - f' x) \<partial>M) = 0" using assms(3) by simp
   800   then have "(\<integral>x \<in> B. (f x - f' x) \<partial>M) = 0" using assms(3) by simp
   751   then have "B \<in> null_sets M"
   801   then have "B \<in> null_sets M"
   752     using B_def null_if_pos_func_has_zero_int[where ?f = "\<lambda>x. f x - f' x" and ?A = B] assms by auto
   802     using B_def null_if_pos_func_has_zero_int[where ?f = "\<lambda>x. f x - f' x" and ?A = B] assms by auto
   753   then have "AE x in M. x \<notin> B" by (simp add: AE_not_in)
   803   then have "AE x in M. x \<notin> B" by (simp add: AE_not_in)
   754   then have "AE x in M. f' x \<ge> f x" unfolding B_def by auto
   804   then have "AE x in M. f' x \<ge> f x" unfolding B_def by auto
   755 
       
   756   then show ?thesis using * by auto
   805   then show ?thesis using * by auto
   757 qed
   806 qed
   758 
   807 
   759 text \<open>The next lemma shows that $L^1$ convergence of a sequence of functions follows from almost
   808 text \<open>The next lemma shows that $L^1$ convergence of a sequence of functions follows from almost
   760 everywhere convergence and the weaker condition of the convergence of the integrated norms (or even
   809 everywhere convergence and the weaker condition of the convergence of the integrated norms (or even