src/HOL/Probability/Lebesgue_Integration.thy
changeset 49799 15ea98537c76
parent 49798 8d5668f73c42
child 49800 a6678da5692c
equal deleted inserted replaced
49798:8d5668f73c42 49799:15ea98537c76
   386     done
   386     done
   387 qed fact
   387 qed fact
   388 
   388 
   389 lemma simple_function_induct_nn[consumes 2, case_names cong set mult add]:
   389 lemma simple_function_induct_nn[consumes 2, case_names cong set mult add]:
   390   fixes u :: "'a \<Rightarrow> ereal"
   390   fixes u :: "'a \<Rightarrow> ereal"
   391   assumes u: "simple_function M u" and nn: "AE x in M. 0 \<le> u x"
   391   assumes u: "simple_function M u" and nn: "\<And>x. 0 \<le> u x"
   392   assumes cong: "\<And>f g. simple_function M f \<Longrightarrow> simple_function M g \<Longrightarrow> (AE x in M. f x = g x) \<Longrightarrow> P f \<Longrightarrow> P g"
   392   assumes cong: "\<And>f g. simple_function M f \<Longrightarrow> simple_function M g \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> P f \<Longrightarrow> P g"
   393   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   393   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   394   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   394   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   395   assumes add: "\<And>u v. simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> simple_function M v \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   395   assumes add: "\<And>u v. simple_function M u \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> simple_function M v \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   396   shows "P u"
   396   shows "P u"
   397 proof -
   397 proof -
   398   def v \<equiv> "max 0 \<circ> u"
       
   399   have v: "simple_function M v"
       
   400     unfolding v_def using u by (rule simple_function_compose)
       
   401   have v_nn: "\<And>x. 0 \<le> v x"
       
   402     unfolding v_def by (auto simp: max_def)
       
   403 
       
   404   show ?thesis
   398   show ?thesis
   405   proof (rule cong)
   399   proof (rule cong)
   406     have "AE x in M. u x = v x"
   400     fix x assume x: "x \<in> space M"
   407       unfolding v_def using nn by eventually_elim (auto simp: max_def)
   401     from simple_function_indicator_representation[OF u x]
   408     with AE_space
   402     show "(\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x) = u x" ..
   409     show "AE x in M. (\<Sum>y\<in>v ` space M. y * indicator (v -` {y} \<inter> space M) x) = u x"
       
   410     proof eventually_elim
       
   411       fix x assume x: "x \<in> space M" and "u x = v x"
       
   412       from simple_function_indicator_representation[OF v x]
       
   413       show "(\<Sum>y\<in>v ` space M. y * indicator (v -` {y} \<inter> space M) x) = u x"
       
   414         unfolding `u x = v x` ..
       
   415     qed
       
   416   next
   403   next
   417     show "simple_function M (\<lambda>x. (\<Sum>y\<in>v ` space M. y * indicator (v -` {y} \<inter> space M) x))"
   404     show "simple_function M (\<lambda>x. (\<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x))"
   418       apply (subst simple_function_cong)
   405       apply (subst simple_function_cong)
   419       apply (rule simple_function_indicator_representation[symmetric])
   406       apply (rule simple_function_indicator_representation[symmetric])
   420       apply (auto intro: v)
   407       apply (auto intro: u)
   421       done
   408       done
   422   next
   409   next
   423     from v v_nn have "finite (v ` space M)" "\<And>x. x \<in> v ` space M \<Longrightarrow> 0 \<le> x"
   410     from u nn have "finite (u ` space M)" "\<And>x. x \<in> u ` space M \<Longrightarrow> 0 \<le> x"
   424       unfolding simple_function_def by auto
   411       unfolding simple_function_def by auto
   425     then show "P (\<lambda>x. \<Sum>y\<in>v ` space M. y * indicator (v -` {y} \<inter> space M) x)"
   412     then show "P (\<lambda>x. \<Sum>y\<in>u ` space M. y * indicator (u -` {y} \<inter> space M) x)"
   426     proof induct
   413     proof induct
   427       case empty show ?case
   414       case empty show ?case
   428         using set[of "{}"] by (simp add: indicator_def[abs_def])
   415         using set[of "{}"] by (simp add: indicator_def[abs_def])
   429     qed (auto intro!: add mult set simple_functionD v setsum_nonneg
   416     qed (auto intro!: add mult set simple_functionD u setsum_nonneg
   430        simple_function_setsum)
   417        simple_function_setsum)
   431   qed fact
   418   qed fact
   432 qed
   419 qed
   433 
   420 
   434 lemma borel_measurable_induct[consumes 2, case_names cong set mult add seq, induct set: borel_measurable]:
   421 lemma borel_measurable_induct[consumes 2, case_names cong set mult add seq, induct set: borel_measurable]:
   435   fixes u :: "'a \<Rightarrow> ereal"
   422   fixes u :: "'a \<Rightarrow> ereal"
   436   assumes u: "u \<in> borel_measurable M" "AE x in M. 0 \<le> u x"
   423   assumes u: "u \<in> borel_measurable M" "\<And>x. 0 \<le> u x"
   437   assumes cong: "\<And>f g. f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> (AE x in M. f x = g x) \<Longrightarrow> P f \<Longrightarrow> P g"
   424   assumes cong: "\<And>f g. f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> P g \<Longrightarrow> P f"
   438   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   425   assumes set: "\<And>A. A \<in> sets M \<Longrightarrow> P (indicator A)"
   439   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   426   assumes mult: "\<And>u c. 0 \<le> c \<Longrightarrow> u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> P (\<lambda>x. c * u x)"
   440   assumes add: "\<And>u v. u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> v \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   427   assumes add: "\<And>u v. u \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> u x) \<Longrightarrow> P u \<Longrightarrow> v \<in> borel_measurable M \<Longrightarrow> (\<And>x. 0 \<le> v x) \<Longrightarrow> P v \<Longrightarrow> P (\<lambda>x. v x + u x)"
   441   assumes seq: "\<And>U. (\<And>i. U i \<in> borel_measurable M) \<Longrightarrow>  (\<And>i x. 0 \<le> U i x) \<Longrightarrow>  (\<And>i. P (U i)) \<Longrightarrow> incseq U \<Longrightarrow> P (SUP i. U i)"
   428   assumes seq: "\<And>U. (\<And>i. U i \<in> borel_measurable M) \<Longrightarrow>  (\<And>i x. 0 \<le> U i x) \<Longrightarrow>  (\<And>i. P (U i)) \<Longrightarrow> incseq U \<Longrightarrow> P (SUP i. U i)"
   442   shows "P u"
   429   shows "P u"
   443   using u
   430   using u
   444 proof (induct rule: borel_measurable_implies_simple_function_sequence')
   431 proof (induct rule: borel_measurable_implies_simple_function_sequence')
   445   fix U assume U: "\<And>i. simple_function M (U i)" "incseq U" "\<And>i. \<infinity> \<notin> range (U i)" and
   432   fix U assume U: "\<And>i. simple_function M (U i)" "incseq U" "\<And>i. \<infinity> \<notin> range (U i)" and
   446     sup: "\<And>x. (SUP i. U i x) = max 0 (u x)" and nn: "\<And>i x. 0 \<le> U i x"
   433     sup: "\<And>x. (SUP i. U i x) = max 0 (u x)" and nn: "\<And>i x. 0 \<le> U i x"
   447   have u_eq: "max 0 \<circ> u = (SUP i. U i)" and "\<And>i. AE x in M. 0 \<le> U i x"
   434   have u_eq: "u = (SUP i. U i)"
   448     using nn u sup by (auto simp: max_def)
   435     using nn u sup by (auto simp: max_def)
   449   
   436   
   450   from U have "\<And>i. U i \<in> borel_measurable M"
   437   from U have "\<And>i. U i \<in> borel_measurable M"
   451     by (simp add: borel_measurable_simple_function)
   438     by (simp add: borel_measurable_simple_function)
   452 
   439 
   453   have "max 0 \<circ> u \<in> borel_measurable M" "u \<in> borel_measurable M"
   440   show "P u"
   454     by (auto intro!: measurable_comp u borel_measurable_ereal_max simp: id_def[symmetric])
       
   455   moreover have "AE x in M. (max 0 \<circ> u) x = u x"
       
   456     using u(2) by eventually_elim (auto simp: max_def)
       
   457   moreover have "P (max 0 \<circ> u)"
       
   458     unfolding u_eq
   441     unfolding u_eq
   459   proof (rule seq)
   442   proof (rule seq)
   460     fix i show "P (U i)"
   443     fix i show "P (U i)"
   461       using `simple_function M (U i)` `AE x in M. 0 \<le> U i x`
   444       using `simple_function M (U i)` nn
   462       by (induct rule: simple_function_induct_nn)
   445       by (induct rule: simple_function_induct_nn)
   463          (auto intro: set mult add cong dest!: borel_measurable_simple_function)
   446          (auto intro: set mult add cong dest!: borel_measurable_simple_function)
   464   qed fact+
   447   qed fact+
   465   ultimately show "P u"
       
   466     by fact
       
   467 qed
   448 qed
   468 
   449 
   469 lemma simple_function_If_set:
   450 lemma simple_function_If_set:
   470   assumes sf: "simple_function M f" "simple_function M g" and A: "A \<inter> space M \<in> sets M"
   451   assumes sf: "simple_function M f" "simple_function M g" and A: "A \<inter> space M \<in> sets M"
   471   shows "simple_function M (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function M ?IF")
   452   shows "simple_function M (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function M ?IF")
  1425 lemma positive_integral_const_If:
  1406 lemma positive_integral_const_If:
  1426   "(\<integral>\<^isup>+x. a \<partial>M) = (if 0 \<le> a then a * (emeasure M) (space M) else 0)"
  1407   "(\<integral>\<^isup>+x. a \<partial>M) = (if 0 \<le> a then a * (emeasure M) (space M) else 0)"
  1427   by (auto intro!: positive_integral_0_iff_AE[THEN iffD2])
  1408   by (auto intro!: positive_integral_0_iff_AE[THEN iffD2])
  1428 
  1409 
  1429 lemma positive_integral_subalgebra:
  1410 lemma positive_integral_subalgebra:
  1430   assumes f: "f \<in> borel_measurable N" "AE x in N. 0 \<le> f x"
  1411   assumes f: "f \<in> borel_measurable N" "\<And>x. 0 \<le> f x"
  1431   and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> emeasure N A = emeasure M A"
  1412   and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> emeasure N A = emeasure M A"
  1432   shows "integral\<^isup>P N f = integral\<^isup>P M f"
  1413   shows "integral\<^isup>P N f = integral\<^isup>P M f"
  1433 proof -
  1414 proof -
  1434   from borel_measurable_implies_simple_function_sequence'[OF f(1)] guess fs . note fs = this
  1415   have [simp]: "\<And>f :: 'a \<Rightarrow> ereal. f \<in> borel_measurable N \<Longrightarrow> f \<in> borel_measurable M"
  1435   note sf = simple_function_subalgebra[OF fs(1) N(1,2)]
  1416     using N by (auto simp: measurable_def)
  1436   from positive_integral_monotone_convergence_simple[OF fs(2,5,1), symmetric]
  1417   have [simp]: "\<And>P. (AE x in N. P x) \<Longrightarrow> (AE x in M. P x)"
  1437   have "integral\<^isup>P N f = (SUP i. \<Sum>x\<in>fs i ` space M. x * emeasure N (fs i -` {x} \<inter> space M))"
  1418     using N by (auto simp add: eventually_ae_filter null_sets_def)
  1438     unfolding fs(4) positive_integral_max_0
  1419   have [simp]: "\<And>A. A \<in> sets N \<Longrightarrow> A \<in> sets M"
  1439     unfolding simple_integral_def `space N = space M` by simp
  1420     using N by auto
  1440   also have "\<dots> = (SUP i. \<Sum>x\<in>fs i ` space M. x * (emeasure M) (fs i -` {x} \<inter> space M))"
  1421   from f show ?thesis
  1441     using N simple_functionD(2)[OF fs(1)] unfolding `space N = space M` by auto
  1422     apply induct
  1442   also have "\<dots> = integral\<^isup>P M f"
  1423     apply (simp_all add: positive_integral_add positive_integral_cmult positive_integral_monotone_convergence_SUP N)
  1443     using positive_integral_monotone_convergence_simple[OF fs(2,5) sf, symmetric]
  1424     apply (auto intro!: positive_integral_cong cong: positive_integral_cong simp: N(2)[symmetric])
  1444     unfolding fs(4) positive_integral_max_0
  1425     done
  1445     unfolding simple_integral_def `space N = space M` by simp
       
  1446   finally show ?thesis .
       
  1447 qed
  1426 qed
  1448 
  1427 
  1449 section "Lebesgue Integral"
  1428 section "Lebesgue Integral"
  1450 
  1429 
  1451 definition integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool" where
  1430 definition integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool" where
  2308 
  2287 
  2309 section {* Distributions *}
  2288 section {* Distributions *}
  2310 
  2289 
  2311 lemma positive_integral_distr':
  2290 lemma positive_integral_distr':
  2312   assumes T: "T \<in> measurable M M'"
  2291   assumes T: "T \<in> measurable M M'"
  2313   and f: "f \<in> borel_measurable (distr M M' T)" "AE x in (distr M M' T). 0 \<le> f x"
  2292   and f: "f \<in> borel_measurable (distr M M' T)" "\<And>x. 0 \<le> f x"
  2314   shows "integral\<^isup>P (distr M M' T) f = (\<integral>\<^isup>+ x. f (T x) \<partial>M)"
  2293   shows "integral\<^isup>P (distr M M' T) f = (\<integral>\<^isup>+ x. f (T x) \<partial>M)"
  2315   using f 
  2294   using f 
  2316 proof induct
  2295 proof induct
  2317   case (cong f g)
  2296   case (cong f g)
  2318   then have eq: "AE x in (distr M M' T). g x = f x" "AE x in M. g (T x) = f (T x)"
  2297   with T show ?case
  2319     by (auto dest: AE_distrD[OF T])
  2298     apply (subst positive_integral_cong[of _ f g])
  2320   show ?case
  2299     apply simp
  2321     apply (subst eq(1)[THEN positive_integral_cong_AE])
  2300     apply (subst positive_integral_cong[of _ "\<lambda>x. f (T x)" "\<lambda>x. g (T x)"])
  2322     apply (subst eq(2)[THEN positive_integral_cong_AE])
  2301     apply (simp add: measurable_def Pi_iff)
  2323     apply fact
  2302     apply simp
  2324     done
  2303     done
  2325 next
  2304 next
  2326   case (set A)
  2305   case (set A)
  2327   then have eq: "\<And>x. x \<in> space M \<Longrightarrow> indicator A (T x) = indicator (T -` A \<inter> space M) x"
  2306   then have eq: "\<And>x. x \<in> space M \<Longrightarrow> indicator A (T x) = indicator (T -` A \<inter> space M) x"
  2328     by (auto simp: indicator_def)
  2307     by (auto simp: indicator_def)
  2527        (auto elim: eventually_elim2)
  2506        (auto elim: eventually_elim2)
  2528 qed
  2507 qed
  2529 
  2508 
  2530 lemma positive_integral_density':
  2509 lemma positive_integral_density':
  2531   assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
  2510   assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
  2532   assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
  2511   assumes g: "g \<in> borel_measurable M" "\<And>x. 0 \<le> g x"
  2533   shows "integral\<^isup>P (density M f) g = (\<integral>\<^isup>+ x. f x * g x \<partial>M)"
  2512   shows "integral\<^isup>P (density M f) g = (\<integral>\<^isup>+ x. f x * g x \<partial>M)"
  2534 using g proof induct
  2513 using g proof induct
  2535   case (cong u v)
  2514   case (cong u v)
  2536   then have eq: "AE x in density M f. v x = u x" "AE x in M. f x * v x = f x * u x"
  2515   then show ?case
  2537     by (auto simp: AE_density f)
  2516     apply (subst positive_integral_cong[OF cong(3)])
  2538   show ?case
  2517     apply (simp_all cong: positive_integral_cong)
  2539     apply (subst positive_integral_cong_AE[OF eq(1)])
       
  2540     apply (subst positive_integral_cong_AE[OF eq(2)])
       
  2541     apply fact
       
  2542     done
  2518     done
  2543 next
  2519 next
  2544   case (set A) then show ?case
  2520   case (set A) then show ?case
  2545     by (simp add: emeasure_density f)
  2521     by (simp add: emeasure_density f)
  2546 next
  2522 next