src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy
changeset 64267 b9a1486e79be
parent 63968 4359400adfe7
child 64272 f76b6dda2e56
equal deleted inserted replaced
64265:8eb6365f5916 64267:b9a1486e79be
   180         using integral_f by auto
   180         using integral_f by auto
   181 
   181 
   182       have "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
   182       have "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
   183         (\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)"
   183         (\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)"
   184         using p(1)[THEN tagged_division_ofD(1)]
   184         using p(1)[THEN tagged_division_ofD(1)]
   185         by (safe intro!: setsum.union_inter_neutral) (auto simp: s_def T_def)
   185         by (safe intro!: sum.union_inter_neutral) (auto simp: s_def T_def)
   186       also have "(\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) = (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k))"
   186       also have "(\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) = (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k))"
   187       proof (subst setsum.reindex_nontrivial, safe)
   187       proof (subst sum.reindex_nontrivial, safe)
   188         fix x1 x2 k assume 1: "(x1, k) \<in> p" "(x1, k) \<in> s" and 2: "(x2, k) \<in> p" "(x2, k) \<in> s"
   188         fix x1 x2 k assume 1: "(x1, k) \<in> p" "(x1, k) \<in> s" and 2: "(x2, k) \<in> p" "(x2, k) \<in> s"
   189           and eq: "content k *\<^sub>R f (T X k) \<noteq> 0"
   189           and eq: "content k *\<^sub>R f (T X k) \<noteq> 0"
   190         with tagged_division_ofD(5)[OF p(1), of x1 k x2 k] tagged_division_ofD(4)[OF p(1), of x1 k]
   190         with tagged_division_ofD(5)[OF p(1), of x1 k x2 k] tagged_division_ofD(4)[OF p(1), of x1 k]
   191         show "x1 = x2"
   191         show "x1 = x2"
   192           by (auto simp: content_eq_0_interior)
   192           by (auto simp: content_eq_0_interior)
   193       qed (use p in \<open>auto intro!: setsum.cong\<close>)
   193       qed (use p in \<open>auto intro!: sum.cong\<close>)
   194       finally have eq: "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
   194       finally have eq: "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
   195         (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k)) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)" .
   195         (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k)) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)" .
   196 
   196 
   197       have in_T: "(x, k) \<in> s \<Longrightarrow> T X k \<in> X" for x k
   197       have in_T: "(x, k) \<in> s \<Longrightarrow> T X k \<in> X" for x k
   198         using in_s[of x k] by (auto simp: C_def)
   198         using in_s[of x k] by (auto simp: C_def)
   268                             dest!: p(1)[THEN tagged_division_ofD(4)])
   268                             dest!: p(1)[THEN tagged_division_ofD(4)])
   269       finally show "M - 3 * e \<le> (\<Sum>(x, y)\<in>p \<inter> s. content y)"
   269       finally show "M - 3 * e \<le> (\<Sum>(x, y)\<in>p \<inter> s. content y)"
   270         using \<open>0 < e\<close> by (simp add: split_beta)
   270         using \<open>0 < e\<close> by (simp add: split_beta)
   271     qed (use \<open>a < b\<close> in auto)
   271     qed (use \<open>a < b\<close> in auto)
   272     also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * (b - a))"
   272     also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * (b - a))"
   273       by (simp add: setsum_distrib_right split_beta')
   273       by (simp add: sum_distrib_right split_beta')
   274     also have "\<dots> \<le> (\<Sum>(x, k)\<in>p \<inter> s. content k * (f (T ?F k) - f (T ?E k)))"
   274     also have "\<dots> \<le> (\<Sum>(x, k)\<in>p \<inter> s. content k * (f (T ?F k) - f (T ?E k)))"
   275       using parts(3) by (auto intro!: setsum_mono mult_left_mono diff_mono)
   275       using parts(3) by (auto intro!: sum_mono mult_left_mono diff_mono)
   276     also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?F k)) - (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?E k))"
   276     also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?F k)) - (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?E k))"
   277       by (auto intro!: setsum.cong simp: field_simps setsum_subtractf[symmetric])
   277       by (auto intro!: sum.cong simp: field_simps sum_subtractf[symmetric])
   278     also have "\<dots> = (\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x)"
   278     also have "\<dots> = (\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x)"
   279       by (subst (1 2) parts) auto
   279       by (subst (1 2) parts) auto
   280     also have "\<dots> \<le> norm ((\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x))"
   280     also have "\<dots> \<le> norm ((\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x))"
   281       by auto
   281       by auto
   282     also have "\<dots> \<le> e + e"
   282     also have "\<dots> \<le> e + e"
   399         by (simp add: borel_eq_box subset_eq)
   399         by (simp add: borel_eq_box subset_eq)
   400       have "((\<lambda>x. if x \<in> UNION UNIV F \<inter> box a b then 1 else 0) has_integral ?M (\<Union>i. F i)) (box a b)"
   400       have "((\<lambda>x. if x \<in> UNION UNIV F \<inter> box a b then 1 else 0) has_integral ?M (\<Union>i. F i)) (box a b)"
   401       proof (rule has_integral_monotone_convergence_increasing)
   401       proof (rule has_integral_monotone_convergence_increasing)
   402         let ?f = "\<lambda>k x. \<Sum>i<k. if x \<in> F i \<inter> box a b then 1 else 0 :: real"
   402         let ?f = "\<lambda>k x. \<Sum>i<k. if x \<in> F i \<inter> box a b then 1 else 0 :: real"
   403         show "\<And>k. (?f k has_integral (\<Sum>i<k. ?M (F i))) (box a b)"
   403         show "\<And>k. (?f k has_integral (\<Sum>i<k. ?M (F i))) (box a b)"
   404           using union.IH by (auto intro!: has_integral_setsum simp del: Int_iff)
   404           using union.IH by (auto intro!: has_integral_sum simp del: Int_iff)
   405         show "\<And>k x. ?f k x \<le> ?f (Suc k) x"
   405         show "\<And>k x. ?f k x \<le> ?f (Suc k) x"
   406           by (intro setsum_mono2) auto
   406           by (intro sum_mono2) auto
   407         from union(1) have *: "\<And>x i j. x \<in> F i \<Longrightarrow> x \<in> F j \<longleftrightarrow> j = i"
   407         from union(1) have *: "\<And>x i j. x \<in> F i \<Longrightarrow> x \<in> F j \<longleftrightarrow> j = i"
   408           by (auto simp add: disjoint_family_on_def)
   408           by (auto simp add: disjoint_family_on_def)
   409         show "\<And>x. (\<lambda>k. ?f k x) \<longlonglongrightarrow> (if x \<in> UNION UNIV F \<inter> box a b then 1 else 0)"
   409         show "\<And>x. (\<lambda>k. ?f k x) \<longlonglongrightarrow> (if x \<in> UNION UNIV F \<inter> box a b then 1 else 0)"
   410           apply (auto simp: * setsum.If_cases Iio_Int_singleton)
   410           apply (auto simp: * sum.If_cases Iio_Int_singleton)
   411           apply (rule_tac k="Suc xa" in LIMSEQ_offset)
   411           apply (rule_tac k="Suc xa" in LIMSEQ_offset)
   412           apply simp
   412           apply simp
   413           done
   413           done
   414         have *: "emeasure lborel ((\<Union>x. F x) \<inter> box a b) \<le> emeasure lborel (box a b)"
   414         have *: "emeasure lborel ((\<Union>x. F x) \<inter> box a b) \<le> emeasure lborel (box a b)"
   415           by (intro emeasure_mono) auto
   415           by (intro emeasure_mono) auto
   755 lemma has_integral_integral_lborel:
   755 lemma has_integral_integral_lborel:
   756   assumes f: "integrable lborel f"
   756   assumes f: "integrable lborel f"
   757   shows "(f has_integral (integral\<^sup>L lborel f)) UNIV"
   757   shows "(f has_integral (integral\<^sup>L lborel f)) UNIV"
   758 proof -
   758 proof -
   759   have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   759   have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   760     using f by (intro has_integral_setsum finite_Basis ballI has_integral_scaleR_left has_integral_integral_real) auto
   760     using f by (intro has_integral_sum finite_Basis ballI has_integral_scaleR_left has_integral_integral_real) auto
   761   also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   761   also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   762     by (simp add: fun_eq_iff euclidean_representation)
   762     by (simp add: fun_eq_iff euclidean_representation)
   763   also have "(\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lborel f"
   763   also have "(\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lborel f"
   764     using f by (subst (2) eq_f[symmetric]) simp
   764     using f by (subst (2) eq_f[symmetric]) simp
   765   finally show ?thesis .
   765   finally show ?thesis .
   802   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
   802   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
   803   assumes f: "integrable lebesgue f"
   803   assumes f: "integrable lebesgue f"
   804   shows "(f has_integral (integral\<^sup>L lebesgue f)) UNIV"
   804   shows "(f has_integral (integral\<^sup>L lebesgue f)) UNIV"
   805 proof -
   805 proof -
   806   have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   806   have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   807     using f by (intro has_integral_setsum finite_Basis ballI has_integral_scaleR_left has_integral_integral_lebesgue_real) auto
   807     using f by (intro has_integral_sum finite_Basis ballI has_integral_scaleR_left has_integral_integral_lebesgue_real) auto
   808   also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   808   also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   809     by (simp add: fun_eq_iff euclidean_representation)
   809     by (simp add: fun_eq_iff euclidean_representation)
   810   also have "(\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lebesgue f"
   810   also have "(\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lebesgue f"
   811     using f by (subst (2) eq_f[symmetric]) simp
   811     using f by (subst (2) eq_f[symmetric]) simp
   812   finally show ?thesis .
   812   finally show ?thesis .
  1243   proof -
  1243   proof -
  1244     have BM_ge0: "0 \<le> B * (DIM('M) * prj1 (vf X - uf X))" if "X \<in> \<D>'" for X
  1244     have BM_ge0: "0 \<le> B * (DIM('M) * prj1 (vf X - uf X))" if "X \<in> \<D>'" for X
  1245       using \<open>0 < B\<close> \<open>\<D>' \<subseteq> \<D>\<close> that vu_pos by fastforce
  1245       using \<open>0 < B\<close> \<open>\<D>' \<subseteq> \<D>\<close> that vu_pos by fastforce
  1246     have "{} \<notin> \<D>'"
  1246     have "{} \<notin> \<D>'"
  1247       using cbox \<open>\<D>' \<subseteq> \<D>\<close> interior_empty by blast
  1247       using cbox \<open>\<D>' \<subseteq> \<D>\<close> interior_empty by blast
  1248     have "(\<Sum>k\<in>fbx`\<D>'. measure lebesgue k) \<le> setsum (measure lebesgue o fbx) \<D>'"
  1248     have "(\<Sum>k\<in>fbx`\<D>'. measure lebesgue k) \<le> sum (measure lebesgue o fbx) \<D>'"
  1249       by (rule setsum_image_le [OF \<open>finite \<D>'\<close>]) (force simp: fbx_def)
  1249       by (rule sum_image_le [OF \<open>finite \<D>'\<close>]) (force simp: fbx_def)
  1250     also have "\<dots> \<le> (\<Sum>X\<in>\<D>'. (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X)"
  1250     also have "\<dots> \<le> (\<Sum>X\<in>\<D>'. (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X)"
  1251     proof (rule setsum_mono)
  1251     proof (rule sum_mono)
  1252       fix X assume "X \<in> \<D>'"
  1252       fix X assume "X \<in> \<D>'"
  1253       then have "X \<in> \<D>" using \<open>\<D>' \<subseteq> \<D>\<close> by blast
  1253       then have "X \<in> \<D>" using \<open>\<D>' \<subseteq> \<D>\<close> by blast
  1254       then have ufvf: "cbox (uf X) (vf X) = X"
  1254       then have ufvf: "cbox (uf X) (vf X) = X"
  1255         using uvz by blast
  1255         using uvz by blast
  1256       have "prj1 (vf X - uf X) ^ DIM('M) = (\<Prod>i::'M \<in> Basis. prj1 (vf X - uf X))"
  1256       have "prj1 (vf X - uf X) ^ DIM('M) = (\<Prod>i::'M \<in> Basis. prj1 (vf X - uf X))"
  1279         done
  1279         done
  1280       also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X"
  1280       also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X"
  1281         by (subst (3) ufvf[symmetric]) simp
  1281         by (subst (3) ufvf[symmetric]) simp
  1282       finally show "(measure lebesgue \<circ> fbx) X \<le> (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X" .
  1282       finally show "(measure lebesgue \<circ> fbx) X \<le> (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X" .
  1283     qed
  1283     qed
  1284     also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * setsum (measure lebesgue) \<D>'"
  1284     also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * sum (measure lebesgue) \<D>'"
  1285       by (simp add: setsum_distrib_left)
  1285       by (simp add: sum_distrib_left)
  1286     also have "\<dots> \<le> e / 2"
  1286     also have "\<dots> \<le> e / 2"
  1287     proof -
  1287     proof -
  1288       have div: "\<D>' division_of \<Union>\<D>'"
  1288       have div: "\<D>' division_of \<Union>\<D>'"
  1289         apply (auto simp: \<open>finite \<D>'\<close> \<open>{} \<notin> \<D>'\<close> division_of_def)
  1289         apply (auto simp: \<open>finite \<D>'\<close> \<open>{} \<notin> \<D>'\<close> division_of_def)
  1290         using cbox that apply blast
  1290         using cbox that apply blast
  1304             using Ksub [OF \<open>D \<in> \<D>\<close>]
  1304             using Ksub [OF \<open>D \<in> \<D>\<close>]
  1305             by (metis \<open>x \<in> D\<close> Int_iff dist_norm mem_ball norm_minus_commute subsetD RT)
  1305             by (metis \<open>x \<in> D\<close> Int_iff dist_norm mem_ball norm_minus_commute subsetD RT)
  1306         qed
  1306         qed
  1307         finally show "\<Union>\<D>' \<subseteq> T" .
  1307         finally show "\<Union>\<D>' \<subseteq> T" .
  1308       qed
  1308       qed
  1309       have "setsum (measure lebesgue) \<D>' = setsum content \<D>'"
  1309       have "sum (measure lebesgue) \<D>' = sum content \<D>'"
  1310         using  \<open>\<D>' \<subseteq> \<D>\<close> cbox by (force intro: setsum.cong)
  1310         using  \<open>\<D>' \<subseteq> \<D>\<close> cbox by (force intro: sum.cong)
  1311       then have "(2 * B * DIM('M)) ^ DIM('N) * setsum (measure lebesgue) \<D>' =
  1311       then have "(2 * B * DIM('M)) ^ DIM('N) * sum (measure lebesgue) \<D>' =
  1312                  (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue (\<Union>\<D>')"
  1312                  (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue (\<Union>\<D>')"
  1313         using content_division [OF div] by auto
  1313         using content_division [OF div] by auto
  1314       also have "\<dots> \<le> (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue T"
  1314       also have "\<dots> \<le> (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue T"
  1315         apply (rule mult_left_mono [OF le_meaT])
  1315         apply (rule mult_left_mono [OF le_meaT])
  1316         using \<open>0 < B\<close>
  1316         using \<open>0 < B\<close>
  1320         using T \<open>0 < B\<close> by (simp add: field_simps)
  1320         using T \<open>0 < B\<close> by (simp add: field_simps)
  1321       finally show ?thesis .
  1321       finally show ?thesis .
  1322     qed
  1322     qed
  1323     finally show ?thesis .
  1323     finally show ?thesis .
  1324   qed
  1324   qed
  1325   then have e2: "setsum (measure lebesgue) \<G> \<le> e / 2" if "\<G> \<subseteq> fbx ` \<D>" "finite \<G>" for \<G>
  1325   then have e2: "sum (measure lebesgue) \<G> \<le> e / 2" if "\<G> \<subseteq> fbx ` \<D>" "finite \<G>" for \<G>
  1326     by (metis finite_subset_image that)
  1326     by (metis finite_subset_image that)
  1327   show "\<exists>W\<in>lmeasurable. f ` S \<subseteq> W \<and> measure lebesgue W < e"
  1327   show "\<exists>W\<in>lmeasurable. f ` S \<subseteq> W \<and> measure lebesgue W < e"
  1328   proof (intro bexI conjI)
  1328   proof (intro bexI conjI)
  1329     have "\<exists>X\<in>\<D>. f y \<in> fbx X" if "y \<in> S" for y
  1329     have "\<exists>X\<in>\<D>. f y \<in> fbx X" if "y \<in> S" for y
  1330     proof -
  1330     proof -
  1337       have yin: "y \<in> cbox (uf X) (vf X)" and zin: "(zf X) \<in> cbox (uf X) (vf X)"
  1337       have yin: "y \<in> cbox (uf X) (vf X)" and zin: "(zf X) \<in> cbox (uf X) (vf X)"
  1338         using uvz \<open>X \<in> \<D>\<close> \<open>y \<in> X\<close> by auto
  1338         using uvz \<open>X \<in> \<D>\<close> \<open>y \<in> X\<close> by auto
  1339       have "norm (y - zf X) \<le> (\<Sum>i\<in>Basis. \<bar>(y - zf X) \<bullet> i\<bar>)"
  1339       have "norm (y - zf X) \<le> (\<Sum>i\<in>Basis. \<bar>(y - zf X) \<bullet> i\<bar>)"
  1340         by (rule norm_le_l1)
  1340         by (rule norm_le_l1)
  1341       also have "\<dots> \<le> real DIM('M) * prj1 (vf X - uf X)"
  1341       also have "\<dots> \<le> real DIM('M) * prj1 (vf X - uf X)"
  1342       proof (rule setsum_bounded_above)
  1342       proof (rule sum_bounded_above)
  1343         fix j::'M assume j: "j \<in> Basis"
  1343         fix j::'M assume j: "j \<in> Basis"
  1344         show "\<bar>(y - zf X) \<bullet> j\<bar> \<le> prj1 (vf X - uf X)"
  1344         show "\<bar>(y - zf X) \<bullet> j\<bar> \<le> prj1 (vf X - uf X)"
  1345           using yin zin j
  1345           using yin zin j
  1346           by (fastforce simp add: mem_box prj1_idem [OF \<open>X \<in> \<D>\<close> j] inner_diff_left)
  1346           by (fastforce simp add: mem_box prj1_idem [OF \<open>X \<in> \<D>\<close> j] inner_diff_left)
  1347       qed
  1347       qed
  1531   using integrable_norm[OF f] by simp
  1531   using integrable_norm[OF f] by simp
  1532 
  1532 
  1533 lemma absolutely_integrable_bounded_variation:
  1533 lemma absolutely_integrable_bounded_variation:
  1534   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  1534   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  1535   assumes f: "f absolutely_integrable_on UNIV"
  1535   assumes f: "f absolutely_integrable_on UNIV"
  1536   obtains B where "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm (integral k f)) d \<le> B"
  1536   obtains B where "\<forall>d. d division_of (\<Union>d) \<longrightarrow> sum (\<lambda>k. norm (integral k f)) d \<le> B"
  1537 proof (rule that[of "integral UNIV (\<lambda>x. norm (f x))"]; safe)
  1537 proof (rule that[of "integral UNIV (\<lambda>x. norm (f x))"]; safe)
  1538   fix d :: "'a set set" assume d: "d division_of \<Union>d"
  1538   fix d :: "'a set set" assume d: "d division_of \<Union>d"
  1539   have *: "k \<in> d \<Longrightarrow> f absolutely_integrable_on k" for k
  1539   have *: "k \<in> d \<Longrightarrow> f absolutely_integrable_on k" for k
  1540     using f[THEN set_integrable_subset, of k] division_ofD(2,4)[OF d, of k] by auto
  1540     using f[THEN set_integrable_subset, of k] division_ofD(2,4)[OF d, of k] by auto
  1541   note d' = division_ofD[OF d]
  1541   note d' = division_ofD[OF d]
  1542 
  1542 
  1543   have "(\<Sum>k\<in>d. norm (integral k f)) = (\<Sum>k\<in>d. norm (LINT x:k|lebesgue. f x))"
  1543   have "(\<Sum>k\<in>d. norm (integral k f)) = (\<Sum>k\<in>d. norm (LINT x:k|lebesgue. f x))"
  1544     by (intro setsum.cong refl arg_cong[where f=norm] set_lebesgue_integral_eq_integral(2)[symmetric] *)
  1544     by (intro sum.cong refl arg_cong[where f=norm] set_lebesgue_integral_eq_integral(2)[symmetric] *)
  1545   also have "\<dots> \<le> (\<Sum>k\<in>d. LINT x:k|lebesgue. norm (f x))"
  1545   also have "\<dots> \<le> (\<Sum>k\<in>d. LINT x:k|lebesgue. norm (f x))"
  1546     by (intro setsum_mono set_integral_norm_bound *)
  1546     by (intro sum_mono set_integral_norm_bound *)
  1547   also have "\<dots> = (\<Sum>k\<in>d. integral k (\<lambda>x. norm (f x)))"
  1547   also have "\<dots> = (\<Sum>k\<in>d. integral k (\<lambda>x. norm (f x)))"
  1548     by (intro setsum.cong refl set_lebesgue_integral_eq_integral(2) set_integrable_norm *)
  1548     by (intro sum.cong refl set_lebesgue_integral_eq_integral(2) set_integrable_norm *)
  1549   also have "\<dots> \<le> integral (\<Union>d) (\<lambda>x. norm (f x))"
  1549   also have "\<dots> \<le> integral (\<Union>d) (\<lambda>x. norm (f x))"
  1550     using integrable_on_subdivision[OF d] assms f unfolding absolutely_integrable_on_def
  1550     using integrable_on_subdivision[OF d] assms f unfolding absolutely_integrable_on_def
  1551     by (subst integral_combine_division_topdown[OF _ d]) auto
  1551     by (subst integral_combine_division_topdown[OF _ d]) auto
  1552   also have "\<dots> \<le> integral UNIV (\<lambda>x. norm (f x))"
  1552   also have "\<dots> \<le> integral UNIV (\<lambda>x. norm (f x))"
  1553     using integrable_on_subdivision[OF d] assms unfolding absolutely_integrable_on_def
  1553     using integrable_on_subdivision[OF d] assms unfolding absolutely_integrable_on_def
  1554     by (intro integral_subset_le) auto
  1554     by (intro integral_subset_le) auto
  1555   finally show "(\<Sum>k\<in>d. norm (integral k f)) \<le> integral UNIV (\<lambda>x. norm (f x))" .
  1555   finally show "(\<Sum>k\<in>d. norm (integral k f)) \<le> integral UNIV (\<lambda>x. norm (f x))" .
  1556 qed
  1556 qed
  1557 
  1557 
  1558 lemma helplemma:
  1558 lemma helplemma:
  1559   assumes "setsum (\<lambda>x. norm (f x - g x)) s < e"
  1559   assumes "sum (\<lambda>x. norm (f x - g x)) s < e"
  1560     and "finite s"
  1560     and "finite s"
  1561   shows "\<bar>setsum (\<lambda>x. norm(f x)) s - setsum (\<lambda>x. norm(g x)) s\<bar> < e"
  1561   shows "\<bar>sum (\<lambda>x. norm(f x)) s - sum (\<lambda>x. norm(g x)) s\<bar> < e"
  1562   unfolding setsum_subtractf[symmetric]
  1562   unfolding sum_subtractf[symmetric]
  1563   apply (rule le_less_trans[OF setsum_abs])
  1563   apply (rule le_less_trans[OF sum_abs])
  1564   apply (rule le_less_trans[OF _ assms(1)])
  1564   apply (rule le_less_trans[OF _ assms(1)])
  1565   apply (rule setsum_mono)
  1565   apply (rule sum_mono)
  1566   apply (rule norm_triangle_ineq3)
  1566   apply (rule norm_triangle_ineq3)
  1567   done
  1567   done
  1568 
  1568 
  1569 lemma bounded_variation_absolutely_integrable_interval:
  1569 lemma bounded_variation_absolutely_integrable_interval:
  1570   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  1570   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  1571   assumes f: "f integrable_on cbox a b"
  1571   assumes f: "f integrable_on cbox a b"
  1572     and *: "\<forall>d. d division_of (cbox a b) \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
  1572     and *: "\<forall>d. d division_of (cbox a b) \<longrightarrow> sum (\<lambda>k. norm(integral k f)) d \<le> B"
  1573   shows "f absolutely_integrable_on cbox a b"
  1573   shows "f absolutely_integrable_on cbox a b"
  1574 proof -
  1574 proof -
  1575   let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of (cbox a b)}"
  1575   let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of (cbox a b)}"
  1576   have D_1: "?D \<noteq> {}"
  1576   have D_1: "?D \<noteq> {}"
  1577     by (rule elementary_interval[of a b]) auto
  1577     by (rule elementary_interval[of a b]) auto
  1747           using p'(2)[OF il(3)]
  1747           using p'(2)[OF il(3)]
  1748           apply auto
  1748           apply auto
  1749           done
  1749           done
  1750       qed
  1750       qed
  1751       have sum_p': "(\<Sum>(x, k)\<in>p'. norm (integral k f)) = (\<Sum>k\<in>snd ` p'. norm (integral k f))"
  1751       have sum_p': "(\<Sum>(x, k)\<in>p'. norm (integral k f)) = (\<Sum>k\<in>snd ` p'. norm (integral k f))"
  1752         apply (subst setsum.over_tagged_division_lemma[OF p'',of "\<lambda>k. norm (integral k f)"])
  1752         apply (subst sum.over_tagged_division_lemma[OF p'',of "\<lambda>k. norm (integral k f)"])
  1753         unfolding norm_eq_zero
  1753         unfolding norm_eq_zero
  1754          apply (rule integral_null)
  1754          apply (rule integral_null)
  1755         apply (simp add: content_eq_0_interior)
  1755         apply (simp add: content_eq_0_interior)
  1756         apply rule
  1756         apply rule
  1757         done
  1757         done
  1773         case 2
  1773         case 2
  1774         have *: "{k \<inter> l | k l. k \<in> d \<and> l \<in> snd ` p} =
  1774         have *: "{k \<inter> l | k l. k \<in> d \<and> l \<in> snd ` p} =
  1775           (\<lambda>(k,l). k \<inter> l) ` {(k,l)|k l. k \<in> d \<and> l \<in> snd ` p}"
  1775           (\<lambda>(k,l). k \<inter> l) ` {(k,l)|k l. k \<in> d \<and> l \<in> snd ` p}"
  1776           by auto
  1776           by auto
  1777         have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>i\<in>d. \<Sum>l\<in>snd ` p. norm (integral (i \<inter> l) f))"
  1777         have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>i\<in>d. \<Sum>l\<in>snd ` p. norm (integral (i \<inter> l) f))"
  1778         proof (rule setsum_mono, goal_cases)
  1778         proof (rule sum_mono, goal_cases)
  1779           case k: (1 k)
  1779           case k: (1 k)
  1780           from d'(4)[OF this] guess u v by (elim exE) note uv=this
  1780           from d'(4)[OF this] guess u v by (elim exE) note uv=this
  1781           define d' where "d' = {cbox u v \<inter> l |l. l \<in> snd ` p \<and>  cbox u v \<inter> l \<noteq> {}}"
  1781           define d' where "d' = {cbox u v \<inter> l |l. l \<in> snd ` p \<and>  cbox u v \<inter> l \<noteq> {}}"
  1782           note uvab = d'(2)[OF k[unfolded uv]]
  1782           note uvab = d'(2)[OF k[unfolded uv]]
  1783           have "d' division_of cbox u v"
  1783           have "d' division_of cbox u v"
  1784             apply (subst d'_def)
  1784             apply (subst d'_def)
  1785             apply (rule division_inter_1)
  1785             apply (rule division_inter_1)
  1786             apply (rule division_of_tagged_division[OF p(1)])
  1786             apply (rule division_of_tagged_division[OF p(1)])
  1787             apply (rule uvab)
  1787             apply (rule uvab)
  1788             done
  1788             done
  1789           then have "norm (integral k f) \<le> setsum (\<lambda>k. norm (integral k f)) d'"
  1789           then have "norm (integral k f) \<le> sum (\<lambda>k. norm (integral k f)) d'"
  1790             unfolding uv
  1790             unfolding uv
  1791             apply (subst integral_combine_division_topdown[of _ _ d'])
  1791             apply (subst integral_combine_division_topdown[of _ _ d'])
  1792             apply (rule integrable_on_subcbox[OF assms(1) uvab])
  1792             apply (rule integrable_on_subcbox[OF assms(1) uvab])
  1793             apply assumption
  1793             apply assumption
  1794             apply (rule setsum_norm_le)
  1794             apply (rule sum_norm_le)
  1795             apply auto
  1795             apply auto
  1796             done
  1796             done
  1797           also have "\<dots> = (\<Sum>k\<in>{k \<inter> l |l. l \<in> snd ` p}. norm (integral k f))"
  1797           also have "\<dots> = (\<Sum>k\<in>{k \<inter> l |l. l \<in> snd ` p}. norm (integral k f))"
  1798             apply (rule setsum.mono_neutral_left)
  1798             apply (rule sum.mono_neutral_left)
  1799             apply (subst Setcompr_eq_image)
  1799             apply (subst Setcompr_eq_image)
  1800             apply (rule finite_imageI)+
  1800             apply (rule finite_imageI)+
  1801             apply fact
  1801             apply fact
  1802             unfolding d'_def uv
  1802             unfolding d'_def uv
  1803             apply blast
  1803             apply blast
  1811             then show ?case
  1811             then show ?case
  1812               using l by auto
  1812               using l by auto
  1813           qed
  1813           qed
  1814           also have "\<dots> = (\<Sum>l\<in>snd ` p. norm (integral (k \<inter> l) f))"
  1814           also have "\<dots> = (\<Sum>l\<in>snd ` p. norm (integral (k \<inter> l) f))"
  1815             unfolding Setcompr_eq_image
  1815             unfolding Setcompr_eq_image
  1816             apply (rule setsum.reindex_nontrivial [unfolded o_def])
  1816             apply (rule sum.reindex_nontrivial [unfolded o_def])
  1817             apply (rule finite_imageI)
  1817             apply (rule finite_imageI)
  1818             apply (rule p')
  1818             apply (rule p')
  1819           proof goal_cases
  1819           proof goal_cases
  1820             case prems: (1 l y)
  1820             case prems: (1 l y)
  1821             have "interior (k \<inter> l) \<subseteq> interior (l \<inter> y)"
  1821             have "interior (k \<inter> l) \<subseteq> interior (l \<inter> y)"
  1843           done
  1843           done
  1844         also have "\<dots> = (\<Sum>x\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (case_prod op \<inter> x) f))"
  1844         also have "\<dots> = (\<Sum>x\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (case_prod op \<inter> x) f))"
  1845           unfolding split_def ..
  1845           unfolding split_def ..
  1846         also have "\<dots> = (\<Sum>k\<in>{i \<inter> l |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral k f))"
  1846         also have "\<dots> = (\<Sum>k\<in>{i \<inter> l |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral k f))"
  1847           unfolding *
  1847           unfolding *
  1848           apply (rule setsum.reindex_nontrivial [symmetric, unfolded o_def])
  1848           apply (rule sum.reindex_nontrivial [symmetric, unfolded o_def])
  1849           apply (rule finite_product_dependent)
  1849           apply (rule finite_product_dependent)
  1850           apply fact
  1850           apply fact
  1851           apply (rule finite_imageI)
  1851           apply (rule finite_imageI)
  1852           apply (rule p')
  1852           apply (rule p')
  1853           unfolding split_paired_all mem_Collect_eq split_conv o_def
  1853           unfolding split_paired_all mem_Collect_eq split_conv o_def
  1884             unfolding content_eq_0_interior[symmetric]
  1884             unfolding content_eq_0_interior[symmetric]
  1885             by auto
  1885             by auto
  1886         qed
  1886         qed
  1887         also have "\<dots> = (\<Sum>(x, k)\<in>p'. norm (integral k f))"
  1887         also have "\<dots> = (\<Sum>(x, k)\<in>p'. norm (integral k f))"
  1888           unfolding sum_p'
  1888           unfolding sum_p'
  1889           apply (rule setsum.mono_neutral_right)
  1889           apply (rule sum.mono_neutral_right)
  1890           apply (subst *)
  1890           apply (subst *)
  1891           apply (rule finite_imageI[OF finite_product_dependent])
  1891           apply (rule finite_imageI[OF finite_product_dependent])
  1892           apply fact
  1892           apply fact
  1893           apply (rule finite_imageI[OF p'(1)])
  1893           apply (rule finite_imageI[OF p'(1)])
  1894           apply safe
  1894           apply safe
  1927           apply auto
  1927           apply auto
  1928           done
  1928           done
  1929         note pdfin = finite_cartesian_product[OF p'(1) d'(1)]
  1929         note pdfin = finite_cartesian_product[OF p'(1) d'(1)]
  1930         have "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x)) = (\<Sum>(x, k)\<in>?S. \<bar>content k\<bar> * norm (f x))"
  1930         have "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x)) = (\<Sum>(x, k)\<in>?S. \<bar>content k\<bar> * norm (f x))"
  1931           unfolding norm_scaleR
  1931           unfolding norm_scaleR
  1932           apply (rule setsum.mono_neutral_left)
  1932           apply (rule sum.mono_neutral_left)
  1933           apply (subst *)
  1933           apply (subst *)
  1934           apply (rule finite_imageI)
  1934           apply (rule finite_imageI)
  1935           apply fact
  1935           apply fact
  1936           unfolding p'alt
  1936           unfolding p'alt
  1937           apply blast
  1937           apply blast
  1941           apply (rule_tac x=l in exI)
  1941           apply (rule_tac x=l in exI)
  1942           apply auto
  1942           apply auto
  1943           done
  1943           done
  1944         also have "\<dots> = (\<Sum>((x,l),i)\<in>p \<times> d. \<bar>content (l \<inter> i)\<bar> * norm (f x))"
  1944         also have "\<dots> = (\<Sum>((x,l),i)\<in>p \<times> d. \<bar>content (l \<inter> i)\<bar> * norm (f x))"
  1945           unfolding *
  1945           unfolding *
  1946           apply (subst setsum.reindex_nontrivial)
  1946           apply (subst sum.reindex_nontrivial)
  1947           apply fact
  1947           apply fact
  1948           unfolding split_paired_all
  1948           unfolding split_paired_all
  1949           unfolding o_def split_def snd_conv fst_conv mem_Sigma_iff prod.inject
  1949           unfolding o_def split_def snd_conv fst_conv mem_Sigma_iff prod.inject
  1950           apply (elim conjE)
  1950           apply (elim conjE)
  1951         proof -
  1951         proof -
  1979           unfolding Sigma_alt
  1979           unfolding Sigma_alt
  1980           apply (subst sum_sum_product[symmetric])
  1980           apply (subst sum_sum_product[symmetric])
  1981           apply (rule p')
  1981           apply (rule p')
  1982           apply rule
  1982           apply rule
  1983           apply (rule d')
  1983           apply (rule d')
  1984           apply (rule setsum.cong)
  1984           apply (rule sum.cong)
  1985           apply (rule refl)
  1985           apply (rule refl)
  1986           unfolding split_paired_all split_conv
  1986           unfolding split_paired_all split_conv
  1987         proof -
  1987         proof -
  1988           fix x l
  1988           fix x l
  1989           assume as: "(x, l) \<in> p"
  1989           assume as: "(x, l) \<in> p"
  1990           note xl = p'(2-4)[OF this]
  1990           note xl = p'(2-4)[OF this]
  1991           from this(3) guess u v by (elim exE) note uv=this
  1991           from this(3) guess u v by (elim exE) note uv=this
  1992           have "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar>) = (\<Sum>k\<in>d. content (k \<inter> cbox u v))"
  1992           have "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar>) = (\<Sum>k\<in>d. content (k \<inter> cbox u v))"
  1993             apply (rule setsum.cong)
  1993             apply (rule sum.cong)
  1994             apply (rule refl)
  1994             apply (rule refl)
  1995             apply (drule d'(4))
  1995             apply (drule d'(4))
  1996             apply safe
  1996             apply safe
  1997             apply (subst Int_commute)
  1997             apply (subst Int_commute)
  1998             unfolding Int_interval uv
  1998             unfolding Int_interval uv
  1999             apply (subst abs_of_nonneg)
  1999             apply (subst abs_of_nonneg)
  2000             apply auto
  2000             apply auto
  2001             done
  2001             done
  2002           also have "\<dots> = setsum content {k \<inter> cbox u v| k. k \<in> d}"
  2002           also have "\<dots> = sum content {k \<inter> cbox u v| k. k \<in> d}"
  2003             unfolding Setcompr_eq_image
  2003             unfolding Setcompr_eq_image
  2004             apply (rule setsum.reindex_nontrivial [unfolded o_def, symmetric])
  2004             apply (rule sum.reindex_nontrivial [unfolded o_def, symmetric])
  2005             apply (rule d')
  2005             apply (rule d')
  2006           proof goal_cases
  2006           proof goal_cases
  2007             case prems: (1 k y)
  2007             case prems: (1 k y)
  2008             from d'(4)[OF this(1)] d'(4)[OF this(2)]
  2008             from d'(4)[OF this(1)] d'(4)[OF this(2)]
  2009             guess u1 v1 u2 v2 by (elim exE) note uv=this
  2009             guess u1 v1 u2 v2 by (elim exE) note uv=this
  2017             also have "\<dots> = interior (k \<inter> cbox u v)"
  2017             also have "\<dots> = interior (k \<inter> cbox u v)"
  2018               unfolding prems(4) by auto
  2018               unfolding prems(4) by auto
  2019             finally show ?case
  2019             finally show ?case
  2020               unfolding uv Int_interval content_eq_0_interior ..
  2020               unfolding uv Int_interval content_eq_0_interior ..
  2021           qed
  2021           qed
  2022           also have "\<dots> = setsum content {cbox u v \<inter> k |k. k \<in> d \<and> cbox u v \<inter> k \<noteq> {}}"
  2022           also have "\<dots> = sum content {cbox u v \<inter> k |k. k \<in> d \<and> cbox u v \<inter> k \<noteq> {}}"
  2023             apply (rule setsum.mono_neutral_right)
  2023             apply (rule sum.mono_neutral_right)
  2024             unfolding Setcompr_eq_image
  2024             unfolding Setcompr_eq_image
  2025             apply (rule finite_imageI)
  2025             apply (rule finite_imageI)
  2026             apply (rule d')
  2026             apply (rule d')
  2027             apply blast
  2027             apply blast
  2028             apply safe
  2028             apply safe
  2038               using prems(1)
  2038               using prems(1)
  2039               using interior_subset[of "k \<inter> cbox u v"]
  2039               using interior_subset[of "k \<inter> cbox u v"]
  2040               by auto
  2040               by auto
  2041           qed
  2041           qed
  2042           finally show "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar> * norm (f x)) = content l *\<^sub>R norm (f x)"
  2042           finally show "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar> * norm (f x)) = content l *\<^sub>R norm (f x)"
  2043             unfolding setsum_distrib_right[symmetric] real_scaleR_def
  2043             unfolding sum_distrib_right[symmetric] real_scaleR_def
  2044             apply (subst(asm) additive_content_division[OF division_inter_1[OF d(1)]])
  2044             apply (subst(asm) additive_content_division[OF division_inter_1[OF d(1)]])
  2045             using xl(2)[unfolded uv]
  2045             using xl(2)[unfolded uv]
  2046             unfolding uv
  2046             unfolding uv
  2047             apply auto
  2047             apply auto
  2048             done
  2048             done
  2054 qed
  2054 qed
  2055 
  2055 
  2056 lemma bounded_variation_absolutely_integrable:
  2056 lemma bounded_variation_absolutely_integrable:
  2057   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2057   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2058   assumes "f integrable_on UNIV"
  2058   assumes "f integrable_on UNIV"
  2059     and "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm (integral k f)) d \<le> B"
  2059     and "\<forall>d. d division_of (\<Union>d) \<longrightarrow> sum (\<lambda>k. norm (integral k f)) d \<le> B"
  2060   shows "f absolutely_integrable_on UNIV"
  2060   shows "f absolutely_integrable_on UNIV"
  2061 proof (rule absolutely_integrable_onI, fact, rule)
  2061 proof (rule absolutely_integrable_onI, fact, rule)
  2062   let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of  (\<Union>d)}"
  2062   let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of  (\<Union>d)}"
  2063   have D_1: "?D \<noteq> {}"
  2063   have D_1: "?D \<noteq> {}"
  2064     by (rule elementary_interval) auto
  2064     by (rule elementary_interval) auto
  2081     case (1 a b)
  2081     case (1 a b)
  2082     show ?case
  2082     show ?case
  2083       using f_int[of a b] unfolding absolutely_integrable_on_def by auto
  2083       using f_int[of a b] unfolding absolutely_integrable_on_def by auto
  2084   next
  2084   next
  2085     case prems: (2 e)
  2085     case prems: (2 e)
  2086     have "\<exists>y\<in>setsum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> ?S - e"
  2086     have "\<exists>y\<in>sum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> ?S - e"
  2087     proof (rule ccontr)
  2087     proof (rule ccontr)
  2088       assume "\<not> ?thesis"
  2088       assume "\<not> ?thesis"
  2089       then have "?S \<le> ?S - e"
  2089       then have "?S \<le> ?S - e"
  2090         by (intro cSUP_least[OF D(1)]) auto
  2090         by (intro cSUP_least[OF D(1)]) auto
  2091       then show False
  2091       then show False
  2092         using prems by auto
  2092         using prems by auto
  2093     qed
  2093     qed
  2094     then obtain K where *: "\<exists>x\<in>{d. d division_of \<Union>d}. K = (\<Sum>k\<in>x. norm (integral k f))"
  2094     then obtain K where *: "\<exists>x\<in>{d. d division_of \<Union>d}. K = (\<Sum>k\<in>x. norm (integral k f))"
  2095       "SUPREMUM {d. d division_of \<Union>d} (setsum (\<lambda>k. norm (integral k f))) - e < K"
  2095       "SUPREMUM {d. d division_of \<Union>d} (sum (\<lambda>k. norm (integral k f))) - e < K"
  2096       by (auto simp add: image_iff not_le)
  2096       by (auto simp add: image_iff not_le)
  2097     from this(1) obtain d where "d division_of \<Union>d"
  2097     from this(1) obtain d where "d division_of \<Union>d"
  2098       and "K = (\<Sum>k\<in>d. norm (integral k f))"
  2098       and "K = (\<Sum>k\<in>d. norm (integral k f))"
  2099       by auto
  2099       by auto
  2100     note d = this(1) *(2)[unfolded this(2)]
  2100     note d = this(1) *(2)[unfolded this(2)]
  2116         apply (rule *[rule_format])
  2116         apply (rule *[rule_format])
  2117         apply safe
  2117         apply safe
  2118         apply (rule d(2))
  2118         apply (rule d(2))
  2119       proof goal_cases
  2119       proof goal_cases
  2120         case 1
  2120         case 1
  2121         have "(\<Sum>k\<in>d. norm (integral k f)) \<le> setsum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
  2121         have "(\<Sum>k\<in>d. norm (integral k f)) \<le> sum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
  2122           apply (intro setsum_mono)
  2122           apply (intro sum_mono)
  2123           subgoal for k
  2123           subgoal for k
  2124             using d'(4)[of k] f_int
  2124             using d'(4)[of k] f_int
  2125             by (auto simp: absolutely_integrable_on_def integral_norm_bound_integral)
  2125             by (auto simp: absolutely_integrable_on_def integral_norm_bound_integral)
  2126           done
  2126           done
  2127         also have "\<dots> = integral (\<Union>d) (\<lambda>x. norm (f x))"
  2127         also have "\<dots> = integral (\<Union>d) (\<lambda>x. norm (f x))"
  2186             done
  2186             done
  2187           show "\<bar>(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - integral (cbox a b) (\<lambda>x. norm(f x))\<bar> < e / 2"
  2187           show "\<bar>(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - integral (cbox a b) (\<lambda>x. norm(f x))\<bar> < e / 2"
  2188             using d1(2)[rule_format,OF conjI[OF p(1,2)]]
  2188             using d1(2)[rule_format,OF conjI[OF p(1,2)]]
  2189             by (simp only: real_norm_def)
  2189             by (simp only: real_norm_def)
  2190           show "(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) = (\<Sum>(x, k)\<in>p. norm (content k *\<^sub>R f x))"
  2190           show "(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) = (\<Sum>(x, k)\<in>p. norm (content k *\<^sub>R f x))"
  2191             apply (rule setsum.cong)
  2191             apply (rule sum.cong)
  2192             apply (rule refl)
  2192             apply (rule refl)
  2193             unfolding split_paired_all split_conv
  2193             unfolding split_paired_all split_conv
  2194             apply (drule tagged_division_ofD(4)[OF p(1)])
  2194             apply (drule tagged_division_ofD(4)[OF p(1)])
  2195             unfolding norm_scaleR
  2195             unfolding norm_scaleR
  2196             apply (subst abs_of_nonneg)
  2196             apply (subst abs_of_nonneg)
  2197             apply auto
  2197             apply auto
  2198             done
  2198             done
  2199           show "(\<Sum>(x, k)\<in>p. norm (integral k f)) \<le> ?S"
  2199           show "(\<Sum>(x, k)\<in>p. norm (integral k f)) \<le> ?S"
  2200             using partial_division_of_tagged_division[of p "cbox a b"] p(1)
  2200             using partial_division_of_tagged_division[of p "cbox a b"] p(1)
  2201             apply (subst setsum.over_tagged_division_lemma[OF p(1)])
  2201             apply (subst sum.over_tagged_division_lemma[OF p(1)])
  2202             apply (simp add: content_eq_0_interior)
  2202             apply (simp add: content_eq_0_interior)
  2203             apply (intro cSUP_upper2[OF D(2), of "snd ` p"])
  2203             apply (intro cSUP_upper2[OF D(2), of "snd ` p"])
  2204             apply (auto simp: tagged_partial_division_of_def)
  2204             apply (auto simp: tagged_partial_division_of_def)
  2205             done
  2205             done
  2206         qed
  2206         qed
  2228     and h :: "'n::euclidean_space \<Rightarrow> 'p::euclidean_space"
  2228     and h :: "'n::euclidean_space \<Rightarrow> 'p::euclidean_space"
  2229   shows "f absolutely_integrable_on s \<Longrightarrow> bounded_linear h \<Longrightarrow> (h \<circ> f) absolutely_integrable_on s"
  2229   shows "f absolutely_integrable_on s \<Longrightarrow> bounded_linear h \<Longrightarrow> (h \<circ> f) absolutely_integrable_on s"
  2230   using integrable_bounded_linear[of h lebesgue "\<lambda>x. indicator s x *\<^sub>R f x"]
  2230   using integrable_bounded_linear[of h lebesgue "\<lambda>x. indicator s x *\<^sub>R f x"]
  2231   by (simp add: linear_simps[of h])
  2231   by (simp add: linear_simps[of h])
  2232 
  2232 
  2233 lemma absolutely_integrable_setsum:
  2233 lemma absolutely_integrable_sum:
  2234   fixes f :: "'a \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2234   fixes f :: "'a \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2235   assumes "finite t" and "\<And>a. a \<in> t \<Longrightarrow> (f a) absolutely_integrable_on s"
  2235   assumes "finite t" and "\<And>a. a \<in> t \<Longrightarrow> (f a) absolutely_integrable_on s"
  2236   shows "(\<lambda>x. setsum (\<lambda>a. f a x) t) absolutely_integrable_on s"
  2236   shows "(\<lambda>x. sum (\<lambda>a. f a x) t) absolutely_integrable_on s"
  2237   using assms(1,2) by induct auto
  2237   using assms(1,2) by induct auto
  2238 
  2238 
  2239 lemma absolutely_integrable_integrable_bound:
  2239 lemma absolutely_integrable_integrable_bound:
  2240   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2240   fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  2241   assumes le: "\<forall>x\<in>s. norm (f x) \<le> g x" and f: "f integrable_on s" and g: "g integrable_on s"
  2241   assumes le: "\<forall>x\<in>s. norm (f x) \<le> g x" and f: "f integrable_on s" and g: "g integrable_on s"