# HG changeset patch # User hoelzl # Date 1269622981 -3600 # Node ID 30d42bfd01748495653882bca88e335bd1eef9c8 # Parent 71620f11dbbbb1b4ed447518f8174d99ac88a3fd Added finite measure space. diff -r 71620f11dbbb -r 30d42bfd0174 src/HOL/Probability/Lebesgue.thy --- a/src/HOL/Probability/Lebesgue.thy Thu Mar 25 23:18:42 2010 +0100 +++ b/src/HOL/Probability/Lebesgue.thy Fri Mar 26 18:03:01 2010 +0100 @@ -1542,31 +1542,6 @@ integral_cong[of "\x. f x * indicator_fn (space M) x" f] by (auto simp add: indicator_fn_def) -lemma integral_finite_singleton: - assumes fin: "finite (space M)" and "Pow (space M) = sets M" - shows "integral f = (\x \ space M. f x * measure M {x})" -proof - - have "f \ borel_measurable M" - unfolding borel_measurable_le_iff - using assms by auto - { fix r let ?x = "f -` {r} \ space M" - have "?x \ space M" by auto - with assms have "measure M ?x = (\i \ ?x. measure M {i})" - by (auto intro!: measure_real_sum_image) } - note measure_eq_setsum = this - show ?thesis - unfolding integral_finite[OF `f \ borel_measurable M` fin] - measure_eq_setsum setsum_right_distrib - apply (subst setsum_Sigma) - apply (simp add: assms) - apply (simp add: assms) - proof (rule setsum_reindex_cong[symmetric]) - fix a assume "a \ Sigma (f ` space M) (\x. f -` {x} \ space M)" - thus "(\(x, y). x * measure M {y}) a = f (snd a) * measure_space.measure M {snd a}" - by auto - qed (auto intro!: image_eqI inj_onI) -qed - section "Radon–Nikodym derivative" definition @@ -1574,48 +1549,103 @@ f \ borel_measurable M \ (\a \ sets M. (integral (\x. f x * indicator_fn a x) = v a))" -lemma RN_deriv_finite_singleton: +end + +locale finite_measure_space = measure_space + + assumes finite_space: "finite (space M)" + and sets_eq_Pow: "sets M = Pow (space M)" + +lemma sigma_algebra_cong: + fixes M :: "('a, 'b) algebra_scheme" and M' :: "('a, 'c) algebra_scheme" + assumes *: "sigma_algebra M" + and cong: "space M = space M'" "sets M = sets M'" + shows "sigma_algebra M'" +using * unfolding sigma_algebra_def algebra_def sigma_algebra_axioms_def unfolding cong . + +lemma finite_Pow_additivity_sufficient: + assumes "finite (space M)" and "sets M = Pow (space M)" + and "positive M (measure M)" and "additive M (measure M)" + shows "finite_measure_space M" +proof - + have "sigma_algebra M" + using assms by (auto intro!: sigma_algebra_cong[OF sigma_algebra_Pow]) + + have "measure_space M" + by (rule Measure.finite_additivity_sufficient) (fact+) + thus ?thesis + unfolding finite_measure_space_def finite_measure_space_axioms_def + using assms by simp +qed + +lemma finite_measure_spaceI: + assumes "measure_space M" and "finite (space M)" and "sets M = Pow (space M)" + shows "finite_measure_space M" + unfolding finite_measure_space_def finite_measure_space_axioms_def + using assms by simp + +lemma (in finite_measure_space) integral_finite_singleton: + "integral f = (\x \ space M. f x * measure M {x})" +proof - + have "f \ borel_measurable M" + unfolding borel_measurable_le_iff + using sets_eq_Pow by auto + { fix r let ?x = "f -` {r} \ space M" + have "?x \ space M" by auto + with finite_space sets_eq_Pow have "measure M ?x = (\i \ ?x. measure M {i})" + by (auto intro!: measure_real_sum_image) } + note measure_eq_setsum = this + show ?thesis + unfolding integral_finite[OF `f \ borel_measurable M` finite_space] + measure_eq_setsum setsum_right_distrib + apply (subst setsum_Sigma) + apply (simp add: finite_space) + apply (simp add: finite_space) + proof (rule setsum_reindex_cong[symmetric]) + fix a assume "a \ Sigma (f ` space M) (\x. f -` {x} \ space M)" + thus "(\(x, y). x * measure M {y}) a = f (snd a) * measure_space.measure M {snd a}" + by auto + qed (auto intro!: image_eqI inj_onI) +qed + +lemma (in finite_measure_space) RN_deriv_finite_singleton: fixes v :: "'a set \ real" - assumes finite: "finite (space M)" and Pow: "Pow (space M) = sets M" - and ms_v: "measure_space (M\measure := v\)" + assumes ms_v: "measure_space (M\measure := v\)" and eq_0: "\x. measure M {x} = 0 \ v {x} = 0" and "x \ space M" and "measure M {x} \ 0" shows "RN_deriv v x = v {x} / (measure M {x})" (is "_ = ?v x") unfolding RN_deriv_def proof (rule someI2_ex[where Q = "\f. f x = ?v x"], rule exI[where x = ?v], safe) show "(\a. v {a} / measure_space.measure M {a}) \ borel_measurable M" - unfolding borel_measurable_le_iff using Pow by auto + unfolding borel_measurable_le_iff using sets_eq_Pow by auto next fix a assume "a \ sets M" hence "a \ space M" and "finite a" - using sets_into_space finite by (auto intro: finite_subset) + using sets_into_space finite_space by (auto intro: finite_subset) have *: "\x a. (if measure M {x} = 0 then 0 else v {x} * indicator_fn a x) = v {x} * indicator_fn a x" using eq_0 by auto from measure_space.measure_real_sum_image[OF ms_v, of a] - Pow `a \ sets M` sets_into_space `finite a` + sets_eq_Pow `a \ sets M` sets_into_space `finite a` have "v a = (\x\a. v {x})" by auto thus "integral (\x. v {x} / measure_space.measure M {x} * indicator_fn a x) = v a" - apply (simp add: eq_0 integral_finite_singleton[OF finite Pow]) + apply (simp add: eq_0 integral_finite_singleton) apply (unfold divide_1) - by (simp add: * indicator_fn_def if_distrib setsum_cases finite `a \ space M` Int_absorb1) + by (simp add: * indicator_fn_def if_distrib setsum_cases finite_space `a \ space M` Int_absorb1) next fix w assume "w \ borel_measurable M" assume int_eq_v: "\a\sets M. integral (\x. w x * indicator_fn a x) = v a" - have "{x} \ sets M" using Pow `x \ space M` by auto + have "{x} \ sets M" using sets_eq_Pow `x \ space M` by auto have "w x * measure M {x} = (\y\space M. w y * indicator_fn {x} y * measure M {y})" apply (subst (3) mult_commute) - unfolding indicator_fn_def if_distrib setsum_cases[OF finite] + unfolding indicator_fn_def if_distrib setsum_cases[OF finite_space] using `x \ space M` by simp also have "... = v {x}" using int_eq_v[rule_format, OF `{x} \ sets M`] - by (simp add: integral_finite_singleton[OF finite Pow]) + by (simp add: integral_finite_singleton) finally show "w x = v {x} / measure M {x}" using `measure M {x} \ 0` by (simp add: eq_divide_eq) qed fact end - -end diff -r 71620f11dbbb -r 30d42bfd0174 src/HOL/Probability/Measure.thy --- a/src/HOL/Probability/Measure.thy Thu Mar 25 23:18:42 2010 +0100 +++ b/src/HOL/Probability/Measure.thy Fri Mar 26 18:03:01 2010 +0100 @@ -10,7 +10,34 @@ "prod_sets A B = {z. \x \ A. \y \ B. z = x \ y}" lemma prod_setsI: "x \ A \ y \ B \ (x \ y) \ prod_sets A B" - by (auto simp add: prod_sets_def) + by (auto simp add: prod_sets_def) + +lemma sigma_prod_sets_finite: + assumes "finite A" and "finite B" + shows "sets (sigma (A \ B) (prod_sets (Pow A) (Pow B))) = Pow (A \ B)" +proof (simp add: sigma_def, safe) + have fin: "finite (A \ B)" using assms by (rule finite_cartesian_product) + + fix x assume subset: "x \ A \ B" + hence "finite x" using fin by (rule finite_subset) + from this subset show "x \ sigma_sets (A\B) (prod_sets (Pow A) (Pow B))" + (is "x \ sigma_sets ?prod ?sets") + proof (induct x) + case empty show ?case by (rule sigma_sets.Empty) + next + case (insert a x) + hence "{a} \ sigma_sets ?prod ?sets" by (auto simp: prod_sets_def intro!: sigma_sets.Basic) + moreover have "x \ sigma_sets ?prod ?sets" using insert by auto + ultimately show ?case unfolding insert_is_Un[of a x] by (rule sigma_sets_Un) + qed +next + fix x a b + assume "x \ sigma_sets (A\B) (prod_sets (Pow A) (Pow B))" and "(a, b) \ x" + from sigma_sets_into_sp[OF _ this(1)] this(2) + show "a \ A" and "b \ B" + by (auto simp: prod_sets_def) +qed + definition closed_cdi where @@ -26,7 +53,7 @@ smallest_ccdi_sets :: "('a, 'b) algebra_scheme \ 'a set set" for M where - Basic [intro]: + Basic [intro]: "a \ sets M \ a \ smallest_ccdi_sets M" | Compl [intro]: "a \ smallest_ccdi_sets M \ space M - a \ smallest_ccdi_sets M" diff -r 71620f11dbbb -r 30d42bfd0174 src/HOL/Probability/Probability_Space.thy --- a/src/HOL/Probability/Probability_Space.thy Thu Mar 25 23:18:42 2010 +0100 +++ b/src/HOL/Probability/Probability_Space.thy Fri Mar 26 18:03:01 2010 +0100 @@ -350,75 +350,6 @@ assumes "finite (space M) \ random_variable borel_space X" shows "expectation X = (\ r \ X ` (space M). r * distribution X {r})" using assms unfolding distribution_def using finite_expectation1 by auto - -lemma finite_marginal_product_space_POW: - assumes "Pow (space M) = events" - assumes "random_variable \ space = X ` (space M), sets = Pow (X ` (space M))\ X" - assumes "random_variable \ space = Y ` (space M), sets = Pow (Y ` (space M))\ Y" - assumes "finite (space M)" - shows "measure_space \ space = ((X ` (space M)) \ (Y ` (space M))), - sets = Pow ((X ` (space M)) \ (Y ` (space M))), - measure = (\a. prob ((\x. (X x,Y x)) -` a \ space M))\" - using assms -proof - - let "?S" = "\ space = ((X ` (space M)) \ (Y ` (space M))), - sets = Pow ((X ` (space M)) \ (Y ` (space M)))\" - let "?M" = "\ space = ((X ` (space M)) \ (Y ` (space M))), - sets = Pow ((X ` (space M)) \ (Y ` (space M)))\" - have pos: "positive ?S (\a. prob ((\x. (X x,Y x)) -` a \ space M))" - unfolding positive_def using positive'[unfolded positive_def] assms by auto - { fix x y - have A: "((\x. (X x, Y x)) -` x) \ space M \ sets M" using assms by auto - have B: "((\x. (X x, Y x)) -` y) \ space M \ sets M" using assms by auto - assume "x \ y = {}" - from additive[unfolded additive_def, rule_format, OF A B] this - have "prob (((\x. (X x, Y x)) -` x \ - (\x. (X x, Y x)) -` y) \ space M) = - prob ((\x. (X x, Y x)) -` x \ space M) + - prob ((\x. (X x, Y x)) -` y \ space M)" - apply (subst Int_Un_distrib2) - by auto } - hence add: "additive ?S (\a. prob ((\x. (X x,Y x)) -` a \ space M))" - unfolding additive_def by auto - interpret S: sigma_algebra "?S" - unfolding sigma_algebra_def algebra_def - sigma_algebra_axioms_def by auto - show ?thesis - using add pos S.finite_additivity_sufficient assms by auto -qed - -lemma finite_marginal_product_space_POW2: - assumes "Pow (space M) = events" - assumes "random_variable \space = s1, sets = Pow s1\ X" - assumes "random_variable \space = s2, sets = Pow s2\ Y" - assumes "finite (space M)" - assumes "finite s1" "finite s2" - shows "measure_space \ space = s1 \ s2, sets = Pow (s1 \ s2), measure = joint_distribution X Y\" -proof - - let "?S" = "\ space = s1 \ s2, sets = Pow (s1 \ s2) \" - let "?M" = "\ space = s1 \ s2, sets = Pow (s1 \ s2), measure = joint_distribution X Y \" - have pos: "positive ?S (joint_distribution X Y)" using positive' - unfolding positive_def joint_distribution_def using assms by auto - { fix x y - have A: "((\x. (X x, Y x)) -` x) \ space M \ sets M" using assms by auto - have B: "((\x. (X x, Y x)) -` y) \ space M \ sets M" using assms by auto - assume "x \ y = {}" - from additive[unfolded additive_def, rule_format, OF A B] this - have "prob (((\x. (X x, Y x)) -` x \ - (\x. (X x, Y x)) -` y) \ space M) = - prob ((\x. (X x, Y x)) -` x \ space M) + - prob ((\x. (X x, Y x)) -` y \ space M)" - apply (subst Int_Un_distrib2) - by auto } - hence add: "additive ?S (joint_distribution X Y)" - unfolding additive_def joint_distribution_def by auto - interpret S: sigma_algebra "?S" - unfolding sigma_algebra_def algebra_def - sigma_algebra_axioms_def by auto - show ?thesis - using add pos S.finite_additivity_sufficient assms by auto -qed - lemma prob_x_eq_1_imp_prob_y_eq_0: assumes "{x} \ events" assumes "(prob {x} = 1)" @@ -453,6 +384,45 @@ ultimately show ?thesis by auto qed + end +locale finite_prob_space = prob_space + finite_measure_space + +lemma (in finite_prob_space) finite_marginal_product_space_POW2: + assumes "finite s1" "finite s2" + shows "finite_measure_space \ space = s1 \ s2, sets = Pow (s1 \ s2), measure = joint_distribution X Y\" + (is "finite_measure_space ?M") +proof (rule finite_Pow_additivity_sufficient) + show "positive ?M (measure ?M)" + unfolding positive_def using positive'[unfolded positive_def] assms sets_eq_Pow + by (simp add: joint_distribution_def) + + show "additive ?M (measure ?M)" unfolding additive_def + proof safe + fix x y + have A: "((\x. (X x, Y x)) -` x) \ space M \ sets M" using assms sets_eq_Pow by auto + have B: "((\x. (X x, Y x)) -` y) \ space M \ sets M" using assms sets_eq_Pow by auto + assume "x \ y = {}" + from additive[unfolded additive_def, rule_format, OF A B] this + show "measure ?M (x \ y) = measure ?M x + measure ?M y" + apply (simp add: joint_distribution_def) + apply (subst Int_Un_distrib2) + by auto + qed + + show "finite (space ?M)" + using assms by auto + + show "sets ?M = Pow (space ?M)" + by simp +qed + +lemma (in finite_prob_space) finite_marginal_product_space_POW: + shows "finite_measure_space \ space = X ` space M \ Y ` space M, + sets = Pow (X ` space M \ Y ` space M), + measure = joint_distribution X Y\" + (is "finite_measure_space ?M") + using finite_space by (auto intro!: finite_marginal_product_space_POW2) + end diff -r 71620f11dbbb -r 30d42bfd0174 src/HOL/Probability/Product_Measure.thy --- a/src/HOL/Probability/Product_Measure.thy Thu Mar 25 23:18:42 2010 +0100 +++ b/src/HOL/Probability/Product_Measure.thy Fri Mar 26 18:03:01 2010 +0100 @@ -32,129 +32,66 @@ by simp qed - - -lemma measure_space_finite_prod_measure: - fixes M :: "('a, 'b) measure_space_scheme" - and M' :: "('c, 'd) measure_space_scheme" - assumes "measure_space M" and "measure_space M'" - and finM: "finite (space M)" "Pow (space M) = sets M" - and finM': "finite (space M')" "Pow (space M') = sets M'" - shows "measure_space (prod_measure_space M M')" -proof (rule finite_additivity_sufficient) - interpret M: measure_space M by fact - interpret M': measure_space M' by fact +lemma finite_prod_measure_space: + assumes "finite_measure_space M" and "finite_measure_space M'" + shows "prod_measure_space M M' = + \ space = space M \ space M', + sets = Pow (space M \ space M'), + measure = prod_measure M M' \" +proof - + interpret M: finite_measure_space M by fact + interpret M': finite_measure_space M' by fact + show ?thesis using M.finite_space M'.finite_space + by (simp add: sigma_prod_sets_finite M.sets_eq_Pow M'.sets_eq_Pow + prod_measure_space_def) +qed - have measure: "measure_space.measure (prod_measure_space M M') = prod_measure M M'" - unfolding prod_measure_space_def by simp - - have prod_sets: "prod_sets (sets M) (sets M') \ Pow (space M \ space M')" - using M.sets_into_space M'.sets_into_space unfolding prod_sets_def by auto - show sigma: "sigma_algebra (prod_measure_space M M')" unfolding prod_measure_space_def - by (rule sigma_algebra_sigma_sets[where a="prod_sets (sets M) (sets M')"]) - (simp_all add: sigma_def prod_sets) +lemma finite_measure_space_finite_prod_measure: + assumes "finite_measure_space M" and "finite_measure_space M'" + shows "finite_measure_space (prod_measure_space M M')" +proof (rule finite_Pow_additivity_sufficient) + interpret M: finite_measure_space M by fact + interpret M': finite_measure_space M' by fact - then interpret sa: sigma_algebra "prod_measure_space M M'" . - - { fix x y assume "y \ sets (prod_measure_space M M')" and "x \ space M" - hence "y \ space M \ space M'" - using sa.sets_into_space unfolding prod_measure_space_def by simp - hence "Pair x -` y \ sets M'" - using `x \ space M` unfolding finM'(2)[symmetric] by auto } - note Pair_in_sets = this + from M.finite_space M'.finite_space + show "finite (space (prod_measure_space M M'))" and + "sets (prod_measure_space M M') = Pow (space (prod_measure_space M M'))" + by (simp_all add: finite_prod_measure_space[OF assms]) show "additive (prod_measure_space M M') (measure (prod_measure_space M M'))" - unfolding measure additive_def - proof safe - fix x y assume x: "x \ sets (prod_measure_space M M')" and y: "y \ sets (prod_measure_space M M')" + unfolding additive_def finite_prod_measure_space[OF assms] + proof (simp, safe) + fix x y assume subs: "x \ space M \ space M'" "y \ space M \ space M'" and disj_x_y: "x \ y = {}" - { fix z have "Pair z -` x \ Pair z -` y = {}" using disj_x_y by auto } - note Pair_disj = this - - from M'.measure_additive[OF Pair_in_sets[OF x] Pair_in_sets[OF y] Pair_disj, symmetric] - show "prod_measure M M' (x \ y) = prod_measure M M' x + prod_measure M M' y" - unfolding prod_measure_def - apply (subst (1 2 3) M.integral_finite_singleton[OF finM]) + have "\z. measure M' (Pair z -` x \ Pair z -` y) = + measure M' (Pair z -` x) + measure M' (Pair z -` y)" + using disj_x_y subs by (subst M'.measure_additive) (auto simp: M'.sets_eq_Pow) + thus "prod_measure M M' (x \ y) = prod_measure M M' x + prod_measure M M' y" + unfolding prod_measure_def M.integral_finite_singleton by (simp_all add: setsum_addf[symmetric] field_simps) qed - show "finite (space (prod_measure_space M M'))" - unfolding prod_measure_space_def using finM finM' by simp - - have singletonM: "\x. x \ space M \ {x} \ sets M" - unfolding finM(2)[symmetric] by simp - show "positive (prod_measure_space M M') (measure (prod_measure_space M M'))" unfolding positive_def - proof (safe, simp add: M.integral_zero prod_measure_space_def prod_measure_def) - fix Q assume "Q \ sets (prod_measure_space M M')" - from Pair_in_sets[OF this] - show "0 \ measure (prod_measure_space M M') Q" - unfolding prod_measure_space_def prod_measure_def - apply (subst M.integral_finite_singleton[OF finM]) - using M.positive M'.positive singletonM - by (auto intro!: setsum_nonneg mult_nonneg_nonneg) - qed + by (auto intro!: setsum_nonneg mult_nonneg_nonneg M'.positive M.positive + simp add: M.integral_zero finite_prod_measure_space[OF assms] + prod_measure_def M.integral_finite_singleton + M.sets_eq_Pow M'.sets_eq_Pow) qed -lemma measure_space_finite_prod_measure_alterantive: - assumes "measure_space M" and "measure_space M'" - and finM: "finite (space M)" "Pow (space M) = sets M" - and finM': "finite (space M')" "Pow (space M') = sets M'" - shows "measure_space \ space = space M \ space M', - sets = Pow (space M \ space M'), - measure = prod_measure M M' \" - (is "measure_space ?space") -proof (rule finite_additivity_sufficient) - interpret M: measure_space M by fact - interpret M': measure_space M' by fact - - show "sigma_algebra ?space" - using sigma_algebra.sigma_algebra_extend[where M="\ space = space M \ space M', sets = Pow (space M \ space M') \"] - by (auto intro!: sigma_algebra_Pow) - then interpret sa: sigma_algebra ?space . - - have measure: "measure_space.measure (prod_measure_space M M') = prod_measure M M'" - unfolding prod_measure_space_def by simp - - { fix x y assume "y \ sets ?space" and "x \ space M" - hence "y \ space M \ space M'" - using sa.sets_into_space by simp - hence "Pair x -` y \ sets M'" - using `x \ space M` unfolding finM'(2)[symmetric] by auto } - note Pair_in_sets = this +lemma finite_measure_space_finite_prod_measure_alterantive: + assumes M: "finite_measure_space M" and M': "finite_measure_space M'" + shows "finite_measure_space \ space = space M \ space M', sets = Pow (space M \ space M'), measure = prod_measure M M' \" + (is "finite_measure_space ?M") +proof - + interpret M: finite_measure_space M by fact + interpret M': finite_measure_space M' by fact - show "additive ?space (measure ?space)" - unfolding measure additive_def - proof safe - fix x y assume x: "x \ sets ?space" and y: "y \ sets ?space" - and disj_x_y: "x \ y = {}" - { fix z have "Pair z -` x \ Pair z -` y = {}" using disj_x_y by auto } - note Pair_disj = this - - from M'.measure_additive[OF Pair_in_sets[OF x] Pair_in_sets[OF y] Pair_disj, symmetric] - show "measure ?space (x \ y) = measure ?space x + measure ?space y" - apply (simp add: prod_measure_def) - apply (subst (1 2 3) M.integral_finite_singleton[OF finM]) - by (simp_all add: setsum_addf[symmetric] field_simps) - qed - - show "finite (space ?space)" using finM finM' by simp - - have singletonM: "\x. x \ space M \ {x} \ sets M" - unfolding finM(2)[symmetric] by simp - - show "positive ?space (measure ?space)" - unfolding positive_def - proof (safe, simp add: M.integral_zero prod_measure_def) - fix Q assume "Q \ sets ?space" - from Pair_in_sets[OF this] - show "0 \ measure ?space Q" - unfolding prod_measure_space_def prod_measure_def - apply (subst M.integral_finite_singleton[OF finM]) - using M.positive M'.positive singletonM - by (auto intro!: setsum_nonneg mult_nonneg_nonneg) - qed + show ?thesis + using finite_measure_space_finite_prod_measure[OF assms] + unfolding prod_measure_space_def M.sets_eq_Pow M'.sets_eq_Pow + using M.finite_space M'.finite_space + by (simp add: sigma_prod_sets_finite) qed end \ No newline at end of file