# HG changeset patch # User hoelzl # Date 1291661696 -3600 # Node ID bea75746dc9dae3b53e5fdc9e3e3cc74c0580d5a # Parent 8b2cd85ecf11914f13c119e775ad83cf2205e4ec folding on arbitrary Lebesgue integrable functions diff -r 8b2cd85ecf11 -r bea75746dc9d src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Mon Dec 06 19:54:53 2010 +0100 +++ b/src/HOL/Probability/Borel_Space.thy Mon Dec 06 19:54:56 2010 +0100 @@ -847,6 +847,15 @@ by (simp add: borel_measurable_iff_ge) qed +lemma (in sigma_algebra) borel_measurable_setsum[simp, intro]: + fixes f :: "'c \ 'a \ real" + assumes "\i. i \ S \ f i \ borel_measurable M" + shows "(\x. \i\S. f i x) \ borel_measurable M" +proof cases + assume "finite S" + thus ?thesis using assms by induct auto +qed simp + lemma (in sigma_algebra) borel_measurable_square: fixes f :: "'a \ real" assumes f: "f \ borel_measurable M" @@ -930,6 +939,15 @@ using 1 2 by simp qed +lemma (in sigma_algebra) borel_measurable_setprod[simp, intro]: + fixes f :: "'c \ 'a \ real" + assumes "\i. i \ S \ f i \ borel_measurable M" + shows "(\x. \i\S. f i x) \ borel_measurable M" +proof cases + assume "finite S" + thus ?thesis using assms by induct auto +qed simp + lemma (in sigma_algebra) borel_measurable_diff[simp, intro]: fixes f :: "'a \ real" assumes f: "f \ borel_measurable M" @@ -937,15 +955,6 @@ shows "(\x. f x - g x) \ borel_measurable M" unfolding diff_minus using assms by fast -lemma (in sigma_algebra) borel_measurable_setsum[simp, intro]: - fixes f :: "'c \ 'a \ real" - assumes "\i. i \ S \ f i \ borel_measurable M" - shows "(\x. \i\S. f i x) \ borel_measurable M" -proof cases - assume "finite S" - thus ?thesis using assms by induct auto -qed simp - lemma (in sigma_algebra) borel_measurable_inverse[simp, intro]: fixes f :: "'a \ real" assumes "f \ borel_measurable M" @@ -1007,6 +1016,11 @@ show ?thesis unfolding * using assms by auto qed +lemma borel_measurable_nth[simp, intro]: + "(\x::real^'n. x $ i) \ borel_measurable borel" + using borel_measurable_euclidean_component + unfolding nth_conv_component by auto + section "Borel space over the real line with infinity" lemma borel_Real_measurable: diff -r 8b2cd85ecf11 -r bea75746dc9d src/HOL/Probability/Lebesgue_Integration.thy --- a/src/HOL/Probability/Lebesgue_Integration.thy Mon Dec 06 19:54:53 2010 +0100 +++ b/src/HOL/Probability/Lebesgue_Integration.thy Mon Dec 06 19:54:56 2010 +0100 @@ -2034,6 +2034,15 @@ using assms(2) by (cases ?thesis) auto qed +lemma (in measure_space) positive_integral_omega_AE: + assumes "f \ borel_measurable M" "positive_integral f \ \" shows "AE x. f x \ \" +proof (rule AE_I) + show "\ (f -` {\} \ space M) = 0" + by (rule positive_integral_omega[OF assms]) + show "f -` {\} \ space M \ sets M" + using assms by (auto intro: borel_measurable_vimage) +qed auto + lemma (in measure_space) simple_integral_omega: assumes "simple_function f" and "simple_integral f \ \" @@ -2044,6 +2053,23 @@ using assms by (simp add: positive_integral_eq_simple_integral) qed +lemma (in measure_space) integral_real: + fixes f :: "'a \ pextreal" + assumes "AE x. f x \ \" + shows "integral (\x. real (f x)) = real (positive_integral f)" (is ?plus) + and "integral (\x. - real (f x)) = - real (positive_integral f)" (is ?minus) +proof - + have "positive_integral (\x. Real (real (f x))) = positive_integral f" + apply (rule positive_integral_cong_AE) + apply (rule AE_mp[OF assms(1)]) + by (auto intro!: AE_cong simp: Real_real) + moreover + have "positive_integral (\x. Real (- real (f x))) = positive_integral (\x. 0)" + by (intro positive_integral_cong) auto + ultimately show ?plus ?minus + by (auto simp: integral_def integrable_def) +qed + lemma (in measure_space) integral_dominated_convergence: assumes u: "\i. integrable (u i)" and bound: "\x j. x\space M \ \u j x\ \ w x" and w: "integrable w" "\x. x \ space M \ 0 \ w x" diff -r 8b2cd85ecf11 -r bea75746dc9d src/HOL/Probability/Product_Measure.thy --- a/src/HOL/Probability/Product_Measure.thy Mon Dec 06 19:54:53 2010 +0100 +++ b/src/HOL/Probability/Product_Measure.thy Mon Dec 06 19:54:56 2010 +0100 @@ -14,6 +14,9 @@ lemma case_prod_distrib: "f (case x of (x, y) \ g x y) = (case x of (x, y) \ f (g x y))" by (cases x) simp +lemma split_beta': "(\(x,y). f x y) = (\x. f (fst x) (snd x))" + by (auto simp: fun_eq_iff) + abbreviation "Pi\<^isub>E A B \ Pi A B \ extensional A" @@ -819,6 +822,147 @@ qed qed +lemma (in pair_sigma_finite) positive_integral_product_swap: + "measure_space.positive_integral + (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \2 M1 \1) f = + positive_integral (\(x,y). f (y,x))" +proof - + interpret Q: pair_sigma_finite M2 \2 M1 \1 by default + have t: "(\y. case case y of (y, x) \ (x, y) of (x, y) \ f (y, x)) = f" + by (auto simp: fun_eq_iff) + have bij: "bij_betw (\(x, y). (y, x)) (space M2 \ space M1) (space P)" + by (auto intro!: inj_onI simp: space_pair_algebra bij_betw_def) + show ?thesis + unfolding positive_integral_vimage[OF bij, of "\(y,x). f (x,y)"] + unfolding pair_sigma_algebra_swap[symmetric] t + proof (rule Q.positive_integral_cong_measure[symmetric]) + fix A assume "A \ sets Q.P" + from this Q.sets_pair_sigma_algebra_swap[OF this] + show "pair_measure ((\(x, y). (y, x)) ` A) = Q.pair_measure A" + by (auto intro!: M1.positive_integral_cong arg_cong[where f=\2] + simp: pair_measure_alt Q.pair_measure_alt2) + qed +qed + +lemma (in pair_sigma_algebra) measurable_product_swap: + "f \ measurable (sigma (pair_algebra M2 M1)) M \ (\(x,y). f (y,x)) \ measurable P M" +proof - + interpret Q: pair_sigma_algebra M2 M1 by default + show ?thesis + using pair_sigma_algebra_measurable[of "\(x,y). f (y, x)"] + by (auto intro!: pair_sigma_algebra_measurable Q.pair_sigma_algebra_measurable iffI) +qed + +lemma (in pair_sigma_finite) integrable_product_swap: + "measure_space.integrable + (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \2 M1 \1) f \ + integrable (\(x,y). f (y,x))" +proof - + interpret Q: pair_sigma_finite M2 \2 M1 \1 by default + show ?thesis + unfolding Q.integrable_def integrable_def + unfolding positive_integral_product_swap + unfolding measurable_product_swap + by (simp add: case_prod_distrib) +qed + +lemma (in pair_sigma_finite) integral_product_swap: + "measure_space.integral + (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \2 M1 \1) f = + integral (\(x,y). f (y,x))" +proof - + interpret Q: pair_sigma_finite M2 \2 M1 \1 by default + show ?thesis + unfolding integral_def Q.integral_def positive_integral_product_swap + by (simp add: case_prod_distrib) +qed + +lemma (in pair_sigma_finite) integrable_fst_measurable: + assumes f: "integrable f" + shows "M1.almost_everywhere (\x. M2.integrable (\ y. f (x, y)))" (is "?AE") + and "M1.integral (\ x. M2.integral (\ y. f (x, y))) = integral f" (is "?INT") +proof - + let "?pf x" = "Real (f x)" and "?nf x" = "Real (- f x)" + have + borel: "?nf \ borel_measurable P""?pf \ borel_measurable P" and + int: "positive_integral ?nf \ \" "positive_integral ?pf \ \" + using assms by auto + have "M1.positive_integral (\x. M2.positive_integral (\y. Real (f (x, y)))) \ \" + "M1.positive_integral (\x. M2.positive_integral (\y. Real (- f (x, y)))) \ \" + using borel[THEN positive_integral_fst_measurable(1)] int + unfolding borel[THEN positive_integral_fst_measurable(2)] by simp_all + with borel[THEN positive_integral_fst_measurable(1)] + have AE: "M1.almost_everywhere (\x. M2.positive_integral (\y. Real (f (x, y))) \ \)" + "M1.almost_everywhere (\x. M2.positive_integral (\y. Real (- f (x, y))) \ \)" + by (auto intro!: M1.positive_integral_omega_AE) + then show ?AE + apply (rule M1.AE_mp[OF _ M1.AE_mp]) + apply (rule M1.AE_cong) + using assms unfolding M2.integrable_def + by (auto intro!: measurable_pair_image_snd) + have "M1.integrable + (\x. real (M2.positive_integral (\xa. Real (f (x, xa)))))" (is "M1.integrable ?f") + proof (unfold M1.integrable_def, intro conjI) + show "?f \ borel_measurable M1" + using borel by (auto intro!: M1.borel_measurable_real positive_integral_fst_measurable) + have "M1.positive_integral (\x. Real (?f x)) = + M1.positive_integral (\x. M2.positive_integral (\xa. Real (f (x, xa))))" + apply (rule M1.positive_integral_cong_AE) + apply (rule M1.AE_mp[OF AE(1)]) + apply (rule M1.AE_cong) + by (auto simp: Real_real) + then show "M1.positive_integral (\x. Real (?f x)) \ \" + using positive_integral_fst_measurable[OF borel(2)] int by simp + have "M1.positive_integral (\x. Real (- ?f x)) = M1.positive_integral (\x. 0)" + by (intro M1.positive_integral_cong) simp + then show "M1.positive_integral (\x. Real (- ?f x)) \ \" by simp + qed + moreover have "M1.integrable + (\x. real (M2.positive_integral (\xa. Real (- f (x, xa)))))" (is "M1.integrable ?f") + proof (unfold M1.integrable_def, intro conjI) + show "?f \ borel_measurable M1" + using borel by (auto intro!: M1.borel_measurable_real positive_integral_fst_measurable) + have "M1.positive_integral (\x. Real (?f x)) = + M1.positive_integral (\x. M2.positive_integral (\xa. Real (- f (x, xa))))" + apply (rule M1.positive_integral_cong_AE) + apply (rule M1.AE_mp[OF AE(2)]) + apply (rule M1.AE_cong) + by (auto simp: Real_real) + then show "M1.positive_integral (\x. Real (?f x)) \ \" + using positive_integral_fst_measurable[OF borel(1)] int by simp + have "M1.positive_integral (\x. Real (- ?f x)) = M1.positive_integral (\x. 0)" + by (intro M1.positive_integral_cong) simp + then show "M1.positive_integral (\x. Real (- ?f x)) \ \" by simp + qed + ultimately show ?INT + unfolding M2.integral_def integral_def + borel[THEN positive_integral_fst_measurable(2), symmetric] + by (simp add: M1.integral_real[OF AE(1)] M1.integral_real[OF AE(2)]) +qed + +lemma (in pair_sigma_finite) integrable_snd_measurable: + assumes f: "integrable f" + shows "M2.almost_everywhere (\y. M1.integrable (\x. f (x, y)))" (is "?AE") + and "M2.integral (\y. M1.integral (\x. f (x, y))) = integral f" (is "?INT") +proof - + interpret Q: pair_sigma_finite M2 \2 M1 \1 by default + have Q_int: "Q.integrable (\(x, y). f (y, x))" + using f unfolding integrable_product_swap by simp + show ?INT + using Q.integrable_fst_measurable(2)[OF Q_int] + unfolding integral_product_swap by simp + show ?AE + using Q.integrable_fst_measurable(1)[OF Q_int] + by simp +qed + +lemma (in pair_sigma_finite) Fubini_integral: + assumes f: "integrable f" + shows "M2.integral (\y. M1.integral (\x. f (x, y))) = + M1.integral (\x. M2.integral (\y. f (x, y)))" + unfolding integrable_snd_measurable[OF assms] + unfolding integrable_fst_measurable[OF assms] .. + section "Finite product spaces" section "Products" @@ -891,6 +1035,16 @@ qed qed auto +lemma borel_measurable_product_component: + assumes "i \ I" + shows "(\x. x i) \ borel_measurable (sigma (product_algebra (\x. borel) I))" +proof - + have *: "\A. (\x. x i) -` A \ extensional I = (\\<^isub>E j\I. if j = i then A else UNIV)" + using `i \ I` by (auto elim!: PiE) + show ?thesis + by (auto simp: * measurable_def product_algebra_def) +qed + section "Generating set generates also product algebra" lemma pair_sigma_algebra_sigma: @@ -1414,11 +1568,14 @@ (auto simp: pair_algebra_def dest: extensional_restrict) qed -lemma (in product_sigma_finite) measure_fold_left: +lemma (in product_sigma_finite) measure_fold: assumes IJ[simp]: "I \ J = {}" and fin: "finite I" "finite J" - and f: "f \ borel_measurable (sigma (product_algebra M (I \ J)))" - shows "product_positive_integral (I \ J) f = - product_positive_integral I (\x. product_positive_integral J (\y. f (merge I x J y)))" + assumes A: "A \ sets (sigma (product_algebra M (I \ J)))" + shows "pair_sigma_finite.pair_measure + (sigma (product_algebra M I)) (product_measure I) + (sigma (product_algebra M J)) (product_measure J) + ((\x. ((\i\I. x i), (\i\J. x i))) ` A) = + product_measure (I \ J) A" proof - interpret I: finite_product_sigma_finite M \ I by default fact interpret J: finite_product_sigma_finite M \ J by default fact @@ -1426,28 +1583,17 @@ interpret IJ: finite_product_sigma_finite M \ "I \ J" by default fact interpret P: pair_sigma_finite I.P I.measure J.P J.measure by default let ?f = "\x. ((\i\I. x i), (\i\J. x i))" - have P_borel: "(\x. f (case x of (x, y) \ merge I x J y)) \ borel_measurable P.P" - by (subst product_product_vimage_algebra_eq[OF IJ fin, symmetric]) - (auto simp: space_pair_algebra intro!: IJ.measurable_vimage f) - have split_f_image[simp]: "\F. ?f ` (Pi\<^isub>E (I \ J) F) = (Pi\<^isub>E I F) \ (Pi\<^isub>E J F)" - apply auto apply (rule_tac x="merge I a J b" in image_eqI) - by (auto dest: extensional_restrict) - have "IJ.positive_integral f = IJ.positive_integral (\x. f (restrict x (I \ J)))" - by (auto intro!: IJ.positive_integral_cong arg_cong[where f=f] dest!: extensional_restrict) - also have "\ = I.positive_integral (\x. J.positive_integral (\y. f (merge I x J y)))" - unfolding P.positive_integral_fst_measurable[OF P_borel, simplified] - unfolding P.positive_integral_vimage[unfolded space_sigma, OF bij_betw_restrict_I_J[OF IJ]] - unfolding product_product_vimage_algebra[OF IJ fin] - proof (simp, rule IJ.positive_integral_cong_measure[symmetric]) - fix A assume *: "A \ sets IJ.P" from IJ.sigma_finite_pairs obtain F where F: "\i. i\ I \ J \ range (F i) \ sets (M i)" "(\k. \\<^isub>E i\I \ J. F i k) \ space IJ.G" "\k. \i\I\J. \ i (F i k) \ \" by auto let ?F = "\k. \\<^isub>E i\I \ J. F i k" + have split_f_image[simp]: "\F. ?f ` (Pi\<^isub>E (I \ J) F) = (Pi\<^isub>E I F) \ (Pi\<^isub>E J F)" + apply auto apply (rule_tac x="merge I a J b" in image_eqI) + by (auto dest: extensional_restrict) show "P.pair_measure (?f ` A) = IJ.measure A" - proof (rule measure_unique_Int_stable[OF _ _ _ _ _ _ _ _ *]) + proof (rule measure_unique_Int_stable[OF _ _ _ _ _ _ _ _ A]) show "Int_stable IJ.G" by (simp add: PiE_Int Int_stable_def product_algebra_def) auto show "range ?F \ sets IJ.G" using F by (simp add: image_subset_iff product_algebra_def) show "?F \ space IJ.G " using F(2) by simp @@ -1480,10 +1626,36 @@ using `finite I` F by (simp add: setprod_\) qed simp qed + +lemma (in product_sigma_finite) product_positive_integral_fold: + assumes IJ[simp]: "I \ J = {}" and fin: "finite I" "finite J" + and f: "f \ borel_measurable (sigma (product_algebra M (I \ J)))" + shows "product_positive_integral (I \ J) f = + product_positive_integral I (\x. product_positive_integral J (\y. f (merge I x J y)))" +proof - + interpret I: finite_product_sigma_finite M \ I by default fact + interpret J: finite_product_sigma_finite M \ J by default fact + have "finite (I \ J)" using fin by auto + interpret IJ: finite_product_sigma_finite M \ "I \ J" by default fact + interpret P: pair_sigma_finite I.P I.measure J.P J.measure by default + let ?f = "\x. ((\i\I. x i), (\i\J. x i))" + have P_borel: "(\x. f (case x of (x, y) \ merge I x J y)) \ borel_measurable P.P" + by (subst product_product_vimage_algebra_eq[OF IJ fin, symmetric]) + (auto simp: space_pair_algebra intro!: IJ.measurable_vimage f) + have "IJ.positive_integral f = IJ.positive_integral (\x. f (restrict x (I \ J)))" + by (auto intro!: IJ.positive_integral_cong arg_cong[where f=f] dest!: extensional_restrict) + also have "\ = I.positive_integral (\x. J.positive_integral (\y. f (merge I x J y)))" + unfolding P.positive_integral_fst_measurable[OF P_borel, simplified] + unfolding P.positive_integral_vimage[unfolded space_sigma, OF bij_betw_restrict_I_J[OF IJ]] + unfolding product_product_vimage_algebra[OF IJ fin] + apply simp + apply (rule IJ.positive_integral_cong_measure[symmetric]) + apply (rule measure_fold) + using assms by auto finally show ?thesis . qed -lemma (in product_sigma_finite) finite_pair_measure_singleton: +lemma (in product_sigma_finite) product_positive_integral_singleton: assumes f: "f \ borel_measurable (M i)" shows "product_positive_integral {i} (\x. f (x i)) = M.positive_integral i f" proof - @@ -1515,6 +1687,98 @@ qed simp qed +lemma (in product_sigma_finite) product_integral_singleton: + assumes f: "f \ borel_measurable (M i)" + shows "product_integral {i} (\x. f (x i)) = M.integral i f" +proof - + interpret I: finite_product_sigma_finite M \ "{i}" by default simp + have *: "(\x. Real (f x)) \ borel_measurable (M i)" + "(\x. Real (- f x)) \ borel_measurable (M i)" + using assms by auto + show ?thesis + unfolding I.integral_def integral_def + unfolding *[THEN product_positive_integral_singleton] .. +qed + +lemma (in product_sigma_finite) borel_measurable_merge_iff: + assumes IJ[simp]: "I \ J = {}" and fin: "finite I" "finite J" + shows "f \ measurable (sigma (pair_algebra + (sigma (product_algebra M I)) (sigma (product_algebra M J)))) M' \ + (\x. f (restrict x I, restrict x J)) \ measurable (sigma (product_algebra M (I \ J))) M'" +proof - + interpret I: finite_product_sigma_finite M \ I by default fact + interpret J: finite_product_sigma_finite M \ J by default fact + have "finite (I \ J)" using fin by auto + interpret IJ: finite_product_sigma_finite M \ "I \ J" by default fact + interpret P: pair_sigma_finite I.P I.measure J.P J.measure by default + let ?f = "\x. (restrict x I, restrict x J)" + let ?S = "space (product_algebra M (I \ J))" + { fix p assume p: "p \ space (pair_algebra I.P J.P)" + have "?f (the_inv_into ?S ?f p) = p" + proof (intro f_the_inv_into_f[where f="?f"] inj_onI ext) + fix x y t assume "x \ ?S" "y \ ?S" "?f x = ?f y" + show "x t = y t" + proof cases + assume "t \ I \ J" then show ?thesis using `?f x = ?f y` + by (auto simp: restrict_def fun_eq_iff split: split_if_asm) + next + assume "t \ I \ J" then show ?thesis + using `x \ ?S` `y \ ?S` by (auto simp: space_pair_algebra extensional_def) + qed + next + show "p \ ?f ` ?S" using p + by (intro image_eqI[of _ _ "merge I (fst p) J (snd p)"]) + (auto simp: space_pair_algebra extensional_restrict) + qed } + note restrict = this + show ?thesis + apply (subst product_product_vimage_algebra[OF assms, symmetric]) + apply (subst P.measurable_vimage_iff_inv) + using bij_betw_restrict_I_J[OF IJ, of M] apply simp + apply (rule measurable_cong) + by (auto simp del: space_product_algebra simp: restrict) +qed + +lemma (in product_sigma_finite) product_integral_fold: + assumes IJ[simp]: "I \ J = {}" and fin: "finite I" "finite J" + and f: "measure_space.integrable (sigma (product_algebra M (I \ J))) (product_measure (I \ J)) f" + shows "product_integral (I \ J) f = + product_integral I (\x. product_integral J (\y. f (merge I x J y)))" +proof - + interpret I: finite_product_sigma_finite M \ I by default fact + interpret J: finite_product_sigma_finite M \ J by default fact + have "finite (I \ J)" using fin by auto + interpret IJ: finite_product_sigma_finite M \ "I \ J" by default fact + interpret P: pair_sigma_finite I.P I.measure J.P J.measure by default + let ?f = "\(x,y). f (merge I x J y)" + have f_borel: "f \ borel_measurable IJ.P" + "(\x. Real (f x)) \ borel_measurable IJ.P" + "(\x. Real (- f x)) \ borel_measurable IJ.P" + using f unfolding integrable_def by auto + have f_restrict: "(\x. f (restrict x (I \ J))) \ borel_measurable IJ.P" + by (rule measurable_cong[THEN iffD2, OF _ f_borel(1)]) + (auto intro!: arg_cong[where f=f] simp: extensional_restrict) + then have f'_borel: + "(\x. Real (?f x)) \ borel_measurable P.P" + "(\x. Real (- ?f x)) \ borel_measurable P.P" + unfolding borel_measurable_merge_iff[OF IJ fin] + by simp_all + have PI: + "P.positive_integral (\x. Real (?f x)) = IJ.positive_integral (\x. Real (f x))" + "P.positive_integral (\x. Real (- ?f x)) = IJ.positive_integral (\x. Real (- f x))" + using f'_borel[THEN P.positive_integral_fst_measurable(2)] + using f_borel(2,3)[THEN product_positive_integral_fold[OF assms(1-3)]] + by simp_all + have "P.integrable ?f" using `IJ.integrable f` + unfolding P.integrable_def IJ.integrable_def + unfolding borel_measurable_merge_iff[OF IJ fin] + using f_restrict PI by simp_all + show ?thesis + unfolding P.integrable_fst_measurable(2)[OF `P.integrable ?f`, simplified] + unfolding IJ.integral_def P.integral_def + unfolding PI by simp +qed + section "Products on finite spaces" lemma sigma_sets_pair_algebra_finite: