# HG changeset patch # User desharna # Date 1709654121 -3600 # Node ID 1f94d92b0dc26746c013935b949ff44f1c88024c # Parent 0e8620af9c9168fcb58d529c8459ef1d86fd54f4# Parent 817d33f8aa7fe9f356876e8fb17711cf811fb09e merged diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/Analysis/Elementary_Metric_Spaces.thy --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy Tue Mar 05 16:55:21 2024 +0100 @@ -4,7 +4,7 @@ Author: Brian Huffman, Portland State University *) -section \Elementary Metric Spaces\ +chapter \Elementary Metric Spaces\ theory Elementary_Metric_Spaces imports @@ -12,7 +12,7 @@ Metric_Arith begin -subsection \Open and closed balls\ +section \Open and closed balls\ definition\<^marker>\tag important\ ball :: "'a::metric_space \ real \ 'a set" where "ball x e = {y. dist x y < e}" @@ -316,7 +316,7 @@ by blast qed -subsection \Limit Points\ +section \Limit Points\ lemma islimpt_approachable: fixes x :: "'a::metric_space" @@ -349,7 +349,7 @@ by (metis open_ball ball_subset_cball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq) -subsection \Perfect Metric Spaces\ +section \Perfect Metric Spaces\ lemma perfect_choose_dist: "0 < r \ \a. a \ x \ dist a x < r" for x :: "'a::{perfect_space,metric_space}" @@ -362,7 +362,7 @@ not_open_singleton subset_singleton_iff) -subsection \Finite and discrete\ +section \Finite and discrete\ lemma finite_ball_include: fixes a :: "'a::metric_space" @@ -427,7 +427,7 @@ qed -subsection \Interior\ +section \Interior\ lemma mem_interior: "x \ interior S \ (\e>0. ball x e \ S)" using open_contains_ball_eq [where S="interior S"] @@ -441,7 +441,7 @@ by (meson mem_interior mem_interior_cball) -subsection \Frontier\ +section \Frontier\ lemma frontier_straddle: fixes a :: "'a::metric_space" @@ -450,7 +450,7 @@ by (auto simp: mem_interior subset_eq ball_def) -subsection \Limits\ +section \Limits\ proposition Lim: "(f \ l) net \ trivial_limit net \ (\e>0. eventually (\x. dist (f x) l < e) net)" by (auto simp: tendsto_iff trivial_limit_eq) @@ -553,7 +553,7 @@ using assms by (fast intro: tendsto_le tendsto_intros) -subsection \Continuity\ +section \Continuity\ text\Derive the epsilon-delta forms, which we often use as "definitions"\ @@ -656,7 +656,7 @@ unfolding continuous_within by (force intro: Lim_transform_within) -subsection \Closure and Limit Characterization\ +section \Closure and Limit Characterization\ lemma closure_approachable: fixes S :: "'a::metric_space set" @@ -751,7 +751,7 @@ qed -subsection \Boundedness\ +section \Boundedness\ (* FIXME: This has to be unified with BSEQ!! *) definition\<^marker>\tag important\ (in metric_space) bounded :: "'a set \ bool" @@ -882,7 +882,7 @@ qed -subsection \Compactness\ +section \Compactness\ lemma compact_imp_bounded: assumes "compact U" @@ -1097,7 +1097,7 @@ using compact_imp_bounded unfolding compact_eq_Bolzano_Weierstrass by metis -subsection \Banach fixed point theorem\ +section \Banach fixed point theorem\ theorem banach_fix:\ \TODO: rename to \Banach_fix\\ assumes s: "complete s" "s \ {}" @@ -1245,7 +1245,7 @@ qed -subsection \Edelstein fixed point theorem\ +section \Edelstein fixed point theorem\ theorem Edelstein_fix: fixes S :: "'a::metric_space set" @@ -1286,7 +1286,7 @@ using \a \ S\ by blast qed -subsection \The diameter of a set\ +section \The diameter of a set\ definition\<^marker>\tag important\ diameter :: "'a::metric_space set \ real" where "diameter S = (if S = {} then 0 else SUP (x,y)\S\S. dist x y)" @@ -1485,7 +1485,7 @@ qed -subsection \Metric spaces with the Heine-Borel property\ +section \Metric spaces with the Heine-Borel property\ text \ A metric space (or topological vector space) is said to have the @@ -1643,7 +1643,7 @@ qed -subsection \Completeness\ +section \Completeness\ proposition (in metric_space) completeI: assumes "\f. \n. f n \ s \ Cauchy f \ \l\s. f \ l" @@ -1869,7 +1869,7 @@ using assms banach_fix[OF complete_UNIV UNIV_not_empty assms(1,2) subset_UNIV, of f] by auto -subsection \Cauchy continuity\ +section \Cauchy continuity\ definition Cauchy_continuous_on where "Cauchy_continuous_on \ \S f. \\. Cauchy \ \ range \ \ S \ Cauchy (f \ \)" @@ -1937,7 +1937,7 @@ qed -subsection\<^marker>\tag unimportant\\ Finite intersection property\ +section\<^marker>\tag unimportant\\ Finite intersection property\ text\Also developed in HOL's toplogical spaces theory, but the Heine-Borel type class isn't available there.\ @@ -1985,7 +1985,7 @@ by (simp add: closed_limpt compact_eq_bounded_closed convergent_imp_bounded islimpt_insert sequence_unique_limpt) -subsection \Properties of Balls and Spheres\ +section \Properties of Balls and Spheres\ lemma compact_cball[simp]: fixes x :: "'a::heine_borel" @@ -2029,7 +2029,7 @@ qed -subsection \Distance from a Set\ +section \Distance from a Set\ lemma distance_attains_sup: assumes "compact s" "s \ {}" @@ -2066,7 +2066,7 @@ qed -subsection \Infimum Distance\ +section \Infimum Distance\ definition\<^marker>\tag important\ "infdist x A = (if A = {} then 0 else INF a\A. dist x a)" @@ -2299,7 +2299,7 @@ qed -subsection \Separation between Points and Sets\ +section \Separation between Points and Sets\ proposition separate_point_closed: fixes S :: "'a::heine_borel set" @@ -2362,7 +2362,7 @@ qed -subsection \Uniform Continuity\ +section \Uniform Continuity\ lemma uniformly_continuous_onE: assumes "uniformly_continuous_on s f" "0 < e" @@ -2429,7 +2429,7 @@ qed -subsection \Continuity on a Compact Domain Implies Uniform Continuity\ +section \Continuity on a Compact Domain Implies Uniform Continuity\ text\From the proof of the Heine-Borel theorem: Lemma 2 in section 3.7, page 69 of J. C. Burkill and H. Burkill. A Second Course in Mathematical Analysis (CUP, 2002)\ @@ -2521,7 +2521,7 @@ by (force intro: compact_uniformly_equicontinuous [OF S, of "{f}"]) -subsection\<^marker>\tag unimportant\\ Theorems relating continuity and uniform continuity to closures\ +section\<^marker>\tag unimportant\\ Theorems relating continuity and uniform continuity to closures\ lemma continuous_on_closure: "continuous_on (closure S) f \ @@ -2765,7 +2765,7 @@ by (metis (no_types, lifting) assms bounded_closure_image compact_closure compact_continuous_image compact_eq_bounded_closed image_cong uniformly_continuous_imp_continuous uniformly_continuous_on_extension_on_closure) -subsection \With Abstract Topology (TODO: move and remove dependency?)\ +section \With Abstract Topology (TODO: move and remove dependency?)\ lemma openin_contains_ball: "openin (top_of_set T) S \ @@ -2796,7 +2796,7 @@ qed -subsection \Closed Nest\ +section \Closed Nest\ text \Bounded closed nest property (proof does not use Heine-Borel)\ @@ -2908,7 +2908,7 @@ then show ?thesis .. qed -subsection\<^marker>\tag unimportant\ \Making a continuous function avoid some value in a neighbourhood\ +section\<^marker>\tag unimportant\ \Making a continuous function avoid some value in a neighbourhood\ lemma continuous_within_avoid: fixes f :: "'a::metric_space \ 'b::t1_space" @@ -2958,7 +2958,7 @@ using continuous_at_avoid[of x f a] assms(4) by auto -subsection \Consequences for Real Numbers\ +section \Consequences for Real Numbers\ lemma closed_contains_Inf: fixes S :: "real set" @@ -3093,7 +3093,7 @@ by auto -subsection\The infimum of the distance between two sets\ +section\The infimum of the distance between two sets\ definition\<^marker>\tag important\ setdist :: "'a::metric_space set \ 'a set \ real" where "setdist s t \ @@ -3269,4 +3269,72 @@ qed (fact \y \ B\) qed + +section \Diameter Lemma\ + +text \taken from the AFP entry Martingales, by Ata Keskin, TU München\ + +lemma diameter_comp_strict_mono: + fixes s :: "nat \ 'a :: metric_space" + assumes "strict_mono r" "bounded {s i |i. r n \ i}" + shows "diameter {s (r i) | i. n \ i} \ diameter {s i | i. r n \ i}" +proof (rule diameter_subset) + show "{s (r i) | i. n \ i} \ {s i | i. r n \ i}" using assms(1) monotoneD strict_mono_mono by fastforce +qed (intro assms(2)) + +lemma diameter_bounded_bound': + fixes S :: "'a :: metric_space set" + assumes S: "bdd_above (case_prod dist ` (S\S))" and "x \ S" "y \ S" + shows "dist x y \ diameter S" +proof - + have "(x,y) \ S\S" using assms by auto + then have "dist x y \ (SUP (x,y)\S\S. dist x y)" + by (metis S cSUP_upper case_prod_conv) + with \x \ S\ show ?thesis by (auto simp: diameter_def) +qed + +lemma bounded_imp_dist_bounded: + assumes "bounded (range s)" + shows "bounded ((\(i, j). dist (s i) (s j)) ` ({n..} \ {n..}))" + using bounded_dist_comp[OF bounded_fst bounded_snd, OF bounded_Times(1,1)[OF assms(1,1)]] by (rule bounded_subset, force) + +text \A sequence is Cauchy, if and only if it is bounded and its diameter tends to zero. The diameter is well-defined only if the sequence is bounded.\ +lemma cauchy_iff_diameter_tends_to_zero_and_bounded: + fixes s :: "nat \ 'a :: metric_space" + shows "Cauchy s \ ((\n. diameter {s i | i. i \ n}) \ 0 \ bounded (range s))" +proof - + have "{s i |i. N \ i} \ {}" for N by blast + hence diameter_SUP: "diameter {s i |i. N \ i} = (SUP (i, j) \ {N..} \ {N..}. dist (s i) (s j))" for N unfolding diameter_def by (auto intro!: arg_cong[of _ _ Sup]) + show ?thesis + proof (intro iffI) + assume asm: "Cauchy s" + have "\N. \n\N. norm (diameter {s i |i. n \ i}) < e" if e_pos: "e > 0" for e + proof - + obtain N where dist_less: "dist (s n) (s m) < (1/2) * e" if "n \ N" "m \ N" for n m using asm e_pos by (metis Cauchy_def mult_pos_pos zero_less_divide_iff zero_less_numeral zero_less_one) + { + fix r assume "r \ N" + hence "dist (s n) (s m) < (1/2) * e" if "n \ r" "m \ r" for n m using dist_less that by simp + hence "(SUP (i, j) \ {r..} \ {r..}. dist (s i) (s j)) \ (1/2) * e" by (intro cSup_least) fastforce+ + also have "... < e" using e_pos by simp + finally have "diameter {s i |i. r \ i} < e" using diameter_SUP by presburger + } + moreover have "diameter {s i |i. r \ i} \ 0" for r unfolding diameter_SUP using bounded_imp_dist_bounded[OF cauchy_imp_bounded, THEN bounded_imp_bdd_above, OF asm] by (intro cSup_upper2, auto) + ultimately show ?thesis by auto + qed + thus "(\n. diameter {s i |i. n \ i}) \ 0 \ bounded (range s)" using cauchy_imp_bounded[OF asm] by (simp add: LIMSEQ_iff) + next + assume asm: "(\n. diameter {s i |i. n \ i}) \ 0 \ bounded (range s)" + have "\N. \n\N. \m\N. dist (s n) (s m) < e" if e_pos: "e > 0" for e + proof - + obtain N where diam_less: "diameter {s i |i. r \ i} < e" if "r \ N" for r using LIMSEQ_D asm(1) e_pos by fastforce + { + fix n m assume "n \ N" "m \ N" + hence "dist (s n) (s m) < e" using cSUP_lessD[OF bounded_imp_dist_bounded[THEN bounded_imp_bdd_above], OF _ diam_less[unfolded diameter_SUP]] asm by auto + } + thus ?thesis by blast + qed + then show "Cauchy s" by (simp add: Cauchy_def) + qed +qed + end diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/Analysis/Set_Integral.thy --- a/src/HOL/Analysis/Set_Integral.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/Analysis/Set_Integral.thy Tue Mar 05 16:55:21 2024 +0100 @@ -7,13 +7,13 @@ TODO: keep all these? Need unicode translations as well. *) +chapter \Integrals over a Set\ + theory Set_Integral imports Radon_Nikodym begin -(* - Notation -*) +section \Notation\ definition\<^marker>\tag important\ "set_borel_measurable M A f \ (\x. indicator A x *\<^sub>R f x) \ borel_measurable M" @@ -45,9 +45,7 @@ "_set_lebesgue_borel_integral" :: "pttrn \ real set \ real \ real" ("(3LBINT _:_./ _)" [0,0,10] 10) -(* - Basic properties -*) +section \Basic properties\ (* lemma indicator_abs_eq: "\A x. \indicator A x\ = ((indicator A x) :: real)" @@ -149,6 +147,13 @@ (* TODO: integral_cmul_indicator should be named set_integral_const *) (* TODO: borel_integrable_atLeastAtMost should be named something like set_integrable_Icc_isCont *) +lemma set_integral_scaleR_left: + assumes "A \ sets M" "c \ 0 \ integrable M f" + shows "(LINT t:A|M. f t *\<^sub>R c) = (LINT t:A|M. f t) *\<^sub>R c" + unfolding set_lebesgue_integral_def + using integrable_mult_indicator[OF assms] + by (subst integral_scaleR_left[symmetric], auto) + lemma set_integral_scaleR_right [simp]: "(LINT t:A|M. a *\<^sub>R f t) = a *\<^sub>R (LINT t:A|M. f t)" unfolding set_lebesgue_integral_def by (subst integral_scaleR_right[symmetric]) (auto intro!: Bochner_Integration.integral_cong) @@ -444,7 +449,7 @@ using intgbl set_integrable_def by blast qed -(* Proof from Royden Real Analysis, p. 91. *) +text \Proof from Royden, \emph{Real Analysis}, p. 91.\ lemma lebesgue_integral_countable_add: fixes f :: "_ \ 'a :: {banach, second_countable_topology}" assumes meas[intro]: "\i::nat. A i \ sets M" @@ -489,11 +494,7 @@ by simp qed show "LINT x|M. indicator (\(A ` UNIV)) x *\<^sub>R f x = LINT x|M. (\i. indicator (A i) x *\<^sub>R f x)" - apply (rule Bochner_Integration.integral_cong[OF refl]) - apply (subst suminf_scaleR_left[OF sums_summable[OF indicator_sums, OF disj], symmetric]) - using sums_unique[OF indicator_sums[OF disj]] - apply auto - done + by (metis (no_types, lifting) integral_cong sums sums_unique) qed lemma set_integral_cont_up: @@ -562,6 +563,8 @@ qed +section \Complex integrals\ + abbreviation complex_integrable :: "'a measure \ ('a \ complex) \ bool" where "complex_integrable M f \ integrable M f" @@ -610,11 +613,11 @@ "complex_set_lebesgue_integral M A f \ set_lebesgue_integral M A f" syntax -"_ascii_complex_set_lebesgue_integral" :: "pttrn \ 'a set \ 'a measure \ real \ real" -("(4CLINT _:_|_. _)" [0,0,0,10] 10) + "_ascii_complex_set_lebesgue_integral" :: "pttrn \ 'a set \ 'a measure \ real \ real" + ("(4CLINT _:_|_. _)" [0,0,0,10] 10) translations -"CLINT x:A|M. f" == "CONST complex_set_lebesgue_integral M A (\x. f)" + "CLINT x:A|M. f" == "CONST complex_set_lebesgue_integral M A (\x. f)" lemma set_measurable_continuous_on_ivl: assumes "continuous_on {a..b} (f :: real \ real)" @@ -622,6 +625,7 @@ unfolding set_borel_measurable_def by (rule borel_measurable_continuous_on_indicator[OF _ assms]) simp +section \NN Set Integrals\ text\This notation is from Sébastien Gouëzel: His use is not directly in line with the notations in this file, they are more in line with sum, and more readable he thinks.\ @@ -656,7 +660,7 @@ by (auto split: split_indicator) then have "(\\<^sup>+x. f x * indicator (B \ C) x \M) = (\\<^sup>+x. f x * indicator B x + f x * indicator C x \M)" by simp - also have "... = (\\<^sup>+x. f x * indicator B x \M) + (\\<^sup>+x. f x * indicator C x \M)" + also have "\ = (\\<^sup>+x. f x * indicator B x \M) + (\\<^sup>+x. f x * indicator C x \M)" by (rule nn_integral_add) (auto simp add: assms mes pos) finally show ?thesis by simp qed @@ -719,7 +723,7 @@ proof - have "(\\<^sup>+x \ A. (f x + g x) \M) = (\\<^sup>+x. (f x * indicator A x + g x * indicator A x) \M)" by (auto simp add: indicator_def intro!: nn_integral_cong) - also have "... = (\\<^sup>+x. f x * indicator A x \M) + (\\<^sup>+x. g x * indicator A x \M)" + also have "\ = (\\<^sup>+x. f x * indicator A x \M) + (\\<^sup>+x. g x * indicator A x \M)" apply (rule nn_integral_add) using assms(1) assms(2) by auto finally show ?thesis by simp qed @@ -750,9 +754,9 @@ proof - have "(\\<^sup>+x \ A. f (g x) \count_space UNIV) = (\\<^sup>+x. f (g x) \count_space A)" by (auto simp add: nn_integral_count_space_indicator[symmetric]) - also have "... = (\\<^sup>+y. f y \count_space (g`A))" + also have "\ = (\\<^sup>+y. f y \count_space (g`A))" by (simp add: assms nn_integral_bij_count_space inj_on_imp_bij_betw) - also have "... = (\\<^sup>+y \ g`A. f y \count_space UNIV)" + also have "\ = (\\<^sup>+y \ g`A. f y \count_space UNIV)" by (auto simp add: nn_integral_count_space_indicator[symmetric]) finally show ?thesis by simp qed @@ -855,6 +859,8 @@ then show ?thesis using * by auto qed +section \Scheffé's lemma\ + text \The next lemma shows that \L\<^sup>1\ convergence of a sequence of functions follows from almost everywhere convergence and the weaker condition of the convergence of the integrated norms (or even just the nontrivial inequality about them). Useful in a lot of contexts! This statement (or its @@ -897,7 +903,7 @@ then have "AE x in M. liminf (\n. ennreal(G n x)) = ennreal(2 * norm(f x))" using assms(3) by auto then have "(\\<^sup>+ x. liminf (\n. ennreal (G n x)) \M) = (\\<^sup>+ x. 2 * ennreal(norm(f x)) \M)" by (simp add: nn_integral_cong_AE ennreal_mult) - also have "... = 2 * (\\<^sup>+ x. norm(f x) \M)" by (rule nn_integral_cmult) auto + also have "\ = 2 * (\\<^sup>+ x. norm(f x) \M)" by (rule nn_integral_cmult) auto finally have int_liminf: "(\\<^sup>+ x. liminf (\n. ennreal (G n x)) \M) = 2 * (\\<^sup>+ x. norm(f x) \M)" by simp @@ -906,11 +912,11 @@ then have "limsup (\n. (\\<^sup>+x. ennreal(norm(f x)) + ennreal(norm(F n x)) \M)) = limsup (\n. (\\<^sup>+x. norm(f x) \M) + (\\<^sup>+x. norm(F n x) \M))" by simp - also have "... = (\\<^sup>+x. norm(f x) \M) + limsup (\n. (\\<^sup>+x. norm(F n x) \M))" + also have "\ = (\\<^sup>+x. norm(f x) \M) + limsup (\n. (\\<^sup>+x. norm(F n x) \M))" by (rule Limsup_const_add, auto simp add: finint) - also have "... \ (\\<^sup>+x. norm(f x) \M) + (\\<^sup>+x. norm(f x) \M)" + also have "\ \ (\\<^sup>+x. norm(f x) \M) + (\\<^sup>+x. norm(f x) \M)" using assms(4) by (simp add: add_left_mono) - also have "... = 2 * (\\<^sup>+x. norm(f x) \M)" + also have "\ = 2 * (\\<^sup>+x. norm(f x) \M)" unfolding one_add_one[symmetric] distrib_right by simp ultimately have a: "limsup (\n. (\\<^sup>+x. ennreal(norm(f x)) + ennreal(norm(F n x)) \M)) \ 2 * (\\<^sup>+x. norm(f x) \M)" by simp @@ -994,6 +1000,7 @@ with eq show ?case by simp qed +section \Convergence of integrals over an interval\ text \ The next lemmas relate convergence of integrals over an interval to @@ -1122,7 +1129,7 @@ using \c>0\ A by (auto simp: ennreal_mult'[symmetric]) then have "emeasure M {x \ A. u x \ c} = emeasure M ({x \ A. ennreal(1/c) * u x \ 1})" by simp - also have "... \ ennreal(1/c) * (\\<^sup>+ x. ennreal(u x) * indicator A x \M)" + also have "\ \ ennreal(1/c) * (\\<^sup>+ x. ennreal(u x) * indicator A x \M)" by (intro nn_integral_Markov_inequality meas assms) also have "(\\<^sup>+ x. ennreal(u x) * indicator A x \M) = ennreal (set_lebesgue_integral M A u)" unfolding set_lebesgue_integral_def nn_integral_set_ennreal using assms AE @@ -1178,4 +1185,767 @@ by (simp add: exp_minus field_simps) qed + +section \Integrable Simple Functions\ + +text \This section is from the Martingales AFP entry, by Ata Keskin, TU München\ + +text \We restate some basic results concerning Bochner-integrable functions.\ + +lemma integrable_implies_simple_function_sequence: + fixes f :: "'a \ 'b::{banach, second_countable_topology}" + assumes "integrable M f" + obtains s where "\i. simple_function M (s i)" + and "\i. emeasure M {y \ space M. s i y \ 0} \ \" + and "\x. x \ space M \ (\i. s i x) \ f x" + and "\x i. x \ space M \ norm (s i x) \ 2 * norm (f x)" +proof- + have f: "f \ borel_measurable M" "(\\<^sup>+x. norm (f x) \M) < \" using assms unfolding integrable_iff_bounded by auto + obtain s where s: "\i. simple_function M (s i)" "\x. x \ space M \ (\i. s i x) \ f x" "\i x. x \ space M \ norm (s i x) \ 2 * norm (f x)" using borel_measurable_implies_sequence_metric[OF f(1)] unfolding norm_conv_dist by metis + { + fix i + have "(\\<^sup>+x. norm (s i x) \M) \ (\\<^sup>+x. ennreal (2 * norm (f x)) \M)" using s by (intro nn_integral_mono, auto) + also have "\ < \" using f by (simp add: nn_integral_cmult ennreal_mult_less_top ennreal_mult) + finally have sbi: "Bochner_Integration.simple_bochner_integrable M (s i)" using s by (intro simple_bochner_integrableI_bounded) auto + hence "emeasure M {y \ space M. s i y \ 0} \ \" by (auto intro: integrableI_simple_bochner_integrable simple_bochner_integrable.cases) + } + thus ?thesis using that s by blast +qed + +text \Simple functions can be represented by sums of indicator functions.\ + +lemma simple_function_indicator_representation_banach: + fixes f ::"'a \ 'b :: {second_countable_topology, banach}" + assumes "simple_function M f" "x \ space M" + shows "f x = (\y \ f ` space M. indicator (f -` {y} \ space M) x *\<^sub>R y)" + (is "?l = ?r") +proof - + have "?r = (\y \ f ` space M. (if y = f x then indicator (f -` {y} \ space M) x *\<^sub>R y else 0))" + by (auto intro!: sum.cong) + also have "\ = indicator (f -` {f x} \ space M) x *\<^sub>R f x" using assms by (auto dest: simple_functionD) + also have "\ = f x" using assms by (auto simp: indicator_def) + finally show ?thesis by auto +qed + +lemma simple_function_indicator_representation_AE: + fixes f ::"'a \ 'b :: {second_countable_topology, banach}" + assumes "simple_function M f" + shows "AE x in M. f x = (\y \ f ` space M. indicator (f -` {y} \ space M) x *\<^sub>R y)" + by (metis (mono_tags, lifting) AE_I2 simple_function_indicator_representation_banach assms) + +lemmas simple_function_scaleR[intro] = simple_function_compose2[where h="(*\<^sub>R)"] +lemmas integrable_simple_function = simple_bochner_integrable.intros[THEN has_bochner_integral_simple_bochner_integrable, THEN integrable.intros] + +text \Induction rule for simple integrable functions.\ + +lemma\<^marker>\tag important\ integrable_simple_function_induct[consumes 2, case_names cong indicator add, induct set: simple_function]: + fixes f :: "'a \ 'b :: {second_countable_topology, banach}" + assumes f: "simple_function M f" "emeasure M {y \ space M. f y \ 0} \ \" + assumes cong: "\f g. simple_function M f \ emeasure M {y \ space M. f y \ 0} \ \ + \ simple_function M g \ emeasure M {y \ space M. g y \ 0} \ \ + \ (\x. x \ space M \ f x = g x) \ P f \ P g" + assumes indicator: "\A y. A \ sets M \ emeasure M A < \ \ P (\x. indicator A x *\<^sub>R y)" + assumes add: "\f g. simple_function M f \ emeasure M {y \ space M. f y \ 0} \ \ \ + simple_function M g \ emeasure M {y \ space M. g y \ 0} \ \ \ + (\z. z \ space M \ norm (f z + g z) = norm (f z) + norm (g z)) \ + P f \ P g \ P (\x. f x + g x)" + shows "P f" +proof- + let ?f = "\x. (\y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + have f_ae_eq: "f x = ?f x" if "x \ space M" for x using simple_function_indicator_representation_banach[OF f(1) that] . + moreover have "emeasure M {y \ space M. ?f y \ 0} \ \" by (metis (no_types, lifting) Collect_cong calculation f(2)) + moreover have "P (\x. \y\S. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + "simple_function M (\x. \y\S. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + "emeasure M {y \ space M. (\x\S. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ \" + if "S \ f ` space M" for S using simple_functionD(1)[OF assms(1), THEN rev_finite_subset, OF that] that + proof (induction rule: finite_induct) + case empty + { + case 1 + then show ?case using indicator[of "{}"] by force + next + case 2 + then show ?case by force + next + case 3 + then show ?case by force + } + next + case (insert x F) + have "(f -` {x} \ space M) \ {y \ space M. f y \ 0}" if "x \ 0" using that by blast + moreover have "{y \ space M. f y \ 0} = space M - (f -` {0} \ space M)" by blast + moreover have "space M - (f -` {0} \ space M) \ sets M" using simple_functionD(2)[OF f(1)] by blast + ultimately have fin_0: "emeasure M (f -` {x} \ space M) < \" if "x \ 0" using that by (metis emeasure_mono f(2) infinity_ennreal_def top.not_eq_extremum top_unique) + hence fin_1: "emeasure M {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0} \ \" if "x \ 0" by (metis (mono_tags, lifting) emeasure_mono f(1) indicator_simps(2) linorder_not_less mem_Collect_eq scaleR_eq_0_iff simple_functionD(2) subsetI that) + + have *: "(\y\insert x F. indicat_real (f -` {y} \ space M) xa *\<^sub>R y) = (\y\F. indicat_real (f -` {y} \ space M) xa *\<^sub>R y) + indicat_real (f -` {x} \ space M) xa *\<^sub>R x" for xa by (metis (no_types, lifting) Diff_empty Diff_insert0 add.commute insert.hyps(1) insert.hyps(2) sum.insert_remove) + have **: "{y \ space M. (\x\insert x F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0}" unfolding * by fastforce + { + case 1 + hence x: "x \ f ` space M" and F: "F \ f ` space M" by auto + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert(3)[OF F] by simp + next + case False + have norm_argument: "norm ((\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) + indicat_real (f -` {x} \ space M) z *\<^sub>R x) = norm (\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) + norm (indicat_real (f -` {x} \ space M) z *\<^sub>R x)" if z: "z \ space M" for z + proof (cases "f z = x") + case True + have "indicat_real (f -` {y} \ space M) z *\<^sub>R y = 0" if "y \ F" for y + using True insert(2) z that 1 unfolding indicator_def by force + hence "(\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) = 0" by (meson sum.neutral) + then show ?thesis by force + next + case False + then show ?thesis by force + qed + show ?thesis + using False simple_functionD(2)[OF f(1)] insert(3,5)[OF F] simple_function_scaleR fin_0 fin_1 + by (subst *, subst add, subst simple_function_sum) (blast intro: norm_argument indicator)+ + qed + next + case 2 + hence x: "x \ f ` space M" and F: "F \ f ` space M" by auto + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert(4)[OF F] by simp + next + case False + then show ?thesis unfolding * using insert(4)[OF F] simple_functionD(2)[OF f(1)] by fast + qed + next + case 3 + hence x: "x \ f ` space M" and F: "F \ f ` space M" by auto + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert(5)[OF F] by simp + next + case False + have "emeasure M {y \ space M. (\x\insert x F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ emeasure M ({y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0})" + using ** simple_functionD(2)[OF insert(4)[OF F]] simple_functionD(2)[OF f(1)] by (intro emeasure_mono, force+) + also have "\ \ emeasure M {y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} + emeasure M {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0}" + using simple_functionD(2)[OF insert(4)[OF F]] simple_functionD(2)[OF f(1)] by (intro emeasure_subadditive, force+) + also have "\ < \" using insert(5)[OF F] fin_1[OF False] by (simp add: less_top) + finally show ?thesis by simp + qed + } + qed + moreover have "simple_function M (\x. \y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" using calculation by blast + moreover have "P (\x. \y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" using calculation by blast + ultimately show ?thesis by (intro cong[OF _ _ f(1,2)], blast, presburger+) +qed + +text \Induction rule for non-negative simple integrable functions\ +lemma\<^marker>\tag important\ integrable_simple_function_induct_nn[consumes 3, case_names cong indicator add, induct set: simple_function]: + fixes f :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes f: "simple_function M f" "emeasure M {y \ space M. f y \ 0} \ \" "\x. x \ space M \ f x \ 0" + assumes cong: "\f g. simple_function M f \ emeasure M {y \ space M. f y \ 0} \ \ \ (\x. x \ space M \ f x \ 0) \ simple_function M g \ emeasure M {y \ space M. g y \ 0} \ \ \ (\x. x \ space M \ g x \ 0) \ (\x. x \ space M \ f x = g x) \ P f \ P g" + assumes indicator: "\A y. y \ 0 \ A \ sets M \ emeasure M A < \ \ P (\x. indicator A x *\<^sub>R y)" + assumes add: "\f g. (\x. x \ space M \ f x \ 0) \ simple_function M f \ emeasure M {y \ space M. f y \ 0} \ \ \ + (\x. x \ space M \ g x \ 0) \ simple_function M g \ emeasure M {y \ space M. g y \ 0} \ \ \ + (\z. z \ space M \ norm (f z + g z) = norm (f z) + norm (g z)) \ + P f \ P g \ P (\x. f x + g x)" + shows "P f" +proof- + let ?f = "\x. (\y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + have f_ae_eq: "f x = ?f x" if "x \ space M" for x using simple_function_indicator_representation_banach[OF f(1) that] . + moreover have "emeasure M {y \ space M. ?f y \ 0} \ \" by (metis (no_types, lifting) Collect_cong calculation f(2)) + moreover have "P (\x. \y\S. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + "simple_function M (\x. \y\S. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + "emeasure M {y \ space M. (\x\S. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ \" + "\x. x \ space M \ 0 \ (\y\S. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + if "S \ f ` space M" for S using simple_functionD(1)[OF assms(1), THEN rev_finite_subset, OF that] that + proof (induction rule: finite_subset_induct') + case empty + { + case 1 + then show ?case using indicator[of 0 "{}"] by force + next + case 2 + then show ?case by force + next + case 3 + then show ?case by force + next + case 4 + then show ?case by force + } + next + case (insert x F) + have "(f -` {x} \ space M) \ {y \ space M. f y \ 0}" if "x \ 0" + using that by blast + moreover have "{y \ space M. f y \ 0} = space M - (f -` {0} \ space M)" + by blast + moreover have "space M - (f -` {0} \ space M) \ sets M" + using simple_functionD(2)[OF f(1)] by blast + ultimately have fin_0: "emeasure M (f -` {x} \ space M) < \" if "x \ 0" + using that by (metis emeasure_mono f(2) infinity_ennreal_def top.not_eq_extremum top_unique) + hence fin_1: "emeasure M {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0} \ \" if "x \ 0" + by (metis (mono_tags, lifting) emeasure_mono f(1) indicator_simps(2) linorder_not_less mem_Collect_eq scaleR_eq_0_iff simple_functionD(2) subsetI that) + + have nonneg_x: "x \ 0" using insert f by blast + have *: "(\y\insert x F. indicat_real (f -` {y} \ space M) xa *\<^sub>R y) = (\y\F. indicat_real (f -` {y} \ space M) xa *\<^sub>R y) + indicat_real (f -` {x} \ space M) xa *\<^sub>R x" for xa by (metis (no_types, lifting) add.commute insert.hyps(1) insert.hyps(4) sum.insert) + have **: "{y \ space M. (\x\insert x F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0}" unfolding * by fastforce + { + case 1 + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert by simp + next + case False + have norm_argument: "norm ((\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) + indicat_real (f -` {x} \ space M) z *\<^sub>R x) + = norm (\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) + norm (indicat_real (f -` {x} \ space M) z *\<^sub>R x)" + if z: "z \ space M" for z + proof (cases "f z = x") + case True + have "indicat_real (f -` {y} \ space M) z *\<^sub>R y = 0" if "y \ F" for y + using True insert z that 1 unfolding indicator_def by force + hence "(\y\F. indicat_real (f -` {y} \ space M) z *\<^sub>R y) = 0" + by (meson sum.neutral) + thus ?thesis by force + qed (force) + show ?thesis using False fin_0 fin_1 f norm_argument + by (subst *, subst add, presburger add: insert, intro insert, intro insert, fastforce simp add: indicator_def intro!: insert(2) f(3), auto intro!: indicator insert nonneg_x) + qed + next + case 2 + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert by simp + next + case False + then show ?thesis unfolding * using insert simple_functionD(2)[OF f(1)] by fast + qed + next + case 3 + show ?case + proof (cases "x = 0") + case True + then show ?thesis unfolding * using insert by simp + next + case False + have "emeasure M {y \ space M. (\x\insert x F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} + \ emeasure M ({y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} \ {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0})" + using ** simple_functionD(2)[OF insert(6)] simple_functionD(2)[OF f(1)] insert.IH(2) by (intro emeasure_mono, blast, simp) + also have "\ \ emeasure M {y \ space M. (\x\F. indicat_real (f -` {x} \ space M) y *\<^sub>R x) \ 0} + emeasure M {y \ space M. indicat_real (f -` {x} \ space M) y *\<^sub>R x \ 0}" + using simple_functionD(2)[OF insert(6)] simple_functionD(2)[OF f(1)] by (intro emeasure_subadditive, force+) + also have "\ < \" using insert(7) fin_1[OF False] by (simp add: less_top) + finally show ?thesis by simp + qed + next + case (4 \) + thus ?case using insert nonneg_x f(3) by (auto simp add: scaleR_nonneg_nonneg intro: sum_nonneg) + } + qed + moreover have "simple_function M (\x. \y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + using calculation by blast + moreover have "P (\x. \y\f ` space M. indicat_real (f -` {y} \ space M) x *\<^sub>R y)" + using calculation by blast + moreover have "\x. x \ space M \ 0 \ f x" using f(3) by simp + ultimately show ?thesis + by (smt (verit) Collect_cong f(1) local.cong) +qed + +lemma finite_nn_integral_imp_ae_finite: + fixes f :: "'a \ ennreal" + assumes "f \ borel_measurable M" "(\\<^sup>+x. f x \M) < \" + shows "AE x in M. f x < \" +proof (rule ccontr, goal_cases) + case 1 + let ?A = "space M \ {x. f x = \}" + have *: "emeasure M ?A > 0" using 1 assms(1) + by (metis (mono_tags, lifting) assms(2) eventually_mono infinity_ennreal_def nn_integral_noteq_infinite top.not_eq_extremum) + have "(\\<^sup>+x. f x * indicator ?A x \M) = (\\<^sup>+x. \ * indicator ?A x \M)" + by (metis (mono_tags, lifting) indicator_inter_arith indicator_simps(2) mem_Collect_eq mult_eq_0_iff) + also have "\ = \ * emeasure M ?A" + using assms(1) by (intro nn_integral_cmult_indicator, simp) + also have "\ = \" + using * by fastforce + finally have "(\\<^sup>+x. f x * indicator ?A x \M) = \" . + moreover have "(\\<^sup>+x. f x * indicator ?A x \M) \ (\\<^sup>+x. f x \M)" + by (intro nn_integral_mono, simp add: indicator_def) + ultimately show ?case using assms(2) by simp +qed + +text \Convergence in L1-Norm implies existence of a subsequence which convergences almost everywhere. + This lemma is easier to use than the existing one in \<^theory>\HOL-Analysis.Bochner_Integration\\ + +lemma cauchy_L1_AE_cauchy_subseq: + fixes s :: "nat \ 'a \ 'b::{banach, second_countable_topology}" + assumes [measurable]: "\n. integrable M (s n)" + and "\e. e > 0 \ \N. \i\N. \j\N. LINT x|M. norm (s i x - s j x) < e" + obtains r where "strict_mono r" "AE x in M. Cauchy (\i. s (r i) x)" +proof- + have "\r. \n. (\i\r n. \j\ r n. LINT x|M. norm (s i x - s j x) < (1 / 2) ^ n) \ (r (Suc n) > r n)" + proof (intro dependent_nat_choice, goal_cases) + case 1 + then show ?case using assms(2) by presburger + next + case (2 x n) + obtain N where *: "LINT x|M. norm (s i x - s j x) < (1 / 2) ^ Suc n" if "i \ N" "j \ N" for i j + using assms(2)[of "(1 / 2) ^ Suc n"] by auto + { + fix i j assume "i \ max N (Suc x)" "j \ max N (Suc x)" + hence "integral\<^sup>L M (\x. norm (s i x - s j x)) < (1 / 2) ^ Suc n" using * by fastforce + } + then show ?case by fastforce + qed + then obtain r where strict_mono: "strict_mono r" and "\i\r n. \j\ r n. LINT x|M. norm (s i x - s j x) < (1 / 2) ^ n" for n + using strict_mono_Suc_iff by blast + hence r_is: "LINT x|M. norm (s (r (Suc n)) x - s (r n) x) < (1 / 2) ^ n" for n by (simp add: strict_mono_leD) + + define g where "g = (\n x. (\i\n. ennreal (norm (s (r (Suc i)) x - s (r i) x))))" + define g' where "g' = (\x. \i. ennreal (norm (s (r (Suc i)) x - s (r i) x)))" + + have integrable_g: "(\\<^sup>+ x. g n x \M) < 2" for n + proof - + have "(\\<^sup>+ x. g n x \M) = (\\<^sup>+ x. (\i\n. ennreal (norm (s (r (Suc i)) x - s (r i) x))) \M)" + using g_def by simp + also have "\ = (\i\n. (\\<^sup>+ x. ennreal (norm (s (r (Suc i)) x - s (r i) x)) \M))" + by (intro nn_integral_sum, simp) + also have "\ = (\i\n. LINT x|M. norm (s (r (Suc i)) x - s (r i) x))" + unfolding dist_norm using assms(1) by (subst nn_integral_eq_integral[OF integrable_norm], auto) + also have "\ < ennreal (\i\n. (1 / 2) ^ i)" + by (intro ennreal_lessI[OF sum_pos sum_strict_mono[OF finite_atMost _ r_is]], auto) + also have "\ \ ennreal 2" + unfolding sum_gp0[of "1 / 2" n] by (intro ennreal_leI, auto) + finally show "(\\<^sup>+ x. g n x \M) < 2" by simp + qed + + have integrable_g': "(\\<^sup>+ x. g' x \M) \ 2" + proof - + have "incseq (\n. g n x)" for x by (intro incseq_SucI, auto simp add: g_def ennreal_leI) + hence "convergent (\n. g n x)" for x + unfolding convergent_def using LIMSEQ_incseq_SUP by fast + hence "(\n. g n x) \ g' x" for x + unfolding g_def g'_def by (intro summable_iff_convergent'[THEN iffD2, THEN summable_LIMSEQ'], blast) + hence "(\\<^sup>+ x. g' x \M) = (\\<^sup>+ x. liminf (\n. g n x) \M)" by (metis lim_imp_Liminf trivial_limit_sequentially) + also have "\ \ liminf (\n. \\<^sup>+ x. g n x \M)" by (intro nn_integral_liminf, simp add: g_def) + also have "\ \ liminf (\n. 2)" using integrable_g by (intro Liminf_mono) (simp add: order_le_less) + also have "\ = 2" + using sequentially_bot tendsto_iff_Liminf_eq_Limsup by blast + finally show ?thesis . + qed + hence "AE x in M. g' x < \" + by (intro finite_nn_integral_imp_ae_finite) (auto simp add: order_le_less_trans g'_def) + moreover have "summable (\i. norm (s (r (Suc i)) x - s (r i) x))" if "g' x \ \" for x + using that unfolding g'_def by (intro summable_suminf_not_top) fastforce+ + ultimately have ae_summable: "AE x in M. summable (\i. s (r (Suc i)) x - s (r i) x)" + using summable_norm_cancel unfolding dist_norm by force + + { + fix x assume "summable (\i. s (r (Suc i)) x - s (r i) x)" + hence "(\n. \i (\i. s (r (Suc i)) x - s (r i) x)" + using summable_LIMSEQ by blast + moreover have "(\n. (\in. s (r n) x - s (r 0) x)" + using sum_lessThan_telescope by fastforce + ultimately have "(\n. s (r n) x - s (r 0) x) \ (\i. s (r (Suc i)) x - s (r i) x)" by argo + hence "(\n. s (r n) x - s (r 0) x + s (r 0) x) \ (\i. s (r (Suc i)) x - s (r i) x) + s (r 0) x" + by (intro isCont_tendsto_compose[of _ "\z. z + s (r 0) x"], auto) + hence "Cauchy (\n. s (r n) x)" by (simp add: LIMSEQ_imp_Cauchy) + } + hence "AE x in M. Cauchy (\i. s (r i) x)" using ae_summable by fast + thus ?thesis by (rule that[OF strict_mono(1)]) +qed + +subsection \Totally Ordered Banach Spaces\ + +lemma integrable_max[simp, intro]: + fixes f :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology}" + assumes fg[measurable]: "integrable M f" "integrable M g" + shows "integrable M (\x. max (f x) (g x))" +proof (rule Bochner_Integration.integrable_bound) + { + fix x y :: 'b + have "norm (max x y) \ max (norm x) (norm y)" by linarith + also have "\ \ norm x + norm y" by simp + finally have "norm (max x y) \ norm (norm x + norm y)" by simp + } + thus "AE x in M. norm (max (f x) (g x)) \ norm (norm (f x) + norm (g x))" by simp +qed (auto intro: Bochner_Integration.integrable_add[OF integrable_norm[OF fg(1)] integrable_norm[OF fg(2)]]) + +lemma integrable_min[simp, intro]: + fixes f :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology}" + assumes [measurable]: "integrable M f" "integrable M g" + shows "integrable M (\x. min (f x) (g x))" +proof - + have "norm (min (f x) (g x)) \ norm (f x) \ norm (min (f x) (g x)) \ norm (g x)" for x by linarith + thus ?thesis + by (intro integrable_bound[OF integrable_max[OF integrable_norm(1,1), OF assms]], auto) +qed + +text \Restatement of \integral_nonneg_AE\ for functions taking values in a Banach space.\ +lemma integral_nonneg_AE_banach: + fixes f :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes [measurable]: "f \ borel_measurable M" and nonneg: "AE x in M. 0 \ f x" + shows "0 \ integral\<^sup>L M f" +proof cases + assume integrable: "integrable M f" + hence max: "(\x. max 0 (f x)) \ borel_measurable M" "\x. 0 \ max 0 (f x)" "integrable M (\x. max 0 (f x))" by auto + hence "0 \ integral\<^sup>L M (\x. max 0 (f x))" + proof - + obtain s where *: "\i. simple_function M (s i)" + "\i. emeasure M {y \ space M. s i y \ 0} \ \" + "\x. x \ space M \ (\i. s i x) \ f x" + "\x i. x \ space M \ norm (s i x) \ 2 * norm (f x)" + using integrable_implies_simple_function_sequence[OF integrable] by blast + have simple: "\i. simple_function M (\x. max 0 (s i x))" + using * by fast + have "\i. {y \ space M. max 0 (s i y) \ 0} \ {y \ space M. s i y \ 0}" + unfolding max_def by force + moreover have "\i. {y \ space M. s i y \ 0} \ sets M" + using * by measurable + ultimately have "\i. emeasure M {y \ space M. max 0 (s i y) \ 0} \ emeasure M {y \ space M. s i y \ 0}" + by (rule emeasure_mono) + hence **:"\i. emeasure M {y \ space M. max 0 (s i y) \ 0} \ \" + using *(2) by (auto intro: order.strict_trans1 simp add: top.not_eq_extremum) + have "\x. x \ space M \ (\i. max 0 (s i x)) \ max 0 (f x)" + using *(3) tendsto_max by blast + moreover have "\x i. x \ space M \ norm (max 0 (s i x)) \ norm (2 *\<^sub>R f x)" + using *(4) unfolding max_def by auto + ultimately have tendsto: "(\i. integral\<^sup>L M (\x. max 0 (s i x))) \ integral\<^sup>L M (\x. max 0 (f x))" + using borel_measurable_simple_function simple integrable by (intro integral_dominated_convergence[OF max(1) _ integrable_norm[OF integrable_scaleR_right], of _ 2 f], blast+) + { + fix h :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assume "simple_function M h" "emeasure M {y \ space M. h y \ 0} \ \" "\x. x \ space M \ h x \ 0" + hence *: "integral\<^sup>L M h \ 0" + proof (induct rule: integrable_simple_function_induct_nn) + case (cong f g) + then show ?case using Bochner_Integration.integral_cong by force + next + case (indicator A y) + hence "A \ {} \ y \ 0" using sets.sets_into_space by fastforce + then show ?case using indicator by (cases "A = {}", auto simp add: scaleR_nonneg_nonneg) + next + case (add f g) + then show ?case by (simp add: integrable_simple_function) + qed + } + thus ?thesis using LIMSEQ_le_const[OF tendsto, of 0] ** simple by fastforce + qed + also have "\ = integral\<^sup>L M f" using nonneg by (auto intro: integral_cong_AE) + finally show ?thesis . +qed (simp add: not_integrable_integral_eq) + +lemma integral_mono_AE_banach: + fixes f g :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "integrable M f" "integrable M g" "AE x in M. f x \ g x" + shows "integral\<^sup>L M f \ integral\<^sup>L M g" + using integral_nonneg_AE_banach[of "\x. g x - f x"] assms Bochner_Integration.integral_diff[OF assms(1,2)] by force + +lemma integral_mono_banach: + fixes f g :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "integrable M f" "integrable M g" "\x. x \ space M \ f x \ g x" + shows "integral\<^sup>L M f \ integral\<^sup>L M g" + using integral_mono_AE_banach assms by blast + +subsection \Auxiliary Lemmas for Set Integrals\ + +lemma nn_set_integral_eq_set_integral: + assumes [measurable]:"integrable M f" + and "AE x \ A in M. 0 \ f x" "A \ sets M" + shows "(\\<^sup>+x\A. f x \M) = (\ x \ A. f x \M)" +proof- + have "(\\<^sup>+x. indicator A x *\<^sub>R f x \M) = (\ x \ A. f x \M)" + unfolding set_lebesgue_integral_def + using assms(2) by (intro nn_integral_eq_integral[of _ "\x. indicat_real A x *\<^sub>R f x"], blast intro: assms integrable_mult_indicator, fastforce) + moreover have "(\\<^sup>+x. indicator A x *\<^sub>R f x \M) = (\\<^sup>+x\A. f x \M)" + by (metis ennreal_0 indicator_simps(1) indicator_simps(2) mult.commute mult_1 mult_zero_left real_scaleR_def) + ultimately show ?thesis by argo +qed + +lemma set_integral_restrict_space: + fixes f :: "'a \ 'b::{banach, second_countable_topology}" + assumes "\ \ space M \ sets M" + shows "set_lebesgue_integral (restrict_space M \) A f = set_lebesgue_integral M A (\x. indicator \ x *\<^sub>R f x)" + unfolding set_lebesgue_integral_def + by (subst integral_restrict_space, auto intro!: integrable_mult_indicator assms simp: mult.commute) + +lemma set_integral_const: + fixes c :: "'b::{banach, second_countable_topology}" + assumes "A \ sets M" "emeasure M A \ \" + shows "set_lebesgue_integral M A (\_. c) = measure M A *\<^sub>R c" + unfolding set_lebesgue_integral_def + using assms by (metis has_bochner_integral_indicator has_bochner_integral_integral_eq infinity_ennreal_def less_top) + +lemma set_integral_mono_banach: + fixes f g :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "set_integrable M A f" "set_integrable M A g" + "\x. x \ A \ f x \ g x" + shows "(LINT x:A|M. f x) \ (LINT x:A|M. g x)" + using assms unfolding set_integrable_def set_lebesgue_integral_def + by (auto intro: integral_mono_banach split: split_indicator) + +lemma set_integral_mono_AE_banach: + fixes f g :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "set_integrable M A f" "set_integrable M A g" "AE x\A in M. f x \ g x" + shows "set_lebesgue_integral M A f \ set_lebesgue_integral M A g" using assms unfolding set_lebesgue_integral_def by (auto simp add: set_integrable_def intro!: integral_mono_AE_banach[of M "\x. indicator A x *\<^sub>R f x" "\x. indicator A x *\<^sub>R g x"], simp add: indicator_def) + +subsection \Integrability and Measurability of the Diameter\ + +context + fixes s :: "nat \ 'a \ 'b :: {second_countable_topology, banach}" and M + assumes bounded: "\x. x \ space M \ bounded (range (\i. s i x))" +begin + +lemma borel_measurable_diameter: + assumes [measurable]: "\i. (s i) \ borel_measurable M" + shows "(\x. diameter {s i x |i. n \ i}) \ borel_measurable M" +proof - + have "{s i x |i. N \ i} \ {}" for x N by blast + hence diameter_SUP: "diameter {s i x |i. N \ i} = (SUP (i, j) \ {N..} \ {N..}. dist (s i x) (s j x))" for x N unfolding diameter_def by (auto intro!: arg_cong[of _ _ Sup]) + + have "case_prod dist ` ({s i x |i. n \ i} \ {s i x |i. n \ i}) = ((\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..}))" for x by fast + hence *: "(\x. diameter {s i x |i. n \ i}) = (\x. Sup ((\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..})))" using diameter_SUP by (simp add: case_prod_beta') + + have "bounded ((\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..}))" if "x \ space M" for x by (rule bounded_imp_dist_bounded[OF bounded, OF that]) + hence bdd: "bdd_above ((\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..}))" if "x \ space M" for x using that bounded_imp_bdd_above by presburger + have "fst p \ borel_measurable M" "snd p \ borel_measurable M" if "p \ s ` {n..} \ s ` {n..}" for p using that by fastforce+ + hence "(\x. fst p x - snd p x) \ borel_measurable M" if "p \ s ` {n..} \ s ` {n..}" for p using that borel_measurable_diff by simp + hence "(\x. case p of (f, g) \ dist (f x) (g x)) \ borel_measurable M" if "p \ s ` {n..} \ s ` {n..}" for p unfolding dist_norm using that by measurable + moreover have "countable (s ` {n..} \ s ` {n..})" by (intro countable_SIGMA countable_image, auto) + ultimately show ?thesis unfolding * by (auto intro!: borel_measurable_cSUP bdd) +qed + +lemma integrable_bound_diameter: + fixes f :: "'a \ real" + assumes "integrable M f" + and [measurable]: "\i. (s i) \ borel_measurable M" + and "\x i. x \ space M \ norm (s i x) \ f x" + shows "integrable M (\x. diameter {s i x |i. n \ i})" +proof - + have "{s i x |i. N \ i} \ {}" for x N by blast + hence diameter_SUP: "diameter {s i x |i. N \ i} = (SUP (i, j) \ {N..} \ {N..}. dist (s i x) (s j x))" for x N unfolding diameter_def by (auto intro!: arg_cong[of _ _ Sup]) + { + fix x assume x: "x \ space M" + let ?S = "(\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..})" + have "case_prod dist ` ({s i x |i. n \ i} \ {s i x |i. n \ i}) = (\(i, j). dist (s i x) (s j x)) ` ({n..} \ {n..})" by fast + hence *: "diameter {s i x |i. n \ i} = Sup ?S" using diameter_SUP by (simp add: case_prod_beta') + + have "bounded ?S" by (rule bounded_imp_dist_bounded[OF bounded[OF x]]) + hence Sup_S_nonneg:"0 \ Sup ?S" by (auto intro!: cSup_upper2 x bounded_imp_bdd_above) + + have "dist (s i x) (s j x) \ 2 * f x" for i j by (intro dist_triangle2[THEN order_trans, of _ 0]) (metis norm_conv_dist assms(3) x add_mono mult_2) + hence "\c \ ?S. c \ 2 * f x" by force + hence "Sup ?S \ 2 * f x" by (intro cSup_least, auto) + hence "norm (Sup ?S) \ 2 * norm (f x)" using Sup_S_nonneg by auto + also have "\ = norm (2 *\<^sub>R f x)" by simp + finally have "norm (diameter {s i x |i. n \ i}) \ norm (2 *\<^sub>R f x)" unfolding * . + } + hence "AE x in M. norm (diameter {s i x |i. n \ i}) \ norm (2 *\<^sub>R f x)" by blast + thus "integrable M (\x. diameter {s i x |i. n \ i})" using borel_measurable_diameter by (intro Bochner_Integration.integrable_bound[OF assms(1)[THEN integrable_scaleR_right[of 2]]], measurable) +qed +end + +subsection \Averaging Theorem\ + +text \We aim to lift results from the real case to arbitrary Banach spaces. + Our fundamental tool in this regard will be the averaging theorem. The proof of this theorem is due to Serge Lang (Real and Functional Analysis) \cite{Lang_1993}. + The theorem allows us to make statements about a function’s value almost everywhere, depending on the value its integral takes on various sets of the measure space.\ + +text \Before we introduce and prove the averaging theorem, we will first show the following lemma which is crucial for our proof. + While not stated exactly in this manner, our proof makes use of the characterization of second-countable topological spaces given in the book General Topology by Ryszard Engelking (Theorem 4.1.15) \cite{engelking_1989}. + (Engelking's book \emph{General Topology})\ + +lemma balls_countable_basis: + obtains D :: "'a :: {metric_space, second_countable_topology} set" + where "topological_basis (case_prod ball ` (D \ (\ \ {0<..})))" + and "countable D" + and "D \ {}" +proof - + obtain D :: "'a set" where dense_subset: "countable D" "D \ {}" "\open U; U \ {}\ \ \y \ D. y \ U" for U using countable_dense_exists by blast + have "topological_basis (case_prod ball ` (D \ (\ \ {0<..})))" + proof (intro topological_basis_iff[THEN iffD2], fast, clarify) + fix U and x :: 'a assume asm: "open U" "x \ U" + obtain e where e: "e > 0" "ball x e \ U" using asm openE by blast + obtain y where y: "y \ D" "y \ ball x (e / 3)" using dense_subset(3)[OF open_ball, of x "e / 3"] centre_in_ball[THEN iffD2, OF divide_pos_pos[OF e(1), of 3]] by force + obtain r where r: "r \ \ \ {e/3<.. ball y r" using r y by (simp add: dist_commute) + hence "ball y r \ U" using r by (intro order_trans[OF _ e(2)], simp, metric) + moreover have "ball y r \ (case_prod ball ` (D \ (\ \ {0<..})))" using y(1) r by force + ultimately show "\B'\(case_prod ball ` (D \ (\ \ {0<..}))). x \ B' \ B' \ U" using * by meson + qed + thus ?thesis using that dense_subset by blast +qed + +context sigma_finite_measure +begin + +text \To show statements concerning \\\-finite measure spaces, one usually shows the statement for finite measure spaces and uses a limiting argument to show it for the \\\-finite case. + The following induction scheme formalizes this.\ +lemma sigma_finite_measure_induct[case_names finite_measure, consumes 0]: + assumes "\(N :: 'a measure) \. finite_measure N + \ N = restrict_space M \ + \ \ \ sets M + \ emeasure N \ \ \ + \ emeasure N \ \ 0 + \ almost_everywhere N Q" + and [measurable]: "Measurable.pred M Q" + shows "almost_everywhere M Q" +proof - + have *: "almost_everywhere N Q" if "finite_measure N" "N = restrict_space M \" "\ \ sets M" "emeasure N \ \ \" for N \ using that by (cases "emeasure N \ = 0", auto intro: emeasure_0_AE assms(1)) + + obtain A :: "nat \ 'a set" where A: "range A \ sets M" "(\i. A i) = space M" and emeasure_finite: "emeasure M (A i) \ \" for i using sigma_finite by metis + note A(1)[measurable] + have space_restr: "space (restrict_space M (A i)) = A i" for i unfolding space_restrict_space by simp + { + fix i + have *: "{x \ A i \ space M. Q x} = {x \ space M. Q x} \ (A i)" by fast + have "Measurable.pred (restrict_space M (A i)) Q" using A by (intro measurableI, auto simp add: space_restr intro!: sets_restrict_space_iff[THEN iffD2], measurable, auto) + } + note this[measurable] + { + fix i + have "finite_measure (restrict_space M (A i))" using emeasure_finite by (intro finite_measureI, subst space_restr, subst emeasure_restrict_space, auto) + hence "emeasure (restrict_space M (A i)) {x \ A i. \Q x} = 0" using emeasure_finite by (intro AE_iff_measurable[THEN iffD1, OF _ _ *], measurable, subst space_restr[symmetric], intro sets.top, auto simp add: emeasure_restrict_space) + hence "emeasure M {x \ A i. \ Q x} = 0" by (subst emeasure_restrict_space[symmetric], auto) + } + hence "emeasure M (\i. {x \ A i. \ Q x}) = 0" by (intro emeasure_UN_eq_0, auto) + moreover have "(\i. {x \ A i. \ Q x}) = {x \ space M. \ Q x}" using A by auto + ultimately show ?thesis by (intro AE_iff_measurable[THEN iffD2], auto) +qed + +text \Real Functional Analysis - Lang\ +text \The Averaging Theorem allows us to make statements concerning how a function behaves almost everywhere, depending on its behaviour on average.\ +lemma averaging_theorem: + fixes f::"_ \ 'b::{second_countable_topology, banach}" + assumes [measurable]: "integrable M f" + and closed: "closed S" + and "\A. A \ sets M \ measure M A > 0 \ (1 / measure M A) *\<^sub>R set_lebesgue_integral M A f \ S" + shows "AE x in M. f x \ S" +proof (induct rule: sigma_finite_measure_induct) + case (finite_measure N \) + + interpret finite_measure N by (rule finite_measure) + + have integrable[measurable]: "integrable N f" using assms finite_measure by (auto simp: integrable_restrict_space integrable_mult_indicator) + have average: "(1 / Sigma_Algebra.measure N A) *\<^sub>R set_lebesgue_integral N A f \ S" if "A \ sets N" "measure N A > 0" for A + proof - + have *: "A \ sets M" using that by (simp add: sets_restrict_space_iff finite_measure) + have "A = A \ \" by (metis finite_measure(2,3) inf.orderE sets.sets_into_space space_restrict_space that(1)) + hence "set_lebesgue_integral N A f = set_lebesgue_integral M A f" unfolding finite_measure by (subst set_integral_restrict_space, auto simp add: finite_measure set_lebesgue_integral_def indicator_inter_arith[symmetric]) + moreover have "measure N A = measure M A" using that by (auto intro!: measure_restrict_space simp add: finite_measure sets_restrict_space_iff) + ultimately show ?thesis using that * assms(3) by presburger + qed + + obtain D :: "'b set" where balls_basis: "topological_basis (case_prod ball ` (D \ (\ \ {0<..})))" and countable_D: "countable D" using balls_countable_basis by blast + have countable_balls: "countable (case_prod ball ` (D \ (\ \ {0<..})))" using countable_rat countable_D by blast + + obtain B where B_balls: "B \ case_prod ball ` (D \ (\ \ {0<..}))" "\B = -S" using topological_basis[THEN iffD1, OF balls_basis] open_Compl[OF assms(2)] by meson + hence countable_B: "countable B" using countable_balls countable_subset by fast + + define b where "b = from_nat_into (B \ {{}})" + have "B \ {{}} \ {}" by simp + have range_b: "range b = B \ {{}}" using countable_B by (auto simp add: b_def intro!: range_from_nat_into) + have open_b: "open (b i)" for i unfolding b_def using B_balls open_ball from_nat_into[of "B \ {{}}" i] by force + have Union_range_b: "\(range b) = -S" using B_balls range_b by simp + + { + fix v r assume ball_in_Compl: "ball v r \ -S" + define A where "A = f -` ball v r \ space N" + have dist_less: "dist (f x) v < r" if "x \ A" for x using that unfolding A_def vimage_def by (simp add: dist_commute) + hence AE_less: "AE x \ A in N. norm (f x - v) < r" by (auto simp add: dist_norm) + have *: "A \ sets N" unfolding A_def by simp + have "emeasure N A = 0" + proof - + { + assume asm: "emeasure N A > 0" + hence measure_pos: "measure N A > 0" unfolding emeasure_eq_measure by simp + hence "(1 / measure N A) *\<^sub>R set_lebesgue_integral N A f - v + = (1 / measure N A) *\<^sub>R set_lebesgue_integral N A (\x. f x - v)" + using integrable integrable_const * + by (subst set_integral_diff(2), auto simp add: set_integrable_def set_integral_const[OF *] algebra_simps intro!: integrable_mult_indicator) + moreover have "norm (\x\A. (f x - v)\N) \ (\x\A. norm (f x - v)\N)" + using * by (auto intro!: integral_norm_bound[of N "\x. indicator A x *\<^sub>R (f x - v)", THEN order_trans] integrable_mult_indicator integrable simp add: set_lebesgue_integral_def) + ultimately have "norm ((1 / measure N A) *\<^sub>R set_lebesgue_integral N A f - v) + \ set_lebesgue_integral N A (\x. norm (f x - v)) / measure N A" using asm by (auto intro: divide_right_mono) + also have "\ < set_lebesgue_integral N A (\x. r) / measure N A" + unfolding set_lebesgue_integral_def + using asm * integrable integrable_const AE_less measure_pos + by (intro divide_strict_right_mono integral_less_AE[of _ _ A] integrable_mult_indicator) + (fastforce simp add: dist_less dist_norm indicator_def)+ + also have "\ = r" using * measure_pos by (simp add: set_integral_const) + finally have "dist ((1 / measure N A) *\<^sub>R set_lebesgue_integral N A f) v < r" by (subst dist_norm) + hence "False" using average[OF * measure_pos] by (metis ComplD dist_commute in_mono mem_ball ball_in_Compl) + } + thus ?thesis by fastforce + qed + } + note * = this + { + fix b' assume "b' \ B" + hence ball_subset_Compl: "b' \ -S" and ball_radius_pos: "\v \ D. \r>0. b' = ball v r" using B_balls by (blast, fast) + } + note ** = this + hence "emeasure N (f -` b i \ space N) = 0" for i by (cases "b i = {}", simp) (metis UnE singletonD * range_b[THEN eq_refl, THEN range_subsetD]) + hence "emeasure N (\i. f -` b i \ space N) = 0" using open_b by (intro emeasure_UN_eq_0) fastforce+ + moreover have "(\i. f -` b i \ space N) = f -` (\(range b)) \ space N" by blast + ultimately have "emeasure N (f -` (-S) \ space N) = 0" using Union_range_b by argo + hence "AE x in N. f x \ -S" using open_Compl[OF assms(2)] by (intro AE_iff_measurable[THEN iffD2], auto) + thus ?case by force +qed (simp add: pred_sets2[OF borel_closed] assms(2)) + +lemma density_zero: + fixes f::"'a \ 'b::{second_countable_topology, banach}" + assumes "integrable M f" + and density_0: "\A. A \ sets M \ set_lebesgue_integral M A f = 0" + shows "AE x in M. f x = 0" + using averaging_theorem[OF assms(1), of "{0}"] assms(2) + by (simp add: scaleR_nonneg_nonneg) + +text \The following lemma shows that densities are unique in Banach spaces.\ +lemma density_unique_banach: + fixes f f'::"'a \ 'b::{second_countable_topology, banach}" + assumes "integrable M f" "integrable M f'" + and density_eq: "\A. A \ sets M \ set_lebesgue_integral M A f = set_lebesgue_integral M A f'" + shows "AE x in M. f x = f' x" +proof- + { + fix A assume asm: "A \ sets M" + hence "LINT x|M. indicat_real A x *\<^sub>R (f x - f' x) = 0" using density_eq assms(1,2) by (simp add: set_lebesgue_integral_def algebra_simps Bochner_Integration.integral_diff[OF integrable_mult_indicator(1,1)]) + } + thus ?thesis using density_zero[OF Bochner_Integration.integrable_diff[OF assms(1,2)]] by (simp add: set_lebesgue_integral_def) +qed + +lemma density_nonneg: + fixes f::"_ \ 'b::{second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "integrable M f" + and "\A. A \ sets M \ set_lebesgue_integral M A f \ 0" + shows "AE x in M. f x \ 0" + using averaging_theorem[OF assms(1), of "{0..}", OF closed_atLeast] assms(2) + by (simp add: scaleR_nonneg_nonneg) + +corollary integral_nonneg_eq_0_iff_AE_banach: + fixes f :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes f[measurable]: "integrable M f" and nonneg: "AE x in M. 0 \ f x" + shows "integral\<^sup>L M f = 0 \ (AE x in M. f x = 0)" +proof + assume *: "integral\<^sup>L M f = 0" + { + fix A assume asm: "A \ sets M" + have "0 \ integral\<^sup>L M (\x. indicator A x *\<^sub>R f x)" using nonneg by (subst integral_zero[of M, symmetric], intro integral_mono_AE_banach integrable_mult_indicator asm f integrable_zero, auto simp add: indicator_def) + moreover have "\ \ integral\<^sup>L M f" using nonneg by (intro integral_mono_AE_banach integrable_mult_indicator asm f, auto simp add: indicator_def) + ultimately have "set_lebesgue_integral M A f = 0" unfolding set_lebesgue_integral_def using * by force + } + thus "AE x in M. f x = 0" by (intro density_zero f, blast) +qed (auto simp add: integral_eq_zero_AE) + +corollary integral_eq_mono_AE_eq_AE: + fixes f g :: "'a \ 'b :: {second_countable_topology, banach, linorder_topology, ordered_real_vector}" + assumes "integrable M f" "integrable M g" "integral\<^sup>L M f = integral\<^sup>L M g" "AE x in M. f x \ g x" + shows "AE x in M. f x = g x" +proof - + define h where "h = (\x. g x - f x)" + have "AE x in M. h x = 0" unfolding h_def using assms by (subst integral_nonneg_eq_0_iff_AE_banach[symmetric]) auto + then show ?thesis unfolding h_def by auto +qed + end + +end diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/Finite_Set.thy Tue Mar 05 16:55:21 2024 +0100 @@ -1873,6 +1873,11 @@ by (simp add: card_Diff_subset) qed +lemma card_Int_Diff: + assumes "finite A" + shows "card A = card (A \ B) + card (A - B)" + by (simp add: assms card_Diff_subset_Int card_mono) + lemma diff_card_le_card_Diff: assumes "finite B" shows "card A - card B \ card (A - B)" diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/HOL.thy --- a/src/HOL/HOL.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/HOL.thy Tue Mar 05 16:55:21 2024 +0100 @@ -1089,6 +1089,8 @@ lemma ex_disj_distrib: "(\x. P x \ Q x) \ (\x. P x) \ (\x. Q x)" by iprover lemma all_conj_distrib: "(\x. P x \ Q x) \ (\x. P x) \ (\x. Q x)" by iprover +lemma all_imp_conj_distrib: "(\x. P x \ Q x \ R x) \ (\x. P x \ Q x) \ (\x. P x \ R x)" + by iprover text \ \<^medskip> The \\\ congruence rule: not included by default! diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/Probability/Information.thy --- a/src/HOL/Probability/Information.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/Probability/Information.thy Tue Mar 05 16:55:21 2024 +0100 @@ -36,15 +36,15 @@ lemma log_mult_eq: "log b (A * B) = (if 0 < A * B then log b \A\ + log b \B\ else log b 0)" - using log_mult[of b "\A\" "\B\"] b_gt_1 log_neg_const[of "A * B"] + using log_mult[of "\A\" "\B\"] b_gt_1 log_neg_const[of "A * B"] by (auto simp: zero_less_mult_iff mult_le_0_iff) lemma log_inverse_eq: "log b (inverse B) = (if 0 < B then - log b B else log b 0)" - using log_inverse[of b B] log_neg_const[of "inverse B"] b_gt_1 by simp + using ln_inverse log_def log_neg_const by force lemma log_divide_eq: - "log b (A / B) = (if 0 < A * B then log b \A\ - log b \B\ else log b 0)" + "log b (A / B) = (if 0 < A * B then (log b \A\) - log b \B\ else log b 0)" unfolding divide_inverse log_mult_eq log_inverse_eq abs_inverse by (auto simp: zero_less_mult_iff mult_le_0_iff) @@ -1809,16 +1809,18 @@ assumes Pxy: "finite_entropy (S \\<^sub>M T) (\x. (X x, Y x)) Pxy" shows "conditional_entropy b S T X Y \ entropy b S X" proof - - have "0 \ mutual_information b S T X Y" by (rule mutual_information_nonneg') fact+ also have "\ = entropy b S X - conditional_entropy b S T X Y" - apply (intro mutual_information_eq_entropy_conditional_entropy') - using assms - by (auto intro!: finite_entropy_integrable finite_entropy_distributed - finite_entropy_integrable_transform[OF Px] - finite_entropy_integrable_transform[OF Py] - intro: finite_entropy_nn) + proof (intro mutual_information_eq_entropy_conditional_entropy') + show "integrable (S \\<^sub>M T) (\x. Pxy x * log b (Px (fst x)))" + "integrable (S \\<^sub>M T) (\x. Pxy x * log b (Py (snd x)))" + "integrable (S \\<^sub>M T) (\x. Pxy x * log b (Pxy x))" + using assms + by (auto intro!: finite_entropy_integrable finite_entropy_distributed + finite_entropy_integrable_transform[OF Px] finite_entropy_integrable_transform[OF Py] + intro: finite_entropy_nn) + qed (use assms Px Py Pxy finite_entropy_nn finite_entropy_distributed in auto) finally show ?thesis by auto qed @@ -1874,13 +1876,8 @@ qed corollary (in information_space) entropy_data_processing: - assumes X: "simple_function M X" shows "\(f \ X) \ \(X)" -proof - - note fX = simple_function_compose[OF X, of f] - from X have "\(X) = \(f\X) + \(X|f\X)" by (rule entropy_partition) - then show "\(f \ X) \ \(X)" - by (simp only: conditional_entropy_nonneg [OF X fX] le_add_same_cancel1) -qed + assumes "simple_function M X" shows "\(f \ X) \ \(X)" + by (smt (verit) assms conditional_entropy_nonneg entropy_partition simple_function_compose) corollary (in information_space) entropy_of_inj: assumes X: "simple_function M X" and inj: "inj_on f (X`space M)" diff -r 0e8620af9c91 -r 1f94d92b0dc2 src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Tue Mar 05 15:02:31 2024 +0100 +++ b/src/HOL/Transcendental.thy Tue Mar 05 16:55:21 2024 +0100 @@ -2585,17 +2585,18 @@ lemma powr_log_cancel [simp]: "0 < a \ a \ 1 \ 0 < x \ a powr (log a x) = x" by (simp add: powr_def log_def) -lemma log_powr_cancel [simp]: "0 < a \ a \ 1 \ log a (a powr y) = y" +lemma log_powr_cancel [simp]: "0 < a \ a \ 1 \ log a (a powr x) = x" by (simp add: log_def powr_def) +lemma powr_eq_iff: "\y>0; a>1\ \ a powr x = y \ log a y = x" + by auto + lemma log_mult: - "0 < a \ a \ 1 \ 0 < x \ 0 < y \ - log a (x * y) = log a x + log a y" + "0 < x \ 0 < y \ log a (x * y) = log a x + log a y" by (simp add: log_def ln_mult divide_inverse distrib_right) lemma log_eq_div_ln_mult_log: - "0 < a \ a \ 1 \ 0 < b \ b \ 1 \ 0 < x \ - log a x = (ln b/ln a) * log b x" + "0 < b \ b \ 1 \ 0 < x \ log a x = (ln b/ln a) * log b x" by (simp add: log_def divide_inverse) text\Base 10 logarithms\ @@ -2611,10 +2612,10 @@ lemma log_eq_one [simp]: "0 < a \ a \ 1 \ log a a = 1" by (simp add: log_def) -lemma log_inverse: "0 < a \ a \ 1 \ 0 < x \ log a (inverse x) = - log a x" +lemma log_inverse: "0 < x \ log a (inverse x) = - log a x" using ln_inverse log_def by auto -lemma log_divide: "0 < a \ a \ 1 \ 0 < x \ 0 < y \ log a (x/y) = log a x - log a y" +lemma log_divide: "0 < x \ 0 < y \ log a (x/y) = log a x - log a y" by (simp add: log_mult divide_inverse log_inverse) lemma powr_gt_zero [simp]: "0 < x powr a \ x \ 0"