# HG changeset patch # User hoelzl # Date 1349863936 -7200 # Node ID dfa8ddb874ceb094b1b8721510ad99ee65396df0 # Parent 16907431e477c79314ce6e4a1181086d5bc3f078 use continuity to show Borel-measurability diff -r 16907431e477 -r dfa8ddb874ce src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Wed Oct 10 12:12:15 2012 +0200 +++ b/src/HOL/Probability/Borel_Space.thy Wed Oct 10 12:12:16 2012 +0200 @@ -632,7 +632,7 @@ "(f::'a \ real) \ borel_measurable M = (\a. {w \ space M. a < f w} \ sets M)" using borel_measurable_iff_halfspace_greater[where 'c=real] by simp -lemma borel_measurable_euclidean_component: +lemma borel_measurable_euclidean_component': "(\x::'a::euclidean_space. x $$ i) \ borel_measurable borel" proof (rule borel_measurableI) fix S::"real set" assume "open S" @@ -641,13 +641,18 @@ by (auto intro: borel_open) qed +lemma borel_measurable_euclidean_component: + fixes f :: "'a \ 'b::euclidean_space" + assumes f: "f \ borel_measurable M" + shows "(\x. f x $$ i) \ borel_measurable M" + using measurable_comp[OF f borel_measurable_euclidean_component'] by (simp add: comp_def) + lemma borel_measurable_euclidean_space: fixes f :: "'a \ 'c::ordered_euclidean_space" shows "f \ borel_measurable M \ (\ix. f x $$ i) \ borel_measurable M)" proof safe fix i assume "f \ borel_measurable M" then show "(\x. f x $$ i) \ borel_measurable M" - using measurable_comp[of f _ _ "\x. x $$ i", unfolded comp_def] by (auto intro: borel_measurable_euclidean_component) next assume f: "\ix. f x $$ i) \ borel_measurable M" @@ -657,6 +662,144 @@ subsection "Borel measurable operators" +lemma borel_measurable_continuous_on1: + fixes f :: "'a::topological_space \ 'b::topological_space" + assumes "continuous_on UNIV f" + shows "f \ borel_measurable borel" + apply(rule borel_measurableI) + using continuous_open_preimage[OF assms] unfolding vimage_def by auto + +lemma borel_measurable_continuous_on: + fixes f :: "'a::topological_space \ 'b::topological_space" + assumes f: "continuous_on UNIV f" and g: "g \ borel_measurable M" + shows "(\x. f (g x)) \ borel_measurable M" + using measurable_comp[OF g borel_measurable_continuous_on1[OF f]] by (simp add: comp_def) + +lemma borel_measurable_continuous_on_open': + fixes f :: "'a::topological_space \ 'b::t1_space" + assumes cont: "continuous_on A f" "open A" + shows "(\x. if x \ A then f x else c) \ borel_measurable borel" (is "?f \ _") +proof (rule borel_measurableI) + fix S :: "'b set" assume "open S" + then have "open {x\A. f x \ S}" + by (intro continuous_open_preimage[OF cont]) auto + then have *: "{x\A. f x \ S} \ sets borel" by auto + have "?f -` S \ space borel = + {x\A. f x \ S} \ (if c \ S then space borel - A else {})" + by (auto split: split_if_asm) + also have "\ \ sets borel" + using * `open A` by (auto simp del: space_borel intro!: Un) + finally show "?f -` S \ space borel \ sets borel" . +qed + +lemma borel_measurable_continuous_on_open: + fixes f :: "'a::topological_space \ 'b::t1_space" + assumes cont: "continuous_on A f" "open A" + assumes g: "g \ borel_measurable M" + shows "(\x. if g x \ A then f (g x) else c) \ borel_measurable M" + using measurable_comp[OF g borel_measurable_continuous_on_open'[OF cont], of c] + by (simp add: comp_def) + +lemma borel_measurable_uminus[simp, intro]: + fixes g :: "'a \ real" + assumes g: "g \ borel_measurable M" + shows "(\x. - g x) \ borel_measurable M" + by (rule borel_measurable_continuous_on[OF _ g]) (auto intro: continuous_on_minus continuous_on_id) + +lemma euclidean_component_prod: + fixes x :: "'a :: euclidean_space \ 'b :: euclidean_space" + shows "x $$ i = (if i < DIM('a) then fst x $$ i else snd x $$ (i - DIM('a)))" + unfolding euclidean_component_def basis_prod_def inner_prod_def by auto + +lemma borel_measurable_Pair[simp, intro]: + fixes f :: "'a \ 'b::ordered_euclidean_space" and g :: "'a \ 'c::ordered_euclidean_space" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows "(\x. (f x, g x)) \ borel_measurable M" +proof (intro borel_measurable_iff_halfspace_le[THEN iffD2] allI impI) + fix i and a :: real assume i: "i < DIM('b \ 'c)" + have [simp]: "\P A B C. {w. (P \ A w \ B w) \ (\ P \ A w \ C w)} = + {w. A w \ (P \ B w) \ (\ P \ C w)}" by auto + from i f g show "{w \ space M. (f w, g w) $$ i \ a} \ sets M" + by (auto simp: euclidean_component_prod intro!: sets_Collect borel_measurable_euclidean_component) +qed + +lemma continuous_on_fst: "continuous_on UNIV fst" +proof - + have [simp]: "range fst = UNIV" by (auto simp: image_iff) + show ?thesis + using closed_vimage_fst + by (auto simp: continuous_on_closed closed_closedin vimage_def) +qed + +lemma continuous_on_snd: "continuous_on UNIV snd" +proof - + have [simp]: "range snd = UNIV" by (auto simp: image_iff) + show ?thesis + using closed_vimage_snd + by (auto simp: continuous_on_closed closed_closedin vimage_def) +qed + +lemma borel_measurable_continuous_Pair: + fixes f :: "'a \ 'b::ordered_euclidean_space" and g :: "'a \ 'c::ordered_euclidean_space" + assumes [simp]: "f \ borel_measurable M" + assumes [simp]: "g \ borel_measurable M" + assumes H: "continuous_on UNIV (\x. H (fst x) (snd x))" + shows "(\x. H (f x) (g x)) \ borel_measurable M" +proof - + have eq: "(\x. H (f x) (g x)) = (\x. (\x. H (fst x) (snd x)) (f x, g x))" by auto + show ?thesis + unfolding eq by (rule borel_measurable_continuous_on[OF H]) auto +qed + +lemma borel_measurable_add[simp, intro]: + fixes f g :: "'a \ 'c::ordered_euclidean_space" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows "(\x. f x + g x) \ borel_measurable M" + using f g + by (rule borel_measurable_continuous_Pair) + (auto intro: continuous_on_fst continuous_on_snd continuous_on_add) + +lemma borel_measurable_setsum[simp, intro]: + fixes f :: "'c \ 'a \ real" + assumes "\i. i \ S \ f i \ borel_measurable M" + shows "(\x. \i\S. f i x) \ borel_measurable M" +proof cases + assume "finite S" + thus ?thesis using assms by induct auto +qed simp + +lemma borel_measurable_diff[simp, intro]: + fixes f :: "'a \ real" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows "(\x. f x - g x) \ borel_measurable M" + unfolding diff_minus using assms by fast + +lemma borel_measurable_times[simp, intro]: + fixes f :: "'a \ real" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows "(\x. f x * g x) \ borel_measurable M" + using f g + by (rule borel_measurable_continuous_Pair) + (auto intro: continuous_on_fst continuous_on_snd continuous_on_mult) + +lemma continuous_on_dist: + fixes f :: "'a :: t2_space \ 'b :: metric_space" + shows "continuous_on A f \ continuous_on A g \ continuous_on A (\x. dist (f x) (g x))" + unfolding continuous_on_eq_continuous_within by (auto simp: continuous_dist) + +lemma borel_measurable_dist[simp, intro]: + fixes g f :: "'a \ 'b::ordered_euclidean_space" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows "(\x. dist (f x) (g x)) \ borel_measurable M" + using f g + by (rule borel_measurable_continuous_Pair) + (intro continuous_on_dist continuous_on_fst continuous_on_snd) + lemma affine_borel_measurable_vector: fixes f :: "'a \ 'x::real_normed_vector" assumes "f \ borel_measurable M" @@ -683,116 +826,6 @@ shows "(\x. a + (g x) * b) \ borel_measurable M" using affine_borel_measurable_vector[OF assms] by (simp add: mult_commute) -lemma borel_measurable_add[simp, intro]: - fixes f :: "'a \ real" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "(\x. f x + g x) \ borel_measurable M" -proof - - have 1: "\a. {w\space M. a \ f w + g w} = {w \ space M. a + g w * -1 \ f w}" - by auto - have "\a. (\w. a + (g w) * -1) \ borel_measurable M" - by (rule affine_borel_measurable [OF g]) - then have "\a. {w \ space M. (\w. a + (g w) * -1)(w) \ f w} \ sets M" using f - by auto - then have "\a. {w \ space M. a \ f w + g w} \ sets M" - by (simp add: 1) - then show ?thesis - by (simp add: borel_measurable_iff_ge) -qed - -lemma borel_measurable_setsum[simp, intro]: - fixes f :: "'c \ 'a \ real" - assumes "\i. i \ S \ f i \ borel_measurable M" - shows "(\x. \i\S. f i x) \ borel_measurable M" -proof cases - assume "finite S" - thus ?thesis using assms by induct auto -qed simp - -lemma borel_measurable_square: - fixes f :: "'a \ real" - assumes f: "f \ borel_measurable M" - shows "(\x. (f x)^2) \ borel_measurable M" -proof - - { - fix a - have "{w \ space M. (f w)\ \ a} \ sets M" - proof (cases rule: linorder_cases [of a 0]) - case less - hence "{w \ space M. (f w)\ \ a} = {}" - by auto (metis less order_le_less_trans power2_less_0) - also have "... \ sets M" - by (rule empty_sets) - finally show ?thesis . - next - case equal - hence "{w \ space M. (f w)\ \ a} = - {w \ space M. f w \ 0} \ {w \ space M. 0 \ f w}" - by auto - also have "... \ sets M" - apply (insert f) - apply (rule Int) - apply (simp add: borel_measurable_iff_le) - apply (simp add: borel_measurable_iff_ge) - done - finally show ?thesis . - next - case greater - have "\x. (f x ^ 2 \ sqrt a ^ 2) = (- sqrt a \ f x & f x \ sqrt a)" - by (metis abs_le_interval_iff abs_of_pos greater real_sqrt_abs - real_sqrt_le_iff real_sqrt_power) - hence "{w \ space M. (f w)\ \ a} = - {w \ space M. -(sqrt a) \ f w} \ {w \ space M. f w \ sqrt a}" - using greater by auto - also have "... \ sets M" - apply (insert f) - apply (rule Int) - apply (simp add: borel_measurable_iff_ge) - apply (simp add: borel_measurable_iff_le) - done - finally show ?thesis . - qed - } - thus ?thesis by (auto simp add: borel_measurable_iff_le) -qed - -lemma times_eq_sum_squares: - fixes x::real - shows"x*y = ((x+y)^2)/4 - ((x-y)^ 2)/4" -by (simp add: power2_eq_square ring_distribs diff_divide_distrib [symmetric]) - -lemma borel_measurable_uminus[simp, intro]: - fixes g :: "'a \ real" - assumes g: "g \ borel_measurable M" - shows "(\x. - g x) \ borel_measurable M" -proof - - have "(\x. - g x) = (\x. 0 + (g x) * -1)" - by simp - also have "... \ borel_measurable M" - by (fast intro: affine_borel_measurable g) - finally show ?thesis . -qed - -lemma borel_measurable_times[simp, intro]: - fixes f :: "'a \ real" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "(\x. f x * g x) \ borel_measurable M" -proof - - have 1: "(\x. 0 + (f x + g x)\ * inverse 4) \ borel_measurable M" - using assms by (fast intro: affine_borel_measurable borel_measurable_square) - have "(\x. -((f x + -g x) ^ 2 * inverse 4)) = - (\x. 0 + ((f x + -g x) ^ 2 * inverse -4))" - by (simp add: minus_divide_right) - also have "... \ borel_measurable M" - using f g by (fast intro: affine_borel_measurable borel_measurable_square f g) - finally have 2: "(\x. -((f x + -g x) ^ 2 * inverse 4)) \ borel_measurable M" . - show ?thesis - apply (simp add: times_eq_sum_squares diff_minus) - using 1 2 by simp -qed - lemma borel_measurable_setprod[simp, intro]: fixes f :: "'c \ 'a \ real" assumes "\i. i \ S \ f i \ borel_measurable M" @@ -802,26 +835,17 @@ thus ?thesis using assms by induct auto qed simp -lemma borel_measurable_diff[simp, intro]: - fixes f :: "'a \ real" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "(\x. f x - g x) \ borel_measurable M" - unfolding diff_minus using assms by fast - lemma borel_measurable_inverse[simp, intro]: fixes f :: "'a \ real" - assumes "f \ borel_measurable M" + assumes f: "f \ borel_measurable M" shows "(\x. inverse (f x)) \ borel_measurable M" - unfolding borel_measurable_iff_ge unfolding inverse_eq_divide -proof safe - fix a :: real - have *: "{w \ space M. a \ 1 / f w} = - ({w \ space M. 0 < f w} \ {w \ space M. a * f w \ 1}) \ - ({w \ space M. f w < 0} \ {w \ space M. 1 \ a * f w}) \ - ({w \ space M. f w = 0} \ {w \ space M. a \ 0})" by (auto simp: le_divide_eq) - show "{w \ space M. a \ 1 / f w} \ sets M" using assms unfolding * - by (auto intro!: Int Un) +proof - + have *: "\x::real. inverse x = (if x \ UNIV - {0} then inverse x else 0)" by auto + show ?thesis + apply (subst *) + apply (rule borel_measurable_continuous_on_open) + apply (auto intro!: f continuous_on_inverse continuous_on_id) + done qed lemma borel_measurable_divide[simp, intro]: @@ -837,30 +861,14 @@ assumes "f \ borel_measurable M" assumes "g \ borel_measurable M" shows "(\x. max (g x) (f x)) \ borel_measurable M" - unfolding borel_measurable_iff_le -proof safe - fix a - have "{x \ space M. max (g x) (f x) \ a} = - {x \ space M. g x \ a} \ {x \ space M. f x \ a}" by auto - thus "{x \ space M. max (g x) (f x) \ a} \ sets M" - using assms unfolding borel_measurable_iff_le - by (auto intro!: Int) -qed + unfolding max_def by (auto intro!: assms measurable_If) lemma borel_measurable_min[intro, simp]: fixes f g :: "'a \ real" assumes "f \ borel_measurable M" assumes "g \ borel_measurable M" shows "(\x. min (g x) (f x)) \ borel_measurable M" - unfolding borel_measurable_iff_ge -proof safe - fix a - have "{x \ space M. a \ min (g x) (f x)} = - {x \ space M. a \ g x} \ {x \ space M. a \ f x}" by auto - thus "{x \ space M. a \ min (g x) (f x)} \ sets M" - using assms unfolding borel_measurable_iff_ge - by (auto intro!: Int) -qed + unfolding min_def by (auto intro!: assms measurable_If) lemma borel_measurable_abs[simp, intro]: assumes "f \ borel_measurable M" @@ -872,76 +880,50 @@ lemma borel_measurable_nth[simp, intro]: "(\x::real^'n. x $ i) \ borel_measurable borel" - using borel_measurable_euclidean_component + using borel_measurable_euclidean_component' unfolding nth_conv_component by auto -lemma borel_measurable_continuous_on1: - fixes f :: "'a::topological_space \ 'b::t1_space" - assumes "continuous_on UNIV f" - shows "f \ borel_measurable borel" - apply(rule borel_measurableI) - using continuous_open_preimage[OF assms] unfolding vimage_def by auto - -lemma borel_measurable_continuous_on: - fixes f :: "'a::topological_space \ 'b::t1_space" - assumes cont: "continuous_on A f" "open A" - shows "(\x. if x \ A then f x else c) \ borel_measurable borel" (is "?f \ _") -proof (rule borel_measurableI) - fix S :: "'b set" assume "open S" - then have "open {x\A. f x \ S}" - by (intro continuous_open_preimage[OF cont]) auto - then have *: "{x\A. f x \ S} \ sets borel" by auto - have "?f -` S \ space borel = - {x\A. f x \ S} \ (if c \ S then space borel - A else {})" - by (auto split: split_if_asm) - also have "\ \ sets borel" - using * `open A` by (auto simp del: space_borel intro!: Un) - finally show "?f -` S \ space borel \ sets borel" . -qed - lemma convex_measurable: fixes a b :: real assumes X: "X \ borel_measurable M" "X ` space M \ { a <..< b}" assumes q: "convex_on { a <..< b} q" - shows "q \ X \ borel_measurable M" + shows "(\x. q (X x)) \ borel_measurable M" proof - - have "(\x. if x \ {a <..< b} then q x else 0) \ borel_measurable borel" - proof (rule borel_measurable_continuous_on) + have "(\x. if X x \ {a <..< b} then q (X x) else 0) \ borel_measurable M" (is "?qX") + proof (rule borel_measurable_continuous_on_open[OF _ _ X(1)]) show "open {a<..x. if x \ {a <..< b} then q x else 0) \ X \ borel_measurable M" (is ?qX) - using X by (intro measurable_comp) auto - moreover have "?qX \ q \ X \ borel_measurable M" + moreover have "?qX \ (\x. q (X x)) \ borel_measurable M" using X by (intro measurable_cong) auto ultimately show ?thesis by simp qed -lemma borel_measurable_borel_log: assumes "1 < b" shows "log b \ borel_measurable borel" +lemma borel_measurable_ln[simp,intro]: + assumes f: "f \ borel_measurable M" + shows "(\x. ln (f x)) \ borel_measurable M" proof - { fix x :: real assume x: "x \ 0" { fix x::real assume "x \ 0" then have "\u. exp u = x \ False" by auto } - from this[of x] x this[of 0] have "log b 0 = log b x" - by (auto simp: ln_def log_def) } - note log_imp = this - have "(\x. if x \ {0<..} then log b x else log b 0) \ borel_measurable borel" - proof (rule borel_measurable_continuous_on) - show "continuous_on {0<..} (log b)" - by (auto intro!: continuous_at_imp_continuous_on DERIV_log DERIV_isCont + from this[of x] x this[of 0] have "ln 0 = ln x" + by (auto simp: ln_def) } + note ln_imp = this + have "(\x. if f x \ {0<..} then ln (f x) else ln 0) \ borel_measurable M" + proof (rule borel_measurable_continuous_on_open[OF _ _ f]) + show "continuous_on {0<..} ln" + by (auto intro!: continuous_at_imp_continuous_on DERIV_ln DERIV_isCont simp: continuous_isCont[symmetric]) show "open ({0<..}::real set)" by auto qed - also have "(\x. if x \ {0<..} then log b x else log b 0) = log b" - by (simp add: fun_eq_iff not_less log_imp) + also have "(\x. if x \ {0<..} then ln x else ln 0) = ln" + by (simp add: fun_eq_iff not_less ln_imp) finally show ?thesis . qed lemma borel_measurable_log[simp,intro]: - assumes f: "f \ borel_measurable M" and "1 < b" - shows "(\x. log b (f x)) \ borel_measurable M" - using measurable_comp[OF f borel_measurable_borel_log[OF `1 < b`]] - by (simp add: comp_def) + "f \ borel_measurable M \ (\x. log b (f x)) \ borel_measurable M" + unfolding log_def by auto lemma borel_measurable_real_floor: "(\x::real. real \x\) \ borel_measurable borel" @@ -967,45 +949,91 @@ subsection "Borel space on the extended reals" -lemma borel_measurable_ereal_borel: - "ereal \ borel_measurable borel" -proof (rule borel_measurableI) - fix X :: "ereal set" assume "open X" - then have "open (ereal -` X \ space borel)" - by (simp add: open_ereal_vimage) - then show "ereal -` X \ space borel \ sets borel" by auto -qed - lemma borel_measurable_ereal[simp, intro]: assumes f: "f \ borel_measurable M" shows "(\x. ereal (f x)) \ borel_measurable M" - using measurable_comp[OF f borel_measurable_ereal_borel] unfolding comp_def . + using continuous_on_ereal f by (rule borel_measurable_continuous_on) -lemma borel_measurable_real_of_ereal_borel: - "(real :: ereal \ real) \ borel_measurable borel" -proof (rule borel_measurableI) - fix B :: "real set" assume "open B" - have *: "ereal -` real -` (B - {0}) = B - {0}" by auto - have open_real: "open (real -` (B - {0}) :: ereal set)" - unfolding open_ereal_def * using `open B` by auto - show "(real -` B \ space borel :: ereal set) \ sets borel" - proof cases - assume "0 \ B" - then have *: "real -` B = real -` (B - {0}) \ {-\, \, 0::ereal}" - by (auto simp add: real_of_ereal_eq_0) - then show "(real -` B :: ereal set) \ space borel \ sets borel" - using open_real by auto - next - assume "0 \ B" - then have *: "(real -` B :: ereal set) = real -` (B - {0})" - by (auto simp add: real_of_ereal_eq_0) - then show "(real -` B :: ereal set) \ space borel \ sets borel" - using open_real by auto - qed +lemma borel_measurable_real_of_ereal[simp, intro]: + fixes f :: "'a \ ereal" + assumes f: "f \ borel_measurable M" + shows "(\x. real (f x)) \ borel_measurable M" +proof - + have "(\x. if f x \ UNIV - { \, - \ } then real (f x) else 0) \ borel_measurable M" + using continuous_on_real + by (rule borel_measurable_continuous_on_open[OF _ _ f]) auto + also have "(\x. if f x \ UNIV - { \, - \ } then real (f x) else 0) = (\x. real (f x))" + by auto + finally show ?thesis . +qed + +lemma borel_measurable_ereal_cases: + fixes f :: "'a \ ereal" + assumes f: "f \ borel_measurable M" + assumes H: "(\x. H (ereal (real (f x)))) \ borel_measurable M" + shows "(\x. H (f x)) \ borel_measurable M" +proof - + let ?F = "\x. if x \ f -` {\} then H \ else if x \ f -` {-\} then H (-\) else H (ereal (real (f x)))" + { fix x have "H (f x) = ?F x" by (cases "f x") auto } + moreover + have "?F \ borel_measurable M" + by (intro measurable_If_set f measurable_sets[OF f] H) auto + ultimately + show ?thesis by simp qed -lemma borel_measurable_real_of_ereal[simp, intro]: - assumes f: "f \ borel_measurable M" shows "(\x. real (f x :: ereal)) \ borel_measurable M" - using measurable_comp[OF f borel_measurable_real_of_ereal_borel] unfolding comp_def . +lemma + fixes f :: "'a \ ereal" assumes f[simp]: "f \ borel_measurable M" + shows borel_measurable_ereal_abs[intro, simp]: "(\x. \f x\) \ borel_measurable M" + and borel_measurable_ereal_inverse[simp, intro]: "(\x. inverse (f x) :: ereal) \ borel_measurable M" + and borel_measurable_uminus_ereal[intro]: "(\x. - f x :: ereal) \ borel_measurable M" + by (auto simp del: abs_real_of_ereal simp: borel_measurable_ereal_cases[OF f] measurable_If) + +lemma borel_measurable_uminus_eq_ereal[simp]: + "(\x. - f x :: ereal) \ borel_measurable M \ f \ borel_measurable M" (is "?l = ?r") +proof + assume ?l from borel_measurable_uminus_ereal[OF this] show ?r by simp +qed auto + +lemma sets_Collect_If_set: + assumes "A \ space M \ sets M" "{x \ space M. P x} \ sets M" "{x \ space M. Q x} \ sets M" + shows "{x \ space M. if x \ A then P x else Q x} \ sets M" +proof - + have *: "{x \ space M. if x \ A then P x else Q x} = + {x \ space M. if x \ A \ space M then P x else Q x}" by auto + show ?thesis unfolding * unfolding if_bool_eq_conj using assms + by (auto intro!: sets_Collect simp: Int_def conj_commute) +qed + +lemma set_Collect_ereal2: + fixes f g :: "'a \ ereal" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + assumes H: "{x \ space M. H (ereal (real (f x))) (ereal (real (g x)))} \ sets M" + "{x \ space M. H (-\) (ereal (real (g x)))} \ sets M" + "{x \ space M. H (\) (ereal (real (g x)))} \ sets M" + "{x \ space M. H (ereal (real (f x))) (-\)} \ sets M" + "{x \ space M. H (ereal (real (f x))) (\)} \ sets M" + shows "{x \ space M. H (f x) (g x)} \ sets M" +proof - + let ?G = "\y x. if x \ g -` {\} then H y \ else if x \ g -` {-\} then H y (-\) else H y (ereal (real (g x)))" + let ?F = "\x. if x \ f -` {\} then ?G \ x else if x \ f -` {-\} then ?G (-\) x else ?G (ereal (real (f x))) x" + { fix x have "H (f x) (g x) = ?F x" by (cases "f x" "g x" rule: ereal2_cases) auto } + moreover + have "{x \ space M. ?F x} \ sets M" + by (intro sets_Collect H measurable_sets[OF f] measurable_sets[OF g] sets_Collect_If_set) auto + ultimately + show ?thesis by simp +qed + +lemma + fixes f g :: "'a \ ereal" + assumes f: "f \ borel_measurable M" + assumes g: "g \ borel_measurable M" + shows borel_measurable_ereal_le[intro,simp]: "{x \ space M. f x \ g x} \ sets M" + and borel_measurable_ereal_less[intro,simp]: "{x \ space M. f x < g x} \ sets M" + and borel_measurable_ereal_eq[intro,simp]: "{w \ space M. f w = g w} \ sets M" + and borel_measurable_ereal_neq[intro,simp]: "{w \ space M. f w \ g w} \ sets M" + using f g by (auto simp: f g set_Collect_ereal2[OF f g] intro!: sets_Collect_neg) lemma borel_measurable_ereal_iff: shows "(\x. ereal (f x)) \ borel_measurable M \ f \ borel_measurable M" @@ -1029,52 +1057,6 @@ finally show "f \ borel_measurable M" . qed (auto intro: measurable_sets borel_measurable_real_of_ereal) -lemma less_eq_ge_measurable: - fixes f :: "'a \ 'c::linorder" - shows "f -` {a <..} \ space M \ sets M \ f -` {..a} \ space M \ sets M" -proof - assume "f -` {a <..} \ space M \ sets M" - moreover have "f -` {..a} \ space M = space M - f -` {a <..} \ space M" by auto - ultimately show "f -` {..a} \ space M \ sets M" by auto -next - assume "f -` {..a} \ space M \ sets M" - moreover have "f -` {a <..} \ space M = space M - f -` {..a} \ space M" by auto - ultimately show "f -` {a <..} \ space M \ sets M" by auto -qed - -lemma greater_eq_le_measurable: - fixes f :: "'a \ 'c::linorder" - shows "f -` {..< a} \ space M \ sets M \ f -` {a ..} \ space M \ sets M" -proof - assume "f -` {a ..} \ space M \ sets M" - moreover have "f -` {..< a} \ space M = space M - f -` {a ..} \ space M" by auto - ultimately show "f -` {..< a} \ space M \ sets M" by auto -next - assume "f -` {..< a} \ space M \ sets M" - moreover have "f -` {a ..} \ space M = space M - f -` {..< a} \ space M" by auto - ultimately show "f -` {a ..} \ space M \ sets M" by auto -qed - -lemma borel_measurable_uminus_borel_ereal: - "(uminus :: ereal \ ereal) \ borel_measurable borel" -proof (rule borel_measurableI) - fix X :: "ereal set" assume "open X" - have "uminus -` X = uminus ` X" by (force simp: image_iff) - then have "open (uminus -` X)" using `open X` ereal_open_uminus by auto - then show "uminus -` X \ space borel \ sets borel" by auto -qed - -lemma borel_measurable_uminus_ereal[intro]: - assumes "f \ borel_measurable M" - shows "(\x. - f x :: ereal) \ borel_measurable M" - using measurable_comp[OF assms borel_measurable_uminus_borel_ereal] by (simp add: comp_def) - -lemma borel_measurable_uminus_eq_ereal[simp]: - "(\x. - f x :: ereal) \ borel_measurable M \ f \ borel_measurable M" (is "?l = ?r") -proof - assume ?l from borel_measurable_uminus_ereal[OF this] show ?r by simp -qed auto - lemma borel_measurable_eq_atMost_ereal: fixes f :: "'a \ ereal" shows "f \ borel_measurable M \ (\a. f -` {..a} \ space M \ sets M)" @@ -1118,94 +1100,88 @@ then show "f \ borel_measurable M" by simp qed (simp add: measurable_sets) +lemma greater_eq_le_measurable: + fixes f :: "'a \ 'c::linorder" + shows "f -` {..< a} \ space M \ sets M \ f -` {a ..} \ space M \ sets M" +proof + assume "f -` {a ..} \ space M \ sets M" + moreover have "f -` {..< a} \ space M = space M - f -` {a ..} \ space M" by auto + ultimately show "f -` {..< a} \ space M \ sets M" by auto +next + assume "f -` {..< a} \ space M \ sets M" + moreover have "f -` {a ..} \ space M = space M - f -` {..< a} \ space M" by auto + ultimately show "f -` {a ..} \ space M \ sets M" by auto +qed + lemma borel_measurable_ereal_iff_less: "(f::'a \ ereal) \ borel_measurable M \ (\a. f -` {..< a} \ space M \ sets M)" unfolding borel_measurable_eq_atLeast_ereal greater_eq_le_measurable .. +lemma less_eq_ge_measurable: + fixes f :: "'a \ 'c::linorder" + shows "f -` {a <..} \ space M \ sets M \ f -` {..a} \ space M \ sets M" +proof + assume "f -` {a <..} \ space M \ sets M" + moreover have "f -` {..a} \ space M = space M - f -` {a <..} \ space M" by auto + ultimately show "f -` {..a} \ space M \ sets M" by auto +next + assume "f -` {..a} \ space M \ sets M" + moreover have "f -` {a <..} \ space M = space M - f -` {..a} \ space M" by auto + ultimately show "f -` {a <..} \ space M \ sets M" by auto +qed + lemma borel_measurable_ereal_iff_ge: "(f::'a \ ereal) \ borel_measurable M \ (\a. f -` {a <..} \ space M \ sets M)" unfolding borel_measurable_eq_atMost_ereal less_eq_ge_measurable .. -lemma borel_measurable_ereal_eq_const: - fixes f :: "'a \ ereal" assumes "f \ borel_measurable M" - shows "{x\space M. f x = c} \ sets M" -proof - - have "{x\space M. f x = c} = (f -` {c} \ space M)" by auto - then show ?thesis using assms by (auto intro!: measurable_sets) -qed - -lemma borel_measurable_ereal_neq_const: - fixes f :: "'a \ ereal" assumes "f \ borel_measurable M" - shows "{x\space M. f x \ c} \ sets M" -proof - - have "{x\space M. f x \ c} = space M - (f -` {c} \ space M)" by auto - then show ?thesis using assms by (auto intro!: measurable_sets) -qed - -lemma borel_measurable_ereal_le[intro,simp]: - fixes f g :: "'a \ ereal" +lemma borel_measurable_ereal2: + fixes f g :: "'a \ ereal" assumes f: "f \ borel_measurable M" assumes g: "g \ borel_measurable M" - shows "{x \ space M. f x \ g x} \ sets M" + assumes H: "(\x. H (ereal (real (f x))) (ereal (real (g x)))) \ borel_measurable M" + "(\x. H (-\) (ereal (real (g x)))) \ borel_measurable M" + "(\x. H (\) (ereal (real (g x)))) \ borel_measurable M" + "(\x. H (ereal (real (f x))) (-\)) \ borel_measurable M" + "(\x. H (ereal (real (f x))) (\)) \ borel_measurable M" + shows "(\x. H (f x) (g x)) \ borel_measurable M" proof - - have "{x \ space M. f x \ g x} = - {x \ space M. real (f x) \ real (g x)} - (f -` {\, -\} \ space M \ g -` {\, -\} \ space M) \ - f -` {-\} \ space M \ g -` {\} \ space M" (is "?l = ?r") - proof (intro set_eqI) - fix x show "x \ ?l \ x \ ?r" by (cases rule: ereal2_cases[of "f x" "g x"]) auto - qed - with f g show ?thesis by (auto intro!: Un simp: measurable_sets) + let ?G = "\y x. if x \ g -` {\} then H y \ else if x \ g -` {-\} then H y (-\) else H y (ereal (real (g x)))" + let ?F = "\x. if x \ f -` {\} then ?G \ x else if x \ f -` {-\} then ?G (-\) x else ?G (ereal (real (f x))) x" + { fix x have "H (f x) (g x) = ?F x" by (cases "f x" "g x" rule: ereal2_cases) auto } + moreover + have "?F \ borel_measurable M" + by (intro measurable_If_set measurable_sets[OF f] measurable_sets[OF g] H) auto + ultimately + show ?thesis by simp qed -lemma borel_measurable_ereal_less[intro,simp]: - fixes f :: "'a \ ereal" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "{x \ space M. f x < g x} \ sets M" -proof - - have "{x \ space M. f x < g x} = space M - {x \ space M. g x \ f x}" by auto - then show ?thesis using g f by auto -qed - -lemma borel_measurable_ereal_eq[intro,simp]: - fixes f :: "'a \ ereal" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "{w \ space M. f w = g w} \ sets M" -proof - - have "{x \ space M. f x = g x} = {x \ space M. g x \ f x} \ {x \ space M. f x \ g x}" by auto - then show ?thesis using g f by auto -qed - -lemma borel_measurable_ereal_neq[intro,simp]: - fixes f :: "'a \ ereal" - assumes f: "f \ borel_measurable M" - assumes g: "g \ borel_measurable M" - shows "{w \ space M. f w \ g w} \ sets M" -proof - - have "{w \ space M. f w \ g w} = space M - {w \ space M. f w = g w}" by auto - thus ?thesis using f g by auto -qed +lemma + fixes f :: "'a \ ereal" assumes f: "f \ borel_measurable M" + shows borel_measurable_ereal_eq_const: "{x\space M. f x = c} \ sets M" + and borel_measurable_ereal_neq_const: "{x\space M. f x \ c} \ sets M" + using f by auto lemma split_sets: "{x\space M. P x \ Q x} = {x\space M. P x} \ {x\space M. Q x}" "{x\space M. P x \ Q x} = {x\space M. P x} \ {x\space M. Q x}" by auto -lemma borel_measurable_ereal_add[intro, simp]: +lemma fixes f :: "'a \ ereal" - assumes "f \ borel_measurable M" "g \ borel_measurable M" - shows "(\x. f x + g x) \ borel_measurable M" -proof - - { fix x assume "x \ space M" then have "f x + g x = - (if f x = \ \ g x = \ then \ - else if f x = -\ \ g x = -\ then -\ - else ereal (real (f x) + real (g x)))" - by (cases rule: ereal2_cases[of "f x" "g x"]) auto } - with assms show ?thesis - by (auto cong: measurable_cong simp: split_sets - intro!: Un measurable_If measurable_sets) -qed + assumes [simp]: "f \ borel_measurable M" "g \ borel_measurable M" + shows borel_measurable_ereal_add[intro, simp]: "(\x. f x + g x) \ borel_measurable M" + and borel_measurable_ereal_times[intro, simp]: "(\x. f x * g x) \ borel_measurable M" + and borel_measurable_ereal_min[simp, intro]: "(\x. min (g x) (f x)) \ borel_measurable M" + and borel_measurable_ereal_max[simp, intro]: "(\x. max (g x) (f x)) \ borel_measurable M" + by (auto simp add: borel_measurable_ereal2 measurable_If min_def max_def) + +lemma + fixes f g :: "'a \ ereal" + assumes "f \ borel_measurable M" + assumes "g \ borel_measurable M" + shows borel_measurable_ereal_diff[simp, intro]: "(\x. f x - g x) \ borel_measurable M" + and borel_measurable_ereal_divide[simp, intro]: "(\x. f x / g x) \ borel_measurable M" + unfolding minus_ereal_def divide_ereal_def using assms by auto lemma borel_measurable_ereal_setsum[simp, intro]: fixes f :: "'c \ 'a \ ereal" @@ -1215,39 +1191,7 @@ assume "finite S" thus ?thesis using assms by induct auto -qed (simp add: borel_measurable_const) - -lemma borel_measurable_ereal_abs[intro, simp]: - fixes f :: "'a \ ereal" assumes "f \ borel_measurable M" - shows "(\x. \f x\) \ borel_measurable M" -proof - - { fix x have "\f x\ = (if 0 \ f x then f x else - f x)" by auto } - then show ?thesis using assms by (auto intro!: measurable_If) -qed - -lemma borel_measurable_ereal_times[intro, simp]: - fixes f :: "'a \ ereal" assumes "f \ borel_measurable M" "g \ borel_measurable M" - shows "(\x. f x * g x) \ borel_measurable M" -proof - - { fix f g :: "'a \ ereal" - assume b: "f \ borel_measurable M" "g \ borel_measurable M" - and pos: "\x. 0 \ f x" "\x. 0 \ g x" - { fix x have *: "f x * g x = (if f x = 0 \ g x = 0 then 0 - else if f x = \ \ g x = \ then \ - else ereal (real (f x) * real (g x)))" - apply (cases rule: ereal2_cases[of "f x" "g x"]) - using pos[of x] by auto } - with b have "(\x. f x * g x) \ borel_measurable M" - by (auto cong: measurable_cong simp: split_sets - intro!: Un measurable_If measurable_sets) } - note pos_times = this - have *: "(\x. f x * g x) = - (\x. if 0 \ f x \ 0 \ g x \ f x < 0 \ g x < 0 then \f x\ * \g x\ else - (\f x\ * \g x\))" - by (auto simp: fun_eq_iff) - show ?thesis using assms unfolding * - by (intro measurable_If pos_times borel_measurable_uminus_ereal) - (auto simp: split_sets intro!: Int) -qed +qed simp lemma borel_measurable_ereal_setprod[simp, intro]: fixes f :: "'c \ 'a \ ereal" @@ -1258,20 +1202,6 @@ thus ?thesis using assms by induct auto qed simp -lemma borel_measurable_ereal_min[simp, intro]: - fixes f g :: "'a \ ereal" - assumes "f \ borel_measurable M" - assumes "g \ borel_measurable M" - shows "(\x. min (g x) (f x)) \ borel_measurable M" - using assms unfolding min_def by (auto intro!: measurable_If) - -lemma borel_measurable_ereal_max[simp, intro]: - fixes f g :: "'a \ ereal" - assumes "f \ borel_measurable M" - and "g \ borel_measurable M" - shows "(\x. max (g x) (f x)) \ borel_measurable M" - using assms unfolding max_def by (auto intro!: measurable_If) - lemma borel_measurable_SUP[simp, intro]: fixes f :: "'d\countable \ 'a \ ereal" assumes "\i. i \ A \ f i \ borel_measurable M" @@ -1298,38 +1228,24 @@ using assms by auto qed -lemma borel_measurable_liminf[simp, intro]: - fixes f :: "nat \ 'a \ ereal" - assumes "\i. f i \ borel_measurable M" - shows "(\x. liminf (\i. f i x)) \ borel_measurable M" - unfolding liminf_SUPR_INFI using assms by auto - -lemma borel_measurable_limsup[simp, intro]: +lemma fixes f :: "nat \ 'a \ ereal" assumes "\i. f i \ borel_measurable M" - shows "(\x. limsup (\i. f i x)) \ borel_measurable M" - unfolding limsup_INFI_SUPR using assms by auto - -lemma borel_measurable_ereal_diff[simp, intro]: - fixes f g :: "'a \ ereal" - assumes "f \ borel_measurable M" - assumes "g \ borel_measurable M" - shows "(\x. f x - g x) \ borel_measurable M" - unfolding minus_ereal_def using assms by auto + shows borel_measurable_liminf[simp, intro]: "(\x. liminf (\i. f i x)) \ borel_measurable M" + and borel_measurable_limsup[simp, intro]: "(\x. limsup (\i. f i x)) \ borel_measurable M" + unfolding liminf_SUPR_INFI limsup_INFI_SUPR using assms by auto -lemma borel_measurable_ereal_inverse[simp, intro]: - assumes f: "f \ borel_measurable M" shows "(\x. inverse (f x) :: ereal) \ borel_measurable M" +lemma borel_measurable_ereal_LIMSEQ: + fixes u :: "nat \ 'a \ ereal" + assumes u': "\x. x \ space M \ (\i. u i x) ----> u' x" + and u: "\i. u i \ borel_measurable M" + shows "u' \ borel_measurable M" proof - - { fix x have "inverse (f x) = (if f x = 0 then \ else ereal (inverse (real (f x))))" - by (cases "f x") auto } - with f show ?thesis - by (auto intro!: measurable_If) + have "\x. x \ space M \ u' x = liminf (\n. u n x)" + using u' by (simp add: lim_imp_Liminf[symmetric]) + then show ?thesis by (simp add: u cong: measurable_cong) qed -lemma borel_measurable_ereal_divide[simp, intro]: - "f \ borel_measurable M \ g \ borel_measurable M \ (\x. f x / g x :: ereal) \ borel_measurable M" - unfolding divide_ereal_def by auto - lemma borel_measurable_psuminf[simp, intro]: fixes f :: "nat \ 'a \ ereal" assumes "\i. f i \ borel_measurable M" and pos: "\i x. x \ space M \ 0 \ f i x" @@ -1354,4 +1270,38 @@ ultimately show ?thesis by (simp cong: measurable_cong add: borel_measurable_ereal_iff) qed -end +lemma sets_Collect_Cauchy: + fixes f :: "nat \ 'a => real" + assumes f: "\i. f i \ borel_measurable M" + shows "{x\space M. Cauchy (\i. f i x)} \ sets M" + unfolding Cauchy_iff2 using f by (auto intro!: sets_Collect) + +lemma borel_measurable_lim: + fixes f :: "nat \ 'a \ real" + assumes f: "\i. f i \ borel_measurable M" + shows "(\x. lim (\i. f i x)) \ borel_measurable M" +proof - + have *: "\x. lim (\i. f i x) = + (if Cauchy (\i. f i x) then lim (\i. if Cauchy (\i. f i x) then f i x else 0) else (THE x. False))" + by (auto simp: lim_def convergent_eq_cauchy[symmetric]) + { fix x have "convergent (\i. if Cauchy (\i. f i x) then f i x else 0)" + by (cases "Cauchy (\i. f i x)") + (auto simp add: convergent_eq_cauchy[symmetric] convergent_def) } + note convergent = this + show ?thesis + unfolding * + apply (intro measurable_If sets_Collect_Cauchy f borel_measurable_const) + apply (rule borel_measurable_LIMSEQ) + apply (rule convergent_LIMSEQ_iff[THEN iffD1, OF convergent]) + apply (intro measurable_If sets_Collect_Cauchy f borel_measurable_const) + done +qed + +lemma borel_measurable_suminf: + fixes f :: "nat \ 'a \ real" + assumes f: "\i. f i \ borel_measurable M" + shows "(\x. suminf (\i. f i x)) \ borel_measurable M" + unfolding suminf_def sums_def[abs_def] lim_def[symmetric] + by (simp add: f borel_measurable_lim) + +end