src/HOL/Probability/Lebesgue_Integration.thy
changeset 41661 baf1964bc468
parent 41545 9c869baf1c66
child 41689 3e39b0e730d6
equal deleted inserted replaced
41660:7795aaab6038 41661:baf1964bc468
   469   using assms
   469   using assms
   470   unfolding simple_function_def
   470   unfolding simple_function_def
   471   unfolding sigma_algebra.simple_function_def[OF N_subalgebra(3)]
   471   unfolding sigma_algebra.simple_function_def[OF N_subalgebra(3)]
   472   by auto
   472   by auto
   473 
   473 
   474 lemma (in sigma_algebra) simple_function_vimage:
   474 lemma (in measure_space) simple_function_vimage:
   475   fixes g :: "'a \<Rightarrow> pextreal" and f :: "'d \<Rightarrow> 'a"
   475   assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
   476   assumes g: "simple_function g" and f: "f \<in> S \<rightarrow> space M"
   476     and f: "sigma_algebra.simple_function M' f"
   477   shows "sigma_algebra.simple_function (vimage_algebra S f) (\<lambda>x. g (f x))"
   477   shows "simple_function (\<lambda>x. f (T x))"
   478 proof -
   478 proof (intro simple_function_def[THEN iffD2] conjI ballI)
   479   have subset: "(\<lambda>x. g (f x)) ` S \<subseteq> g ` space M"
   479   interpret T: sigma_algebra M' by fact
   480     using f by auto
   480   have "(\<lambda>x. f (T x)) ` space M \<subseteq> f ` space M'"
   481   interpret V: sigma_algebra "vimage_algebra S f"
   481     using T unfolding measurable_def by auto
   482     using f by (rule sigma_algebra_vimage)
   482   then show "finite ((\<lambda>x. f (T x)) ` space M)"
   483   show ?thesis using g
   483     using f unfolding T.simple_function_def by (auto intro: finite_subset)
   484     unfolding simple_function_eq_borel_measurable
   484   fix i assume i: "i \<in> (\<lambda>x. f (T x)) ` space M"
   485     unfolding V.simple_function_eq_borel_measurable
   485   then have "i \<in> f ` space M'"
   486     using measurable_vimage[OF _ f, of g borel]
   486     using T unfolding measurable_def by auto
   487     using finite_subset[OF subset] by auto
   487   then have "f -` {i} \<inter> space M' \<in> sets M'"
       
   488     using f unfolding T.simple_function_def by auto
       
   489   then have "T -` (f -` {i} \<inter> space M') \<inter> space M \<in> sets M"
       
   490     using T unfolding measurable_def by auto
       
   491   also have "T -` (f -` {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) -` {i} \<inter> space M"
       
   492     using T unfolding measurable_def by auto
       
   493   finally show "(\<lambda>x. f (T x)) -` {i} \<inter> space M \<in> sets M" .
   488 qed
   494 qed
   489 
   495 
   490 section "Simple integral"
   496 section "Simple integral"
   491 
   497 
   492 definition (in measure_space) simple_integral (binder "\<integral>\<^isup>S " 10) where
   498 definition (in measure_space) simple_integral (binder "\<integral>\<^isup>S " 10) where
   814   shows "measure_space.simple_integral N \<mu> = simple_integral"
   820   shows "measure_space.simple_integral N \<mu> = simple_integral"
   815   unfolding simple_integral_def_raw
   821   unfolding simple_integral_def_raw
   816   unfolding measure_space.simple_integral_def_raw[OF N] by simp
   822   unfolding measure_space.simple_integral_def_raw[OF N] by simp
   817 
   823 
   818 lemma (in measure_space) simple_integral_vimage:
   824 lemma (in measure_space) simple_integral_vimage:
   819   fixes g :: "'a \<Rightarrow> pextreal" and f :: "'d \<Rightarrow> 'a"
   825   assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
   820   assumes f: "bij_betw f S (space M)"
   826     and f: "sigma_algebra.simple_function M' f"
   821   shows "simple_integral g =
   827   shows "measure_space.simple_integral M' (\<lambda>A. \<mu> (T -` A \<inter> space M)) f = (\<integral>\<^isup>S x. f (T x))"
   822          measure_space.simple_integral (vimage_algebra S f) (\<lambda>A. \<mu> (f ` A)) (\<lambda>x. g (f x))"
   828     (is "measure_space.simple_integral M' ?nu f = _")
   823     (is "_ = measure_space.simple_integral ?T ?\<mu> _")
   829 proof -
   824 proof -
   830   interpret T: measure_space M' ?nu using T by (rule measure_space_vimage) auto
   825   from f interpret T: measure_space ?T ?\<mu> by (rule measure_space_isomorphic)
   831   show "T.simple_integral f = (\<integral>\<^isup>S x. f (T x))"
   826   have surj: "f`S = space M"
   832     unfolding simple_integral_def T.simple_integral_def
   827     using f unfolding bij_betw_def by simp
   833   proof (intro setsum_mono_zero_cong_right ballI)
   828   have *: "(\<lambda>x. g (f x)) ` S = g ` f ` S" by auto
   834     show "(\<lambda>x. f (T x)) ` space M \<subseteq> f ` space M'"
   829   have **: "f`S = space M" using f unfolding bij_betw_def by auto
   835       using T unfolding measurable_def by auto
   830   { fix x assume "x \<in> space M"
   836     show "finite (f ` space M')"
   831     have "(f ` ((\<lambda>x. g (f x)) -` {g x} \<inter> S)) =
   837       using f unfolding T.simple_function_def by auto
   832       (f ` (f -` (g -` {g x}) \<inter> S))" by auto
   838   next
   833     also have "f -` (g -` {g x}) \<inter> S = f -` (g -` {g x} \<inter> space M) \<inter> S"
   839     fix i assume "i \<in> f ` space M' - (\<lambda>x. f (T x)) ` space M"
   834       using f unfolding bij_betw_def by auto
   840     then have "T -` (f -` {i} \<inter> space M') \<inter> space M = {}" by (auto simp: image_iff)
   835     also have "(f ` (f -` (g -` {g x} \<inter> space M) \<inter> S)) = g -` {g x} \<inter> space M"
   841     then show "i * \<mu> (T -` (f -` {i} \<inter> space M') \<inter> space M) = 0" by simp
   836       using ** by (intro image_vimage_inter_eq) auto
   842   next
   837     finally have "(f ` ((\<lambda>x. g (f x)) -` {g x} \<inter> S)) = g -` {g x} \<inter> space M" by auto }
   843     fix i assume "i \<in> (\<lambda>x. f (T x)) ` space M"
   838   then show ?thesis using assms
   844     then have "T -` (f -` {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) -` {i} \<inter> space M"
   839     unfolding simple_integral_def T.simple_integral_def bij_betw_def
   845       using T unfolding measurable_def by auto
   840     by (auto simp add: * intro!: setsum_cong)
   846     then show "i * \<mu> (T -` (f -` {i} \<inter> space M') \<inter> space M) = i * \<mu> ((\<lambda>x. f (T x)) -` {i} \<inter> space M)"
       
   847       by auto
       
   848   qed
   841 qed
   849 qed
   842 
   850 
   843 section "Continuous posititve integration"
   851 section "Continuous posititve integration"
   844 
   852 
   845 definition (in measure_space) positive_integral (binder "\<integral>\<^isup>+ " 10) where
   853 definition (in measure_space) positive_integral (binder "\<integral>\<^isup>+ " 10) where
  1014   assumes A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y\<in>B. f x = g y"
  1022   assumes A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y\<in>B. f x = g y"
  1015   assumes B: "\<And>y. y \<in> B \<Longrightarrow> \<exists>x\<in>A. g y = f x"
  1023   assumes B: "\<And>y. y \<in> B \<Longrightarrow> \<exists>x\<in>A. g y = f x"
  1016   shows "f ` A = g ` B"
  1024   shows "f ` A = g ` B"
  1017   using assms by blast
  1025   using assms by blast
  1018 
  1026 
  1019 lemma (in measure_space) positive_integral_vimage:
       
  1020   fixes g :: "'a \<Rightarrow> pextreal" and f :: "'d \<Rightarrow> 'a"
       
  1021   assumes f: "bij_betw f S (space M)"
       
  1022   shows "positive_integral g =
       
  1023          measure_space.positive_integral (vimage_algebra S f) (\<lambda>A. \<mu> (f ` A)) (\<lambda>x. g (f x))"
       
  1024     (is "_ = measure_space.positive_integral ?T ?\<mu> _")
       
  1025 proof -
       
  1026   from f interpret T: measure_space ?T ?\<mu> by (rule measure_space_isomorphic)
       
  1027   have f_fun: "f \<in> S \<rightarrow> space M" using assms unfolding bij_betw_def by auto
       
  1028   from assms have inv: "bij_betw (the_inv_into S f) (space M) S"
       
  1029     by (rule bij_betw_the_inv_into)
       
  1030   then have inv_fun: "the_inv_into S f \<in> space M \<rightarrow> S" unfolding bij_betw_def by auto
       
  1031   have surj: "f`S = space M"
       
  1032     using f unfolding bij_betw_def by simp
       
  1033   have inj: "inj_on f S"
       
  1034     using f unfolding bij_betw_def by simp
       
  1035   have inv_f: "\<And>x. x \<in> space M \<Longrightarrow> f (the_inv_into S f x) = x"
       
  1036     using f_the_inv_into_f[of f S] f unfolding bij_betw_def by auto
       
  1037   from simple_integral_vimage[OF assms, symmetric]
       
  1038   have *: "simple_integral = T.simple_integral \<circ> (\<lambda>g. g \<circ> f)" by (simp add: comp_def)
       
  1039   show ?thesis
       
  1040     unfolding positive_integral_alt1 T.positive_integral_alt1 SUPR_def * image_compose
       
  1041   proof (safe intro!: arg_cong[where f=Sup] image_set_cong, simp_all add: comp_def)
       
  1042     fix g' :: "'a \<Rightarrow> pextreal" assume "simple_function g'" "\<forall>x\<in>space M. g' x \<le> g x \<and> g' x \<noteq> \<omega>"
       
  1043     then show "\<exists>h. T.simple_function h \<and> (\<forall>x\<in>S. h x \<le> g (f x) \<and> h x \<noteq> \<omega>) \<and>
       
  1044                    T.simple_integral (\<lambda>x. g' (f x)) = T.simple_integral h"
       
  1045       using f unfolding bij_betw_def
       
  1046       by (auto intro!: exI[of _ "\<lambda>x. g' (f x)"]
       
  1047                simp add: le_fun_def simple_function_vimage[OF _ f_fun])
       
  1048   next
       
  1049     fix g' :: "'d \<Rightarrow> pextreal" assume g': "T.simple_function g'" "\<forall>x\<in>S. g' x \<le> g (f x) \<and> g' x \<noteq> \<omega>"
       
  1050     let ?g = "\<lambda>x. g' (the_inv_into S f x)"
       
  1051     show "\<exists>h. simple_function h \<and> (\<forall>x\<in>space M. h x \<le> g x \<and> h x \<noteq> \<omega>) \<and>
       
  1052               T.simple_integral g' = T.simple_integral (\<lambda>x. h (f x))"
       
  1053     proof (intro exI[of _ ?g] conjI ballI)
       
  1054       { fix x assume x: "x \<in> space M"
       
  1055         then have "the_inv_into S f x \<in> S" using inv_fun by auto
       
  1056         with g' have "g' (the_inv_into S f x) \<le> g (f (the_inv_into S f x)) \<and> g' (the_inv_into S f x) \<noteq> \<omega>"
       
  1057           by auto
       
  1058         then show "g' (the_inv_into S f x) \<le> g x" "g' (the_inv_into S f x) \<noteq> \<omega>"
       
  1059           using f_the_inv_into_f[of f S x] x f unfolding bij_betw_def by auto }
       
  1060       note vimage_vimage_inv[OF f inv_f inv_fun, simp]
       
  1061       from T.simple_function_vimage[OF g'(1), unfolded space_vimage_algebra, OF inv_fun]
       
  1062       show "simple_function (\<lambda>x. g' (the_inv_into S f x))"
       
  1063         unfolding simple_function_def by (simp add: simple_function_def)
       
  1064       show "T.simple_integral g' = T.simple_integral (\<lambda>x. ?g (f x))"
       
  1065         using the_inv_into_f_f[OF inj] by (auto intro!: T.simple_integral_cong)
       
  1066     qed
       
  1067   qed
       
  1068 qed
       
  1069 
       
  1070 lemma (in measure_space) positive_integral_vimage_inv:
       
  1071   fixes g :: "'d \<Rightarrow> pextreal" and f :: "'d \<Rightarrow> 'a"
       
  1072   assumes f: "bij_inv S (space M) f h"
       
  1073   shows "measure_space.positive_integral (vimage_algebra S f) (\<lambda>A. \<mu> (f ` A)) g =
       
  1074       (\<integral>\<^isup>+x. g (h x))"
       
  1075 proof -
       
  1076   interpret v: measure_space "vimage_algebra S f" "\<lambda>A. \<mu> (f ` A)"
       
  1077     using f by (rule measure_space_isomorphic[OF bij_inv_bij_betw(1)])
       
  1078   show ?thesis
       
  1079     unfolding positive_integral_vimage[OF f[THEN bij_inv_bij_betw(1)], of "\<lambda>x. g (h x)"]
       
  1080     using f[unfolded bij_inv_def]
       
  1081     by (auto intro!: v.positive_integral_cong)
       
  1082 qed
       
  1083 
       
  1084 lemma (in measure_space) positive_integral_SUP_approx:
  1027 lemma (in measure_space) positive_integral_SUP_approx:
  1085   assumes "f \<up> s"
  1028   assumes "f \<up> s"
  1086   and f: "\<And>i. f i \<in> borel_measurable M"
  1029   and f: "\<And>i. f i \<in> borel_measurable M"
  1087   and "simple_function u"
  1030   and "simple_function u"
  1088   and le: "u \<le> s" and real: "\<omega> \<notin> u`space M"
  1031   and le: "u \<le> s" and real: "\<omega> \<notin> u`space M"
  1242 lemma (in measure_space) positive_integral_isoton_simple:
  1185 lemma (in measure_space) positive_integral_isoton_simple:
  1243   assumes "f \<up> u" and e: "\<And>i. simple_function (f i)"
  1186   assumes "f \<up> u" and e: "\<And>i. simple_function (f i)"
  1244   shows "(\<lambda>i. simple_integral (f i)) \<up> positive_integral u"
  1187   shows "(\<lambda>i. simple_integral (f i)) \<up> positive_integral u"
  1245   using positive_integral_isoton[OF `f \<up> u` e(1)[THEN borel_measurable_simple_function]]
  1188   using positive_integral_isoton[OF `f \<up> u` e(1)[THEN borel_measurable_simple_function]]
  1246   unfolding positive_integral_eq_simple_integral[OF e] .
  1189   unfolding positive_integral_eq_simple_integral[OF e] .
       
  1190 
       
  1191 lemma (in measure_space) positive_integral_vimage:
       
  1192   assumes T: "sigma_algebra M'" "T \<in> measurable M M'" and f: "f \<in> borel_measurable M'"
       
  1193   shows "measure_space.positive_integral M' (\<lambda>A. \<mu> (T -` A \<inter> space M)) f = (\<integral>\<^isup>+ x. f (T x))"
       
  1194     (is "measure_space.positive_integral M' ?nu f = _")
       
  1195 proof -
       
  1196   interpret T: measure_space M' ?nu using T by (rule measure_space_vimage) auto
       
  1197   obtain f' where f': "f' \<up> f" "\<And>i. T.simple_function (f' i)"
       
  1198     using T.borel_measurable_implies_simple_function_sequence[OF f] by blast
       
  1199   then have f: "(\<lambda>i x. f' i (T x)) \<up> (\<lambda>x. f (T x))" "\<And>i. simple_function (\<lambda>x. f' i (T x))"
       
  1200     using simple_function_vimage[OF T] unfolding isoton_fun_expand by auto
       
  1201   show "T.positive_integral f = (\<integral>\<^isup>+ x. f (T x))"
       
  1202     using positive_integral_isoton_simple[OF f]
       
  1203     using T.positive_integral_isoton_simple[OF f']
       
  1204     unfolding simple_integral_vimage[OF T f'(2)] isoton_def
       
  1205     by simp
       
  1206 qed
  1247 
  1207 
  1248 lemma (in measure_space) positive_integral_linear:
  1208 lemma (in measure_space) positive_integral_linear:
  1249   assumes f: "f \<in> borel_measurable M"
  1209   assumes f: "f \<in> borel_measurable M"
  1250   and g: "g \<in> borel_measurable M"
  1210   and g: "g \<in> borel_measurable M"
  1251   shows "(\<integral>\<^isup>+ x. a * f x + g x) =
  1211   shows "(\<integral>\<^isup>+ x. a * f x + g x) =
  1612 proof -
  1572 proof -
  1613   have "\<And>x. Real (- f x) = 0" using assms by simp
  1573   have "\<And>x. Real (- f x) = 0" using assms by simp
  1614   thus ?thesis by (simp del: Real_eq_0 add: integral_def)
  1574   thus ?thesis by (simp del: Real_eq_0 add: integral_def)
  1615 qed
  1575 qed
  1616 
  1576 
  1617 lemma (in measure_space) integral_vimage_inv:
  1577 lemma (in measure_space) integral_vimage:
  1618   assumes f: "bij_betw f S (space M)"
  1578   assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
  1619   shows "measure_space.integral (vimage_algebra S f) (\<lambda>A. \<mu> (f ` A)) (\<lambda>x. g x) = (\<integral>x. g (the_inv_into S f x))"
  1579   assumes f: "measure_space.integrable M' (\<lambda>A. \<mu> (T -` A \<inter> space M)) f"
  1620 proof -
  1580   shows "integrable (\<lambda>x. f (T x))" (is ?P)
  1621   interpret v: measure_space "vimage_algebra S f" "\<lambda>A. \<mu> (f ` A)"
  1581     and "measure_space.integral M' (\<lambda>A. \<mu> (T -` A \<inter> space M)) f = (\<integral>x. f (T x))" (is ?I)
  1622     using f by (rule measure_space_isomorphic)
  1582 proof -
  1623   have "\<And>x. x \<in> space (vimage_algebra S f) \<Longrightarrow> the_inv_into S f (f x) = x"
  1583   interpret T: measure_space M' "\<lambda>A. \<mu> (T -` A \<inter> space M)"
  1624     using f[unfolded bij_betw_def] by (simp add: the_inv_into_f_f)
  1584     using T by (rule measure_space_vimage) auto
  1625   then have *: "v.positive_integral (\<lambda>x. Real (g (the_inv_into S f (f x)))) = v.positive_integral (\<lambda>x. Real (g x))"
  1585   from measurable_comp[OF T(2), of f borel]
  1626      "v.positive_integral (\<lambda>x. Real (- g (the_inv_into S f (f x)))) = v.positive_integral (\<lambda>x. Real (- g x))"
  1586   have borel: "(\<lambda>x. Real (f x)) \<in> borel_measurable M'" "(\<lambda>x. Real (- f x)) \<in> borel_measurable M'"
  1627     by (auto intro!: v.positive_integral_cong)
  1587     and "(\<lambda>x. f (T x)) \<in> borel_measurable M"
  1628   show ?thesis
  1588     using f unfolding T.integrable_def by (auto simp: comp_def)
  1629     unfolding integral_def v.integral_def
  1589   then show ?P ?I
  1630     unfolding positive_integral_vimage[OF f]
  1590     using f unfolding T.integral_def integral_def T.integrable_def integrable_def
  1631     by (simp add: *)
  1591     unfolding borel[THEN positive_integral_vimage[OF T]] by auto
  1632 qed
  1592 qed
  1633 
  1593 
  1634 lemma (in measure_space) integral_minus[intro, simp]:
  1594 lemma (in measure_space) integral_minus[intro, simp]:
  1635   assumes "integrable f"
  1595   assumes "integrable f"
  1636   shows "integrable (\<lambda>x. - f x)" "(\<integral>x. - f x) = - integral f"
  1596   shows "integrable (\<lambda>x. - f x)" "(\<integral>x. - f x) = - integral f"