# HG changeset patch # User hoelzl # Date 1351861239 -3600 # Node ID 382bd3173584d4d5fd3a5da7fbd8df00216053f7 # Parent cfe8ee8a1371e7fa8baca29d3e6e7172794eb391 add syntax and a.e.-rules for (conditional) probability on predicates diff -r cfe8ee8a1371 -r 382bd3173584 src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Fri Nov 02 14:00:39 2012 +0100 +++ b/src/HOL/Probability/Borel_Space.thy Fri Nov 02 14:00:39 2012 +0100 @@ -91,6 +91,11 @@ unfolding indicator_def [abs_def] using A by (auto intro!: measurable_If_set) +lemma borel_measurable_indicator': + "{x\space M. x \ A} \ sets M \ indicator A \ borel_measurable M" + unfolding indicator_def[abs_def] + by (auto intro!: measurable_If) + lemma borel_measurable_indicator_iff: "(indicator A :: 'a \ 'x::{t1_space, zero_neq_one}) \ borel_measurable M \ A \ space M \ sets M" (is "?I \ borel_measurable M \ _") diff -r cfe8ee8a1371 -r 382bd3173584 src/HOL/Probability/Lebesgue_Integration.thy --- a/src/HOL/Probability/Lebesgue_Integration.thy Fri Nov 02 14:00:39 2012 +0100 +++ b/src/HOL/Probability/Lebesgue_Integration.thy Fri Nov 02 14:00:39 2012 +0100 @@ -1403,6 +1403,11 @@ finally show ?thesis . qed +lemma AE_iff_positive_integral: + "{x\space M. P x} \ sets M \ (AE x in M. P x) \ integral\<^isup>P M (indicator {x. \ P x}) = 0" + by (subst positive_integral_0_iff_AE) + (auto simp: one_ereal_def zero_ereal_def sets_Collect_neg indicator_def[abs_def] measurable_If) + lemma positive_integral_const_If: "(\\<^isup>+x. a \M) = (if 0 \ a then a * (emeasure M) (space M) else 0)" by (auto intro!: positive_integral_0_iff_AE[THEN iffD2]) diff -r cfe8ee8a1371 -r 382bd3173584 src/HOL/Probability/Measure_Space.thy --- a/src/HOL/Probability/Measure_Space.thy Fri Nov 02 14:00:39 2012 +0100 +++ b/src/HOL/Probability/Measure_Space.thy Fri Nov 02 14:00:39 2012 +0100 @@ -1095,6 +1095,10 @@ show "sigma_algebra (space N) (sets N)" .. qed fact +lemma measure_distr: + "f \ measurable M N \ S \ sets N \ measure (distr M N f) S = measure M (f -` S \ space M)" + by (simp add: emeasure_distr measure_def) + lemma AE_distrD: assumes f: "f \ measurable M M'" and AE: "AE x in distr M M' f. P x" diff -r cfe8ee8a1371 -r 382bd3173584 src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Fri Nov 02 14:00:39 2012 +0100 +++ b/src/HOL/Probability/Probability_Measure.thy Fri Nov 02 14:00:39 2012 +0100 @@ -395,6 +395,81 @@ shows "prob {y} = 0" using prob_one_inter[of "{y}" "{x}"] assms by auto +subsection {* Introduce binder for probability *} + +syntax + "_prob" :: "pttrn \ logic \ logic \ logic" ("('\

'(_ in _. _'))") + +translations + "\

(x in M. P)" => "CONST measure M {x \ CONST space M. P}" + +definition + "cond_prob M P Q = \

(\ in M. P \ \ Q \) / \

(\ in M. Q \)" + +syntax + "_conditional_prob" :: "pttrn \ logic \ logic \ logic \ logic" ("('\

'(_ in _. _ \/ _'))") + +translations + "\

(x in M. P \ Q)" => "CONST cond_prob M (\x. P) (\x. Q)" + +lemma (in prob_space) AE_E_prob: + assumes ae: "AE x in M. P x" + obtains S where "S \ {x \ space M. P x}" "S \ events" "prob S = 1" +proof - + from ae[THEN AE_E] guess N . + then show thesis + by (intro that[of "space M - N"]) + (auto simp: prob_compl prob_space emeasure_eq_measure) +qed + +lemma (in prob_space) prob_neg: "{x\space M. P x} \ events \ \

(x in M. \ P x) = 1 - \

(x in M. P x)" + by (auto intro!: arg_cong[where f=prob] simp add: prob_compl[symmetric]) + +lemma (in prob_space) prob_eq_AE: + "(AE x in M. P x \ Q x) \ {x\space M. P x} \ events \ {x\space M. Q x} \ events \ \

(x in M. P x) = \

(x in M. Q x)" + by (rule finite_measure_eq_AE) auto + +lemma (in prob_space) prob_eq_0_AE: + assumes not: "AE x in M. \ P x" shows "\

(x in M. P x) = 0" +proof cases + assume "{x\space M. P x} \ events" + with not have "\

(x in M. P x) = \

(x in M. False)" + by (intro prob_eq_AE) auto + then show ?thesis by simp +qed (simp add: measure_notin_sets) + +lemma (in prob_space) prob_sums: + assumes P: "\n. {x\space M. P n x} \ events" + assumes Q: "{x\space M. Q x} \ events" + assumes ae: "AE x in M. (\n. P n x \ Q x) \ (Q x \ (\!n. P n x))" + shows "(\n. \

(x in M. P n x)) sums \

(x in M. Q x)" +proof - + from ae[THEN AE_E_prob] guess S . note S = this + then have disj: "disjoint_family (\n. {x\space M. P n x} \ S)" + by (auto simp: disjoint_family_on_def) + from S have ae_S: + "AE x in M. x \ {x\space M. Q x} \ x \ (\n. {x\space M. P n x} \ S)" + "\n. AE x in M. x \ {x\space M. P n x} \ x \ {x\space M. P n x} \ S" + using ae by (auto dest!: AE_prob_1) + from ae_S have *: + "\

(x in M. Q x) = prob (\n. {x\space M. P n x} \ S)" + using P Q S by (intro finite_measure_eq_AE) auto + from ae_S have **: + "\n. \

(x in M. P n x) = prob ({x\space M. P n x} \ S)" + using P Q S by (intro finite_measure_eq_AE) auto + show ?thesis + unfolding * ** using S P disj + by (intro finite_measure_UNION) auto +qed + +lemma (in prob_space) cond_prob_eq_AE: + assumes P: "AE x in M. Q x \ P x \ P' x" "{x\space M. P x} \ events" "{x\space M. P' x} \ events" + assumes Q: "AE x in M. Q x \ Q' x" "{x\space M. Q x} \ events" "{x\space M. Q' x} \ events" + shows "cond_prob M P Q = cond_prob M P' Q'" + using P Q + by (auto simp: cond_prob_def intro!: arg_cong2[where f="op /"] prob_eq_AE sets_Collect_conj) + + lemma (in prob_space) joint_distribution_Times_le_fst: "random_variable MX X \ random_variable MY Y \ A \ sets MX \ B \ sets MY \ emeasure (distr M (MX \\<^isub>M MY) (\x. (X x, Y x))) (A \ B) \ emeasure (distr M MX X) A" @@ -587,7 +662,7 @@ by (auto simp add: eq measurable_Pair measurable_compose[OF _ f(1)] positive_integral_multc intro!: positive_integral_cong) also have "\ = emeasure ?R E" - by (auto simp add: emeasure_density ST.positive_integral_fst_measurable(2)[symmetric] + by (auto simp add: emeasure_density T.positive_integral_fst_measurable(2)[symmetric] intro!: positive_integral_cong split: split_indicator) finally show "emeasure ?L E = emeasure ?R E" . qed @@ -661,7 +736,7 @@ unfolding measurable_pair_iff by (simp add: comp_def) from Pxy show borel: "Px \ borel_measurable S" - by (auto intro!: ST.positive_integral_fst_measurable dest!: distributed_borel_measurable simp: Px_def) + by (auto intro!: T.positive_integral_fst_measurable dest!: distributed_borel_measurable simp: Px_def) interpret Pxy: prob_space "distr M (S \\<^isub>M T) (\x. (X x, Y x))" using XY by (rule prob_space_distr) @@ -679,7 +754,7 @@ using Pxy by (simp add: distributed_def) also have "\ = \\<^isup>+ x. \\<^isup>+ y. Pxy (x, y) * indicator (A \ space T) (x, y) \T \S" using A borel Pxy - by (simp add: emeasure_density ST.positive_integral_fst_measurable(2)[symmetric] distributed_def) + by (simp add: emeasure_density T.positive_integral_fst_measurable(2)[symmetric] distributed_def) also have "\ = \\<^isup>+ x. Px x * indicator A x \S" apply (rule positive_integral_cong_AE) using Pxy[THEN distributed_AE, THEN ST.AE_pair] AE_space