# HG changeset patch # User hoelzl # Date 1323267029 -3600 # Node ID c36637603821a010650e35cba4e569c4abcf06ae # Parent 714100f5fda4949be68dcd0411771977cfae4bcc remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Binary_Product_Measure.thy --- a/src/HOL/Probability/Binary_Product_Measure.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Binary_Product_Measure.thy Wed Dec 07 15:10:29 2011 +0100 @@ -315,12 +315,9 @@ subsection {* Binary products of $\sigma$-finite measure spaces *} -locale pair_sigma_finite = M1: sigma_finite_measure M1 + M2: sigma_finite_measure M2 +locale pair_sigma_finite = pair_sigma_algebra M1 M2 + M1: sigma_finite_measure M1 + M2: sigma_finite_measure M2 for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme" -sublocale pair_sigma_finite \ pair_sigma_algebra M1 M2 - by default - lemma (in pair_sigma_finite) measure_cut_measurable_fst: assumes "Q \ sets P" shows "(\x. measure M2 (Pair x -` Q)) \ borel_measurable M1" (is "?s Q \ _") proof - @@ -919,10 +916,7 @@ show "a \ A" and "b \ B" by auto qed -locale pair_finite_sigma_algebra = M1: finite_sigma_algebra M1 + M2: finite_sigma_algebra M2 - for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme" - -sublocale pair_finite_sigma_algebra \ pair_sigma_algebra by default +locale pair_finite_sigma_algebra = pair_sigma_algebra M1 M2 + M1: finite_sigma_algebra M1 + M2: finite_sigma_algebra M2 for M1 M2 lemma (in pair_finite_sigma_algebra) finite_pair_sigma_algebra: shows "P = \ space = space M1 \ space M2, sets = Pow (space M1 \ space M2), \ = algebra.more P \" @@ -933,20 +927,16 @@ qed sublocale pair_finite_sigma_algebra \ finite_sigma_algebra P - apply default - using M1.finite_space M2.finite_space - apply (subst finite_pair_sigma_algebra) apply simp - apply (subst (1 2) finite_pair_sigma_algebra) apply simp - done +proof + show "finite (space P)" + using M1.finite_space M2.finite_space + by (subst finite_pair_sigma_algebra) simp + show "sets P = Pow (space P)" + by (subst (1 2) finite_pair_sigma_algebra) simp +qed -locale pair_finite_space = M1: finite_measure_space M1 + M2: finite_measure_space M2 - for M1 M2 - -sublocale pair_finite_space \ pair_finite_sigma_algebra - by default - -sublocale pair_finite_space \ pair_sigma_finite - by default +locale pair_finite_space = pair_sigma_finite M1 M2 + pair_finite_sigma_algebra M1 M2 + + M1: finite_measure_space M1 + M2: finite_measure_space M2 for M1 M2 lemma (in pair_finite_space) pair_measure_Pair[simp]: assumes "a \ space M1" "b \ space M2" @@ -964,6 +954,10 @@ using pair_measure_Pair assms by (cases x) auto sublocale pair_finite_space \ finite_measure_space P - by default (auto simp: space_pair_measure) +proof unfold_locales + show "measure P (space P) \ \" + by (subst (2) finite_pair_sigma_algebra) + (simp add: pair_measure_times) +qed end \ No newline at end of file diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Finite_Product_Measure.thy --- a/src/HOL/Probability/Finite_Product_Measure.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Finite_Product_Measure.thy Wed Dec 07 15:10:29 2011 +0100 @@ -240,7 +240,7 @@ locale finite_product_sigma_algebra = product_sigma_algebra M for M :: "'i \ ('a, 'b) measure_space_scheme" + fixes I :: "'i set" - assumes finite_index: "finite I" + assumes finite_index[simp, intro]: "finite I" definition "product_algebra_generator I M = \ space = (\\<^isub>E i \ I. space (M i)), @@ -508,22 +508,15 @@ finally show "(\x. \i\I. X i x) -` E \ space M \ sets M" . qed -locale product_sigma_finite = - fixes M :: "'i \ ('a,'b) measure_space_scheme" +locale product_sigma_finite = product_sigma_algebra M + for M :: "'i \ ('a,'b) measure_space_scheme" + assumes sigma_finite_measures: "\i. sigma_finite_measure (M i)" -locale finite_product_sigma_finite = product_sigma_finite M - for M :: "'i \ ('a,'b) measure_space_scheme" + - fixes I :: "'i set" assumes finite_index'[intro]: "finite I" - sublocale product_sigma_finite \ M: sigma_finite_measure "M i" for i by (rule sigma_finite_measures) -sublocale product_sigma_finite \ product_sigma_algebra - by default - -sublocale finite_product_sigma_finite \ finite_product_sigma_algebra - by default (fact finite_index') +locale finite_product_sigma_finite = finite_product_sigma_algebra M I + product_sigma_finite M + for M :: "'i \ ('a,'b) measure_space_scheme" and I :: "'i set" lemma (in finite_product_sigma_finite) product_algebra_generator_measure: assumes "Pi\<^isub>E I F \ sets G" diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Independent_Family.thy --- a/src/HOL/Probability/Independent_Family.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Independent_Family.thy Wed Dec 07 15:10:29 2011 +0100 @@ -845,8 +845,8 @@ moreover have "D.prob A = P.prob A" proof (rule prob_space_unique_Int_stable) - show "prob_space ?D'" by default - show "prob_space (Pi\<^isub>M I ?M)" by default + show "prob_space ?D'" by unfold_locales + show "prob_space (Pi\<^isub>M I ?M)" by unfold_locales show "Int_stable P.G" using M'.Int by (intro Int_stable_product_algebra_generator) (simp add: Int_stable_def) show "space P.G \ sets P.G" @@ -963,13 +963,13 @@ unfolding space_pair_measure[simplified pair_measure_def space_sigma] using X.top Y.top by (auto intro!: pair_measure_generatorI) - show "prob_space ?J" by default + show "prob_space ?J" by unfold_locales show "space ?J = space ?P" by (simp add: pair_measure_generator_def space_pair_measure) show "sets ?J = sets (sigma ?P)" by (simp add: pair_measure_def) - show "prob_space XY.P" by default + show "prob_space XY.P" by unfold_locales show "space XY.P = space ?P" "sets XY.P = sets (sigma ?P)" by (simp_all add: pair_measure_generator_def pair_measure_def) diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Infinite_Product_Measure.thy --- a/src/HOL/Probability/Infinite_Product_Measure.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Infinite_Product_Measure.thy Wed Dec 07 15:10:29 2011 +0100 @@ -41,36 +41,11 @@ qed qed -locale product_prob_space = - fixes M :: "'i \ ('a,'b) measure_space_scheme" and I :: "'i set" - assumes prob_spaces: "\i. prob_space (M i)" - and I_not_empty: "I \ {}" - -locale finite_product_prob_space = product_prob_space M I - for M :: "'i \ ('a,'b) measure_space_scheme" and I :: "'i set" + - assumes finite_index'[intro]: "finite I" - -sublocale product_prob_space \ M: prob_space "M i" for i - by (rule prob_spaces) - -sublocale product_prob_space \ product_sigma_finite - by default - -sublocale finite_product_prob_space \ finite_product_sigma_finite - by default (fact finite_index') - -sublocale finite_product_prob_space \ prob_space "Pi\<^isub>M I M" -proof - show "measure P (space P) = 1" - by (simp add: measure_times measure_space_1 setprod_1) -qed - lemma (in product_prob_space) measure_preserving_restrict: assumes "J \ {}" "J \ K" "finite K" shows "(\f. restrict f J) \ measure_preserving (\\<^isub>M i\K. M i) (\\<^isub>M i\J. M i)" (is "?R \ _") proof - - interpret K: finite_product_prob_space M K - by default (insert assms, auto) + interpret K: finite_product_prob_space M K by default fact have J: "J \ {}" "finite J" using assms by (auto simp add: finite_subset) interpret J: finite_product_prob_space M J by default (insert J, auto) @@ -297,7 +272,7 @@ definition (in product_prob_space) infprod_algebra :: "('i \ 'a) measure_space" where "infprod_algebra = sigma generator \ measure := (SOME \. (\s\sets generator. \ s = \G s) \ - measure_space \space = space generator, sets = sets (sigma generator), measure = \\)\" + prob_space \space = space generator, sets = sets (sigma generator), measure = \\)\" syntax "_PiP" :: "[pttrn, 'i set, ('b, 'd) measure_space_scheme] => ('i => 'b, 'd) measure_space_scheme" ("(3PIP _:_./ _)" 10) @@ -314,13 +289,13 @@ translations "PIP x:I. M" == "CONST Pi\<^isub>P I (%x. M)" -sublocale product_prob_space \ G!: algebra generator +lemma (in product_prob_space) algebra_generator: + assumes "I \ {}" shows "algebra generator" proof let ?G = generator show "sets ?G \ Pow (space ?G)" by (auto simp: generator_def emb_def) - from I_not_empty - obtain i where "i \ I" by auto + from `I \ {}` obtain i where "i \ I" by auto then show "{} \ sets ?G" by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\i. {}"] simp: product_algebra_def sigma_def sigma_sets.Empty generator_def emb_def) @@ -343,42 +318,54 @@ using XA XB by (auto intro!: generatorI') qed -lemma (in product_prob_space) positive_\G: "positive generator \G" -proof (intro positive_def[THEN iffD2] conjI ballI) - from generatorE[OF G.empty_sets] guess J X . note this[simp] - interpret J: finite_product_sigma_finite M J by default fact - have "X = {}" - by (rule emb_injective[of J I]) simp_all - then show "\G {} = 0" by simp -next - fix A assume "A \ sets generator" - from generatorE[OF this] guess J X . note this[simp] - interpret J: finite_product_sigma_finite M J by default fact - show "0 \ \G A" by simp +lemma (in product_prob_space) positive_\G: + assumes "I \ {}" + shows "positive generator \G" +proof - + interpret G!: algebra generator by (rule algebra_generator) fact + show ?thesis + proof (intro positive_def[THEN iffD2] conjI ballI) + from generatorE[OF G.empty_sets] guess J X . note this[simp] + interpret J: finite_product_sigma_finite M J by default fact + have "X = {}" + by (rule emb_injective[of J I]) simp_all + then show "\G {} = 0" by simp + next + fix A assume "A \ sets generator" + from generatorE[OF this] guess J X . note this[simp] + interpret J: finite_product_sigma_finite M J by default fact + show "0 \ \G A" by simp + qed qed -lemma (in product_prob_space) additive_\G: "additive generator \G" -proof (intro additive_def[THEN iffD2] ballI impI) - fix A assume "A \ sets generator" with generatorE guess J X . note J = this - fix B assume "B \ sets generator" with generatorE guess K Y . note K = this - assume "A \ B = {}" - have JK: "J \ K \ {}" "J \ K \ I" "finite (J \ K)" - using J K by auto - interpret JK: finite_product_sigma_finite M "J \ K" by default fact - have JK_disj: "emb (J \ K) J X \ emb (J \ K) K Y = {}" - apply (rule emb_injective[of "J \ K" I]) - apply (insert `A \ B = {}` JK J K) - apply (simp_all add: JK.Int emb_simps) - done - have AB: "A = emb I (J \ K) (emb (J \ K) J X)" "B = emb I (J \ K) (emb (J \ K) K Y)" - using J K by simp_all - then have "\G (A \ B) = \G (emb I (J \ K) (emb (J \ K) J X \ emb (J \ K) K Y))" - by (simp add: emb_simps) - also have "\ = measure (Pi\<^isub>M (J \ K) M) (emb (J \ K) J X \ emb (J \ K) K Y)" - using JK J(1, 4) K(1, 4) by (simp add: \G_eq JK.Un) - also have "\ = \G A + \G B" - using J K JK_disj by (simp add: JK.measure_additive[symmetric]) - finally show "\G (A \ B) = \G A + \G B" . +lemma (in product_prob_space) additive_\G: + assumes "I \ {}" + shows "additive generator \G" +proof - + interpret G!: algebra generator by (rule algebra_generator) fact + show ?thesis + proof (intro additive_def[THEN iffD2] ballI impI) + fix A assume "A \ sets generator" with generatorE guess J X . note J = this + fix B assume "B \ sets generator" with generatorE guess K Y . note K = this + assume "A \ B = {}" + have JK: "J \ K \ {}" "J \ K \ I" "finite (J \ K)" + using J K by auto + interpret JK: finite_product_sigma_finite M "J \ K" by default fact + have JK_disj: "emb (J \ K) J X \ emb (J \ K) K Y = {}" + apply (rule emb_injective[of "J \ K" I]) + apply (insert `A \ B = {}` JK J K) + apply (simp_all add: JK.Int emb_simps) + done + have AB: "A = emb I (J \ K) (emb (J \ K) J X)" "B = emb I (J \ K) (emb (J \ K) K Y)" + using J K by simp_all + then have "\G (A \ B) = \G (emb I (J \ K) (emb (J \ K) J X \ emb (J \ K) K Y))" + by (simp add: emb_simps) + also have "\ = measure (Pi\<^isub>M (J \ K) M) (emb (J \ K) J X \ emb (J \ K) K Y)" + using JK J(1, 4) K(1, 4) by (simp add: \G_eq JK.Un) + also have "\ = \G A + \G B" + using J K JK_disj by (simp add: JK.measure_additive[symmetric]) + finally show "\G (A \ B) = \G A + \G B" . + qed qed lemma (in product_prob_space) finite_index_eq_finite_product: @@ -386,7 +373,7 @@ shows "sets (sigma generator) = sets (Pi\<^isub>M I M)" proof safe interpret I: finite_product_sigma_algebra M I by default fact - have [simp]: "space generator = space (Pi\<^isub>M I M)" + have space_generator[simp]: "space generator = space (Pi\<^isub>M I M)" by (simp add: generator_def product_algebra_def) { fix A assume "A \ sets (sigma generator)" then show "A \ sets I.P" unfolding sets_sigma @@ -396,19 +383,32 @@ with `finite I` have "emb I J X \ sets I.P" by auto with `emb I J X = A` show "A \ sets I.P" by simp qed auto } - { fix A assume "A \ sets I.P" - moreover with I.sets_into_space have "emb I I A = A" by (intro emb_id) auto - ultimately show "A \ sets (sigma generator)" - using `finite I` I_not_empty unfolding sets_sigma - by (intro sigma_sets.Basic generatorI[of I A]) auto } + { fix A assume A: "A \ sets I.P" + show "A \ sets (sigma generator)" + proof cases + assume "I = {}" + with I.P_empty[OF this] A + have "A = space generator \ A = {}" + unfolding space_generator by auto + then show ?thesis + by (auto simp: sets_sigma simp del: space_generator + intro: sigma_sets.Empty sigma_sets_top) + next + assume "I \ {}" + note A this + moreover with I.sets_into_space have "emb I I A = A" by (intro emb_id) auto + ultimately show "A \ sets (sigma generator)" + using `finite I` unfolding sets_sigma + by (intro sigma_sets.Basic generatorI[of I A]) auto + qed } qed lemma (in product_prob_space) extend_\G: "\\. (\s\sets generator. \ s = \G s) \ - measure_space \space = space generator, sets = sets (sigma generator), measure = \\" + prob_space \space = space generator, sets = sets (sigma generator), measure = \\" proof cases assume "finite I" - interpret I: finite_product_sigma_finite M I by default fact + interpret I: finite_product_prob_space M I by default fact show ?thesis proof (intro exI[of _ "measure (Pi\<^isub>M I M)"] ballI conjI) fix A assume "A \ sets generator" @@ -422,13 +422,20 @@ have "\space = space generator, sets = sets (sigma generator), measure = measure I.P\ = I.P" (is "?P = _") by (auto intro!: measure_space.equality simp: finite_index_eq_finite_product[OF `finite I`]) - then show "measure_space ?P" by simp default + show "prob_space ?P" + proof + show "measure_space ?P" using `?P = I.P` by simp default + show "measure ?P (space ?P) = 1" + using I.measure_space_1 by simp + qed qed next let ?G = generator assume "\ finite I" + then have I_not_empty: "I \ {}" by auto + interpret G!: algebra generator by (rule algebra_generator) fact note \G_mono = - G.additive_increasing[OF positive_\G additive_\G, THEN increasingD] + G.additive_increasing[OF positive_\G[OF I_not_empty] additive_\G[OF I_not_empty], THEN increasingD] { fix Z J assume J: "J \ {}" "finite J" "J \ I" and Z: "Z \ sets ?G" @@ -488,7 +495,9 @@ note this fold le_1 merge_in_G(3) } note fold = this - show ?thesis + have "\\. (\s\sets ?G. \ s = \G s) \ + measure_space \space = space ?G, sets = sets (sigma ?G), measure = \\" + (is "\\. _ \ measure_space (?ms \)") proof (rule G.caratheodory_empty_continuous[OF positive_\G additive_\G]) fix A assume "A \ sets ?G" with generatorE guess J X . note JX = this @@ -503,7 +512,7 @@ proof (rule ccontr) assume "(INF i. \G (A i)) \ 0" (is "?a \ 0") moreover have "0 \ ?a" - using A positive_\G by (auto intro!: INF_greatest simp: positive_def) + using A positive_\G[OF I_not_empty] by (auto intro!: INF_greatest simp: positive_def) ultimately have "0 < ?a" by auto have "\n. \J X. J \ {} \ finite J \ J \ I \ X \ sets (Pi\<^isub>M J M) \ A n = emb I J X \ \G (A n) = measure (Pi\<^isub>M J M) X" @@ -659,7 +668,7 @@ moreover from w have "?a / 2 ^ (k + 1) \ ?q k k (w k)" by auto then have "?M (J k) (A k) (w k) \ {}" - using positive_\G[unfolded positive_def] `0 < ?a` `?a \ 1` + using positive_\G[OF I_not_empty, unfolded positive_def] `0 < ?a` `?a \ 1` by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq) then obtain x where "x \ ?M (J k) (A k) (w k)" by auto then have "merge (J k) (w k) (I - J k) x \ A k" by auto @@ -713,28 +722,42 @@ qed ultimately show "(\i. \G (A i)) ----> 0" using LIMSEQ_ereal_INFI[of "\i. \G (A i)"] by simp + qed fact+ + then guess \ .. note \ = this + show ?thesis + proof (intro exI[of _ \] conjI) + show "\S\sets ?G. \ S = \G S" using \ by simp + show "prob_space (?ms \)" + proof + show "measure_space (?ms \)" using \ by simp + obtain i where "i \ I" using I_not_empty by auto + interpret i: finite_product_sigma_finite M "{i}" by default auto + let ?X = "\\<^isub>E i\{i}. space (M i)" + have X: "?X \ sets (Pi\<^isub>M {i} M)" + by auto + with `i \ I` have "emb I {i} ?X \ sets generator" + by (intro generatorI') auto + with \ have "\ (emb I {i} ?X) = \G (emb I {i} ?X)" by auto + with \G_eq[OF _ _ _ X] `i \ I` + have "\ (emb I {i} ?X) = measure (M i) (space (M i))" + by (simp add: i.measure_times) + also have "emb I {i} ?X = space (Pi\<^isub>P I M)" + using `i \ I` by (auto simp: emb_def infprod_algebra_def generator_def) + finally show "measure (?ms \) (space (?ms \)) = 1" + using M.measure_space_1 by (simp add: infprod_algebra_def) + qed qed qed lemma (in product_prob_space) infprod_spec: - shows "(\s\sets generator. measure (Pi\<^isub>P I M) s = \G s) \ measure_space (Pi\<^isub>P I M)" -proof - - let ?P = "\\. (\A\sets generator. \ A = \G A) \ - measure_space \space = space generator, sets = sets (sigma generator), measure = \\" - have **: "measure infprod_algebra = (SOME \. ?P \)" - unfolding infprod_algebra_def by simp - have *: "Pi\<^isub>P I M = \space = space generator, sets = sets (sigma generator), measure = measure (Pi\<^isub>P I M)\" - unfolding infprod_algebra_def by auto - show ?thesis - apply (subst (2) *) - apply (unfold **) - apply (rule someI_ex[where P="?P"]) - apply (rule extend_\G) - done -qed + "(\s\sets generator. measure (Pi\<^isub>P I M) s = \G s) \ prob_space (Pi\<^isub>P I M)" + (is "?Q infprod_algebra") + unfolding infprod_algebra_def + by (rule someI2_ex[OF extend_\G]) + (auto simp: sigma_def generator_def) -sublocale product_prob_space \ P: measure_space "Pi\<^isub>P I M" - using infprod_spec by auto +sublocale product_prob_space \ P: prob_space "Pi\<^isub>P I M" + using infprod_spec by simp lemma (in product_prob_space) measure_infprod_emb: assumes "J \ {}" "finite J" "J \ I" "X \ sets (Pi\<^isub>M J M)" @@ -745,22 +768,6 @@ with \G_eq[OF assms] infprod_spec show ?thesis by auto qed -sublocale product_prob_space \ P: prob_space "Pi\<^isub>P I M" -proof - obtain i where "i \ I" using I_not_empty by auto - interpret i: finite_product_sigma_finite M "{i}" by default auto - let ?X = "\\<^isub>E i\{i}. space (M i)" - have "?X \ sets (Pi\<^isub>M {i} M)" - by auto - from measure_infprod_emb[OF _ _ _ this] `i \ I` - have "\ (emb I {i} ?X) = measure (M i) (space (M i))" - by (simp add: i.measure_times) - also have "emb I {i} ?X = space (Pi\<^isub>P I M)" - using `i \ I` by (auto simp: emb_def infprod_algebra_def generator_def) - finally show "\ (space (Pi\<^isub>P I M)) = 1" - using M.measure_space_1 by simp -qed - lemma (in product_prob_space) measurable_component: assumes "i \ I" shows "(\x. x i) \ measurable (Pi\<^isub>P I M) (M i)" @@ -821,7 +828,8 @@ assume "J = {}" then have "emb I J (Pi\<^isub>E J X) = space infprod_algebra" by (auto simp: infprod_algebra_def generator_def sigma_def emb_def) - then show ?thesis using `J = {}` prob_space by simp + then show ?thesis using `J = {}` P.prob_space + by simp next assume "J \ {}" interpret J: finite_product_prob_space M J by default fact+ diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Information.thy --- a/src/HOL/Probability/Information.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Information.thy Wed Dec 07 15:10:29 2011 +0100 @@ -198,7 +198,7 @@ proof - interpret \: prob_space "M\measure := \\" by fact have ms: "measure_space (M\measure := \\)" by default - have fms: "finite_measure (M\measure := \\)" by default + have fms: "finite_measure (M\measure := \\)" by unfold_locales note RN = RN_deriv[OF ms ac] from real_RN_deriv[OF fms ac] guess D . note D = this @@ -460,7 +460,7 @@ proof - interpret information_space M by default fact interpret v: finite_prob_space "M\measure := \\" by fact - have ps: "prob_space (M\measure := \\)" by default + have ps: "prob_space (M\measure := \\)" by unfold_locales from KL_ge_0[OF this ac v.integral_finite_singleton(1)] show ?thesis . qed @@ -558,7 +558,7 @@ have eq: "\A\sets XY.P. (ereal \ joint_distribution X Y) A = XY.\ A" proof (rule XY.KL_eq_0_imp) - show "prob_space ?J" by default + show "prob_space ?J" by unfold_locales show "XY.absolutely_continuous (ereal\joint_distribution X Y)" using ac by (simp add: P_def) show "integrable ?J (entropy_density b XY.P (ereal\joint_distribution X Y))" @@ -624,7 +624,7 @@ have "prob_space (P.P\ measure := ereal\joint_distribution X Y\)" using X Y by (auto intro!: distribution_prob_space random_variable_pairI) then show "measure_space (P.P\ measure := ereal\joint_distribution X Y\)" - unfolding prob_space_def by simp + unfolding prob_space_def finite_measure_def sigma_finite_measure_def by simp qed auto qed @@ -654,7 +654,7 @@ note rv = assms[THEN finite_random_variableD] show "XY.absolutely_continuous (ereal\joint_distribution X Y)" proof (rule XY.absolutely_continuousI) - show "finite_measure_space (XY.P\ measure := ereal\joint_distribution X Y\)" by default + show "finite_measure_space (XY.P\ measure := ereal\joint_distribution X Y\)" by unfold_locales fix x assume "x \ space XY.P" and "XY.\ {x} = 0" then obtain a b where "x = (a, b)" and "distribution X {a} = 0 \ distribution Y {b} = 0" @@ -684,8 +684,8 @@ interpret P: finite_prob_space "XY.P\measure := ereal\joint_distribution X Y\" using assms by (auto intro!: joint_distribution_finite_prob_space) - have P_ms: "finite_measure_space (XY.P\measure := ereal\joint_distribution X Y\)" by default - have P_ps: "finite_prob_space (XY.P\measure := ereal\joint_distribution X Y\)" by default + have P_ms: "finite_measure_space (XY.P\measure := ereal\joint_distribution X Y\)" by unfold_locales + have P_ps: "finite_prob_space (XY.P\measure := ereal\joint_distribution X Y\)" by unfold_locales show ?sum unfolding Let_def mutual_information_def diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Measure.thy --- a/src/HOL/Probability/Measure.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Measure.thy Wed Dec 07 15:10:29 2011 +0100 @@ -1175,13 +1175,21 @@ finally show ?thesis by simp qed -locale finite_measure = measure_space + +locale finite_measure = sigma_finite_measure + assumes finite_measure_of_space: "\ (space M) \ \" -sublocale finite_measure < sigma_finite_measure -proof - show "\A. range A \ sets M \ (\i. A i) = space M \ (\i. \ (A i) \ \)" - using finite_measure_of_space by (auto intro!: exI[of _ "\x. space M"]) +lemma finite_measureI[Pure.intro!]: + assumes "measure_space M" + assumes *: "measure M (space M) \ \" + shows "finite_measure M" +proof - + interpret measure_space M by fact + show "finite_measure M" + proof + show "measure M (space M) \ \" by fact + show "\A. range A \ sets M \ (\i. A i) = space M \ (\i. \ (A i) \ \)" + using * by (auto intro!: exI[of _ "\x. space M"]) + qed qed lemma (in finite_measure) finite_measure[simp, intro]: @@ -1222,22 +1230,19 @@ assumes "S \ sets M" shows "finite_measure (restricted_space S)" (is "finite_measure ?r") - unfolding finite_measure_def finite_measure_axioms_def -proof (intro conjI) +proof show "measure_space ?r" using restricted_measure_space[OF assms] . -next show "measure ?r (space ?r) \ \" using finite_measure[OF `S \ sets M`] by auto qed lemma (in measure_space) restricted_to_finite_measure: assumes "S \ sets M" "\ S \ \" shows "finite_measure (restricted_space S)" -proof - - have "measure_space (restricted_space S)" +proof + show "measure_space (restricted_space S)" using `S \ sets M` by (rule restricted_measure_space) - then show ?thesis - unfolding finite_measure_def finite_measure_axioms_def - using assms by auto + show "measure (restricted_space S) (space (restricted_space S)) \ \" + by simp fact qed lemma (in finite_measure) finite_measure_Diff: @@ -1357,66 +1362,43 @@ section "Finite spaces" -locale finite_measure_space = measure_space + finite_sigma_algebra + - assumes finite_single_measure[simp]: "\x. x \ space M \ \ {x} \ \" +locale finite_measure_space = finite_measure + finite_sigma_algebra + +lemma finite_measure_spaceI[Pure.intro!]: + assumes "finite (space M)" + assumes sets_Pow: "sets M = Pow (space M)" + and space: "measure M (space M) \ \" + and pos: "\x. x \ space M \ 0 \ measure M {x}" + and add: "\A. A \ space M \ measure M A = (\x\A. measure M {x})" + shows "finite_measure_space M" +proof - + interpret finite_sigma_algebra M + proof + show "finite (space M)" by fact + qed (auto simp: sets_Pow) + interpret measure_space M + proof (rule finite_additivity_sufficient) + show "sigma_algebra M" by default + show "finite (space M)" by fact + show "positive M (measure M)" + by (auto simp: add positive_def intro!: setsum_nonneg pos) + show "additive M (measure M)" + using `finite (space M)` + by (auto simp add: additive_def add + intro!: setsum_Un_disjoint dest: finite_subset) + qed + interpret finite_measure M + proof + show "\ (space M) \ \" by fact + qed default + show "finite_measure_space M" + by default +qed lemma (in finite_measure_space) sum_over_space: "(\x\space M. \ {x}) = \ (space M)" using measure_setsum[of "space M" "\i. {i}"] by (simp add: sets_eq_Pow disjoint_family_on_def finite_space) -lemma finite_measure_spaceI: - assumes "finite (space M)" "sets M = Pow(space M)" and space: "measure M (space M) \ \" - and add: "\A B. A\space M \ B\space M \ A \ B = {} \ measure M (A \ B) = measure M A + measure M B" - and "measure M {} = 0" "\A. A \ space M \ 0 \ measure M A" - shows "finite_measure_space M" - unfolding finite_measure_space_def finite_measure_space_axioms_def -proof (intro allI impI conjI) - show "measure_space M" - proof (rule finite_additivity_sufficient) - have *: "\space = space M, sets = Pow (space M), \ = algebra.more M\ = M" - unfolding assms(2)[symmetric] by (auto intro!: algebra.equality) - show "sigma_algebra M" - using sigma_algebra_Pow[of "space M" "algebra.more M"] - unfolding * . - show "finite (space M)" by fact - show "positive M (measure M)" unfolding positive_def using assms by auto - show "additive M (measure M)" unfolding additive_def using assms by simp - qed - then interpret measure_space M . - show "finite_sigma_algebra M" - proof - show "finite (space M)" by fact - show "sets M = Pow (space M)" using assms by auto - qed - { fix x assume *: "x \ space M" - with add[of "{x}" "space M - {x}"] space - show "\ {x} \ \" by (auto simp: insert_absorb[OF *] Diff_subset) } -qed - -sublocale finite_measure_space \ finite_measure -proof - show "\ (space M) \ \" - unfolding sum_over_space[symmetric] setsum_Pinfty - using finite_space finite_single_measure by auto -qed - -lemma finite_measure_space_iff: - "finite_measure_space M \ - finite (space M) \ sets M = Pow(space M) \ measure M (space M) \ \ \ - measure M {} = 0 \ (\A\space M. 0 \ measure M A) \ - (\A\space M. \B\space M. A \ B = {} \ measure M (A \ B) = measure M A + measure M B)" - (is "_ = ?rhs") -proof (intro iffI) - assume "finite_measure_space M" - then interpret finite_measure_space M . - show ?rhs - using finite_space sets_eq_Pow measure_additive empty_measure finite_measure - by auto -next - assume ?rhs then show "finite_measure_space M" - by (auto intro!: finite_measure_spaceI) -qed - lemma (in finite_measure_space) finite_measure_singleton: assumes A: "A \ space M" shows "\' A = (\x\A. \' {x})" using A finite_subset[OF A finite_space] diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Probability_Measure.thy Wed Dec 07 15:10:29 2011 +0100 @@ -9,12 +9,20 @@ imports Lebesgue_Measure begin -locale prob_space = measure_space + +locale prob_space = finite_measure + assumes measure_space_1: "measure M (space M) = 1" -sublocale prob_space < finite_measure -proof - from measure_space_1 show "\ (space M) \ \" by simp +lemma prob_spaceI[Pure.intro!]: + assumes "measure_space M" + assumes *: "measure M (space M) = 1" + shows "prob_space M" +proof - + interpret finite_measure M + proof + show "measure_space M" by fact + show "measure M (space M) \ \" using * by simp + qed + show "prob_space M" by default fact qed abbreviation (in prob_space) "events \ sets M" @@ -31,9 +39,10 @@ lemma (in prob_space) prob_space_cong: assumes "\A. A \ sets M \ measure N A = \ A" "space N = space M" "sets N = sets M" shows "prob_space N" -proof - - interpret N: measure_space N by (intro measure_space_cong assms) - show ?thesis by default (insert assms measure_space_1, simp) +proof + show "measure_space N" by (intro measure_space_cong assms) + show "measure N (space N) = 1" + using measure_space_1 assms by simp qed lemma (in prob_space) distribution_cong: @@ -201,18 +210,17 @@ assumes S: "sigma_algebra S" assumes T: "T \ measure_preserving M S" shows "prob_space S" -proof - +proof interpret S: measure_space S using S and T by (rule measure_space_vimage) - show ?thesis - proof - from T[THEN measure_preservingD2] - have "T -` space S \ space M = space M" - by (auto simp: measurable_def) - with T[THEN measure_preservingD, of "space S", symmetric] - show "measure S (space S) = 1" - using measure_space_1 by simp - qed + show "measure_space S" .. + + from T[THEN measure_preservingD2] + have "T -` space S \ space M = space M" + by (auto simp: measurable_def) + with T[THEN measure_preservingD, of "space S", symmetric] + show "measure S (space S) = 1" + using measure_space_1 by simp qed lemma prob_space_unique_Int_stable: @@ -539,12 +547,14 @@ joint_distribution (\x. (X x, Y x)) Z {((x, y), z)}" unfolding distribution_def by (auto intro!: arg_cong[where f=\']) -locale pair_prob_space = M1: prob_space M1 + M2: prob_space M2 for M1 M2 - -sublocale pair_prob_space \ pair_sigma_finite M1 M2 by default +locale pair_prob_space = pair_sigma_finite M1 M2 + M1: prob_space M1 + M2: prob_space M2 for M1 M2 sublocale pair_prob_space \ P: prob_space P -by default (simp add: pair_measure_times M1.measure_space_1 M2.measure_space_1 space_pair_measure) +proof + show "measure_space P" .. + show "measure P (space P) = 1" + by (simp add: pair_measure_times M1.measure_space_1 M2.measure_space_1 space_pair_measure) +qed lemma countably_additiveI[case_names countably]: assumes "\A. \ range A \ sets M ; disjoint_family A ; (\i. A i) \ sets M\ \ @@ -557,20 +567,21 @@ shows "prob_space ((MX \\<^isub>M MY) \ measure := ereal \ joint_distribution X Y\)" using random_variable_pairI[OF assms] by (rule distribution_prob_space) +locale product_prob_space = product_sigma_finite M for M :: "'i \ ('a, 'b) measure_space_scheme" + + fixes I :: "'i set" + assumes prob_space: "\i. prob_space (M i)" -locale finite_product_prob_space = - fixes M :: "'i \ ('a,'b) measure_space_scheme" - and I :: "'i set" - assumes prob_space: "\i. prob_space (M i)" and finite_index: "finite I" - -sublocale finite_product_prob_space \ M: prob_space "M i" for i +sublocale product_prob_space \ M: prob_space "M i" for i by (rule prob_space) -sublocale finite_product_prob_space \ finite_product_sigma_finite M I - by default (rule finite_index) +locale finite_product_prob_space = finite_product_sigma_finite M I + product_prob_space M I for M I sublocale finite_product_prob_space \ prob_space "\\<^isub>M i\I. M i" - proof qed (simp add: measure_times M.measure_space_1 setprod_1) +proof + show "measure_space P" .. + show "measure P (space P) = 1" + by (simp add: measure_times M.measure_space_1 setprod_1) +qed lemma (in finite_product_prob_space) prob_times: assumes X: "\i. i \ I \ X i \ sets (M i)" @@ -667,7 +678,7 @@ interpret MX: finite_sigma_algebra MX using assms by simp interpret MY: finite_sigma_algebra MY using assms by simp interpret P: pair_finite_sigma_algebra MX MY by default - show "finite_sigma_algebra (MX \\<^isub>M MY)" by default + show "finite_sigma_algebra (MX \\<^isub>M MY)" .. have sa: "sigma_algebra M" by default show "(\x. (X x, Y x)) \ measurable M (MX \\<^isub>M MY)" unfolding P.measurable_pair_iff[OF sa] using assms by (simp add: comp_def) @@ -754,25 +765,9 @@ using setsum_joint_distribution[OF assms, of "\ space = UNIV, sets = Pow UNIV \" "\x. ()" "{()}"] using sigma_algebra_Pow[of "UNIV::unit set" "()"] by simp -locale pair_finite_prob_space = M1: finite_prob_space M1 + M2: finite_prob_space M2 for M1 M2 - -sublocale pair_finite_prob_space \ pair_prob_space M1 M2 by default -sublocale pair_finite_prob_space \ pair_finite_space M1 M2 by default -sublocale pair_finite_prob_space \ finite_prob_space P by default +locale pair_finite_prob_space = pair_prob_space M1 M2 + pair_finite_space M1 M2 + M1: finite_prob_space M1 + M2: finite_prob_space M2 for M1 M2 -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 +sublocale pair_finite_prob_space \ finite_prob_space P by default lemma funset_eq_UN_fun_upd_I: assumes *: "\f. f \ F (insert a A) \ f(a := d) \ F A" @@ -815,7 +810,12 @@ using fin by (intro finite_subset[OF *] finite_extensional_funcset) auto qed -lemma (in product_finite_prob_space) singleton_eq_product: +locale finite_product_finite_prob_space = finite_product_prob_space M I for M I + + assumes finite_space: "\i. finite_prob_space (M i)" + +sublocale finite_product_finite_prob_space \ M!: finite_prob_space "M i" using finite_space . + +lemma (in finite_product_finite_prob_space) singleton_eq_product: assumes x: "x \ space P" shows "{x} = (\\<^isub>E i\I. {x i})" proof (safe intro!: ext[of _ x]) fix y i assume *: "y \ (\ i\I. {x i})" "y \ extensional I" @@ -823,7 +823,7 @@ by (cases "i \ I") (auto simp: extensional_def) qed (insert x, auto) -sublocale product_finite_prob_space \ finite_prob_space "Pi\<^isub>M I M" +sublocale finite_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 @@ -844,23 +844,18 @@ 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: +lemma (in finite_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) measure_singleton_times: +lemma (in finite_product_finite_prob_space) measure_singleton_times: assumes x: "x \ space P" shows "\ {x} = (\i\I. M.\ i {x i})" unfolding singleton_eq_product[OF x] using x by (intro measure_finite_times) auto -lemma (in product_finite_prob_space) prob_finite_times: +lemma (in finite_product_finite_prob_space) prob_finite_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 - @@ -873,13 +868,13 @@ finally show ?thesis by simp qed -lemma (in product_finite_prob_space) prob_singleton_times: +lemma (in finite_product_finite_prob_space) prob_singleton_times: assumes x: "x \ space P" shows "prob {x} = (\i\I. M.prob i {x i})" unfolding singleton_eq_product[OF x] using x by (intro prob_finite_times) auto -lemma (in product_finite_prob_space) prob_finite_product: +lemma (in finite_product_finite_prob_space) prob_finite_product: "A \ space P \ prob A = (\x\A. \i\I. M.prob i {x i})" by (auto simp add: finite_measure_singleton prob_singleton_times simp del: space_product_algebra @@ -1010,11 +1005,12 @@ assumes "sigma_algebra N" "sets N \ sets M" "space N = space M" and "\A. A \ sets N \ measure N A = \ A" shows "prob_space N" -proof - +proof interpret N: measure_space N by (rule measure_space_subalgebra[OF assms]) - show ?thesis - proof qed (insert assms(4)[OF N.top], simp add: assms measure_space_1) + show "measure_space N" .. + show "measure N (space N) = 1" + using assms(4)[OF N.top] by (simp add: assms measure_space_1) qed lemma (in prob_space) prob_space_of_restricted_space: @@ -1028,44 +1024,76 @@ by (rule A.sigma_algebra_cong) auto show "prob_space ?P" proof + show "measure_space ?P" + proof + show "positive ?P (measure ?P)" + proof (simp add: positive_def, safe) + show "0 / \ A = 0" using `\ A \ 0` by (cases "\ A") (auto simp: zero_ereal_def) + fix B assume "B \ events" + with real_measure[of "A \ B"] real_measure[OF `A \ events`] `A \ sets M` + show "0 \ \ (A \ B) / \ A" by (auto simp: Int) + qed + show "countably_additive ?P (measure ?P)" + proof (simp add: countably_additive_def, safe) + fix B and F :: "nat \ 'a set" + assume F: "range F \ op \ A ` events" "disjoint_family F" + { fix i + from F have "F i \ op \ A ` events" by auto + with `A \ events` have "F i \ events" by auto } + moreover then have "range F \ events" by auto + moreover have "\S. \ S / \ A = inverse (\ A) * \ S" + by (simp add: mult_commute divide_ereal_def) + moreover have "0 \ inverse (\ A)" + using real_measure[OF `A \ events`] by auto + ultimately show "(\i. \ (F i) / \ A) = \ (\i. F i) / \ A" + using measure_countably_additive[of F] F + by (auto simp: suminf_cmult_ereal) + qed + qed show "measure ?P (space ?P) = 1" using real_measure[OF `A \ events`] `\ A \ 0` by auto - show "positive ?P (measure ?P)" - proof (simp add: positive_def, safe) - show "0 / \ A = 0" using `\ A \ 0` by (cases "\ A") (auto simp: zero_ereal_def) - fix B assume "B \ events" - with real_measure[of "A \ B"] real_measure[OF `A \ events`] `A \ sets M` - show "0 \ \ (A \ B) / \ A" by (auto simp: Int) - qed - show "countably_additive ?P (measure ?P)" - proof (simp add: countably_additive_def, safe) - fix B and F :: "nat \ 'a set" - assume F: "range F \ op \ A ` events" "disjoint_family F" - { fix i - from F have "F i \ op \ A ` events" by auto - with `A \ events` have "F i \ events" by auto } - moreover then have "range F \ events" by auto - moreover have "\S. \ S / \ A = inverse (\ A) * \ S" - by (simp add: mult_commute divide_ereal_def) - moreover have "0 \ inverse (\ A)" - using real_measure[OF `A \ events`] by auto - ultimately show "(\i. \ (F i) / \ A) = \ (\i. F i) / \ A" - using measure_countably_additive[of F] F - by (auto simp: suminf_cmult_ereal) - qed qed qed lemma finite_prob_spaceI: assumes "finite (space M)" "sets M = Pow(space M)" - and "measure M (space M) = 1" "measure M {} = 0" "\A. A \ space M \ 0 \ measure M A" - and "\A B. A\space M \ B\space M \ A \ B = {} \ measure M (A \ B) = measure M A + measure M B" + and 1: "measure M (space M) = 1" and "\x. x \ space M \ 0 \ measure M {x}" + and add: "\A B. A \ space M \ measure M A = (\x\A. measure M {x})" shows "finite_prob_space M" - unfolding finite_prob_space_eq -proof - show "finite_measure_space M" using assms - by (auto intro!: finite_measure_spaceI) - show "measure M (space M) = 1" by fact +proof - + interpret finite_measure_space M + proof + show "measure M (space M) \ \" using 1 by simp + qed fact+ + show ?thesis by default fact +qed + +lemma (in finite_prob_space) distribution_eq_setsum: + "distribution X A = (\x\A \ X ` space M. distribution X {x})" +proof - + have *: "X -` A \ space M = (\x\A \ X ` space M. X -` {x} \ space M)" + by auto + then show "distribution X A = (\x\A \ X ` space M. distribution X {x})" + using finite_space unfolding distribution_def * + by (intro finite_measure_finite_Union) + (auto simp: disjoint_family_on_def) +qed + +lemma (in finite_prob_space) distribution_eq_setsum_finite: + assumes "finite A" + shows "distribution X A = (\x\A. distribution X {x})" +proof - + note distribution_eq_setsum[of X A] + also have "(\x\A \ X ` space M. distribution X {x}) = (\x\A. distribution X {x})" + proof (intro setsum_mono_zero_cong_left ballI) + fix i assume "i\A - A \ X ` space M" + then have "X -` {i} \ space M = {}" by auto + then show "distribution X {i} = 0" + by (simp add: distribution_def) + next + show "finite A" by fact + qed simp_all + finally show ?thesis . qed lemma (in finite_prob_space) finite_measure_space: @@ -1075,11 +1103,9 @@ proof (rule finite_measure_spaceI, simp_all) show "finite (X ` space M)" using finite_space by simp next - fix A B :: "'x set" assume "A \ B = {}" - then show "distribution X (A \ B) = distribution X A + distribution X B" - unfolding distribution_def - by (subst finite_measure_Union[symmetric]) - (auto intro!: arg_cong[where f=\'] simp: sets_eq_Pow) + fix A assume "A \ X ` space M" + then show "distribution X A = (\x\A. distribution X {x})" + by (subst distribution_eq_setsum) (simp add: Int_absorb2) qed lemma (in finite_prob_space) finite_prob_space_of_images: @@ -1095,11 +1121,9 @@ show "finite (s1 \ s2)" using assms by auto next - fix A B :: "('x*'y) set" assume "A \ B = {}" - then show "joint_distribution X Y (A \ B) = joint_distribution X Y A + joint_distribution X Y B" - unfolding distribution_def - by (subst finite_measure_Union[symmetric]) - (auto intro!: arg_cong[where f=\'] simp: sets_eq_Pow) + fix A assume "A \ (s1 \ s2)" + with assms show "joint_distribution X Y A = (\x\A. joint_distribution X Y {x})" + by (intro distribution_eq_setsum_finite) (auto dest: finite_subset) qed lemma (in finite_prob_space) finite_product_measure_space_of_images: @@ -1140,7 +1164,10 @@ by (simp add: pborel_def) interpretation pborel: prob_space pborel - by default (simp add: one_ereal_def pborel_def) +proof + show "measure pborel (space pborel) = 1" + by (simp add: one_ereal_def pborel_def) +qed default lemma pborel_prob: "pborel.prob A = (if A \ sets borel \ A \ {0 ..< 1} then real (lborel.\ A) else 0)" unfolding pborel.\'_def by (auto simp: pborel_def) diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/Radon_Nikodym.thy --- a/src/HOL/Probability/Radon_Nikodym.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/Radon_Nikodym.thy Wed Dec 07 15:10:29 2011 +0100 @@ -427,35 +427,38 @@ have f_le_\: "\A. A \ sets M \ (\\<^isup>+x. ?F A x \M) \ \ A" using `f \ G` unfolding G_def by auto have fmM: "finite_measure ?M" - proof (default, simp_all add: countably_additive_def positive_def, safe del: notI) - fix A :: "nat \ 'a set" assume A: "range A \ sets M" "disjoint_family A" - have "(\n. (\\<^isup>+x. ?F (A n) x \M)) = (\\<^isup>+x. (\n. ?F (A n) x) \M)" - using `range A \ sets M` `\x. 0 \ f x` - by (intro positive_integral_suminf[symmetric]) auto - also have "\ = (\\<^isup>+x. ?F (\n. A n) x \M)" - using `\x. 0 \ f x` - by (intro positive_integral_cong) (simp add: suminf_cmult_ereal suminf_indicator[OF `disjoint_family A`]) - finally have "(\n. (\\<^isup>+x. ?F (A n) x \M)) = (\\<^isup>+x. ?F (\n. A n) x \M)" . - moreover have "(\n. \ (A n)) = \ (\n. A n)" - using M'.measure_countably_additive A by (simp add: comp_def) - moreover have v_fin: "\ (\i. A i) \ \" using M'.finite_measure A by (simp add: countable_UN) - moreover { - have "(\\<^isup>+x. ?F (\i. A i) x \M) \ \ (\i. A i)" - using A `f \ G` unfolding G_def by (auto simp: countable_UN) - also have "\ (\i. A i) < \" using v_fin by simp - finally have "(\\<^isup>+x. ?F (\i. A i) x \M) \ \" by simp } - moreover have "\i. (\\<^isup>+x. ?F (A i) x \M) \ \ (A i)" - using A by (intro f_le_\) auto - ultimately - show "(\n. ?t (A n)) = ?t (\i. A i)" - by (subst suminf_ereal_minus) (simp_all add: positive_integral_positive) + proof + show "measure_space ?M" + proof (default, simp_all add: countably_additive_def positive_def, safe del: notI) + fix A :: "nat \ 'a set" assume A: "range A \ sets M" "disjoint_family A" + have "(\n. (\\<^isup>+x. ?F (A n) x \M)) = (\\<^isup>+x. (\n. ?F (A n) x) \M)" + using `range A \ sets M` `\x. 0 \ f x` + by (intro positive_integral_suminf[symmetric]) auto + also have "\ = (\\<^isup>+x. ?F (\n. A n) x \M)" + using `\x. 0 \ f x` + by (intro positive_integral_cong) (simp add: suminf_cmult_ereal suminf_indicator[OF `disjoint_family A`]) + finally have "(\n. (\\<^isup>+x. ?F (A n) x \M)) = (\\<^isup>+x. ?F (\n. A n) x \M)" . + moreover have "(\n. \ (A n)) = \ (\n. A n)" + using M'.measure_countably_additive A by (simp add: comp_def) + moreover have v_fin: "\ (\i. A i) \ \" using M'.finite_measure A by (simp add: countable_UN) + moreover { + have "(\\<^isup>+x. ?F (\i. A i) x \M) \ \ (\i. A i)" + using A `f \ G` unfolding G_def by (auto simp: countable_UN) + also have "\ (\i. A i) < \" using v_fin by simp + finally have "(\\<^isup>+x. ?F (\i. A i) x \M) \ \" by simp } + moreover have "\i. (\\<^isup>+x. ?F (A i) x \M) \ \ (A i)" + using A by (intro f_le_\) auto + ultimately + show "(\n. ?t (A n)) = ?t (\i. A i)" + by (subst suminf_ereal_minus) (simp_all add: positive_integral_positive) + next + fix A assume A: "A \ sets M" show "0 \ \ A - \\<^isup>+ x. ?F A x \M" + using f_le_\[OF A] `f \ G` M'.finite_measure[OF A] by (auto simp: G_def ereal_le_minus_iff) + qed next - fix A assume A: "A \ sets M" show "0 \ \ A - \\<^isup>+ x. ?F A x \M" - using f_le_\[OF A] `f \ G` M'.finite_measure[OF A] by (auto simp: G_def ereal_le_minus_iff) - next - show "\ (space M) - (\\<^isup>+ x. ?F (space M) x \M) \ \" (is "?a - ?b \ _") + show "measure ?M (space ?M) \ \" using positive_integral_positive[of "?F (space M)"] - by (cases rule: ereal2_cases[of ?a ?b]) auto + by (cases rule: ereal2_cases[of "\ (space M)" "\\<^isup>+ x. ?F (space M) x \M"]) auto qed then interpret M: finite_measure ?M where "space ?M = space M" and "sets ?M = sets M" and "measure ?M = ?t" @@ -498,11 +501,14 @@ interpret b: sigma_algebra ?Mb by (intro sigma_algebra_cong) auto have Mb: "finite_measure ?Mb" proof - show "positive ?Mb (measure ?Mb)" - using `0 \ b` by (auto simp: positive_def) - show "countably_additive ?Mb (measure ?Mb)" - using `0 \ b` measure_countably_additive - by (auto simp: countably_additive_def suminf_cmult_ereal subset_eq) + show "measure_space ?Mb" + proof + show "positive ?Mb (measure ?Mb)" + using `0 \ b` by (auto simp: positive_def) + show "countably_additive ?Mb (measure ?Mb)" + using `0 \ b` measure_countably_additive + by (auto simp: countably_additive_def suminf_cmult_ereal subset_eq) + qed show "measure ?Mb (space ?Mb) \ \" using b by auto qed @@ -772,7 +778,6 @@ (is "finite_measure ?R") by (rule restricted_finite_measure[OF Q_sets[of i]]) then interpret R: finite_measure ?R . have fmv: "finite_measure (restricted_space (Q i) \ measure := \\)" (is "finite_measure ?Q") - unfolding finite_measure_def finite_measure_axioms_def proof show "measure_space ?Q" using v.restricted_measure_space Q_sets[of i] by auto @@ -849,8 +854,8 @@ let ?MT = "M\ measure := ?T \" interpret T: finite_measure ?MT where "space ?MT = space M" and "sets ?MT = sets M" and "measure ?MT = ?T" - unfolding finite_measure_def finite_measure_axioms_def using borel finite nn - by (auto intro!: measure_space_density cong: positive_integral_cong) + using borel finite nn + by (auto intro!: measure_space_density finite_measureI cong: positive_integral_cong) have "T.absolutely_continuous \" proof (unfold T.absolutely_continuous_def, safe) fix N assume "N \ sets M" "(\\<^isup>+x. h x * indicator N x \M) = 0" @@ -1000,7 +1005,7 @@ using h_borel h_nn by (rule measure_space_density) simp then interpret h: measure_space ?H . interpret h: finite_measure "M\ measure := \A. (\\<^isup>+x. h x * indicator A x \M) \" - by default (simp cong: positive_integral_cong add: fin) + by (intro H finite_measureI) (simp cong: positive_integral_cong add: fin) let ?fM = "M\measure := \A. (\\<^isup>+x. f x * indicator A x \M)\" interpret f: measure_space ?fM using f by (rule measure_space_density) simp diff -r 714100f5fda4 -r c36637603821 src/HOL/Probability/ex/Dining_Cryptographers.thy --- a/src/HOL/Probability/ex/Dining_Cryptographers.thy Mon Dec 05 15:10:15 2011 +0100 +++ b/src/HOL/Probability/ex/Dining_Cryptographers.thy Wed Dec 07 15:10:29 2011 +0100 @@ -22,11 +22,8 @@ by (simp_all add: M_def) sublocale finite_space \ finite_measure_space M -proof (rule finite_measure_spaceI) - fix A B :: "'a set" assume "A \ B = {}" "A \ space M" "B \ space M" - then show "measure M (A \ B) = measure M A + measure M B" - by (simp add: M_def card_Un_disjoint finite_subset[OF _ finite] field_simps) -qed (auto simp: M_def divide_nonneg_nonneg) + by (rule finite_measure_spaceI) + (simp_all add: M_def real_of_nat_def) sublocale finite_space \ information_space M 2 by default (simp_all add: M_def one_ereal_def)