# HG changeset patch # User paulson # Date 1568375196 -3600 # Node ID ae37b8fbf023ca21536a5dac1d2db2c38ca988e3 # Parent 0fec12eabad0f2459e087d3c6a545626a00455f8 New theory Equivalence_Measurable_On_Borel, with the HOL Light notion of measurable_on and its equivalence to ours diff -r 0fec12eabad0 -r ae37b8fbf023 src/HOL/Analysis/Analysis.thy --- a/src/HOL/Analysis/Analysis.thy Thu Sep 12 17:17:52 2019 +0200 +++ b/src/HOL/Analysis/Analysis.thy Fri Sep 13 12:46:36 2019 +0100 @@ -16,9 +16,9 @@ Ball_Volume Integral_Test Improper_Integral + Equivalence_Measurable_On_Borel (* Unsorted *) Lebesgue_Integral_Substitution - Improper_Integral Embed_Measure Complete_Measure Radon_Nikodym diff -r 0fec12eabad0 -r ae37b8fbf023 src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy --- a/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy Thu Sep 12 17:17:52 2019 +0200 +++ b/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy Fri Sep 13 12:46:36 2019 +0100 @@ -4479,6 +4479,22 @@ unfolding has_bochner_integral_iff lebesgue_integrable_real_affine_iff by (simp_all add: lebesgue_integral_real_affine[symmetric] divideR_right cong: conj_cong) +lemma has_bochner_integral_reflect_real_lemma[intro]: + fixes f :: "real \ 'a::euclidean_space" + assumes "has_bochner_integral (lebesgue_on {a..b}) f i" + shows "has_bochner_integral (lebesgue_on {-b..-a}) (\x. f(-x)) i" +proof - + have eq: "indicat_real {a..b} (- x) *\<^sub>R f(- x) = indicat_real {- b..- a} x *\<^sub>R f(- x)" for x + by (auto simp: indicator_def) + have i: "has_bochner_integral lebesgue (\x. indicator {a..b} x *\<^sub>R f x) i" + using assms by (auto simp: has_bochner_integral_restrict_space) + then have "has_bochner_integral lebesgue (\x. indicator {-b..-a} x *\<^sub>R f(-x)) i" + using has_bochner_integral_lebesgue_real_affine_iff [of "-1" "(\x. indicator {a..b} x *\<^sub>R f x)" i 0] + by (auto simp: eq) + then show ?thesis + by (auto simp: has_bochner_integral_restrict_space) +qed + subsection\More results on integrability\ lemma integrable_on_all_intervals_UNIV: diff -r 0fec12eabad0 -r ae37b8fbf023 src/HOL/Analysis/Equivalence_Measurable_On_Borel.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Analysis/Equivalence_Measurable_On_Borel.thy Fri Sep 13 12:46:36 2019 +0100 @@ -0,0 +1,1603 @@ +(* Title: HOL/Analysis/Equivalence_Measurable_On_Borel + Author: LC Paulson (some material ported from HOL Light) +*) + +section\Equivalence Between Classical Borel Measurability and HOL Light's\ + +theory Equivalence_Measurable_On_Borel + imports Equivalence_Lebesgue_Henstock_Integration Improper_Integral Continuous_Extension +begin + +(*Borrowed from Ergodic_Theory/SG_Library_Complement*) +abbreviation sym_diff :: "'a set \ 'a set \ 'a set" where + "sym_diff A B \ ((A - B) \ (B-A))" + +subsection\Austin's Lemma\ + +lemma Austin_Lemma: + fixes \ :: "'a::euclidean_space set set" + assumes "finite \" and \: "\D. D \ \ \ \k a b. D = cbox a b \ (\i \ Basis. b\i - a\i = k)" + obtains \ where "\ \ \" "pairwise disjnt \" + "measure lebesgue (\\) \ measure lebesgue (\\) / 3 ^ (DIM('a))" + using assms +proof (induction "card \" arbitrary: \ thesis rule: less_induct) + case less + show ?case + proof (cases "\ = {}") + case True + then show thesis + using less by auto + next + case False + then have "Max (Sigma_Algebra.measure lebesgue ` \) \ Sigma_Algebra.measure lebesgue ` \" + using Max_in finite_imageI \finite \\ by blast + then obtain D where "D \ \" and "measure lebesgue D = Max (measure lebesgue ` \)" + by auto + then have D: "\C. C \ \ \ measure lebesgue C \ measure lebesgue D" + by (simp add: \finite \\) + let ?\ = "{C. C \ \ - {D} \ disjnt C D}" + obtain \' where \'sub: "\' \ ?\" and \'dis: "pairwise disjnt \'" + and \'m: "measure lebesgue (\\') \ measure lebesgue (\?\) / 3 ^ (DIM('a))" + proof (rule less.hyps) + have *: "?\ \ \" + using \D \ \\ by auto + then show "card ?\ < card \" "finite ?\" + by (auto simp: \finite \\ psubset_card_mono) + show "\k a b. D = cbox a b \ (\i\Basis. b \ i - a \ i = k)" if "D \ ?\" for D + using less.prems(3) that by auto + qed + then have [simp]: "\\' - D = \\'" + by (auto simp: disjnt_iff) + show ?thesis + proof (rule less.prems) + show "insert D \' \ \" + using \'sub \D \ \\ by blast + show "disjoint (insert D \')" + using \'dis \'sub by (fastforce simp add: pairwise_def disjnt_sym) + obtain a3 b3 where m3: "content (cbox a3 b3) = 3 ^ DIM('a) * measure lebesgue D" + and sub3: "\C. \C \ \; \ disjnt C D\ \ C \ cbox a3 b3" + proof - + obtain k a b where ab: "D = cbox a b" and k: "\i. i \ Basis \ b\i - a\i = k" + using less.prems \D \ \\ by blast + then have eqk: "\i. i \ Basis \ a \ i \ b \ i \ k \ 0" + by force + show thesis + proof + let ?a = "(a + b) /\<^sub>R 2 - (3/2) *\<^sub>R (b - a)" + let ?b = "(a + b) /\<^sub>R 2 + (3/2) *\<^sub>R (b - a)" + have eq: "(\i\Basis. b \ i * 3 - a \ i * 3) = (\i\Basis. b \ i - a \ i) * 3 ^ DIM('a)" + by (simp add: comm_monoid_mult_class.prod.distrib flip: left_diff_distrib inner_diff_left) + show "content (cbox ?a ?b) = 3 ^ DIM('a) * measure lebesgue D" + by (simp add: content_cbox_if box_eq_empty algebra_simps eq ab k) + show "C \ cbox ?a ?b" if "C \ \" and CD: "\ disjnt C D" for C + proof - + obtain k' a' b' where ab': "C = cbox a' b'" and k': "\i. i \ Basis \ b'\i - a'\i = k'" + using less.prems \C \ \\ by blast + then have eqk': "\i. i \ Basis \ a' \ i \ b' \ i \ k' \ 0" + by force + show ?thesis + proof (clarsimp simp add: disjoint_interval disjnt_def ab ab' not_less subset_box algebra_simps) + show "a \ i * 2 \ a' \ i + b \ i \ a \ i + b' \ i \ b \ i * 2" + if * [rule_format]: "\j\Basis. a' \ j \ b' \ j" and "i \ Basis" for i + proof - + have "a' \ i \ b' \ i \ a \ i \ b \ i \ a \ i \ b' \ i \ a' \ i \ b \ i" + using \i \ Basis\ CD by (simp_all add: disjoint_interval disjnt_def ab ab' not_less) + then show ?thesis + using D [OF \C \ \\] \i \ Basis\ + apply (simp add: ab ab' k k' eqk eqk' content_cbox_cases) + using k k' by fastforce + qed + qed + qed + qed + qed + have \lm: "\D. D \ \ \ D \ lmeasurable" + using less.prems(3) by blast + have "measure lebesgue (\\) \ measure lebesgue (cbox a3 b3 \ (\\ - cbox a3 b3))" + proof (rule measure_mono_fmeasurable) + show "\\ \ sets lebesgue" + using \lm \finite \\ by blast + show "cbox a3 b3 \ (\\ - cbox a3 b3) \ lmeasurable" + by (simp add: \lm fmeasurable.Un fmeasurable.finite_Union less.prems(2) subset_eq) + qed auto + also have "\ = content (cbox a3 b3) + measure lebesgue (\\ - cbox a3 b3)" + by (simp add: \lm fmeasurable.finite_Union less.prems(2) measure_Un2 subsetI) + also have "\ \ (measure lebesgue D + measure lebesgue (\\')) * 3 ^ DIM('a)" + proof - + have "(\\ - cbox a3 b3) \ \?\" + using sub3 by fastforce + then have "measure lebesgue (\\ - cbox a3 b3) \ measure lebesgue (\?\)" + proof (rule measure_mono_fmeasurable) + show "\ \ - cbox a3 b3 \ sets lebesgue" + by (simp add: \lm fmeasurableD less.prems(2) sets.Diff sets.finite_Union subsetI) + show "\ {C \ \ - {D}. disjnt C D} \ lmeasurable" + using \lm less.prems(2) by auto + qed + then have "measure lebesgue (\\ - cbox a3 b3) / 3 ^ DIM('a) \ measure lebesgue (\ \')" + using \'m by (simp add: divide_simps) + then show ?thesis + by (simp add: m3 field_simps) + qed + also have "\ \ measure lebesgue (\(insert D \')) * 3 ^ DIM('a)" + proof (simp add: \lm \D \ \\) + show "measure lebesgue D + measure lebesgue (\\') \ measure lebesgue (D \ \ \')" + proof (subst measure_Un2) + show "\ \' \ lmeasurable" + by (meson \lm \insert D \' \ \\ fmeasurable.finite_Union less.prems(2) finite_subset subset_eq subset_insertI) + show "measure lebesgue D + measure lebesgue (\ \') \ measure lebesgue D + measure lebesgue (\ \' - D)" + using \insert D \' \ \\ infinite_super less.prems(2) by force + qed (simp add: \lm \D \ \\) + qed + finally show "measure lebesgue (\\) / 3 ^ DIM('a) \ measure lebesgue (\(insert D \'))" + by (simp add: divide_simps) + qed + qed +qed + + +subsection\A differentiability-like property of the indefinite integral. \ + +proposition integrable_ccontinuous_explicit: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "\a b::'a. f integrable_on cbox a b" + obtains N where + "negligible N" + "\x e. \x \ N; 0 < e\ \ + \d>0. \h. 0 < h \ h < d \ + norm(integral (cbox x (x + h *\<^sub>R One)) f /\<^sub>R h ^ DIM('a) - f x) < e" +proof - + define BOX where "BOX \ \h. \x::'a. cbox x (x + h *\<^sub>R One)" + define BOX2 where "BOX2 \ \h. \x::'a. cbox (x - h *\<^sub>R One) (x + h *\<^sub>R One)" + define i where "i \ \h x. integral (BOX h x) f /\<^sub>R h ^ DIM('a)" + define \ where "\ \ \x r. \d>0. \h. 0 < h \ h < d \ r \ norm(i h x - f x)" + let ?N = "{x. \e>0. \ x e}" + have "\N. negligible N \ (\x e. x \ N \ 0 < e \ \ \ x e)" + proof (rule exI ; intro conjI allI impI) + let ?M = "\n. {x. \ x (inverse(real n + 1))}" + have "negligible ({x. \ x \} \ cbox a b)" + if "\ > 0" for a b \ + proof (cases "negligible(cbox a b)") + case True + then show ?thesis + by (simp add: negligible_Int) + next + case False + then have "box a b \ {}" + by (simp add: negligible_interval) + then have ab: "\i. i \ Basis \ a\i < b\i" + by (simp add: box_ne_empty) + show ?thesis + unfolding negligible_outer_le + proof (intro allI impI) + fix e::real + let ?ee = "(e * \) / 2 / 6 ^ (DIM('a))" + assume "e > 0" + then have gt0: "?ee > 0" + using \\ > 0\ by auto + have f': "f integrable_on cbox (a - One) (b + One)" + using assms by blast + obtain \ where "gauge \" + and \: "\p. \p tagged_partial_division_of (cbox (a - One) (b + One)); \ fine p\ + \ (\(x, k)\p. norm (content k *\<^sub>R f x - integral k f)) < ?ee" + using Henstock_lemma [OF f' gt0] that by auto + let ?E = "{x. x \ cbox a b \ \ x \}" + have "\h>0. BOX h x \ \ x \ + BOX h x \ cbox (a - One) (b + One) \ \ \ norm (i h x - f x)" + if "x \ cbox a b" "\ x \" for x + proof - + obtain d where "d > 0" and d: "ball x d \ \ x" + using gaugeD [OF \gauge \\, of x] openE by blast + then obtain h where "0 < h" "h < 1" and hless: "h < d / real DIM('a)" + and mule: "\ \ norm (i h x - f x)" + using \\ x \\ [unfolded \_def, rule_format, of "min 1 (d / DIM('a))"] + by auto + show ?thesis + proof (intro exI conjI) + show "0 < h" "\ \ norm (i h x - f x)" by fact+ + have "BOX h x \ ball x d" + proof (clarsimp simp: BOX_def mem_box dist_norm algebra_simps) + fix y + assume "\i\Basis. x \ i \ y \ i \ y \ i \ h + x \ i" + then have lt: "\(x - y) \ i\ < d / real DIM('a)" if "i \ Basis" for i + using hless that by (force simp: inner_diff_left) + have "norm (x - y) \ (\i\Basis. \(x - y) \ i\)" + using norm_le_l1 by blast + also have "\ < d" + using sum_bounded_above_strict [of Basis "\i. \(x - y) \ i\" "d / DIM('a)", OF lt] + by auto + finally show "norm (x - y) < d" . + qed + with d show "BOX h x \ \ x" + by blast + show "BOX h x \ cbox (a - One) (b + One)" + using that \h < 1\ + by (force simp: BOX_def mem_box algebra_simps intro: subset_box_imp) + qed + qed + then obtain \ where h0: "\x. x \ ?E \ \ x > 0" + and BOX_\: "\x. x \ ?E \ BOX (\ x) x \ \ x" + and "\x. x \ ?E \ BOX (\ x) x \ cbox (a - One) (b + One) \ \ \ norm (i (\ x) x - f x)" + by simp metis + then have BOX_cbox: "\x. x \ ?E \ BOX (\ x) x \ cbox (a - One) (b + One)" + and \_le: "\x. x \ ?E \ \ \ norm (i (\ x) x - f x)" + by blast+ + define \' where "\' \ \x. if x \ cbox a b \ \ x \ then ball x (\ x) else \ x" + have "gauge \'" + using \gauge \\ by (auto simp: h0 gauge_def \'_def) + obtain \ where "countable \" + and \: "\\ \ cbox a b" + "\K. K \ \ \ interior K \ {} \ (\c d. K = cbox c d)" + and Dcovered: "\K. K \ \ \ \x. x \ cbox a b \ \ x \ \ x \ K \ K \ \' x" + and subUD: "?E \ \\" + by (rule covering_lemma [of ?E a b \']) (simp_all add: Bex_def \box a b \ {}\ \gauge \'\) + then have "\ \ sets lebesgue" + by fastforce + show "\T. {x. \ x \} \ cbox a b \ T \ T \ lmeasurable \ measure lebesgue T \ e" + proof (intro exI conjI) + show "{x. \ x \} \ cbox a b \ \\" + apply auto + using subUD by auto + have mUE: "measure lebesgue (\ \) \ measure lebesgue (cbox a b)" + if "\ \ \" "finite \" for \ + proof (rule measure_mono_fmeasurable) + show "\ \ \ cbox a b" + using \(1) that(1) by blast + show "\ \ \ sets lebesgue" + by (metis \(2) fmeasurable.finite_Union fmeasurableD lmeasurable_cbox subset_eq that) + qed auto + then show "\\ \ lmeasurable" + by (metis \(2) \countable \\ fmeasurable_Union_bound lmeasurable_cbox) + then have leab: "measure lebesgue (\\) \ measure lebesgue (cbox a b)" + by (meson \(1) fmeasurableD lmeasurable_cbox measure_mono_fmeasurable) + obtain \ where "\ \ \" "finite \" + and \: "measure lebesgue (\\) \ 2 * measure lebesgue (\\)" + proof (cases "measure lebesgue (\\) = 0") + case True + then show ?thesis + by (force intro: that [where \ = "{}"]) + next + case False + obtain \ where "\ \ \" "finite \" + and \: "measure lebesgue (\\)/2 < measure lebesgue (\\)" + proof (rule measure_countable_Union_approachable [of \ "measure lebesgue (\\) / 2" "content (cbox a b)"]) + show "countable \" + by fact + show "0 < measure lebesgue (\ \) / 2" + using False by (simp add: zero_less_measure_iff) + show Dlm: "D \ lmeasurable" if "D \ \" for D + using \(2) that by blast + show "measure lebesgue (\ \) \ content (cbox a b)" + if "\ \ \" "finite \" for \ + proof - + have "measure lebesgue (\ \) \ measure lebesgue (\\)" + proof (rule measure_mono_fmeasurable) + show "\ \ \ \ \" + by (simp add: Sup_subset_mono \\ \ \\) + show "\ \ \ sets lebesgue" + by (meson Dlm fmeasurableD sets.finite_Union subset_eq that) + show "\ \ \ lmeasurable" + by fact + qed + also have "\ \ measure lebesgue (cbox a b)" + proof (rule measure_mono_fmeasurable) + show "\ \ \ sets lebesgue" + by (simp add: \\ \ \ lmeasurable\ fmeasurableD) + qed (auto simp:\(1)) + finally show ?thesis + by simp + qed + qed auto + then show ?thesis + using that by auto + qed + obtain tag where tag_in_E: "\D. D \ \ \ tag D \ ?E" + and tag_in_self: "\D. D \ \ \ tag D \ D" + and tag_sub: "\D. D \ \ \ D \ \' (tag D)" + using Dcovered by simp metis + then have sub_ball_tag: "\D. D \ \ \ D \ ball (tag D) (\ (tag D))" + by (simp add: \'_def) + define \ where "\ \ \D. BOX (\(tag D)) (tag D)" + define \2 where "\2 \ \D. BOX2 (\(tag D)) (tag D)" + obtain \ where "\ \ \2 ` \" "pairwise disjnt \" + "measure lebesgue (\\) \ measure lebesgue (\(\2`\)) / 3 ^ (DIM('a))" + proof (rule Austin_Lemma) + show "finite (\2`\)" + using \finite \\ by blast + have "\k a b. \2 D = cbox a b \ (\i\Basis. b \ i - a \ i = k)" if "D \ \" for D + apply (rule_tac x="2 * \(tag D)" in exI) + apply (rule_tac x="tag D - \(tag D) *\<^sub>R One" in exI) + apply (rule_tac x="tag D + \(tag D) *\<^sub>R One" in exI) + using that + apply (auto simp: \2_def BOX2_def algebra_simps) + done + then show "\D. D \ \2 ` \ \ \k a b. D = cbox a b \ (\i\Basis. b \ i - a \ i = k)" + by blast + qed auto + then obtain \ where "\ \ \" and disj: "pairwise disjnt (\2 ` \)" + and "measure lebesgue (\(\2 ` \)) \ measure lebesgue (\(\2`\)) / 3 ^ (DIM('a))" + unfolding \2_def subset_image_iff + by (meson empty_subsetI equals0D pairwise_imageI) + moreover + have "measure lebesgue (\(\2 ` \)) * 3 ^ DIM('a) \ e/2" + proof - + have "finite \" + using \finite \\ \\ \ \\ infinite_super by blast + have BOX2_m: "\x. x \ tag ` \ \ BOX2 (\ x) x \ lmeasurable" + by (auto simp: BOX2_def) + have BOX_m: "\x. x \ tag ` \ \ BOX (\ x) x \ lmeasurable" + by (auto simp: BOX_def) + have BOX_sub: "BOX (\ x) x \ BOX2 (\ x) x" for x + by (auto simp: BOX_def BOX2_def subset_box algebra_simps) + have DISJ2: "BOX2 (\ (tag X)) (tag X) \ BOX2 (\ (tag Y)) (tag Y) = {}" + if "X \ \" "Y \ \" "tag X \ tag Y" for X Y + proof - + obtain i where i: "i \ Basis" "tag X \ i \ tag Y \ i" + using \tag X \ tag Y\ by (auto simp: euclidean_eq_iff [of "tag X"]) + have XY: "X \ \" "Y \ \" + using \\ \ \\ \\ \ \\ that by auto + then have "0 \ \ (tag X)" "0 \ \ (tag Y)" + by (meson h0 le_cases not_le tag_in_E)+ + with XY i have "BOX2 (\ (tag X)) (tag X) \ BOX2 (\ (tag Y)) (tag Y)" + unfolding eq_iff + by (fastforce simp add: BOX2_def subset_box algebra_simps) + then show ?thesis + using disj that by (auto simp: pairwise_def disjnt_def \2_def) + qed + then have BOX2_disj: "pairwise (\x y. negligible (BOX2 (\ x) x \ BOX2 (\ y) y)) (tag ` \)" + by (simp add: pairwise_imageI) + then have BOX_disj: "pairwise (\x y. negligible (BOX (\ x) x \ BOX (\ y) y)) (tag ` \)" + proof (rule pairwise_mono) + show "negligible (BOX (\ x) x \ BOX (\ y) y)" + if "negligible (BOX2 (\ x) x \ BOX2 (\ y) y)" for x y + by (metis (no_types, hide_lams) that Int_mono negligible_subset BOX_sub) + qed auto + + have eq: "\box. (\D. box (\ (tag D)) (tag D)) ` \ = (\t. box (\ t) t) ` tag ` \" + by (simp add: image_comp) + have "measure lebesgue (BOX2 (\ t) t) * 3 ^ DIM('a) + = measure lebesgue (BOX (\ t) t) * (2*3) ^ DIM('a)" + if "t \ tag ` \" for t + proof - + have "content (cbox (t - \ t *\<^sub>R One) (t + \ t *\<^sub>R One)) + = content (cbox t (t + \ t *\<^sub>R One)) * 2 ^ DIM('a)" + using that by (simp add: algebra_simps content_cbox_if box_eq_empty) + then show ?thesis + by (simp add: BOX2_def BOX_def flip: power_mult_distrib) + qed + then have "measure lebesgue (\(\2 ` \)) * 3 ^ DIM('a) = measure lebesgue (\(\ ` \)) * 6 ^ DIM('a)" + unfolding \_def \2_def eq + by (simp add: measure_negligible_finite_Union_image + \finite \\ BOX2_m BOX_m BOX2_disj BOX_disj sum_distrib_right + del: UN_simps) + also have "\ \ e/2" + proof - + have "\ * measure lebesgue (\D\\. \ D) \ \ * (\D \ \`\. measure lebesgue D)" + using \\ > 0\ \finite \\ by (force simp: BOX_m \_def fmeasurableD intro: measure_Union_le) + also have "\ = (\D \ \`\. measure lebesgue D * \)" + by (metis mult.commute sum_distrib_right) + also have "\ \ (\(x, K) \ (\D. (tag D, \ D)) ` \. norm (content K *\<^sub>R f x - integral K f))" + proof (rule sum_le_included; clarify?) + fix D + assume "D \ \" + then have "\ (tag D) > 0" + using \\ \ \\ \\ \ \\ h0 tag_in_E by auto + then have m_\: "measure lebesgue (\ D) > 0" + by (simp add: \_def BOX_def algebra_simps) + have "\ \ norm (i (\(tag D)) (tag D) - f(tag D))" + using \_le \D \ \\ \\ \ \\ \\ \ \\ tag_in_E by auto + also have "\ = norm ((content (\ D) *\<^sub>R f(tag D) - integral (\ D) f) /\<^sub>R measure lebesgue (\ D))" + using m_\ + unfolding i_def \_def BOX_def + by (simp add: algebra_simps content_cbox_plus norm_minus_commute) + finally have "measure lebesgue (\ D) * \ \ norm (content (\ D) *\<^sub>R f(tag D) - integral (\ D) f)" + using m_\ by (simp add: field_simps) + then show "\y\(\D. (tag D, \ D)) ` \. + snd y = \ D \ measure lebesgue (\ D) * \ \ (case y of (x, k) \ norm (content k *\<^sub>R f x - integral k f))" + using \D \ \\ by auto + qed (use \finite \\ in auto) + also have "\ < ?ee" + proof (rule \) + show "(\D. (tag D, \ D)) ` \ tagged_partial_division_of cbox (a - One) (b + One)" + unfolding tagged_partial_division_of_def + proof (intro conjI allI impI ; clarify ?) + show "tag D \ \ D" + if "D \ \" for D + using that \\ \ \\ \\ \ \\ h0 tag_in_E + by (auto simp: \_def BOX_def mem_box algebra_simps eucl_less_le_not_le in_mono) + show "y \ cbox (a - One) (b + One)" if "D \ \" "y \ \ D" for D y + using that BOX_cbox \_def \\ \ \\ \\ \ \\ tag_in_E by blast + show "tag D = tag E \ \ D = \ E" + if "D \ \" "E \ \" and ne: "interior (\ D) \ interior (\ E) \ {}" for D E + proof - + have "BOX2 (\ (tag D)) (tag D) \ BOX2 (\ (tag E)) (tag E) = {} \ tag E = tag D" + using DISJ2 \D \ \\ \E \ \\ by force + then have "BOX (\ (tag D)) (tag D) \ BOX (\ (tag E)) (tag E) = {} \ tag E = tag D" + using BOX_sub by blast + then show "tag D = tag E \ \ D = \ E" + by (metis \_def interior_Int interior_empty ne) + qed + qed (use \finite \\ \_def BOX_def in auto) + show "\ fine (\D. (tag D, \ D)) ` \" + unfolding fine_def \_def using BOX_\ \\ \ \\ \\ \ \\ tag_in_E by blast + qed + finally show ?thesis + using \\ > 0\ by (auto simp: divide_simps) + qed + finally show ?thesis . + qed + moreover + have "measure lebesgue (\\) \ measure lebesgue (\(\2`\))" + proof (rule measure_mono_fmeasurable) + have "D \ ball (tag D) (\(tag D))" if "D \ \" for D + using \\ \ \\ sub_ball_tag that by blast + moreover have "ball (tag D) (\(tag D)) \ BOX2 (\ (tag D)) (tag D)" if "D \ \" for D + proof (clarsimp simp: \2_def BOX2_def mem_box algebra_simps dist_norm) + fix x and i::'a + assume "norm (tag D - x) < \ (tag D)" and "i \ Basis" + then have "\tag D \ i - x \ i\ \ \ (tag D)" + by (metis eucl_less_le_not_le inner_commute inner_diff_right norm_bound_Basis_le) + then show "tag D \ i \ x \ i + \ (tag D) \ x \ i \ \ (tag D) + tag D \ i" + by (simp add: abs_diff_le_iff) + qed + ultimately show "\\ \ \(\2`\)" + by (force simp: \2_def) + show "\\ \ sets lebesgue" + using \finite \\ \\ \ sets lebesgue\ \\ \ \\ by blast + show "\(\2`\) \ lmeasurable" + unfolding \2_def BOX2_def using \finite \\ by blast + qed + ultimately + have "measure lebesgue (\\) \ e/2" + by (auto simp: divide_simps) + then show "measure lebesgue (\\) \ e" + using \ by linarith + qed + qed + qed + then have "\j. negligible {x. \ x (inverse(real j + 1))}" + using negligible_on_intervals + by (metis (full_types) inverse_positive_iff_positive le_add_same_cancel1 linorder_not_le nat_le_real_less not_add_less1 of_nat_0) + then have "negligible ?M" + by auto + moreover have "?N \ ?M" + proof (clarsimp simp: dist_norm) + fix y e + assume "0 < e" + and ye [rule_format]: "\ y e" + then obtain k where k: "0 < k" "inverse (real k + 1) < e" + by (metis One_nat_def add.commute less_add_same_cancel2 less_imp_inverse_less less_trans neq0_conv of_nat_1 of_nat_Suc reals_Archimedean zero_less_one) + with ye show "\n. \ y (inverse (real n + 1))" + apply (rule_tac x=k in exI) + unfolding \_def + by (force intro: less_le_trans) + qed + ultimately show "negligible ?N" + by (blast intro: negligible_subset) + show "\ \ x e" if "x \ ?N \ 0 < e" for x e + using that by blast + qed + with that show ?thesis + unfolding i_def BOX_def \_def by (fastforce simp add: not_le) +qed + + +subsection\HOL Light measurability\ + +definition measurable_on :: "('a::euclidean_space \ 'b::real_normed_vector) \ 'a set \ bool" + (infixr "measurable'_on" 46) + where "f measurable_on S \ + \N g. negligible N \ + (\n. continuous_on UNIV (g n)) \ + (\x. x \ N \ (\n. g n x) \ (if x \ S then f x else 0))" + +lemma measurable_on_UNIV: + "(\x. if x \ S then f x else 0) measurable_on UNIV \ f measurable_on S" + by (auto simp: measurable_on_def) + +lemma measurable_on_spike_set: + assumes f: "f measurable_on S" and neg: "negligible ((S - T) \ (T - S))" + shows "f measurable_on T" +proof - + obtain N and F + where N: "negligible N" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ N \ (\n. F n x) \ (if x \ S then f x else 0)" + using f by (auto simp: measurable_on_def) + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "continuous_on UNIV (\x. F n x)" for n + by (intro conF continuous_intros) + show "negligible (N \ (S - T) \ (T - S))" + by (metis (full_types) N neg negligible_Un_eq) + show "(\n. F n x) \ (if x \ T then f x else 0)" + if "x \ (N \ (S - T) \ (T - S))" for x + using that tendsF [of x] by auto + qed +qed + +text\ Various common equivalent forms of function measurability. \ + +lemma measurable_on_0 [simp]: "(\x. 0) measurable_on S" + unfolding measurable_on_def +proof (intro exI conjI allI impI) + show "(\n. 0) \ (if x \ S then 0::'b else 0)" for x + by force +qed auto + +lemma measurable_on_scaleR_const: + assumes f: "f measurable_on S" + shows "(\x. c *\<^sub>R f x) measurable_on S" +proof - + obtain NF and F + where NF: "negligible NF" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ NF \ (\n. F n x) \ (if x \ S then f x else 0)" + using f by (auto simp: measurable_on_def) + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "continuous_on UNIV (\x. c *\<^sub>R F n x)" for n + by (intro conF continuous_intros) + show "(\n. c *\<^sub>R F n x) \ (if x \ S then c *\<^sub>R f x else 0)" + if "x \ NF" for x + using tendsto_scaleR [OF tendsto_const tendsF, of x] that by auto + qed (auto simp: NF) +qed + + +lemma measurable_on_cmul: + fixes c :: real + assumes "f measurable_on S" + shows "(\x. c * f x) measurable_on S" + using measurable_on_scaleR_const [OF assms] by simp + +lemma measurable_on_cdivide: + fixes c :: real + assumes "f measurable_on S" + shows "(\x. f x / c) measurable_on S" +proof (cases "c=0") + case False + then show ?thesis + using measurable_on_cmul [of f S "1/c"] + by (simp add: assms) +qed auto + + +lemma measurable_on_minus: + "f measurable_on S \ (\x. -(f x)) measurable_on S" + using measurable_on_scaleR_const [of f S "-1"] by auto + + +lemma continuous_imp_measurable_on: + "continuous_on UNIV f \ f measurable_on UNIV" + unfolding measurable_on_def + apply (rule_tac x="{}" in exI) + apply (rule_tac x="\n. f" in exI, auto) + done + +proposition integrable_subintervals_imp_measurable: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "\a b. f integrable_on cbox a b" + shows "f measurable_on UNIV" +proof - + define BOX where "BOX \ \h. \x::'a. cbox x (x + h *\<^sub>R One)" + define i where "i \ \h x. integral (BOX h x) f /\<^sub>R h ^ DIM('a)" + obtain N where "negligible N" + and k: "\x e. \x \ N; 0 < e\ + \ \d>0. \h. 0 < h \ h < d \ + norm (integral (cbox x (x + h *\<^sub>R One)) f /\<^sub>R h ^ DIM('a) - f x) < e" + using integrable_ccontinuous_explicit assms by blast + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "continuous_on UNIV ((\n x. i (inverse(Suc n)) x) n)" for n + proof (clarsimp simp: continuous_on_iff) + show "\d>0. \x'. dist x' x < d \ dist (i (inverse (1 + real n)) x') (i (inverse (1 + real n)) x) < e" + if "0 < e" + for x e + proof - + let ?e = "e / (1 + real n) ^ DIM('a)" + have "?e > 0" + using \e > 0\ by auto + moreover have "x \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One)" + by (simp add: mem_box inner_diff_left inner_left_distrib) + moreover have "x + One /\<^sub>R real (Suc n) \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One)" + by (auto simp: mem_box inner_diff_left inner_left_distrib field_simps) + ultimately obtain \ where "\ > 0" + and \: "\c' d'. \c' \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One); + d' \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One); + norm(c' - x) \ \; norm(d' - (x + One /\<^sub>R Suc n)) \ \\ + \ norm(integral(cbox c' d') f - integral(cbox x (x + One /\<^sub>R Suc n)) f) < ?e" + by (blast intro: indefinite_integral_continuous [of f _ _ x] assms) + show ?thesis + proof (intro exI impI conjI allI) + show "min \ 1 > 0" + using \\ > 0\ by auto + show "dist (i (inverse (1 + real n)) y) (i (inverse (1 + real n)) x) < e" + if "dist y x < min \ 1" for y + proof - + have no: "norm (y - x) < 1" + using that by (auto simp: dist_norm) + have le1: "inverse (1 + real n) \ 1" + by (auto simp: divide_simps) + have "norm (integral (cbox y (y + One /\<^sub>R real (Suc n))) f + - integral (cbox x (x + One /\<^sub>R real (Suc n))) f) + < e / (1 + real n) ^ DIM('a)" + proof (rule \) + show "y \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One)" + using no by (auto simp: mem_box algebra_simps dest: Basis_le_norm [of _ "y-x"]) + show "y + One /\<^sub>R real (Suc n) \ cbox (x - 2 *\<^sub>R One) (x + 2 *\<^sub>R One)" + proof (simp add: dist_norm mem_box algebra_simps, intro ballI conjI) + fix i::'a + assume "i \ Basis" + then have 1: "\y \ i - x \ i\ < 1" + by (metis inner_commute inner_diff_right no norm_bound_Basis_lt) + moreover have "\ < (2 + inverse (1 + real n))" "1 \ 2 - inverse (1 + real n)" + by (auto simp: field_simps) + ultimately show "x \ i \ y \ i + (2 + inverse (1 + real n))" + "y \ i + inverse (1 + real n) \ x \ i + 2" + by linarith+ + qed + show "norm (y - x) \ \" "norm (y + One /\<^sub>R real (Suc n) - (x + One /\<^sub>R real (Suc n))) \ \" + using that by (auto simp: dist_norm) + qed + then show ?thesis + using that by (simp add: dist_norm i_def BOX_def field_simps flip: scaleR_diff_right) + qed + qed + qed + qed + show "negligible N" + by (simp add: \negligible N\) + show "(\n. i (inverse (Suc n)) x) \ (if x \ UNIV then f x else 0)" + if "x \ N" for x + unfolding lim_sequentially + proof clarsimp + show "\no. \n\no. dist (i (inverse (1 + real n)) x) (f x) < e" + if "0 < e" for e + proof - + obtain d where "d > 0" + and d: "\h. \0 < h; h < d\ \ + norm (integral (cbox x (x + h *\<^sub>R One)) f /\<^sub>R h ^ DIM('a) - f x) < e" + using k [of x e] \x \ N\ \0 < e\ by blast + then obtain M where M: "M \ 0" "0 < inverse (real M)" "inverse (real M) < d" + using real_arch_invD by auto + show ?thesis + proof (intro exI allI impI) + show "dist (i (inverse (1 + real n)) x) (f x) < e" + if "M \ n" for n + proof - + have *: "0 < inverse (1 + real n)" "inverse (1 + real n) \ inverse M" + using that \M \ 0\ by auto + show ?thesis + using that M + apply (simp add: i_def BOX_def dist_norm) + apply (blast intro: le_less_trans * d) + done + qed + qed + qed + qed + qed +qed + + +subsection\Composing continuous and measurable functions; a few variants\ + +lemma measurable_on_compose_continuous: + assumes f: "f measurable_on UNIV" and g: "continuous_on UNIV g" + shows "(g \ f) measurable_on UNIV" +proof - + obtain N and F + where "negligible N" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ N \ (\n. F n x) \ f x" + using f by (auto simp: measurable_on_def) + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "negligible N" + by fact + show "continuous_on UNIV (g \ (F n))" for n + using conF continuous_on_compose continuous_on_subset g by blast + show "(\n. (g \ F n) x) \ (if x \ UNIV then (g \ f) x else 0)" + if "x \ N" for x :: 'a + using that g tendsF by (auto simp: continuous_on_def intro: tendsto_compose) + qed +qed + +lemma measurable_on_compose_continuous_0: + assumes f: "f measurable_on S" and g: "continuous_on UNIV g" and "g 0 = 0" + shows "(g \ f) measurable_on S" +proof - + have f': "(\x. if x \ S then f x else 0) measurable_on UNIV" + using f measurable_on_UNIV by blast + show ?thesis + using measurable_on_compose_continuous [OF f' g] + by (simp add: measurable_on_UNIV o_def if_distrib \g 0 = 0\ cong: if_cong) +qed + + +lemma measurable_on_compose_continuous_box: + assumes fm: "f measurable_on UNIV" and fab: "\x. f x \ box a b" + and contg: "continuous_on (box a b) g" + shows "(g \ f) measurable_on UNIV" +proof - + have "\\. (\n. continuous_on UNIV (\ n)) \ (\x. x \ N \ (\n. \ n x) \ g (f x))" + if "negligible N" + and conth [rule_format]: "\n. continuous_on UNIV (\x. h n x)" + and tends [rule_format]: "\x. x \ N \ (\n. h n x) \ f x" + for N and h :: "nat \ 'a \ 'b" + proof - + define \ where "\ \ \n x. (\i\Basis. (max (a\i + (b\i - a\i) / real (n+2)) + (min ((h n x)\i) + (b\i - (b\i - a\i) / real (n+2)))) *\<^sub>R i)" + have aibi: "\i. i \ Basis \ a \ i < b \ i" + using box_ne_empty(2) fab by auto + then have *: "\i n. i \ Basis \ a \ i + real n * (a \ i) < b \ i + real n * (b \ i)" + by (meson add_mono_thms_linordered_field(3) less_eq_real_def mult_left_mono of_nat_0_le_iff) + show ?thesis + proof (intro exI conjI allI impI) + show "continuous_on UNIV (g \ (\ n))" for n :: nat + unfolding \_def + apply (intro continuous_on_compose2 [OF contg] continuous_intros conth) + apply (auto simp: aibi * mem_box less_max_iff_disj min_less_iff_disj algebra_simps divide_simps) + done + show "(\n. (g \ \ n) x) \ g (f x)" + if "x \ N" for x + unfolding o_def + proof (rule isCont_tendsto_compose [where g=g]) + show "isCont g (f x)" + using contg fab continuous_on_eq_continuous_at by blast + have "(\n. \ n x) \ (\i\Basis. max (a \ i) (min (f x \ i) (b \ i)) *\<^sub>R i)" + unfolding \_def + proof (intro tendsto_intros \x \ N\ tends) + fix i::'b + assume "i \ Basis" + have a: "(\n. a \ i + (b \ i - a \ i) / real n) \ a\i + 0" + by (intro tendsto_add lim_const_over_n tendsto_const) + show "(\n. a \ i + (b \ i - a \ i) / real (n + 2)) \ a \ i" + using LIMSEQ_ignore_initial_segment [where k=2, OF a] by simp + have b: "(\n. b\i - (b \ i - a \ i) / (real n)) \ b\i - 0" + by (intro tendsto_diff lim_const_over_n tendsto_const) + show "(\n. b \ i - (b \ i - a \ i) / real (n + 2)) \ b \ i" + using LIMSEQ_ignore_initial_segment [where k=2, OF b] by simp + qed + also have "(\i\Basis. max (a \ i) (min (f x \ i) (b \ i)) *\<^sub>R i) = (\i\Basis. (f x \ i) *\<^sub>R i)" + apply (rule sum.cong) + using fab + apply auto + apply (intro order_antisym) + apply (auto simp: mem_box) + using less_imp_le apply blast + by (metis (full_types) linear max_less_iff_conj min.bounded_iff not_le) + also have "\ = f x" + using euclidean_representation by blast + finally show "(\n. \ n x) \ f x" . + qed + qed + qed + then show ?thesis + using fm by (auto simp: measurable_on_def) +qed + +lemma measurable_on_Pair: + assumes f: "f measurable_on S" and g: "g measurable_on S" + shows "(\x. (f x, g x)) measurable_on S" +proof - + obtain NF and F + where NF: "negligible NF" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ NF \ (\n. F n x) \ (if x \ S then f x else 0)" + using f by (auto simp: measurable_on_def) + obtain NG and G + where NG: "negligible NG" + and conG: "\n. continuous_on UNIV (G n)" + and tendsG: "\x. x \ NG \ (\n. G n x) \ (if x \ S then g x else 0)" + using g by (auto simp: measurable_on_def) + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "negligible (NF \ NG)" + by (simp add: NF NG) + show "continuous_on UNIV (\x. (F n x, G n x))" for n + using conF conG continuous_on_Pair by blast + show "(\n. (F n x, G n x)) \ (if x \ S then (f x, g x) else 0)" + if "x \ NF \ NG" for x + using tendsto_Pair [OF tendsF tendsG, of x x] that unfolding zero_prod_def + by (simp add: split: if_split_asm) + qed +qed + +lemma measurable_on_combine: + assumes f: "f measurable_on S" and g: "g measurable_on S" + and h: "continuous_on UNIV (\x. h (fst x) (snd x))" and "h 0 0 = 0" + shows "(\x. h (f x) (g x)) measurable_on S" +proof - + have *: "(\x. h (f x) (g x)) = (\x. h (fst x) (snd x)) \ (\x. (f x, g x))" + by auto + show ?thesis + unfolding * by (auto simp: measurable_on_compose_continuous_0 measurable_on_Pair assms) +qed + +lemma measurable_on_add: + assumes f: "f measurable_on S" and g: "g measurable_on S" + shows "(\x. f x + g x) measurable_on S" + by (intro continuous_intros measurable_on_combine [OF assms]) auto + +lemma measurable_on_diff: + assumes f: "f measurable_on S" and g: "g measurable_on S" + shows "(\x. f x - g x) measurable_on S" + by (intro continuous_intros measurable_on_combine [OF assms]) auto + +lemma measurable_on_scaleR: + assumes f: "f measurable_on S" and g: "g measurable_on S" + shows "(\x. f x *\<^sub>R g x) measurable_on S" + by (intro continuous_intros measurable_on_combine [OF assms]) auto + +lemma measurable_on_sum: + assumes "finite I" "\i. i \ I \ f i measurable_on S" + shows "(\x. sum (\i. f i x) I) measurable_on S" + using assms by (induction I) (auto simp: measurable_on_add) + +lemma measurable_on_spike: + assumes f: "f measurable_on T" and "negligible S" and gf: "\x. x \ T - S \ g x = f x" + shows "g measurable_on T" +proof - + obtain NF and F + where NF: "negligible NF" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ NF \ (\n. F n x) \ (if x \ T then f x else 0)" + using f by (auto simp: measurable_on_def) + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "negligible (NF \ S)" + by (simp add: NF \negligible S\) + show "\x. x \ NF \ S \ (\n. F n x) \ (if x \ T then g x else 0)" + by (metis (full_types) Diff_iff Un_iff gf tendsF) + qed (auto simp: conF) +qed + + +lemma measurable_on_preimage_lemma0: + fixes f :: "'a::euclidean_space \ real" + assumes "m \ \" and f: "m / 2^n \ (f x)" "(f x) < (m+1) / 2^n" and m: "\m\ \ 2^(2 * n)" + shows "(\k\{k \ \. \k\ \ 2^(2 * n)}. + (k / 2^n) * indicator {y. k / 2^n \ f y \ f y < (k+1) / 2^n} x) + = (m / 2^n)" (is "?lhs = ?rhs") +proof - + have "?lhs = (\k\{m}. (k / 2^n) * indicator {y. k / 2^n \ f y \ f y < (k+1) / 2^n} x)" + proof (intro sum.mono_neutral_right ballI) + show "finite {k::real. k \ \ \ \k\ \ 2^(2 * n)}" + using finite_abs_int_segment by blast + show "(i / 2^n) * indicat_real {y. i / 2^n \ f y \ f y < (i+1) / 2^n} x = 0" + if "i \ {N \ \. \N\ \ 2^(2 * n)} - {m}" for i + using f m \m \ \\ that Ints_eq_abs_less1 [of i m] + by (auto simp: indicator_def divide_simps) + qed (auto simp: assms) + also have "\ = ?rhs" + using assms by (auto simp: indicator_def) + finally show ?thesis . +qed + +(*see HOL Light's lebesgue_measurable BUT OUR lmeasurable IS NOT THE SAME. It's more like "sets lebesgue" + `lebesgue_measurable s <=> (indicator s) measurable_on (:real^N)`;; +*) + +proposition indicator_measurable_on: + assumes "S \ sets lebesgue" + shows "indicat_real S measurable_on UNIV" +proof - + { fix n::nat + let ?\ = "(1::real) / (2 * 2^n)" + have \: "?\ > 0" + by auto + obtain T where "closed T" "T \ S" "S-T \ lmeasurable" and ST: "emeasure lebesgue (S - T) < ?\" + by (meson \ assms sets_lebesgue_inner_closed) + obtain U where "open U" "S \ U" "(U - S) \ lmeasurable" and US: "emeasure lebesgue (U - S) < ?\" + by (meson \ assms sets_lebesgue_outer_open) + have eq: "-T \ U = (S-T) \ (U - S)" + using \T \ S\ \S \ U\ by auto + have "emeasure lebesgue ((S-T) \ (U - S)) \ emeasure lebesgue (S - T) + emeasure lebesgue (U - S)" + using \S - T \ lmeasurable\ \U - S \ lmeasurable\ emeasure_subadditive by blast + also have "\ < ?\ + ?\" + using ST US add_mono_ennreal by metis + finally have le: "emeasure lebesgue (-T \ U) < ennreal (1 / 2^n)" + by (simp add: eq) + have 1: "continuous_on (T \ -U) (indicat_real S)" + unfolding indicator_def + proof (rule continuous_on_cases [OF \closed T\]) + show "closed (- U)" + using \open U\ by blast + show "continuous_on T (\x. 1::real)" "continuous_on (- U) (\x. 0::real)" + by (auto simp: continuous_on) + show "\x. x \ T \ x \ S \ x \ - U \ x \ S \ (1::real) = 0" + using \T \ S\ \S \ U\ by auto + qed + have 2: "closedin (top_of_set UNIV) (T \ -U)" + using \closed T\ \open U\ by auto + obtain g where "continuous_on UNIV g" "\x. x \ T \ -U \ g x = indicat_real S x" "\x. norm(g x) \ 1" + by (rule Tietze [OF 1 2, of 1]) auto + with le have "\g E. continuous_on UNIV g \ (\x \ -E. g x = indicat_real S x) \ + (\x. norm(g x) \ 1) \ E \ sets lebesgue \ emeasure lebesgue E < ennreal (1 / 2^n)" + apply (rule_tac x=g in exI) + apply (rule_tac x="-T \ U" in exI) + using \S - T \ lmeasurable\ \U - S \ lmeasurable\ eq by auto + } + then obtain g E where cont: "\n. continuous_on UNIV (g n)" + and geq: "\n x. x \ - E n \ g n x = indicat_real S x" + and ng1: "\n x. norm(g n x) \ 1" + and Eset: "\n. E n \ sets lebesgue" + and Em: "\n. emeasure lebesgue (E n) < ennreal (1 / 2^n)" + by metis + have null: "limsup E \ null_sets lebesgue" + proof (rule borel_cantelli_limsup1 [OF Eset]) + show "emeasure lebesgue (E n) < \" for n + by (metis Em infinity_ennreal_def order.asym top.not_eq_extremum) + show "summable (\n. measure lebesgue (E n))" + proof (rule summable_comparison_test' [OF summable_geometric, of "1/2" 0]) + show "norm (measure lebesgue (E n)) \ (1/2) ^ n" for n + using Em [of n] by (simp add: measure_def enn2real_leI power_one_over) + qed auto + qed + have tends: "(\n. g n x) \ indicat_real S x" if "x \ limsup E" for x + proof - + have "\\<^sub>F n in sequentially. x \ - E n" + using that by (simp add: mem_limsup_iff not_frequently) + then show ?thesis + unfolding tendsto_iff dist_real_def + by (simp add: eventually_mono geq) + qed + show ?thesis + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "negligible (limsup E)" + using negligible_iff_null_sets null by blast + show "continuous_on UNIV (g n)" for n + using cont by blast + qed (use tends in auto) +qed + +lemma measurable_on_restrict: + assumes f: "f measurable_on UNIV" and S: "S \ sets lebesgue" + shows "(\x. if x \ S then f x else 0) measurable_on UNIV" +proof - + have "indicat_real S measurable_on UNIV" + by (simp add: S indicator_measurable_on) + then show ?thesis + using measurable_on_scaleR [OF _ f, of "indicat_real S"] + by (simp add: indicator_scaleR_eq_if) +qed + +lemma measurable_on_const_UNIV: "(\x. k) measurable_on UNIV" + by (simp add: continuous_imp_measurable_on) + +lemma measurable_on_const [simp]: "S \ sets lebesgue \ (\x. k) measurable_on S" + using measurable_on_UNIV measurable_on_const_UNIV measurable_on_restrict by blast + +lemma simple_function_indicator_representation_real: + fixes f ::"'a \ real" + assumes f: "simple_function M f" and x: "x \ space M" and nn: "\x. f x \ 0" + shows "f x = (\y \ f ` space M. y * indicator (f -` {y} \ space M) x)" +proof - + have f': "simple_function M (ennreal \ f)" + by (simp add: f) + have *: "f x = + enn2real + (\y\ ennreal ` f ` space M. + y * indicator ((ennreal \ f) -` {y} \ space M) x)" + using arg_cong [OF simple_function_indicator_representation [OF f' x], of enn2real, simplified nn o_def] nn + unfolding o_def image_comp + by (metis enn2real_ennreal) + have "enn2real (\y\ennreal ` f ` space M. if ennreal (f x) = y \ x \ space M then y else 0) + = sum (enn2real \ (\y. if ennreal (f x) = y \ x \ space M then y else 0)) + (ennreal ` f ` space M)" + by (rule enn2real_sum) auto + also have "\ = sum (enn2real \ (\y. if ennreal (f x) = y \ x \ space M then y else 0) \ ennreal) + (f ` space M)" + by (rule sum.reindex) (use nn in \auto simp: inj_on_def intro: sum.cong\) + also have "\ = (\y\f ` space M. if f x = y \ x \ space M then y else 0)" + using nn + by (auto simp: inj_on_def intro: sum.cong) + finally show ?thesis + by (subst *) (simp add: enn2real_sum indicator_def if_distrib cong: if_cong) +qed + +lemma\<^marker>\tag important\ simple_function_induct_real + [consumes 1, case_names cong set mult add, induct set: simple_function]: + fixes u :: "'a \ real" + assumes u: "simple_function M u" + assumes cong: "\f g. simple_function M f \ simple_function M g \ (AE x in M. f x = g x) \ P f \ P g" + assumes set: "\A. A \ sets M \ P (indicator A)" + assumes mult: "\u c. P u \ P (\x. c * u x)" + assumes add: "\u v. P u \ P v \ P (\x. u x + v x)" + and nn: "\x. u x \ 0" + shows "P u" +proof (rule cong) + from AE_space show "AE x in M. (\y\u ` space M. y * indicator (u -` {y} \ space M) x) = u x" + proof eventually_elim + fix x assume x: "x \ space M" + from simple_function_indicator_representation_real[OF u x] nn + show "(\y\u ` space M. y * indicator (u -` {y} \ space M) x) = u x" + by metis + qed +next + from u have "finite (u ` space M)" + unfolding simple_function_def by auto + then show "P (\x. \y\u ` space M. y * indicator (u -` {y} \ space M) x)" + proof induct + case empty + then show ?case + using set[of "{}"] by (simp add: indicator_def[abs_def]) + next + case (insert a F) + have eq: "\ {y. u x = y \ (y = a \ y \ F) \ x \ space M} + = (if u x = a \ x \ space M then a else 0) + \ {y. u x = y \ y \ F \ x \ space M}" for x + proof (cases "x \ space M") + case True + have *: "{y. u x = y \ (y = a \ y \ F)} = {y. u x = a \ y = a} \ {y. u x = y \ y \ F}" + by auto + show ?thesis + using insert by (simp add: * True) + qed auto + have a: "P (\x. a * indicator (u -` {a} \ space M) x)" + proof (intro mult set) + show "u -` {a} \ space M \ sets M" + using u by auto + qed + show ?case + using nn insert a + by (simp add: eq indicator_times_eq_if [where f = "\x. a"] add) + qed +next + show "simple_function M (\x. (\y\u ` space M. y * indicator (u -` {y} \ space M) x))" + apply (subst simple_function_cong) + apply (rule simple_function_indicator_representation_real[symmetric]) + apply (auto intro: u nn) + done +qed fact + +proposition simple_function_measurable_on_UNIV: + fixes f :: "'a::euclidean_space \ real" + assumes f: "simple_function lebesgue f" and nn: "\x. f x \ 0" + shows "f measurable_on UNIV" + using f +proof (induction f) + case (cong f g) + then obtain N where "negligible N" "{x. g x \ f x} \ N" + by (auto simp: eventually_ae_filter_negligible eq_commute) + then show ?case + by (blast intro: measurable_on_spike cong) +next + case (set S) + then show ?case + by (simp add: indicator_measurable_on) +next + case (mult u c) + then show ?case + by (simp add: measurable_on_cmul) + case (add u v) + then show ?case + by (simp add: measurable_on_add) +qed (auto simp: nn) + +lemma simple_function_lebesgue_if: + fixes f :: "'a::euclidean_space \ real" + assumes f: "simple_function lebesgue f" and S: "S \ sets lebesgue" + shows "simple_function lebesgue (\x. if x \ S then f x else 0)" +proof - + have ffin: "finite (range f)" and fsets: "\x. f -` {f x} \ sets lebesgue" + using f by (auto simp: simple_function_def) + have "finite (f ` S)" + by (meson finite_subset subset_image_iff ffin top_greatest) + moreover have "finite ((\x. 0::real) ` T)" for T :: "'a set" + by (auto simp: image_def) + moreover have if_sets: "(\x. if x \ S then f x else 0) -` {f a} \ sets lebesgue" for a + proof - + have *: "(\x. if x \ S then f x else 0) -` {f a} + = (if f a = 0 then -S \ f -` {f a} else (f -` {f a}) \ S)" + by (auto simp: split: if_split_asm) + show ?thesis + unfolding * by (metis Compl_in_sets_lebesgue S sets.Int sets.Un fsets) + qed + moreover have "(\x. if x \ S then f x else 0) -` {0} \ sets lebesgue" + proof (cases "0 \ range f") + case True + then show ?thesis + by (metis (no_types, lifting) if_sets rangeE) + next + case False + then have "(\x. if x \ S then f x else 0) -` {0} = -S" + by auto + then show ?thesis + by (simp add: Compl_in_sets_lebesgue S) + qed + ultimately show ?thesis + by (auto simp: simple_function_def) +qed + +corollary simple_function_measurable_on: + fixes f :: "'a::euclidean_space \ real" + assumes f: "simple_function lebesgue f" and nn: "\x. f x \ 0" and S: "S \ sets lebesgue" + shows "f measurable_on S" + by (simp add: measurable_on_UNIV [symmetric, of f] S f simple_function_lebesgue_if nn simple_function_measurable_on_UNIV) + +lemma + fixes f :: "'a::euclidean_space \ 'b::ordered_euclidean_space" + assumes f: "f measurable_on S" and g: "g measurable_on S" + shows measurable_on_sup: "(\x. sup (f x) (g x)) measurable_on S" + and measurable_on_inf: "(\x. inf (f x) (g x)) measurable_on S" +proof - + obtain NF and F + where NF: "negligible NF" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ NF \ (\n. F n x) \ (if x \ S then f x else 0)" + using f by (auto simp: measurable_on_def) + obtain NG and G + where NG: "negligible NG" + and conG: "\n. continuous_on UNIV (G n)" + and tendsG: "\x. x \ NG \ (\n. G n x) \ (if x \ S then g x else 0)" + using g by (auto simp: measurable_on_def) + show "(\x. sup (f x) (g x)) measurable_on S" + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "continuous_on UNIV (\x. sup (F n x) (G n x))" for n + unfolding sup_max eucl_sup by (intro conF conG continuous_intros) + show "(\n. sup (F n x) (G n x)) \ (if x \ S then sup (f x) (g x) else 0)" + if "x \ NF \ NG" for x + using tendsto_sup [OF tendsF tendsG, of x x] that by auto + qed (simp add: NF NG) + show "(\x. inf (f x) (g x)) measurable_on S" + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "continuous_on UNIV (\x. inf (F n x) (G n x))" for n + unfolding inf_min eucl_inf by (intro conF conG continuous_intros) + show "(\n. inf (F n x) (G n x)) \ (if x \ S then inf (f x) (g x) else 0)" + if "x \ NF \ NG" for x + using tendsto_inf [OF tendsF tendsG, of x x] that by auto + qed (simp add: NF NG) +qed + +proposition measurable_on_componentwise_UNIV: + "f measurable_on UNIV \ (\i\Basis. (\x. (f x \ i) *\<^sub>R i) measurable_on UNIV)" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + show ?rhs + proof + fix i::'b + assume "i \ Basis" + have cont: "continuous_on UNIV (\x. (x \ i) *\<^sub>R i)" + by (intro continuous_intros) + show "(\x. (f x \ i) *\<^sub>R i) measurable_on UNIV" + using measurable_on_compose_continuous [OF L cont] + by (simp add: o_def) + qed +next + assume ?rhs + then have "\N g. negligible N \ + (\n. continuous_on UNIV (g n)) \ + (\x. x \ N \ (\n. g n x) \ (f x \ i) *\<^sub>R i)" + if "i \ Basis" for i + by (simp add: measurable_on_def that) + then obtain N g where N: "\i. i \ Basis \ negligible (N i)" + and cont: "\i n. i \ Basis \ continuous_on UNIV (g i n)" + and tends: "\i x. \i \ Basis; x \ N i\ \ (\n. g i n x) \ (f x \ i) *\<^sub>R i" + by metis + show ?lhs + unfolding measurable_on_def + proof (intro exI conjI allI impI) + show "negligible (\i \ Basis. N i)" + using N eucl.finite_Basis by blast + show "continuous_on UNIV (\x. (\i\Basis. g i n x))" for n + by (intro continuous_intros cont) + next + fix x + assume "x \ (\i \ Basis. N i)" + then have "\i. i \ Basis \ x \ N i" + by auto + then have "(\n. (\i\Basis. g i n x)) \ (\i\Basis. (f x \ i) *\<^sub>R i)" + by (intro tends tendsto_intros) + then show "(\n. (\i\Basis. g i n x)) \ (if x \ UNIV then f x else 0)" + by (simp add: euclidean_representation) + qed +qed + +corollary measurable_on_componentwise: + "f measurable_on S \ (\i\Basis. (\x. (f x \ i) *\<^sub>R i) measurable_on S)" + apply (subst measurable_on_UNIV [symmetric]) + apply (subst measurable_on_componentwise_UNIV) + apply (simp add: measurable_on_UNIV if_distrib [of "\x. inner x _"] if_distrib [of "\x. scaleR x _"] cong: if_cong) + done + + +(*FIXME: avoid duplication of proofs WRT borel_measurable_implies_simple_function_sequence*) +lemma\<^marker>\tag important\ borel_measurable_implies_simple_function_sequence_real: + fixes u :: "'a \ real" + assumes u[measurable]: "u \ borel_measurable M" and nn: "\x. u x \ 0" + shows "\f. incseq f \ (\i. simple_function M (f i)) \ (\x. bdd_above (range (\i. f i x))) \ + (\i x. 0 \ f i x) \ u = (SUP i. f i)" +proof - + define f where [abs_def]: + "f i x = real_of_int (floor ((min i (u x)) * 2^i)) / 2^i" for i x + + have [simp]: "0 \ f i x" for i x + by (auto simp: f_def intro!: divide_nonneg_nonneg mult_nonneg_nonneg nn) + + have *: "2^n * real_of_int x = real_of_int (2^n * x)" for n x + by simp + + have "real_of_int \real i * 2 ^ i\ = real_of_int \i * 2 ^ i\" for i + by (intro arg_cong[where f=real_of_int]) simp + then have [simp]: "real_of_int \real i * 2 ^ i\ = i * 2 ^ i" for i + unfolding floor_of_nat by simp + + have bdd: "bdd_above (range (\i. f i x))" for x + by (rule bdd_aboveI [where M = "u x"]) (auto simp: f_def field_simps min_def) + + have "incseq f" + proof (intro monoI le_funI) + fix m n :: nat and x assume "m \ n" + moreover + { fix d :: nat + have "\2^d::real\ * \2^m * (min (of_nat m) (u x))\ \ \2^d * (2^m * (min (of_nat m) (u x)))\" + by (rule le_mult_floor) (auto simp: nn) + also have "\ \ \2^d * (2^m * (min (of_nat d + of_nat m) (u x)))\" + by (intro floor_mono mult_mono min.mono) + (auto simp: nn min_less_iff_disj of_nat_less_top) + finally have "f m x \ f(m + d) x" + unfolding f_def + by (auto simp: field_simps power_add * simp del: of_int_mult) } + ultimately show "f m x \ f n x" + by (auto simp: le_iff_add) + qed + then have inc_f: "incseq (\i. f i x)" for x + by (auto simp: incseq_def le_fun_def) + moreover + have "simple_function M (f i)" for i + proof (rule simple_function_borel_measurable) + have "\(min (of_nat i) (u x)) * 2 ^ i\ \ \int i * 2 ^ i\" for x + by (auto split: split_min intro!: floor_mono) + then have "f i ` space M \ (\n. real_of_int n / 2^i) ` {0 .. of_nat i * 2^i}" + unfolding floor_of_int by (auto simp: f_def nn intro!: imageI) + then show "finite (f i ` space M)" + by (rule finite_subset) auto + show "f i \ borel_measurable M" + unfolding f_def enn2real_def by measurable + qed + moreover + { fix x + have "(SUP i. (f i x)) = u x" + proof - + obtain n where "u x \ of_nat n" using real_arch_simple by auto + then have min_eq_r: "\\<^sub>F i in sequentially. min (real i) (u x) = u x" + by (auto simp: eventually_sequentially intro!: exI[of _ n] split: split_min) + have "(\i. real_of_int \min (real i) (u x) * 2^i\ / 2^i) \ u x" + proof (rule tendsto_sandwich) + show "(\n. u x - (1/2)^n) \ u x" + by (auto intro!: tendsto_eq_intros LIMSEQ_power_zero) + show "\\<^sub>F n in sequentially. real_of_int \min (real n) (u x) * 2 ^ n\ / 2 ^ n \ u x" + using min_eq_r by eventually_elim (auto simp: field_simps) + have *: "u x * (2 ^ n * 2 ^ n) \ 2^n + 2^n * real_of_int \u x * 2 ^ n\" for n + using real_of_int_floor_ge_diff_one[of "u x * 2^n", THEN mult_left_mono, of "2^n"] + by (auto simp: field_simps) + show "\\<^sub>F n in sequentially. u x - (1/2)^n \ real_of_int \min (real n) (u x) * 2 ^ n\ / 2 ^ n" + using min_eq_r by eventually_elim (insert *, auto simp: field_simps) + qed auto + then have "(\i. (f i x)) \ u x" + by (simp add: f_def) + from LIMSEQ_unique LIMSEQ_incseq_SUP [OF bdd inc_f] this + show ?thesis + by blast + qed } + ultimately show ?thesis + by (intro exI [of _ "\i x. f i x"]) (auto simp: \incseq f\ bdd image_comp) +qed + + +lemma homeomorphic_open_interval_UNIV: + fixes a b:: real + assumes "a < b" + shows "{a<.. {}" + shows "box a b homeomorphic (UNIV::'a set)" +proof - + have "{a \ i <.. i} homeomorphic (UNIV::real set)" if "i \ Basis" for i + using assms box_ne_empty that by (blast intro: homeomorphic_open_interval_UNIV) + then have "\f g. (\x. a \ i < x \ x < b \ i \ g (f x) = x) \ + (\y. a \ i < g y \ g y < b \ i \ f(g y) = y) \ + continuous_on {a \ i<.. i} f \ + continuous_on (UNIV::real set) g" + if "i \ Basis" for i + using that by (auto simp: homeomorphic_minimal mem_box Ball_def) + then obtain f g where gf: "\i x. \i \ Basis; a \ i < x; x < b \ i\ \ g i (f i x) = x" + and fg: "\i y. i \ Basis \ a \ i < g i y \ g i y < b \ i \ f i (g i y) = y" + and contf: "\i. i \ Basis \ continuous_on {a \ i<.. i} (f i)" + and contg: "\i. i \ Basis \ continuous_on (UNIV::real set) (g i)" + by metis + define F where "F \ \x. \i\Basis. (f i (x \ i)) *\<^sub>R i" + define G where "G \ \x. \i\Basis. (g i (x \ i)) *\<^sub>R i" + show ?thesis + unfolding homeomorphic_minimal + proof (intro exI conjI ballI) + show "G y \ box a b" for y + using fg by (simp add: G_def mem_box) + show "G (F x) = x" if "x \ box a b" for x + using that by (simp add: F_def G_def gf mem_box euclidean_representation) + show "F (G y) = y" for y + by (simp add: F_def G_def fg mem_box euclidean_representation) + show "continuous_on (box a b) F" + unfolding F_def + proof (intro continuous_intros continuous_on_compose2 [OF contf continuous_on_inner]) + show "(\x. x \ i) ` box a b \ {a \ i<.. i}" if "i \ Basis" for i + using that by (auto simp: mem_box) + qed + show "continuous_on UNIV G" + unfolding G_def + by (intro continuous_intros continuous_on_compose2 [OF contg continuous_on_inner]) auto + qed auto +qed + + + +lemma diff_null_sets_lebesgue: "\N \ null_sets (lebesgue_on S); X-N \ sets (lebesgue_on S); N \ X\ + \ X \ sets (lebesgue_on S)" + by (metis Int_Diff_Un inf.commute inf.orderE null_setsD2 sets.Un) + +lemma borel_measurable_diff_null: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes N: "N \ null_sets (lebesgue_on S)" and S: "S \ sets lebesgue" + shows "f \ borel_measurable (lebesgue_on (S-N)) \ f \ borel_measurable (lebesgue_on S)" + unfolding in_borel_measurable borel_measurable_UNIV_eq [symmetric] space_lebesgue_on sets_restrict_UNIV +proof (intro ball_cong iffI) + show "f -` T \ S \ sets (lebesgue_on S)" + if "f -` T \ (S-N) \ sets (lebesgue_on (S-N))" for T + using that assms + by (smt Diff_Int_distrib completion.complete2 diff_null_sets_lebesgue inf.idem inf_le2 inf_mono lebesgue_on_UNIV_eq null_setsD2 null_sets_restrict_space sets.Diff sets_restrict_space_iff space_lebesgue_on space_restrict_space) + show "f -` T \ (S-N) \ sets (lebesgue_on (S-N))" + if "f -` T \ S \ sets (lebesgue_on S)" for T + using image_eqI inf.commute inf_top_right sets_restrict_space that + by (smt Int_Diff S sets.Int_space_eq2 sets_restrict_space_iff space_lebesgue_on) +qed auto + +lemma lebesgue_measurable_diff_null: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "N \ null_sets lebesgue" + shows "f \ borel_measurable (lebesgue_on (-N)) \ f \ borel_measurable lebesgue" + by (simp add: Compl_eq_Diff_UNIV assms borel_measurable_diff_null lebesgue_on_UNIV_eq) + + + +proposition measurable_on_imp_borel_measurable_lebesgue_UNIV: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "f measurable_on UNIV" + shows "f \ borel_measurable lebesgue" +proof - + obtain N and F + where NF: "negligible N" + and conF: "\n. continuous_on UNIV (F n)" + and tendsF: "\x. x \ N \ (\n. F n x) \ f x" + using assms by (auto simp: measurable_on_def) + obtain N where "N \ null_sets lebesgue" "f \ borel_measurable (lebesgue_on (-N))" + proof + show "f \ borel_measurable (lebesgue_on (- N))" + proof (rule borel_measurable_LIMSEQ_metric) + show "F i \ borel_measurable (lebesgue_on (- N))" for i + by (meson Compl_in_sets_lebesgue NF conF continuous_imp_measurable_on_sets_lebesgue continuous_on_subset negligible_imp_sets subset_UNIV) + show "(\i. F i x) \ f x" if "x \ space (lebesgue_on (- N))" for x + using that + by (simp add: tendsF) + qed + show "N \ null_sets lebesgue" + using NF negligible_iff_null_sets by blast + qed + then show ?thesis + using lebesgue_measurable_diff_null by blast +qed + +corollary measurable_on_imp_borel_measurable_lebesgue: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "f measurable_on S" and S: "S \ sets lebesgue" + shows "f \ borel_measurable (lebesgue_on S)" +proof - + have "(\x. if x \ S then f x else 0) measurable_on UNIV" + using assms(1) measurable_on_UNIV by blast + then show ?thesis + by (simp add: borel_measurable_if_D measurable_on_imp_borel_measurable_lebesgue_UNIV) +qed + + +proposition measurable_on_limit: + fixes f :: "nat \ 'a::euclidean_space \ 'b::euclidean_space" + assumes f: "\n. f n measurable_on S" and N: "negligible N" + and lim: "\x. x \ S - N \ (\n. f n x) \ g x" + shows "g measurable_on S" +proof - + have "box (0::'b) One homeomorphic (UNIV::'b set)" + by (simp add: homeomorphic_box_UNIV) + then obtain h h':: "'b\'b" where hh': "\x. x \ box 0 One \ h (h' x) = x" + and h'im: "h' ` box 0 One = UNIV" + and conth: "continuous_on UNIV h" + and conth': "continuous_on (box 0 One) h'" + and h'h: "\y. h' (h y) = y" + and rangeh: "range h = box 0 One" + by (auto simp: homeomorphic_def homeomorphism_def) + have "norm y \ DIM('b)" if y: "y \ box 0 One" for y::'b + proof - + have y01: "0 < y \ i" "y \ i < 1" if "i \ Basis" for i + using that y by (auto simp: mem_box) + have "norm y \ (\i\Basis. \y \ i\)" + using norm_le_l1 by blast + also have "\ \ (\i::'b\Basis. 1)" + proof (rule sum_mono) + show "\y \ i\ \ 1" if "i \ Basis" for i + using y01 that by fastforce + qed + also have "\ \ DIM('b)" + by auto + finally show ?thesis . + qed + then have norm_le: "norm(h y) \ DIM('b)" for y + by (metis UNIV_I image_eqI rangeh) + have "(h' \ (h \ (\x. if x \ S then g x else 0))) measurable_on UNIV" + proof (rule measurable_on_compose_continuous_box) + let ?\ = "h \ (\x. if x \ S then g x else 0)" + let ?f = "\n. h \ (\x. if x \ S then f n x else 0)" + show "?\ measurable_on UNIV" + proof (rule integrable_subintervals_imp_measurable) + show "?\ integrable_on cbox a b" for a b + proof (rule integrable_spike_set) + show "?\ integrable_on (cbox a b - N)" + proof (rule dominated_convergence_integrable) + show const: "(\x. DIM('b)) integrable_on cbox a b - N" + by (simp add: N has_integral_iff integrable_const integrable_negligible integrable_setdiff negligible_diff) + show "norm ((h \ (\x. if x \ S then g x else 0)) x) \ DIM('b)" if "x \ cbox a b - N" for x + using that norm_le by (simp add: o_def) + show "(\k. ?f k x) \ ?\ x" if "x \ cbox a b - N" for x + using that lim [of x] conth + by (auto simp: continuous_on_def intro: tendsto_compose) + show "(?f n) absolutely_integrable_on cbox a b - N" for n + proof (rule measurable_bounded_by_integrable_imp_absolutely_integrable) + show "?f n \ borel_measurable (lebesgue_on (cbox a b - N))" + proof (rule measurable_on_imp_borel_measurable_lebesgue [OF measurable_on_spike_set]) + show "?f n measurable_on cbox a b" + unfolding measurable_on_UNIV [symmetric, of _ "cbox a b"] + proof (rule measurable_on_restrict) + have f': "(\x. if x \ S then f n x else 0) measurable_on UNIV" + by (simp add: f measurable_on_UNIV) + show "?f n measurable_on UNIV" + using measurable_on_compose_continuous [OF f' conth] by auto + qed auto + show "negligible (sym_diff (cbox a b) (cbox a b - N))" + by (auto intro: negligible_subset [OF N]) + show "cbox a b - N \ sets lebesgue" + by (simp add: N negligible_imp_sets sets.Diff) + qed + show "cbox a b - N \ sets lebesgue" + by (simp add: N negligible_imp_sets sets.Diff) + show "norm (?f n x) \ DIM('b)" + if "x \ cbox a b - N" for x + using that local.norm_le by simp + qed (auto simp: const) + qed + show "negligible {x \ cbox a b - N - cbox a b. ?\ x \ 0}" + by (auto simp: empty_imp_negligible) + have "{x \ cbox a b - (cbox a b - N). ?\ x \ 0} \ N" + by auto + then show "negligible {x \ cbox a b - (cbox a b - N). ?\ x \ 0}" + using N negligible_subset by blast + qed + qed + show "?\ x \ box 0 One" for x + using rangeh by auto + show "continuous_on (box 0 One) h'" + by (rule conth') + qed + then show ?thesis + by (simp add: o_def h'h measurable_on_UNIV) +qed + + +lemma measurable_on_if_simple_function_limit: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + shows "\\n. g n measurable_on UNIV; \n. finite (range (g n)); \x. (\n. g n x) \ f x\ + \ f measurable_on UNIV" + by (force intro: measurable_on_limit [where N="{}"]) + + +lemma lebesgue_measurable_imp_measurable_on_nnreal_UNIV: + fixes u :: "'a::euclidean_space \ real" + assumes u: "u \ borel_measurable lebesgue" and nn: "\x. u x \ 0" + shows "u measurable_on UNIV" +proof - + obtain f where "incseq f" and f: "\i. simple_function lebesgue (f i)" + and bdd: "\x. bdd_above (range (\i. f i x))" + and nnf: "\i x. 0 \ f i x" and *: "u = (SUP i. f i)" + using borel_measurable_implies_simple_function_sequence_real nn u by metis + show ?thesis + unfolding * + proof (rule measurable_on_if_simple_function_limit [of concl: "Sup (range f)"]) + show "(f i) measurable_on UNIV" for i + by (simp add: f nnf simple_function_measurable_on_UNIV) + show "finite (range (f i))" for i + by (metis f simple_function_def space_borel space_completion space_lborel) + show "(\i. f i x) \ Sup (range f) x" for x + proof - + have "incseq (\i. f i x)" + using \incseq f\ apply (auto simp: incseq_def) + by (simp add: le_funD) + then show ?thesis + by (metis SUP_apply bdd LIMSEQ_incseq_SUP) + qed + qed +qed + +lemma lebesgue_measurable_imp_measurable_on_nnreal: + fixes u :: "'a::euclidean_space \ real" + assumes "u \ borel_measurable lebesgue" "\x. u x \ 0""S \ sets lebesgue" + shows "u measurable_on S" + unfolding measurable_on_UNIV [symmetric, of u] + using assms + by (auto intro: lebesgue_measurable_imp_measurable_on_nnreal_UNIV) + +lemma lebesgue_measurable_imp_measurable_on_real: + fixes u :: "'a::euclidean_space \ real" + assumes u: "u \ borel_measurable lebesgue" and S: "S \ sets lebesgue" + shows "u measurable_on S" +proof - + let ?f = "\x. \u x\ + u x" + let ?g = "\x. \u x\ - u x" + have "?f measurable_on S" "?g measurable_on S" + using S u by (auto intro: lebesgue_measurable_imp_measurable_on_nnreal) + then have "(\x. (?f x - ?g x) / 2) measurable_on S" + using measurable_on_cdivide measurable_on_diff by blast + then show ?thesis + by auto +qed + + +proposition lebesgue_measurable_imp_measurable_on: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes f: "f \ borel_measurable lebesgue" and S: "S \ sets lebesgue" + shows "f measurable_on S" + unfolding measurable_on_componentwise [of f] +proof + fix i::'b + assume "i \ Basis" + have "(\x. (f x \ i)) \ borel_measurable lebesgue" + using \i \ Basis\ borel_measurable_euclidean_space f by blast + then have "(\x. (f x \ i)) measurable_on S" + using S lebesgue_measurable_imp_measurable_on_real by blast + then show "(\x. (f x \ i) *\<^sub>R i) measurable_on S" + by (intro measurable_on_scaleR measurable_on_const S) +qed + +proposition measurable_on_iff_borel_measurable: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "S \ sets lebesgue" + shows "f measurable_on S \ f \ borel_measurable (lebesgue_on S)" (is "?lhs = ?rhs") +proof + show "f \ borel_measurable (lebesgue_on S)" + if "f measurable_on S" + using that by (simp add: assms measurable_on_imp_borel_measurable_lebesgue) +next + assume "f \ borel_measurable (lebesgue_on S)" + then have "(\a. if a \ S then f a else 0) measurable_on UNIV" + by (simp add: assms borel_measurable_if lebesgue_measurable_imp_measurable_on) + then show "f measurable_on S" + using measurable_on_UNIV by blast +qed + +end diff -r 0fec12eabad0 -r ae37b8fbf023 src/HOL/Analysis/Lebesgue_Measure.thy --- a/src/HOL/Analysis/Lebesgue_Measure.thy Thu Sep 12 17:17:52 2019 +0200 +++ b/src/HOL/Analysis/Lebesgue_Measure.thy Fri Sep 13 12:46:36 2019 +0100 @@ -544,6 +544,20 @@ shows "(\x. if x \ S then f x else 0) \ borel_measurable lebesgue \ f \ borel_measurable (lebesgue_on S)" using assms borel_measurable_if_D borel_measurable_if_I by blast +lemma borel_measurable_if_lebesgue_on: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "S \ sets lebesgue" "T \ sets lebesgue" "S \ T" + shows "(\x. if x \ S then f x else 0) \ borel_measurable (lebesgue_on T) \ f \ borel_measurable (lebesgue_on S)" + (is "?lhs = ?rhs") +proof + assume ?lhs then show ?rhs + using measurable_restrict_mono [OF _ \S \ T\] + by (subst measurable_lebesgue_cong [where g = "(\x. if x \ S then f x else 0)"]) auto +next + assume ?rhs then show ?lhs + by (simp add: \S \ sets lebesgue\ borel_measurable_if_I measurable_restrict_space1) +qed + lemma borel_measurable_vimage_halfspace_component_lt: "f \ borel_measurable (lebesgue_on S) \ (\a i. i \ Basis \ {x \ S. f x \ i < a} \ sets (lebesgue_on S))" diff -r 0fec12eabad0 -r ae37b8fbf023 src/HOL/Limits.thy --- a/src/HOL/Limits.thy Thu Sep 12 17:17:52 2019 +0200 +++ b/src/HOL/Limits.thy Fri Sep 13 12:46:36 2019 +0100 @@ -2340,6 +2340,21 @@ by (auto intro!: exI[of _ L] decseq_ge) qed +lemma monoseq_convergent: + fixes X :: "nat \ real" + assumes X: "monoseq X" and B: "\i. \X i\ \ B" + obtains L where "X \ L" + using X unfolding monoseq_iff +proof + assume "incseq X" + show thesis + using abs_le_D1 [OF B] incseq_convergent [OF \incseq X\] that by meson +next + assume "decseq X" + show thesis + using decseq_convergent [OF \decseq X\] that + by (metis B abs_le_iff add.inverse_inverse neg_le_iff_le) +qed subsection \Power Sequences\