# HG changeset patch # User hoelzl # Date 1353087957 -3600 # Node ID de19856feb5468549d04ff5095134fe7fa8f5e81 # Parent 3d89c38408cd72170e74d3c794d2817e4e6acd00 move theorems to be more generally useable diff -r 3d89c38408cd -r de19856feb54 src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Library/Extended_Real.thy Fri Nov 16 18:45:57 2012 +0100 @@ -124,7 +124,6 @@ fix x :: ereal show "x \ range uminus" by (intro image_eqI[of _ _ "-x"]) auto qed auto - instantiation ereal :: abs begin function abs_ereal where @@ -145,6 +144,9 @@ lemma abs_ereal_uminus[simp]: "\- x\ = \x::ereal\" by (cases x) auto +lemma ereal_infinity_cases: "(a::ereal) \ \ \ a \ -\ \ \a\ \ \" + by auto + subsubsection "Addition" instantiation ereal :: comm_monoid_add @@ -530,6 +532,9 @@ qed end +lemma real_ereal_1[simp]: "real (1::ereal) = 1" + unfolding one_ereal_def by simp + lemma real_of_ereal_le_1: fixes a :: ereal shows "a \ 1 \ real a \ 1" by (cases a) (auto simp: one_ereal_def) @@ -659,6 +664,16 @@ shows "0 < a * b \ (0 < a \ 0 < b) \ (a < 0 \ b < 0)" by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_less_mult_iff) +lemma ereal_left_mult_cong: + fixes a b c :: ereal + shows "(c \ 0 \ a = b) \ c * a = c * b" + by (cases "c = 0") simp_all + +lemma ereal_right_mult_cong: + fixes a b c :: ereal + shows "(c \ 0 \ a = b) \ a * c = b * c" + by (cases "c = 0") simp_all + lemma ereal_distrib: fixes a b c :: ereal assumes "a \ \ \ b \ -\" "a \ -\ \ b \ \" "\c\ \ \" @@ -941,6 +956,10 @@ using assms apply (cases x, cases e) apply auto done +lemma ereal_minus_eq_PInfty_iff: + fixes x y :: ereal shows "x - y = \ \ y = -\ \ x = \" + by (cases x y rule: ereal2_cases) simp_all + subsubsection {* Division *} instantiation ereal :: inverse diff -r 3d89c38408cd -r de19856feb54 src/HOL/Library/FuncSet.thy --- a/src/HOL/Library/FuncSet.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Library/FuncSet.thy Fri Nov 16 18:45:57 2012 +0100 @@ -81,7 +81,10 @@ by (simp add: Pi_def) lemma funcset_image: "f \ A\B ==> f ` A \ B" -by auto + by auto + +lemma image_subset_iff_funcset: "F ` A \ B \ F \ A \ B" + by auto lemma Pi_eq_empty[simp]: "((PI x: A. B x) = {}) = (\x\A. B(x) = {})" apply (simp add: Pi_def, auto) diff -r 3d89c38408cd -r de19856feb54 src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Nov 16 18:45:57 2012 +0100 @@ -5914,4 +5914,71 @@ } ultimately show ?thesis by blast qed + +lemma convex_le_Inf_differential: + fixes f :: "real \ real" + assumes "convex_on I f" + assumes "x \ interior I" "y \ I" + shows "f y \ f x + Inf ((\t. (f x - f t) / (x - t)) ` ({x<..} \ I)) * (y - x)" + (is "_ \ _ + Inf (?F x) * (y - x)") +proof (cases rule: linorder_cases) + assume "x < y" + moreover + have "open (interior I)" by auto + from openE[OF this `x \ interior I`] guess e . note e = this + moreover def t \ "min (x + e / 2) ((x + y) / 2)" + ultimately have "x < t" "t < y" "t \ ball x e" + by (auto simp: dist_real_def field_simps split: split_min) + with `x \ interior I` e interior_subset[of I] have "t \ I" "x \ I" by auto + + have "open (interior I)" by auto + from openE[OF this `x \ interior I`] guess e . + moreover def K \ "x - e / 2" + with `0 < e` have "K \ ball x e" "K < x" by (auto simp: dist_real_def) + ultimately have "K \ I" "K < x" "x \ I" + using interior_subset[of I] `x \ interior I` by auto + + have "Inf (?F x) \ (f x - f y) / (x - y)" + proof (rule Inf_lower2) + show "(f x - f t) / (x - t) \ ?F x" + using `t \ I` `x < t` by auto + show "(f x - f t) / (x - t) \ (f x - f y) / (x - y)" + using `convex_on I f` `x \ I` `y \ I` `x < t` `t < y` by (rule convex_on_diff) + next + fix y assume "y \ ?F x" + with order_trans[OF convex_on_diff[OF `convex_on I f` `K \ I` _ `K < x` _]] + show "(f K - f x) / (K - x) \ y" by auto + qed + then show ?thesis + using `x < y` by (simp add: field_simps) +next + assume "y < x" + moreover + have "open (interior I)" by auto + from openE[OF this `x \ interior I`] guess e . note e = this + moreover def t \ "x + e / 2" + ultimately have "x < t" "t \ ball x e" + by (auto simp: dist_real_def field_simps) + with `x \ interior I` e interior_subset[of I] have "t \ I" "x \ I" by auto + + have "(f x - f y) / (x - y) \ Inf (?F x)" + proof (rule Inf_greatest) + have "(f x - f y) / (x - y) = (f y - f x) / (y - x)" + using `y < x` by (auto simp: field_simps) + also + fix z assume "z \ ?F x" + with order_trans[OF convex_on_diff[OF `convex_on I f` `y \ I` _ `y < x`]] + have "(f y - f x) / (y - x) \ z" by auto + finally show "(f x - f y) / (x - y) \ z" . + next + have "open (interior I)" by auto + from openE[OF this `x \ interior I`] guess e . note e = this + then have "x + e / 2 \ ball x e" by (auto simp: dist_real_def) + with e interior_subset[of I] have "x + e / 2 \ {x<..} \ I" by auto + then show "?F x \ {}" by blast + qed + then show ?thesis + using `y < x` by (simp add: field_simps) +qed simp + end diff -r 3d89c38408cd -r de19856feb54 src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy --- a/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Nov 16 18:45:57 2012 +0100 @@ -423,6 +423,11 @@ using ereal_Lim_uminus[of f f0] lim_imp_Liminf[of net "(%x. -(f x))" "-f0"] ereal_Liminf_uminus[of net f] assms by simp +lemma convergent_ereal_limsup: + fixes X :: "nat \ ereal" + shows "convergent X \ limsup X = lim X" + by (auto simp: convergent_def limI lim_imp_Limsup) + lemma Liminf_PInfty: fixes f :: "'a \ ereal" assumes "\ trivial_limit net" @@ -486,6 +491,12 @@ shows "(f ---> f0) net \ Liminf net f = f0 \ Limsup net f = f0" by (metis assms ereal_Liminf_eq_Limsup lim_imp_Liminf lim_imp_Limsup) +lemma convergent_ereal: + fixes X :: "nat \ ereal" + shows "convergent X \ limsup X = liminf X" + using ereal_Liminf_eq_Limsup_iff[of sequentially] + by (auto simp: convergent_def) + lemma limsup_INFI_SUPR: fixes f :: "nat \ ereal" shows "limsup f = (INF n. SUP m:{n..}. f m)" @@ -1496,4 +1507,20 @@ by induct (simp_all add: suminf_add_ereal setsum_nonneg) qed simp +lemma suminf_ereal_eq_0: + fixes f :: "nat \ ereal" + assumes nneg: "\i. 0 \ f i" + shows "(\i. f i) = 0 \ (\i. f i = 0)" +proof + assume "(\i. f i) = 0" + { fix i assume "f i \ 0" + with nneg have "0 < f i" by (auto simp: less_le) + also have "f i = (\j. if j = i then f i else 0)" + by (subst suminf_finite[where N="{i}"]) auto + also have "\ \ (\i. f i)" + using nneg by (auto intro!: suminf_le_pos) + finally have False using `(\i. f i) = 0` by auto } + then show "\i. f i = 0" by auto +qed simp + end diff -r 3d89c38408cd -r de19856feb54 src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Fri Nov 16 18:45:57 2012 +0100 @@ -483,6 +483,13 @@ show ?thesis unfolding content_def using assms by (auto simp: *) qed +lemma content_singleton[simp]: "content {a} = 0" +proof - + have "content {a .. a} = 0" + by (subst content_closed_interval) auto + then show ?thesis by simp +qed + lemma content_unit[intro]: "content{0..One::'a::ordered_euclidean_space} = 1" proof - have *: "\i (One::'a)$$i" by auto @@ -1665,6 +1672,16 @@ unfolding o_def[THEN sym] apply(rule has_integral_linear,assumption) by(rule bounded_linear_scaleR_right) +lemma has_integral_cmult_real: + fixes c :: real + assumes "c \ 0 \ (f has_integral x) A" + shows "((\x. c * f x) has_integral c * x) A" +proof cases + assume "c \ 0" + from has_integral_cmul[OF assms[OF this], of c] show ?thesis + unfolding real_scaleR_def . +qed simp + lemma has_integral_neg: shows "(f has_integral k) s \ ((\x. -(f x)) has_integral (-k)) s" apply(drule_tac c="-1" in has_integral_cmul) by auto @@ -1746,6 +1763,12 @@ shows "f integrable_on s \ (\x. c *\<^sub>R f(x)) integrable_on s" unfolding integrable_on_def by(auto intro: has_integral_cmul) +lemma integrable_on_cmult_iff: + fixes c :: real assumes "c \ 0" + shows "(\x. c * f x) integrable_on s \ f integrable_on s" + using integrable_cmul[of "\x. c * f x" s "1 / c"] integrable_cmul[of f s c] `c \ 0` + by auto + lemma integrable_neg: shows "f integrable_on s \ (\x. -f(x)) integrable_on s" unfolding integrable_on_def by(auto intro: has_integral_neg) @@ -2669,6 +2692,11 @@ unfolding split_def apply(subst scaleR_left.setsum[THEN sym, unfolded o_def]) defer apply(subst additive_content_tagged_division[unfolded split_def]) apply assumption by auto +lemma integral_const[simp]: + fixes a b :: "'a::ordered_euclidean_space" + shows "integral {a .. b} (\x. c) = content {a .. b} *\<^sub>R c" + by (rule integral_unique) (rule has_integral_const) + subsection {* Bounds on the norm of Riemann sums and the integral itself. *} lemma dsum_bound: assumes "p division_of {a..b}" "norm(c) \ e" diff -r 3d89c38408cd -r de19856feb54 src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Nov 16 18:45:57 2012 +0100 @@ -2891,6 +2891,10 @@ by (fast intro: less_trans, fast intro: le_less_trans, fast intro: order_trans) +lemma atLeastAtMost_singleton_euclidean[simp]: + fixes a :: "'a::ordered_euclidean_space" shows "{a .. a} = {a}" + by (force simp: eucl_le[where 'a='a] euclidean_eq[where 'a='a]) + lemma basis_real_range: "basis ` {..<1} = {1::real}" by auto instance real::ordered_euclidean_space diff -r 3d89c38408cd -r de19856feb54 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Nov 16 18:45:57 2012 +0100 @@ -2044,6 +2044,10 @@ unfolding bounded_any_center [where a=0] by (simp add: dist_norm) +lemma bounded_realI: assumes "\x\s. abs (x::real) \ B" shows "bounded s" + unfolding bounded_def dist_real_def apply(rule_tac x=0 in exI) + using assms by auto + lemma bounded_empty[simp]: "bounded {}" by (simp add: bounded_def) lemma bounded_subset: "bounded T \ S \ T ==> bounded S" by (metis bounded_def subset_eq) diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Binary_Product_Measure.thy --- a/src/HOL/Probability/Binary_Product_Measure.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Binary_Product_Measure.thy Fri Nov 16 18:45:57 2012 +0100 @@ -8,24 +8,12 @@ imports Lebesgue_Integration begin -lemma times_eq_iff: "A \ B = C \ D \ A = C \ B = D \ ((A = {} \ B = {}) \ (C = {} \ D = {}))" - by auto - -lemma times_Int_times: "A \ B \ C \ D = (A \ C) \ (B \ D)" - by auto - -lemma Pair_vimage_times[simp]: "\A B x. Pair x -` (A \ B) = (if x \ A then B else {})" +lemma Pair_vimage_times[simp]: "Pair x -` (A \ B) = (if x \ A then B else {})" by auto -lemma rev_Pair_vimage_times[simp]: "\A B y. (\x. (x, y)) -` (A \ B) = (if y \ B then A else {})" +lemma rev_Pair_vimage_times[simp]: "(\x. (x, y)) -` (A \ B) = (if y \ B then A else {})" by auto -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) - section "Binary products" definition pair_measure (infixr "\\<^isub>M" 80) where @@ -787,4 +775,39 @@ intro!: positive_integral_cong arg_cong[where f="emeasure N"]) qed simp +lemma pair_measure_eqI: + assumes "sigma_finite_measure M1" "sigma_finite_measure M2" + assumes sets: "sets (M1 \\<^isub>M M2) = sets M" + assumes emeasure: "\A B. A \ sets M1 \ B \ sets M2 \ emeasure M1 A * emeasure M2 B = emeasure M (A \ B)" + shows "M1 \\<^isub>M M2 = M" +proof - + interpret M1: sigma_finite_measure M1 by fact + interpret M2: sigma_finite_measure M2 by fact + interpret pair_sigma_finite M1 M2 by default + from sigma_finite_up_in_pair_measure_generator guess F :: "nat \ ('a \ 'b) set" .. note F = this + let ?E = "{a \ b |a b. a \ sets M1 \ b \ sets M2}" + let ?P = "M1 \\<^isub>M M2" + show ?thesis + proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of M1 M2]]) + show "?E \ Pow (space ?P)" + using space_closed[of M1] space_closed[of M2] by (auto simp: space_pair_measure) + show "sets ?P = sigma_sets (space ?P) ?E" + by (simp add: sets_pair_measure space_pair_measure) + then show "sets M = sigma_sets (space ?P) ?E" + using sets[symmetric] by simp + next + show "range F \ ?E" "(\i. F i) = space ?P" "\i. emeasure ?P (F i) \ \" + using F by (auto simp: space_pair_measure) + next + fix X assume "X \ ?E" + then obtain A B where X[simp]: "X = A \ B" and A: "A \ sets M1" and B: "B \ sets M2" by auto + then have "emeasure ?P X = emeasure M1 A * emeasure M2 B" + by (simp add: M2.emeasure_pair_measure_Times) + also have "\ = emeasure M (A \ B)" + using A B emeasure by auto + finally show "emeasure ?P X = emeasure M X" + by simp + qed +qed + end \ No newline at end of file diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Borel_Space.thy Fri Nov 16 18:45:57 2012 +0100 @@ -1114,21 +1114,10 @@ and borel_measurable_limsup: "(\x. limsup (\i. f i x)) \ borel_measurable M" unfolding liminf_SUPR_INFI limsup_INFI_SUPR using assms by auto -lemma sets_Collect_eventually_sequientially[measurable]: +lemma sets_Collect_eventually_sequentially[measurable]: "(\i. {x\space M. P x i} \ sets M) \ {x\space M. eventually (P x) sequentially} \ sets M" unfolding eventually_sequentially by simp -lemma convergent_ereal: - fixes X :: "nat \ ereal" - shows "convergent X \ limsup X = liminf X" - using ereal_Liminf_eq_Limsup_iff[of sequentially] - by (auto simp: convergent_def) - -lemma convergent_ereal_limsup: - fixes X :: "nat \ ereal" - shows "convergent X \ limsup X = lim X" - by (auto simp: convergent_def limI lim_imp_Limsup) - lemma sets_Collect_ereal_convergent[measurable]: fixes f :: "nat \ 'a => ereal" assumes f[measurable]: "\i. f i \ borel_measurable M" diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Finite_Product_Measure.thy --- a/src/HOL/Probability/Finite_Product_Measure.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Finite_Product_Measure.thy Fri Nov 16 18:45:57 2012 +0100 @@ -262,6 +262,47 @@ using Pi_eq_empty_iff[of I F] Pi_eq_empty_iff[of I F'] by auto 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 + +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 + section "Finite product spaces" section "Products" @@ -441,6 +482,31 @@ done qed +lemma prod_algebra_cong: + assumes "I = J" and sets: "(\i. i \ I \ sets (M i) = sets (N i))" + shows "prod_algebra I M = prod_algebra J N" +proof - + have space: "\i. i \ I \ space (M i) = space (N i)" + using sets_eq_imp_space_eq[OF sets] by auto + with sets show ?thesis unfolding `I = J` + by (intro antisym prod_algebra_mono) auto +qed + +lemma space_in_prod_algebra: + "(\\<^isub>E i\I. space (M i)) \ prod_algebra I M" +proof cases + assume "I = {}" then show ?thesis + by (auto simp add: prod_algebra_def image_iff prod_emb_def) +next + assume "I \ {}" + then obtain i where "i \ I" by auto + then have "(\\<^isub>E i\I. space (M i)) = prod_emb I M {i} (\\<^isub>E i\{i}. space (M i))" + by (auto simp: prod_emb_def Pi_iff) + also have "\ \ prod_algebra I M" + using `i \ I` by (intro prod_algebraI) auto + finally show ?thesis . +qed + lemma space_PiM: "space (\\<^isub>M i\I. M i) = (\\<^isub>E i\I. space (M i))" using prod_algebra_sets_into_space unfolding PiM_def prod_algebra_def by (intro space_extend_measure) simp @@ -1007,6 +1073,23 @@ show ?thesis unfolding lebesgue_integral_def *[THEN product_positive_integral_singleton] .. qed +lemma (in product_sigma_finite) distr_component: + "distr (M i) (Pi\<^isub>M {i} M) (\x. \i\{i}. x) = Pi\<^isub>M {i} M" (is "?D = ?P") +proof (intro measure_eqI[symmetric]) + interpret I: finite_product_sigma_finite M "{i}" by default simp + + have eq: "\x. x \ extensional {i} \ (\j\{i}. x i) = x" + by (auto simp: extensional_def restrict_def) + + fix A assume A: "A \ sets ?P" + then have "emeasure ?P A = (\\<^isup>+x. indicator A x \?P)" + by simp + also have "\ = (\\<^isup>+x. indicator ((\x. \i\{i}. x) -` A \ space (M i)) (x i) \PiM {i} M)" + by (intro positive_integral_cong) (auto simp: space_PiM indicator_def simp: eq) + also have "\ = emeasure ?D A" + using A by (simp add: product_positive_integral_singleton emeasure_distr) + finally show "emeasure (Pi\<^isub>M {i} M) A = emeasure ?D A" . +qed simp lemma (in product_sigma_finite) product_integral_fold: assumes IJ[simp]: "I \ J = {}" and fin: "finite I" "finite J" @@ -1250,4 +1333,31 @@ by (auto intro!: sigma_sets_subset sets_PiM_I_finite simp: E_generates P_def) qed +lemma pair_measure_eq_distr_PiM: + fixes M1 :: "'a measure" and M2 :: "'a measure" + assumes "sigma_finite_measure M1" "sigma_finite_measure M2" + shows "(M1 \\<^isub>M M2) = distr (Pi\<^isub>M UNIV (bool_case M1 M2)) (M1 \\<^isub>M M2) (\x. (x True, x False))" + (is "?P = ?D") +proof (rule pair_measure_eqI[OF assms]) + interpret B: product_sigma_finite "bool_case M1 M2" + unfolding product_sigma_finite_def using assms by (auto split: bool.split) + let ?B = "Pi\<^isub>M UNIV (bool_case M1 M2)" + + have [simp]: "fst \ (\x. (x True, x False)) = (\x. x True)" "snd \ (\x. (x True, x False)) = (\x. x False)" + by auto + fix A B assume A: "A \ sets M1" and B: "B \ sets M2" + have "emeasure M1 A * emeasure M2 B = (\ i\UNIV. emeasure (bool_case M1 M2 i) (bool_case A B i))" + by (simp add: UNIV_bool ac_simps) + also have "\ = emeasure ?B (Pi\<^isub>E UNIV (bool_case A B))" + using A B by (subst B.emeasure_PiM) (auto split: bool.split) + also have "Pi\<^isub>E UNIV (bool_case A B) = (\x. (x True, x False)) -` (A \ B) \ space ?B" + using A[THEN sets_into_space] B[THEN sets_into_space] + by (auto simp: Pi_iff all_bool_eq space_PiM split: bool.split) + finally show "emeasure M1 A * emeasure M2 B = emeasure ?D (A \ B)" + using A B + measurable_component_singleton[of True UNIV "bool_case M1 M2"] + measurable_component_singleton[of False UNIV "bool_case M1 M2"] + by (subst emeasure_distr) (auto simp: measurable_pair_iff) +qed simp + end diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Independent_Family.thy --- a/src/HOL/Probability/Independent_Family.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Independent_Family.thy Fri Nov 16 18:45:57 2012 +0100 @@ -18,9 +18,6 @@ definition (in prob_space) indep_events_def_alt: "indep_events A I \ indep_sets (\i. {A i}) I" -lemma image_subset_iff_funcset: "F ` A \ B \ F \ A \ B" - by auto - lemma (in prob_space) indep_events_def: "indep_events A I \ (A`I \ events) \ (\J\I. J \ {} \ finite J \ prob (\j\J. A j) = (\j\J. prob (A j)))" @@ -827,31 +824,6 @@ using I by auto qed fact+ -lemma prod_algebra_cong: - assumes "I = J" and sets: "(\i. i \ I \ sets (M i) = sets (N i))" - shows "prod_algebra I M = prod_algebra J N" -proof - - have space: "\i. i \ I \ space (M i) = space (N i)" - using sets_eq_imp_space_eq[OF sets] by auto - with sets show ?thesis unfolding `I = J` - by (intro antisym prod_algebra_mono) auto -qed - -lemma space_in_prod_algebra: - "(\\<^isub>E i\I. space (M i)) \ prod_algebra I M" -proof cases - assume "I = {}" then show ?thesis - by (auto simp add: prod_algebra_def image_iff prod_emb_def) -next - assume "I \ {}" - then obtain i where "i \ I" by auto - then have "(\\<^isub>E i\I. space (M i)) = prod_emb I M {i} (\\<^isub>E i\{i}. space (M i))" - by (auto simp: prod_emb_def Pi_iff) - also have "\ \ prod_algebra I M" - using `i \ I` by (intro prod_algebraI) auto - finally show ?thesis . -qed - lemma (in prob_space) indep_vars_iff_distr_eq_PiM: fixes I :: "'i set" and X :: "'i \ 'a \ 'b" assumes "I \ {}" @@ -972,114 +944,6 @@ unfolding UNIV_bool by auto qed -lemma measurable_bool_case[simp, intro]: - "(\(x, y). bool_case x y) \ measurable (M \\<^isub>M N) (Pi\<^isub>M UNIV (bool_case M N))" - (is "?f \ measurable ?B ?P") -proof (rule measurable_PiM_single) - show "?f \ space ?B \ (\\<^isub>E i\UNIV. space (bool_case M N i))" - by (auto simp: space_pair_measure extensional_def split: bool.split) - fix i A assume "A \ sets (case i of True \ M | False \ N)" - moreover then have "{\ \ space (M \\<^isub>M N). prod_case bool_case \ i \ A} - = (case i of True \ A \ space N | False \ space M \ A)" - by (auto simp: space_pair_measure split: bool.split dest!: sets_into_space) - ultimately show "{\ \ space (M \\<^isub>M N). prod_case bool_case \ i \ A} \ sets ?B" - by (auto split: bool.split) -qed - -lemma borel_measurable_indicator': - "A \ sets N \ f \ measurable M N \ (\x. indicator A (f x)) \ borel_measurable M" - using measurable_comp[OF _ borel_measurable_indicator, of f M N A] by (auto simp add: comp_def) - -lemma (in product_sigma_finite) distr_component: - "distr (M i) (Pi\<^isub>M {i} M) (\x. \i\{i}. x) = Pi\<^isub>M {i} M" (is "?D = ?P") -proof (intro measure_eqI[symmetric]) - interpret I: finite_product_sigma_finite M "{i}" by default simp - - have eq: "\x. x \ extensional {i} \ (\j\{i}. x i) = x" - by (auto simp: extensional_def restrict_def) - - fix A assume A: "A \ sets ?P" - then have "emeasure ?P A = (\\<^isup>+x. indicator A x \?P)" - by simp - also have "\ = (\\<^isup>+x. indicator ((\x. \i\{i}. x) -` A \ space (M i)) (x i) \PiM {i} M)" - by (intro positive_integral_cong) (auto simp: space_PiM indicator_def simp: eq) - also have "\ = emeasure ?D A" - using A by (simp add: product_positive_integral_singleton emeasure_distr) - finally show "emeasure (Pi\<^isub>M {i} M) A = emeasure ?D A" . -qed simp - -lemma pair_measure_eqI: - assumes "sigma_finite_measure M1" "sigma_finite_measure M2" - assumes sets: "sets (M1 \\<^isub>M M2) = sets M" - assumes emeasure: "\A B. A \ sets M1 \ B \ sets M2 \ emeasure M1 A * emeasure M2 B = emeasure M (A \ B)" - shows "M1 \\<^isub>M M2 = M" -proof - - interpret M1: sigma_finite_measure M1 by fact - interpret M2: sigma_finite_measure M2 by fact - interpret pair_sigma_finite M1 M2 by default - from sigma_finite_up_in_pair_measure_generator guess F :: "nat \ ('a \ 'b) set" .. note F = this - let ?E = "{a \ b |a b. a \ sets M1 \ b \ sets M2}" - let ?P = "M1 \\<^isub>M M2" - show ?thesis - proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of M1 M2]]) - show "?E \ Pow (space ?P)" - using space_closed[of M1] space_closed[of M2] by (auto simp: space_pair_measure) - show "sets ?P = sigma_sets (space ?P) ?E" - by (simp add: sets_pair_measure space_pair_measure) - then show "sets M = sigma_sets (space ?P) ?E" - using sets[symmetric] by simp - next - show "range F \ ?E" "(\i. F i) = space ?P" "\i. emeasure ?P (F i) \ \" - using F by (auto simp: space_pair_measure) - next - fix X assume "X \ ?E" - then obtain A B where X[simp]: "X = A \ B" and A: "A \ sets M1" and B: "B \ sets M2" by auto - then have "emeasure ?P X = emeasure M1 A * emeasure M2 B" - by (simp add: M2.emeasure_pair_measure_Times) - also have "\ = emeasure M (A \ B)" - using A B emeasure by auto - finally show "emeasure ?P X = emeasure M X" - by simp - qed -qed - -lemma pair_measure_eq_distr_PiM: - fixes M1 :: "'a measure" and M2 :: "'a measure" - assumes "sigma_finite_measure M1" "sigma_finite_measure M2" - shows "(M1 \\<^isub>M M2) = distr (Pi\<^isub>M UNIV (bool_case M1 M2)) (M1 \\<^isub>M M2) (\x. (x True, x False))" - (is "?P = ?D") -proof (rule pair_measure_eqI[OF assms]) - interpret B: product_sigma_finite "bool_case M1 M2" - unfolding product_sigma_finite_def using assms by (auto split: bool.split) - let ?B = "Pi\<^isub>M UNIV (bool_case M1 M2)" - - have [simp]: "fst \ (\x. (x True, x False)) = (\x. x True)" "snd \ (\x. (x True, x False)) = (\x. x False)" - by auto - fix A B assume A: "A \ sets M1" and B: "B \ sets M2" - have "emeasure M1 A * emeasure M2 B = (\ i\UNIV. emeasure (bool_case M1 M2 i) (bool_case A B i))" - by (simp add: UNIV_bool ac_simps) - also have "\ = emeasure ?B (Pi\<^isub>E UNIV (bool_case A B))" - using A B by (subst B.emeasure_PiM) (auto split: bool.split) - also have "Pi\<^isub>E UNIV (bool_case A B) = (\x. (x True, x False)) -` (A \ B) \ space ?B" - using A[THEN sets_into_space] B[THEN sets_into_space] - by (auto simp: Pi_iff all_bool_eq space_PiM split: bool.split) - finally show "emeasure M1 A * emeasure M2 B = emeasure ?D (A \ B)" - using A B - measurable_component_singleton[of True UNIV "bool_case M1 M2"] - measurable_component_singleton[of False UNIV "bool_case M1 M2"] - by (subst emeasure_distr) (auto simp: measurable_pair_iff) -qed simp - -lemma measurable_Pair: - assumes rvs: "X \ measurable M S" "Y \ measurable M T" - shows "(\x. (X x, Y x)) \ measurable M (S \\<^isub>M T)" -proof - - have [simp]: "fst \ (\x. (X x, Y x)) = (\x. X x)" "snd \ (\x. (X x, Y x)) = (\x. Y x)" - by auto - show " (\x. (X x, Y x)) \ measurable M (S \\<^isub>M T)" - by (auto simp: measurable_pair_iff rvs) -qed - lemma (in prob_space) indep_var_distribution_eq: "indep_var S X T Y \ random_variable S X \ random_variable T Y \ distr M S X \\<^isub>M distr M T Y = distr M (S \\<^isub>M T) (\x. (X x, Y x))" (is "_ \ _ \ _ \ ?S \\<^isub>M ?T = ?J") diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Lebesgue_Integration.thy --- a/src/HOL/Probability/Lebesgue_Integration.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Lebesgue_Integration.thy Fri Nov 16 18:45:57 2012 +0100 @@ -9,16 +9,6 @@ imports Measure_Space Borel_Space begin -lemma ereal_minus_eq_PInfty_iff: - fixes x y :: ereal shows "x - y = \ \ y = -\ \ x = \" - by (cases x y rule: ereal2_cases) simp_all - -lemma real_ereal_1[simp]: "real (1::ereal) = 1" - unfolding one_ereal_def by simp - -lemma ereal_indicator_pos[simp,intro]: "0 \ (indicator A x ::ereal)" - unfolding indicator_def by auto - lemma tendsto_real_max: fixes x y :: real assumes "(X ---> x) net" @@ -42,11 +32,6 @@ then show ?thesis using assms by (auto intro: measurable_sets) qed -lemma incseq_Suc_iff: "incseq f \ (\n. f n \ f (Suc n))" -proof - assume "\n. f n \ f (Suc n)" then show "incseq f" by (auto intro!: incseq_SucI) -qed (auto simp: incseq_def) - section "Simple function" text {* diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Lebesgue_Measure.thy --- a/src/HOL/Probability/Lebesgue_Measure.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Lebesgue_Measure.thy Fri Nov 16 18:45:57 2012 +0100 @@ -9,14 +9,32 @@ imports Finite_Product_Measure begin -lemma borel_measurable_indicator': - "A \ sets borel \ f \ borel_measurable M \ (\x. indicator A (f x)) \ borel_measurable M" - using measurable_comp[OF _ borel_measurable_indicator, of f M borel A] by (auto simp add: comp_def) +lemma bchoice_iff: "(\x\A. \y. P x y) \ (\f. \x\A. P x (f x))" + by metis + +lemma absolutely_integrable_on_indicator[simp]: + fixes A :: "'a::ordered_euclidean_space set" + shows "((indicator A :: _ \ real) absolutely_integrable_on X) \ + (indicator A :: _ \ real) integrable_on X" + unfolding absolutely_integrable_on_def by simp -lemma borel_measurable_sets: - assumes "f \ measurable borel M" "A \ sets M" - shows "f -` A \ sets borel" - using measurable_sets[OF assms] by simp +lemma has_integral_indicator_UNIV: + fixes s A :: "'a::ordered_euclidean_space set" and x :: real + shows "((indicator (s \ A) :: 'a\real) has_integral x) UNIV = ((indicator s :: _\real) has_integral x) A" +proof - + have "(\x. if x \ A then indicator s x else 0) = (indicator (s \ A) :: _\real)" + by (auto simp: fun_eq_iff indicator_def) + then show ?thesis + unfolding has_integral_restrict_univ[where s=A, symmetric] by simp +qed + +lemma + fixes s a :: "'a::ordered_euclidean_space set" + shows integral_indicator_UNIV: + "integral UNIV (indicator (s \ A) :: 'a\real) = integral A (indicator s :: _\real)" + and integrable_indicator_UNIV: + "(indicator (s \ A) :: 'a\real) integrable_on UNIV \ (indicator s :: 'a\real) integrable_on A" + unfolding integral_def integrable_on_def has_integral_indicator_UNIV by auto subsection {* Standard Cubes *} @@ -62,6 +80,23 @@ lemma cube_subset_Suc[intro]: "cube n \ cube (Suc n)" unfolding cube_def subset_eq apply safe unfolding mem_interval apply auto done +lemma has_integral_interval_cube: + fixes a b :: "'a::ordered_euclidean_space" + shows "(indicator {a .. b} has_integral + content ({\\ i. max (- real n) (a $$ i) .. \\ i. min (real n) (b $$ i)} :: 'a set)) (cube n)" + (is "(?I has_integral content ?R) (cube n)") +proof - + let "{?N .. ?P}" = ?R + have [simp]: "(\x. if x \ cube n then ?I x else 0) = indicator ?R" + by (auto simp: indicator_def cube_def fun_eq_iff eucl_le[where 'a='a]) + have "(?I has_integral content ?R) (cube n) \ (indicator ?R has_integral content ?R) UNIV" + unfolding has_integral_restrict_univ[where s="cube n", symmetric] by simp + also have "\ \ ((\x. 1) has_integral content ?R) ?R" + unfolding indicator_def [abs_def] has_integral_restrict_univ .. + finally show ?thesis + using has_integral_const[of "1::real" "?N" "?P"] by simp +qed + subsection {* Lebesgue measure *} definition lebesgue :: "'a::ordered_euclidean_space measure" where @@ -74,26 +109,6 @@ lemma lebesgueI: "(\n. (indicator A :: _ \ real) integrable_on cube n) \ A \ sets lebesgue" unfolding lebesgue_def by simp -lemma absolutely_integrable_on_indicator[simp]: - fixes A :: "'a::ordered_euclidean_space set" - shows "((indicator A :: _ \ real) absolutely_integrable_on X) \ - (indicator A :: _ \ real) integrable_on X" - unfolding absolutely_integrable_on_def by simp - -lemma LIMSEQ_indicator_UN: - "(\k. indicator (\ i (indicator (\i. A i) x :: real)" -proof cases - assume "\i. x \ A i" then guess i .. note i = this - then have *: "\n. (indicator (\ i i. A i) x :: real) = 1" by (auto simp: indicator_def) - show ?thesis - apply (rule LIMSEQ_offset[of _ "Suc i"]) unfolding * by auto -qed (auto simp: indicator_def) - -lemma indicator_add: - "A \ B = {} \ (indicator A x::_::monoid_add) + indicator B x = indicator (A \ B) x" - unfolding indicator_def by auto - lemma sigma_algebra_lebesgue: defines "leb \ {A. \n. (indicator A :: 'a::ordered_euclidean_space \ real) integrable_on cube n}" shows "sigma_algebra UNIV leb" @@ -198,23 +213,6 @@ qed qed (auto, fact) -lemma has_integral_interval_cube: - fixes a b :: "'a::ordered_euclidean_space" - shows "(indicator {a .. b} has_integral - content ({\\ i. max (- real n) (a $$ i) .. \\ i. min (real n) (b $$ i)} :: 'a set)) (cube n)" - (is "(?I has_integral content ?R) (cube n)") -proof - - let "{?N .. ?P}" = ?R - have [simp]: "(\x. if x \ cube n then ?I x else 0) = indicator ?R" - by (auto simp: indicator_def cube_def fun_eq_iff eucl_le[where 'a='a]) - have "(?I has_integral content ?R) (cube n) \ (indicator ?R has_integral content ?R) UNIV" - unfolding has_integral_restrict_univ[where s="cube n", symmetric] by simp - also have "\ \ ((\x. 1) has_integral content ?R) ?R" - unfolding indicator_def [abs_def] has_integral_restrict_univ .. - finally show ?thesis - using has_integral_const[of "1::real" "?N" "?P"] by simp -qed - lemma lebesgueI_borel[intro, simp]: fixes s::"'a::ordered_euclidean_space set" assumes "s \ sets borel" shows "s \ sets lebesgue" @@ -261,24 +259,6 @@ using cube_subset assms by (intro monoI integral_subset_le) (auto dest!: lebesgueD) qed -lemma has_integral_indicator_UNIV: - fixes s A :: "'a::ordered_euclidean_space set" and x :: real - shows "((indicator (s \ A) :: 'a\real) has_integral x) UNIV = ((indicator s :: _\real) has_integral x) A" -proof - - have "(\x. if x \ A then indicator s x else 0) = (indicator (s \ A) :: _\real)" - by (auto simp: fun_eq_iff indicator_def) - then show ?thesis - unfolding has_integral_restrict_univ[where s=A, symmetric] by simp -qed - -lemma - fixes s a :: "'a::ordered_euclidean_space set" - shows integral_indicator_UNIV: - "integral UNIV (indicator (s \ A) :: 'a\real) = integral A (indicator s :: _\real)" - and integrable_indicator_UNIV: - "(indicator (s \ A) :: 'a\real) integrable_on UNIV \ (indicator s :: 'a\real) integrable_on A" - unfolding integral_def integrable_on_def has_integral_indicator_UNIV by auto - lemma lmeasure_finite_has_integral: fixes s :: "'a::ordered_euclidean_space set" assumes "s \ sets lebesgue" "emeasure lebesgue s = ereal m" @@ -429,11 +409,6 @@ qed qed -lemma integral_const[simp]: - fixes a b :: "'a::ordered_euclidean_space" - shows "integral {a .. b} (\x. c) = content {a .. b} *\<^sub>R c" - by (rule integral_unique) (rule has_integral_const) - lemma lmeasure_UNIV[intro]: "emeasure lebesgue (UNIV::'a::ordered_euclidean_space set) = \" proof (simp add: emeasure_lebesgue, intro SUP_PInfty bexI) fix n :: nat @@ -467,17 +442,6 @@ by (simp add: indicator_def [abs_def]) qed -lemma atLeastAtMost_singleton_euclidean[simp]: - fixes a :: "'a::ordered_euclidean_space" shows "{a .. a} = {a}" - by (force simp: eucl_le[where 'a='a] euclidean_eq[where 'a='a]) - -lemma content_singleton[simp]: "content {a} = 0" -proof - - have "content {a .. a} = 0" - by (subst content_closed_interval) auto - then show ?thesis by simp -qed - lemma lmeasure_singleton[simp]: fixes a :: "'a::ordered_euclidean_space" shows "emeasure lebesgue {a} = 0" using lmeasure_atLeastAtMost[of a a] by simp @@ -609,16 +573,6 @@ subsection {* Lebesgue integrable implies Gauge integrable *} -lemma has_integral_cmult_real: - fixes c :: real - assumes "c \ 0 \ (f has_integral x) A" - shows "((\x. c * f x) has_integral c * x) A" -proof cases - assume "c \ 0" - from has_integral_cmul[OF assms[OF this], of c] show ?thesis - unfolding real_scaleR_def . -qed simp - lemma simple_function_has_integral: fixes f::"'a::ordered_euclidean_space \ ereal" assumes f:"simple_function lebesgue f" @@ -657,10 +611,6 @@ finally show "((\x. real (\y\range f. y * ?F y x)) has_integral real (\x\range f. x * ?M x)) UNIV" . qed fact -lemma bounded_realI: assumes "\x\s. abs (x::real) \ B" shows "bounded s" - unfolding bounded_def dist_real_def apply(rule_tac x=0 in exI) - using assms by auto - lemma simple_function_has_integral': fixes f::"'a::ordered_euclidean_space \ ereal" assumes f: "simple_function lebesgue f" "\x. 0 \ f x" @@ -695,9 +645,6 @@ qed qed -lemma ereal_indicator: "ereal (indicator A x) = indicator A x" - by (auto simp: indicator_def one_ereal_def) - lemma positive_integral_has_integral: fixes f :: "'a::ordered_euclidean_space \ ereal" assumes f: "f \ borel_measurable lebesgue" "range f \ {0..<\}" "integral\<^isup>P lebesgue f \ \" @@ -843,12 +790,6 @@ unfolding lebesgue_integral_eq_borel[OF borel] by simp qed -lemma integrable_on_cmult_iff: - fixes c :: real assumes "c \ 0" - shows "(\x. c * f x) integrable_on s \ f integrable_on s" - using integrable_cmul[of "\x. c * f x" s "1 / c"] integrable_cmul[of f s c] `c \ 0` - by auto - lemma positive_integral_lebesgue_has_integral: fixes f :: "'a::ordered_euclidean_space \ real" assumes f_borel: "f \ borel_measurable lebesgue" and nonneg: "\x. 0 \ f x" @@ -983,9 +924,6 @@ interpretation lborel_space: finite_product_sigma_finite "\x. lborel::real measure" "{..x\A. \y. P x y) \ (\f. \x\A. P x (f x))" - by metis - lemma sets_product_borel: assumes I: "finite I" shows "sets (\\<^isub>M i\I. lborel) = sigma_sets (\\<^isub>E i\I. UNIV) { \\<^isub>E i\I. {..< x i :: real} | x. True}" (is "_ = ?G") diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Measure_Space.thy --- a/src/HOL/Probability/Measure_Space.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Measure_Space.thy Fri Nov 16 18:45:57 2012 +0100 @@ -18,6 +18,28 @@ apply (subst LIMSEQ_Suc_iff[symmetric]) unfolding atLeastLessThanSuc_atLeastAtMost atLeast0AtMost .. +subsection "Relate extended reals and the indicator function" + +lemma ereal_indicator: "ereal (indicator A x) = indicator A x" + by (auto simp: indicator_def one_ereal_def) + +lemma ereal_indicator_pos[simp,intro]: "0 \ (indicator A x ::ereal)" + unfolding indicator_def by auto + +lemma LIMSEQ_indicator_UN: + "(\k. indicator (\ i (indicator (\i. A i) x :: real)" +proof cases + assume "\i. x \ A i" then guess i .. note i = this + then have *: "\n. (indicator (\ i i. A i) x :: real) = 1" by (auto simp: indicator_def) + show ?thesis + apply (rule LIMSEQ_offset[of _ "Suc i"]) unfolding * by auto +qed (auto simp: indicator_def) + +lemma indicator_add: + "A \ B = {} \ (indicator A x::_::monoid_add) + indicator B x = indicator (A \ B) x" + unfolding indicator_def by auto + lemma suminf_cmult_indicator: fixes f :: "nat \ ereal" assumes "disjoint_family A" "x \ A i" "\i. 0 \ f i" @@ -111,7 +133,7 @@ "increasing M f \ x \ y \ x\M \ y\M \ f x \ f y" by (auto simp add: increasing_def) -lemma countably_additiveI: +lemma countably_additiveI[case_names countably]: "(\A. range A \ M \ disjoint_family A \ (\i. A i) \ M \ (\i. f (A i)) = f (\i. A i)) \ countably_additive M f" by (simp add: countably_additive_def) @@ -1114,6 +1136,9 @@ show "sigma_algebra (space N) (sets N)" .. qed fact +lemma distr_id[simp]: "distr N N (\x. x) = N" + by (rule measure_eqI) (auto simp: emeasure_distr) + 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) @@ -1389,6 +1414,107 @@ shows "measure M A = measure M B" using assms emeasure_eq_AE[OF assms] by (simp add: emeasure_eq_measure) +lemma (in finite_measure) measure_increasing: "increasing M (measure M)" + by (auto intro!: finite_measure_mono simp: increasing_def) + +lemma (in finite_measure) measure_zero_union: + assumes "s \ sets M" "t \ sets M" "measure M t = 0" + shows "measure M (s \ t) = measure M s" +using assms +proof - + have "measure M (s \ t) \ measure M s" + using finite_measure_subadditive[of s t] assms by auto + moreover have "measure M (s \ t) \ measure M s" + using assms by (blast intro: finite_measure_mono) + ultimately show ?thesis by simp +qed + +lemma (in finite_measure) measure_eq_compl: + assumes "s \ sets M" "t \ sets M" + assumes "measure M (space M - s) = measure M (space M - t)" + shows "measure M s = measure M t" + using assms finite_measure_compl by auto + +lemma (in finite_measure) measure_eq_bigunion_image: + assumes "range f \ sets M" "range g \ sets M" + assumes "disjoint_family f" "disjoint_family g" + assumes "\ n :: nat. measure M (f n) = measure M (g n)" + shows "measure M (\ i. f i) = measure M (\ i. g i)" +using assms +proof - + have a: "(\ i. measure M (f i)) sums (measure M (\ i. f i))" + by (rule finite_measure_UNION[OF assms(1,3)]) + have b: "(\ i. measure M (g i)) sums (measure M (\ i. g i))" + by (rule finite_measure_UNION[OF assms(2,4)]) + show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp +qed + +lemma (in finite_measure) measure_countably_zero: + assumes "range c \ sets M" + assumes "\ i. measure M (c i) = 0" + shows "measure M (\ i :: nat. c i) = 0" +proof (rule antisym) + show "measure M (\ i :: nat. c i) \ 0" + using finite_measure_subadditive_countably[OF assms(1)] by (simp add: assms(2)) +qed (simp add: measure_nonneg) + +lemma (in finite_measure) measure_space_inter: + assumes events:"s \ sets M" "t \ sets M" + assumes "measure M t = measure M (space M)" + shows "measure M (s \ t) = measure M s" +proof - + have "measure M ((space M - s) \ (space M - t)) = measure M (space M - s)" + using events assms finite_measure_compl[of "t"] by (auto intro!: measure_zero_union) + also have "(space M - s) \ (space M - t) = space M - (s \ t)" + by blast + finally show "measure M (s \ t) = measure M s" + using events by (auto intro!: measure_eq_compl[of "s \ t" s]) +qed + +lemma (in finite_measure) measure_equiprobable_finite_unions: + assumes s: "finite s" "\x. x \ s \ {x} \ sets M" + assumes "\ x y. \x \ s; y \ s\ \ measure M {x} = measure M {y}" + shows "measure M s = real (card s) * measure M {SOME x. x \ s}" +proof cases + assume "s \ {}" + then have "\ x. x \ s" by blast + from someI_ex[OF this] assms + have prob_some: "\ x. x \ s \ measure M {x} = measure M {SOME y. y \ s}" by blast + have "measure M s = (\ x \ s. measure M {x})" + using finite_measure_eq_setsum_singleton[OF s] by simp + also have "\ = (\ x \ s. measure M {SOME y. y \ s})" using prob_some by auto + also have "\ = real (card s) * measure M {(SOME x. x \ s)}" + using setsum_constant assms by (simp add: real_eq_of_nat) + finally show ?thesis by simp +qed simp + +lemma (in finite_measure) measure_real_sum_image_fn: + assumes "e \ sets M" + assumes "\ x. x \ s \ e \ f x \ sets M" + assumes "finite s" + assumes disjoint: "\ x y. \x \ s ; y \ s ; x \ y\ \ f x \ f y = {}" + assumes upper: "space M \ (\ i \ s. f i)" + shows "measure M e = (\ x \ s. measure M (e \ f x))" +proof - + have e: "e = (\ i \ s. e \ f i)" + using `e \ sets M` sets_into_space upper by blast + hence "measure M e = measure M (\ i \ s. e \ f i)" by simp + also have "\ = (\ x \ s. measure M (e \ f x))" + proof (rule finite_measure_finite_Union) + show "finite s" by fact + show "(\i. e \ f i)`s \ sets M" using assms(2) by auto + show "disjoint_family_on (\i. e \ f i) s" + using disjoint by (auto simp: disjoint_family_on_def) + qed + finally show ?thesis . +qed + +lemma (in finite_measure) measure_exclude: + assumes "A \ sets M" "B \ sets M" + assumes "measure M A = measure M (space M)" "A \ B = {}" + shows "measure M B = 0" + using measure_space_inter[of B A] assms by (auto simp: ac_simps) + section {* Counting space *} lemma strict_monoI_Suc: diff -r 3d89c38408cd -r de19856feb54 src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Probability/Probability_Measure.thy Fri Nov 16 18:45:57 2012 +0100 @@ -9,125 +9,6 @@ imports Lebesgue_Measure Radon_Nikodym begin -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 - -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 - - -lemma countably_additiveI[case_names countably]: - assumes "\A. \ range A \ M ; disjoint_family A ; (\i. A i) \ M\ \ (\n. \ (A n)) = \ (\i. A i)" - shows "countably_additive M \" - using assms unfolding countably_additive_def by auto - -lemma convex_le_Inf_differential: - fixes f :: "real \ real" - assumes "convex_on I f" - assumes "x \ interior I" "y \ I" - shows "f y \ f x + Inf ((\t. (f x - f t) / (x - t)) ` ({x<..} \ I)) * (y - x)" - (is "_ \ _ + Inf (?F x) * (y - x)") -proof - - show ?thesis - proof (cases rule: linorder_cases) - assume "x < y" - moreover - have "open (interior I)" by auto - from openE[OF this `x \ interior I`] guess e . note e = this - moreover def t \ "min (x + e / 2) ((x + y) / 2)" - ultimately have "x < t" "t < y" "t \ ball x e" - by (auto simp: dist_real_def field_simps split: split_min) - with `x \ interior I` e interior_subset[of I] have "t \ I" "x \ I" by auto - - have "open (interior I)" by auto - from openE[OF this `x \ interior I`] guess e . - moreover def K \ "x - e / 2" - with `0 < e` have "K \ ball x e" "K < x" by (auto simp: dist_real_def) - ultimately have "K \ I" "K < x" "x \ I" - using interior_subset[of I] `x \ interior I` by auto - - have "Inf (?F x) \ (f x - f y) / (x - y)" - proof (rule Inf_lower2) - show "(f x - f t) / (x - t) \ ?F x" - using `t \ I` `x < t` by auto - show "(f x - f t) / (x - t) \ (f x - f y) / (x - y)" - using `convex_on I f` `x \ I` `y \ I` `x < t` `t < y` by (rule convex_on_diff) - next - fix y assume "y \ ?F x" - with order_trans[OF convex_on_diff[OF `convex_on I f` `K \ I` _ `K < x` _]] - show "(f K - f x) / (K - x) \ y" by auto - qed - then show ?thesis - using `x < y` by (simp add: field_simps) - next - assume "y < x" - moreover - have "open (interior I)" by auto - from openE[OF this `x \ interior I`] guess e . note e = this - moreover def t \ "x + e / 2" - ultimately have "x < t" "t \ ball x e" - by (auto simp: dist_real_def field_simps) - with `x \ interior I` e interior_subset[of I] have "t \ I" "x \ I" by auto - - have "(f x - f y) / (x - y) \ Inf (?F x)" - proof (rule Inf_greatest) - have "(f x - f y) / (x - y) = (f y - f x) / (y - x)" - using `y < x` by (auto simp: field_simps) - also - fix z assume "z \ ?F x" - with order_trans[OF convex_on_diff[OF `convex_on I f` `y \ I` _ `y < x`]] - have "(f y - f x) / (y - x) \ z" by auto - finally show "(f x - f y) / (x - y) \ z" . - next - have "open (interior I)" by auto - from openE[OF this `x \ interior I`] guess e . note e = this - then have "x + e / 2 \ ball x e" by (auto simp: dist_real_def) - with e interior_subset[of I] have "x + e / 2 \ {x<..} \ I" by auto - then show "?F x \ {}" by blast - qed - then show ?thesis - using `y < x` by (simp add: field_simps) - qed simp -qed - -lemma distr_id[simp]: "distr N N (\x. x) = N" - by (rule measure_eqI) (auto simp: emeasure_distr) - locale prob_space = finite_measure + assumes emeasure_space_1: "emeasure M (space M) = 1" @@ -230,101 +111,6 @@ then show False by auto qed -lemma (in finite_measure) prob_space_increasing: "increasing M (measure M)" - by (auto intro!: finite_measure_mono simp: increasing_def) - -lemma (in finite_measure) prob_zero_union: - assumes "s \ sets M" "t \ sets M" "measure M t = 0" - shows "measure M (s \ t) = measure M s" -using assms -proof - - have "measure M (s \ t) \ measure M s" - using finite_measure_subadditive[of s t] assms by auto - moreover have "measure M (s \ t) \ measure M s" - using assms by (blast intro: finite_measure_mono) - ultimately show ?thesis by simp -qed - -lemma (in finite_measure) prob_eq_compl: - assumes "s \ sets M" "t \ sets M" - assumes "measure M (space M - s) = measure M (space M - t)" - shows "measure M s = measure M t" - using assms finite_measure_compl by auto - -lemma (in prob_space) prob_one_inter: - assumes events:"s \ events" "t \ events" - assumes "prob t = 1" - shows "prob (s \ t) = prob s" -proof - - have "prob ((space M - s) \ (space M - t)) = prob (space M - s)" - using events assms prob_compl[of "t"] by (auto intro!: prob_zero_union) - also have "(space M - s) \ (space M - t) = space M - (s \ t)" - by blast - finally show "prob (s \ t) = prob s" - using events by (auto intro!: prob_eq_compl[of "s \ t" s]) -qed - -lemma (in finite_measure) prob_eq_bigunion_image: - assumes "range f \ sets M" "range g \ sets M" - assumes "disjoint_family f" "disjoint_family g" - assumes "\ n :: nat. measure M (f n) = measure M (g n)" - shows "measure M (\ i. f i) = measure M (\ i. g i)" -using assms -proof - - have a: "(\ i. measure M (f i)) sums (measure M (\ i. f i))" - by (rule finite_measure_UNION[OF assms(1,3)]) - have b: "(\ i. measure M (g i)) sums (measure M (\ i. g i))" - by (rule finite_measure_UNION[OF assms(2,4)]) - show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp -qed - -lemma (in finite_measure) prob_countably_zero: - assumes "range c \ sets M" - assumes "\ i. measure M (c i) = 0" - shows "measure M (\ i :: nat. c i) = 0" -proof (rule antisym) - show "measure M (\ i :: nat. c i) \ 0" - using finite_measure_subadditive_countably[OF assms(1)] by (simp add: assms(2)) -qed (simp add: measure_nonneg) - -lemma (in prob_space) prob_equiprobable_finite_unions: - assumes "s \ events" - assumes s_finite: "finite s" "\x. x \ s \ {x} \ events" - assumes "\ x y. \x \ s; y \ s\ \ (prob {x} = prob {y})" - shows "prob s = real (card s) * prob {SOME x. x \ s}" -proof (cases "s = {}") - case False hence "\ x. x \ s" by blast - from someI_ex[OF this] assms - have prob_some: "\ x. x \ s \ prob {x} = prob {SOME y. y \ s}" by blast - have "prob s = (\ x \ s. prob {x})" - using finite_measure_eq_setsum_singleton[OF s_finite] by simp - also have "\ = (\ x \ s. prob {SOME y. y \ s})" using prob_some by auto - also have "\ = real (card s) * prob {(SOME x. x \ s)}" - using setsum_constant assms by (simp add: real_eq_of_nat) - finally show ?thesis by simp -qed simp - -lemma (in prob_space) prob_real_sum_image_fn: - assumes "e \ events" - assumes "\ x. x \ s \ e \ f x \ events" - assumes "finite s" - assumes disjoint: "\ x y. \x \ s ; y \ s ; x \ y\ \ f x \ f y = {}" - assumes upper: "space M \ (\ i \ s. f i)" - shows "prob e = (\ x \ s. prob (e \ f x))" -proof - - have e: "e = (\ i \ s. e \ f i)" - using `e \ events` sets_into_space upper by blast - hence "prob e = prob (\ i \ s. e \ f i)" by simp - also have "\ = (\ x \ s. prob (e \ f x))" - proof (rule finite_measure_finite_Union) - show "finite s" by fact - show "(\i. e \ f i)`s \ events" using assms(2) by auto - show "disjoint_family_on (\i. e \ f i) s" - using disjoint by (auto simp: disjoint_family_on_def) - qed - finally show ?thesis . -qed - lemma (in prob_space) expectation_less: assumes [simp]: "integrable M X" assumes gt: "AE x in M. X x < b" @@ -398,14 +184,6 @@ finally show "q (expectation X) \ expectation (\x. q (X x))" . qed -lemma (in prob_space) prob_x_eq_1_imp_prob_y_eq_0: - assumes "{x} \ events" - assumes "prob {x} = 1" - assumes "{y} \ events" - assumes "y \ x" - shows "prob {y} = 0" - using prob_one_inter[of "{y}" "{x}"] assms by auto - subsection {* Introduce binder for probability *} syntax diff -r 3d89c38408cd -r de19856feb54 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Fri Nov 16 18:49:46 2012 +0100 +++ b/src/HOL/Product_Type.thy Fri Nov 16 18:45:57 2012 +0100 @@ -393,6 +393,9 @@ from `PROP P (fst x, snd x)` show "PROP P x" by simp qed +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 + text {* The rule @{thm [source] split_paired_all} does not work with the Simplifier because it also affects premises in congrence rules, @@ -495,6 +498,10 @@ lemma split_beta [mono]: "(%(x, y). P x y) z = P (fst z) (snd z)" by (subst surjective_pairing, rule split_conv) +lemma split_beta': "(\(x,y). f x y) = (\x. f (fst x) (snd x))" + by (auto simp: fun_eq_iff) + + lemma split_split [no_atp]: "R(split c p) = (ALL x y. p = (x, y) --> R(c x y))" -- {* For use with @{text split} and the Simplifier. *} by (insert surj_pair [of p], clarify, simp) @@ -1019,6 +1026,9 @@ lemma Times_empty[simp]: "A \ B = {} \ A = {} \ B = {}" by auto +lemma times_eq_iff: "A \ B = C \ D \ A = C \ B = D \ ((A = {} \ B = {}) \ (C = {} \ D = {}))" + by auto + lemma fst_image_times[simp]: "fst ` (A \ B) = (if B = {} then {} else A)" by force @@ -1036,6 +1046,9 @@ apply auto done +lemma times_Int_times: "A \ B \ C \ D = (A \ C) \ (B \ D)" + by auto + lemma swap_inj_on: "inj_on (\(i, j). (j, i)) A" by (auto intro!: inj_onI)