# HG changeset patch # User hoelzl # Date 1305827879 -7200 # Node ID d9dfc733f25c7c4b1cef795d278c2d2917836a1f # Parent 348fa5df7d3fb379b70f7effdfab88e08fcf48cb add product of probability spaces with finite cardinality diff -r 348fa5df7d3f -r d9dfc733f25c src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Thu May 19 18:11:15 2011 +0200 +++ b/src/HOL/Probability/Probability_Measure.thy Thu May 19 19:57:59 2011 +0200 @@ -543,6 +543,115 @@ sublocale pair_finite_prob_space \ pair_finite_space M1 M2 by default sublocale pair_finite_prob_space \ finite_prob_space P by default +locale product_finite_prob_space = + fixes M :: "'i \ ('a,'b) measure_space_scheme" + and I :: "'i set" + assumes finite_space: "\i. finite_prob_space (M i)" and finite_index: "finite I" + +sublocale product_finite_prob_space \ M!: finite_prob_space "M i" using finite_space . +sublocale product_finite_prob_space \ finite_product_sigma_finite M I by default (rule finite_index) +sublocale product_finite_prob_space \ prob_space "Pi\<^isub>M I M" +proof + show "\ (space P) = 1" + using measure_times[OF M.top] M.measure_space_1 + by (simp add: setprod_1 space_product_algebra) +qed + +lemma funset_eq_UN_fun_upd_I: + assumes *: "\f. f \ F (insert a A) \ f(a := d) \ F A" + and **: "\f. f \ F (insert a A) \ f a \ G (f(a:=d))" + and ***: "\f x. \ f \ F A ; x \ G f \ \ f(a:=x) \ F (insert a A)" + shows "F (insert a A) = (\f\F A. fun_upd f a ` (G f))" +proof safe + fix f assume f: "f \ F (insert a A)" + show "f \ (\f\F A. fun_upd f a ` G f)" + proof (rule UN_I[of "f(a := d)"]) + show "f(a := d) \ F A" using *[OF f] . + show "f \ fun_upd (f(a:=d)) a ` G (f(a:=d))" + proof (rule image_eqI[of _ _ "f a"]) + show "f a \ G (f(a := d))" using **[OF f] . + qed simp + qed +next + fix f x assume "f \ F A" "x \ G f" + from ***[OF this] show "f(a := x) \ F (insert a A)" . +qed + +lemma extensional_funcset_insert_eq[simp]: + assumes "a \ A" + shows "extensional (insert a A) \ (insert a A \ B) = (\f \ extensional A \ (A \ B). (\b. f(a := b)) ` B)" + apply (rule funset_eq_UN_fun_upd_I) + using assms + by (auto intro!: inj_onI dest: inj_onD split: split_if_asm simp: extensional_def) + +lemma finite_extensional_funcset[simp, intro]: + assumes "finite A" "finite B" + shows "finite (extensional A \ (A \ B))" + using assms by induct (auto simp: extensional_funcset_insert_eq) + +lemma finite_PiE[simp, intro]: + assumes fin: "finite A" "\i. i \ A \ finite (B i)" + shows "finite (Pi\<^isub>E A B)" +proof - + have *: "(Pi\<^isub>E A B) \ extensional A \ (A \ (\i\A. B i))" by auto + show ?thesis + using fin by (intro finite_subset[OF *] finite_extensional_funcset) auto +qed + +sublocale product_finite_prob_space \ finite_prob_space "Pi\<^isub>M I M" +proof + show "finite (space P)" + using finite_index M.finite_space by auto + + { fix x assume "x \ space P" + then have x: "{x} = (\\<^isub>E i\I. {x i})" + proof safe + fix y assume *: "y \ (\ i\I. {x i})" "y \ extensional I" + show "y = x" + proof + fix i show "y i = x i" + using * `x \ space P` by (cases "i \ I") (auto simp: extensional_def) + qed + qed auto + with `x \ space P` have "{x} \ sets P" + by (auto intro!: in_P) } + note x_in_P = this + + have "Pow (space P) \ sets P" + proof + fix X assume "X \ Pow (space P)" + moreover then have "finite X" + using `finite (space P)` by (blast intro: finite_subset) + ultimately have "(\x\X. {x}) \ sets P" + by (intro finite_UN x_in_P) auto + then show "X \ sets P" by simp + qed + with space_closed show [simp]: "sets P = Pow (space P)" .. + + + { fix x assume "x \ space P" + from this top have "\ {x} \ \ (space P)" by (intro measure_mono) auto + then show "\ {x} \ \" + using measure_space_1 by auto } +qed + +lemma (in product_finite_prob_space) measure_finite_times: + "(\i. i \ I \ X i \ space (M i)) \ \ (\\<^isub>E i\I. X i) = (\i\I. M.\ i (X i))" + by (rule measure_times) simp + +lemma (in product_finite_prob_space) prob_times: + assumes X: "\i. i \ I \ X i \ space (M i)" + shows "prob (\\<^isub>E i\I. X i) = (\i\I. M.prob i (X i))" +proof - + have "extreal (\' (\\<^isub>E i\I. X i)) = \ (\\<^isub>E i\I. X i)" + using X by (intro finite_measure_eq[symmetric] in_P) auto + also have "\ = (\i\I. M.\ i (X i))" + using measure_finite_times X by simp + also have "\ = extreal (\i\I. M.\' i (X i))" + using X by (simp add: M.finite_measure_eq setprod_extreal) + finally show ?thesis by simp +qed + lemma (in prob_space) joint_distribution_finite_prob_space: assumes X: "finite_random_variable MX X" assumes Y: "finite_random_variable MY Y"