1984 show "measure lebesgue (\<Union>\<D>) - e < measure lebesgue (UNION {..N} (from_nat_into \<D>))" |
1987 show "measure lebesgue (\<Union>\<D>) - e < measure lebesgue (UNION {..N} (from_nat_into \<D>))" |
1985 using N [OF order_refl] |
1988 using N [OF order_refl] |
1986 by (auto simp: eq algebra_simps dist_norm) |
1989 by (auto simp: eq algebra_simps dist_norm) |
1987 qed auto |
1990 qed auto |
1988 qed |
1991 qed |
|
1992 |
|
1993 |
|
1994 subsection\<open>Negligibility is a local property\<close> |
|
1995 |
|
1996 lemma locally_negligible_alt: |
|
1997 "negligible S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>U. openin (subtopology euclidean S) U \<and> x \<in> U \<and> negligible U)" |
|
1998 (is "_ = ?rhs") |
|
1999 proof |
|
2000 assume "negligible S" |
|
2001 then show ?rhs |
|
2002 using openin_subtopology_self by blast |
|
2003 next |
|
2004 assume ?rhs |
|
2005 then obtain U where ope: "\<And>x. x \<in> S \<Longrightarrow> openin (subtopology euclidean S) (U x)" |
|
2006 and cov: "\<And>x. x \<in> S \<Longrightarrow> x \<in> U x" |
|
2007 and neg: "\<And>x. x \<in> S \<Longrightarrow> negligible (U x)" |
|
2008 by metis |
|
2009 obtain \<F> where "\<F> \<subseteq> U ` S" "countable \<F>" and eq: "\<Union>\<F> = UNION S U" |
|
2010 using ope by (force intro: Lindelof_openin [of "U ` S" S]) |
|
2011 then have "negligible (\<Union>\<F>)" |
|
2012 by (metis imageE neg negligible_countable_Union subset_eq) |
|
2013 with eq have "negligible (UNION S U)" |
|
2014 by metis |
|
2015 moreover have "S \<subseteq> UNION S U" |
|
2016 using cov by blast |
|
2017 ultimately show "negligible S" |
|
2018 using negligible_subset by blast |
|
2019 qed |
|
2020 |
|
2021 lemma locally_negligible: |
|
2022 "locally negligible S \<longleftrightarrow> negligible S" |
|
2023 unfolding locally_def |
|
2024 apply safe |
|
2025 apply (meson negligible_subset openin_subtopology_self locally_negligible_alt) |
|
2026 by (meson negligible_subset openin_imp_subset order_refl) |
|
2027 |
1989 |
2028 |
1990 subsection\<open>Integral bounds\<close> |
2029 subsection\<open>Integral bounds\<close> |
1991 |
2030 |
1992 lemma set_integral_norm_bound: |
2031 lemma set_integral_norm_bound: |
1993 fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}" |
2032 fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}" |
2562 qed |
2601 qed |
2563 then show "(\<lambda>x. norm (f x)) integrable_on UNIV" |
2602 then show "(\<lambda>x. norm (f x)) integrable_on UNIV" |
2564 by blast |
2603 by blast |
2565 qed |
2604 qed |
2566 |
2605 |
|
2606 |
|
2607 subsection\<open>Outer and inner approximation of measurable sets by well-behaved sets.\<close> |
|
2608 |
|
2609 proposition measurable_outer_intervals_bounded: |
|
2610 assumes "S \<in> lmeasurable" "S \<subseteq> cbox a b" "e > 0" |
|
2611 obtains \<D> |
|
2612 where "countable \<D>" |
|
2613 "\<And>K. K \<in> \<D> \<Longrightarrow> K \<subseteq> cbox a b \<and> K \<noteq> {} \<and> (\<exists>c d. K = cbox c d)" |
|
2614 "pairwise (\<lambda>A B. interior A \<inter> interior B = {}) \<D>" |
|
2615 "\<And>u v. cbox u v \<in> \<D> \<Longrightarrow> \<exists>n. \<forall>i \<in> Basis. v \<bullet> i - u \<bullet> i = (b \<bullet> i - a \<bullet> i)/2^n" |
|
2616 "\<And>K. \<lbrakk>K \<in> \<D>; box a b \<noteq> {}\<rbrakk> \<Longrightarrow> interior K \<noteq> {}" |
|
2617 "S \<subseteq> \<Union>\<D>" "\<Union>\<D> \<in> lmeasurable" "measure lebesgue (\<Union>\<D>) \<le> measure lebesgue S + e" |
|
2618 proof (cases "box a b = {}") |
|
2619 case True |
|
2620 show ?thesis |
|
2621 proof (cases "cbox a b = {}") |
|
2622 case True |
|
2623 with assms have [simp]: "S = {}" |
|
2624 by auto |
|
2625 show ?thesis |
|
2626 proof |
|
2627 show "countable {}" |
|
2628 by simp |
|
2629 qed (use \<open>e > 0\<close> in auto) |
|
2630 next |
|
2631 case False |
|
2632 show ?thesis |
|
2633 proof |
|
2634 show "countable {cbox a b}" |
|
2635 by simp |
|
2636 show "\<And>u v. cbox u v \<in> {cbox a b} \<Longrightarrow> \<exists>n. \<forall>i\<in>Basis. v \<bullet> i - u \<bullet> i = (b \<bullet> i - a \<bullet> i)/2 ^ n" |
|
2637 using False by (force simp: eq_cbox intro: exI [where x=0]) |
|
2638 show "measure lebesgue (\<Union>{cbox a b}) \<le> measure lebesgue S + e" |
|
2639 using assms by (simp add: sum_content.box_empty_imp [OF True]) |
|
2640 qed (use assms \<open>cbox a b \<noteq> {}\<close> in auto) |
|
2641 qed |
|
2642 next |
|
2643 case False |
|
2644 let ?\<mu> = "measure lebesgue" |
|
2645 have "S \<inter> cbox a b \<in> lmeasurable" |
|
2646 using \<open>S \<in> lmeasurable\<close> by blast |
|
2647 then have indS_int: "(indicator S has_integral (?\<mu> S)) (cbox a b)" |
|
2648 by (metis integral_indicator \<open>S \<subseteq> cbox a b\<close> has_integral_integrable_integral inf.orderE integrable_on_indicator) |
|
2649 with \<open>e > 0\<close> obtain \<gamma> where "gauge \<gamma>" and \<gamma>: |
|
2650 "\<And>\<D>. \<lbrakk>\<D> tagged_division_of (cbox a b); \<gamma> fine \<D>\<rbrakk> \<Longrightarrow> norm ((\<Sum>(x,K)\<in>\<D>. content(K) *\<^sub>R indicator S x) - ?\<mu> S) < e" |
|
2651 by (force simp: has_integral) |
|
2652 have inteq: "integral (cbox a b) (indicat_real S) = integral UNIV (indicator S)" |
|
2653 using assms by (metis has_integral_iff indS_int lmeasure_integral_UNIV) |
|
2654 obtain \<D> where \<D>: "countable \<D>" "\<Union>\<D> \<subseteq> cbox a b" |
|
2655 and cbox: "\<And>K. K \<in> \<D> \<Longrightarrow> interior K \<noteq> {} \<and> (\<exists>c d. K = cbox c d)" |
|
2656 and djointish: "pairwise (\<lambda>A B. interior A \<inter> interior B = {}) \<D>" |
|
2657 and covered: "\<And>K. K \<in> \<D> \<Longrightarrow> \<exists>x \<in> S \<inter> K. K \<subseteq> \<gamma> x" |
|
2658 and close: "\<And>u v. cbox u v \<in> \<D> \<Longrightarrow> \<exists>n. \<forall>i \<in> Basis. v\<bullet>i - u\<bullet>i = (b\<bullet>i - a\<bullet>i)/2^n" |
|
2659 and covers: "S \<subseteq> \<Union>\<D>" |
|
2660 using covering_lemma [of S a b \<gamma>] \<open>gauge \<gamma>\<close> \<open>box a b \<noteq> {}\<close> assms by force |
|
2661 show ?thesis |
|
2662 proof |
|
2663 show "\<And>K. K \<in> \<D> \<Longrightarrow> K \<subseteq> cbox a b \<and> K \<noteq> {} \<and> (\<exists>c d. K = cbox c d)" |
|
2664 by (meson Sup_le_iff \<D>(2) cbox interior_empty) |
|
2665 have negl_int: "negligible(K \<inter> L)" if "K \<in> \<D>" "L \<in> \<D>" "K \<noteq> L" for K L |
|
2666 proof - |
|
2667 have "interior K \<inter> interior L = {}" |
|
2668 using djointish pairwiseD that by fastforce |
|
2669 moreover obtain u v x y where "K = cbox u v" "L = cbox x y" |
|
2670 using cbox \<open>K \<in> \<D>\<close> \<open>L \<in> \<D>\<close> by blast |
|
2671 ultimately show ?thesis |
|
2672 by (simp add: Int_interval box_Int_box negligible_interval(1)) |
|
2673 qed |
|
2674 have fincase: "\<Union>\<F> \<in> lmeasurable \<and> ?\<mu> (\<Union>\<F>) \<le> ?\<mu> S + e" if "finite \<F>" "\<F> \<subseteq> \<D>" for \<F> |
|
2675 proof - |
|
2676 obtain t where t: "\<And>K. K \<in> \<F> \<Longrightarrow> t K \<in> S \<inter> K \<and> K \<subseteq> \<gamma>(t K)" |
|
2677 using covered \<open>\<F> \<subseteq> \<D>\<close> subsetD by metis |
|
2678 have "\<forall>K \<in> \<F>. \<forall>L \<in> \<F>. K \<noteq> L \<longrightarrow> interior K \<inter> interior L = {}" |
|
2679 using that djointish by (simp add: pairwise_def) (metis subsetD) |
|
2680 with cbox that \<D> have \<F>div: "\<F> division_of (\<Union>\<F>)" |
|
2681 by (fastforce simp: division_of_def dest: cbox) |
|
2682 then have 1: "\<Union>\<F> \<in> lmeasurable" |
|
2683 by blast |
|
2684 have norme: "\<And>p. \<lbrakk>p tagged_division_of cbox a b; \<gamma> fine p\<rbrakk> |
|
2685 \<Longrightarrow> norm ((\<Sum>(x,K)\<in>p. content K * indicator S x) - integral (cbox a b) (indicator S)) < e" |
|
2686 by (auto simp: lmeasure_integral_UNIV assms inteq dest: \<gamma>) |
|
2687 have "\<forall>x K y L. (x,K) \<in> (\<lambda>K. (t K,K)) ` \<F> \<and> (y,L) \<in> (\<lambda>K. (t K,K)) ` \<F> \<and> (x,K) \<noteq> (y,L) \<longrightarrow> interior K \<inter> interior L = {}" |
|
2688 using that djointish by (clarsimp simp: pairwise_def) (metis subsetD) |
|
2689 with that \<D> have tagged: "(\<lambda>K. (t K, K)) ` \<F> tagged_partial_division_of cbox a b" |
|
2690 by (auto simp: tagged_partial_division_of_def dest: t cbox) |
|
2691 have fine: "\<gamma> fine (\<lambda>K. (t K, K)) ` \<F>" |
|
2692 using t by (auto simp: fine_def) |
|
2693 have *: "y \<le> ?\<mu> S \<Longrightarrow> \<bar>x - y\<bar> \<le> e \<Longrightarrow> x \<le> ?\<mu> S + e" for x y |
|
2694 by arith |
|
2695 have "?\<mu> (\<Union>\<F>) \<le> ?\<mu> S + e" |
|
2696 proof (rule *) |
|
2697 have "(\<Sum>K\<in>\<F>. ?\<mu> (K \<inter> S)) = ?\<mu> (\<Union>C\<in>\<F>. C \<inter> S)" |
|
2698 apply (rule measure_negligible_finite_Union_image [OF \<open>finite \<F>\<close>, symmetric]) |
|
2699 using \<F>div \<open>S \<in> lmeasurable\<close> apply blast |
|
2700 unfolding pairwise_def |
|
2701 by (metis inf.commute inf_sup_aci(3) negligible_Int subsetCE negl_int \<open>\<F> \<subseteq> \<D>\<close>) |
|
2702 also have "\<dots> = ?\<mu> (\<Union>\<F> \<inter> S)" |
|
2703 by simp |
|
2704 also have "\<dots> \<le> ?\<mu> S" |
|
2705 by (simp add: "1" \<open>S \<in> lmeasurable\<close> fmeasurableD measure_mono_fmeasurable sets.Int) |
|
2706 finally show "(\<Sum>K\<in>\<F>. ?\<mu> (K \<inter> S)) \<le> ?\<mu> S" . |
|
2707 next |
|
2708 have "?\<mu> (\<Union>\<F>) = sum ?\<mu> \<F>" |
|
2709 by (metis \<F>div content_division) |
|
2710 also have "\<dots> = (\<Sum>K\<in>\<F>. content K)" |
|
2711 using \<F>div by (force intro: sum.cong) |
|
2712 also have "\<dots> = (\<Sum>x\<in>\<F>. content x * indicator S (t x))" |
|
2713 using t by auto |
|
2714 finally have eq1: "?\<mu> (\<Union>\<F>) = (\<Sum>x\<in>\<F>. content x * indicator S (t x))" . |
|
2715 have eq2: "(\<Sum>K\<in>\<F>. ?\<mu> (K \<inter> S)) = (\<Sum>K\<in>\<F>. integral K (indicator S))" |
|
2716 apply (rule sum.cong [OF refl]) |
|
2717 by (metis integral_indicator \<F>div \<open>S \<in> lmeasurable\<close> division_ofD(4) fmeasurable.Int inf.commute lmeasurable_cbox) |
|
2718 have "\<bar>\<Sum>(x,K)\<in>(\<lambda>K. (t K, K)) ` \<F>. content K * indicator S x - integral K (indicator S)\<bar> \<le> e" |
|
2719 using Henstock_lemma_part1 [of "indicator S::'a\<Rightarrow>real", OF _ \<open>e > 0\<close> \<open>gauge \<gamma>\<close> _ tagged fine] |
|
2720 indS_int norme by auto |
|
2721 then show "\<bar>?\<mu> (\<Union>\<F>) - (\<Sum>K\<in>\<F>. ?\<mu> (K \<inter> S))\<bar> \<le> e" |
|
2722 by (simp add: eq1 eq2 comm_monoid_add_class.sum.reindex inj_on_def sum_subtractf) |
|
2723 qed |
|
2724 with 1 show ?thesis by blast |
|
2725 qed |
|
2726 have "\<Union>\<D> \<in> lmeasurable \<and> ?\<mu> (\<Union>\<D>) \<le> ?\<mu> S + e" |
|
2727 proof (cases "finite \<D>") |
|
2728 case True |
|
2729 with fincase show ?thesis |
|
2730 by blast |
|
2731 next |
|
2732 case False |
|
2733 let ?T = "from_nat_into \<D>" |
|
2734 have T: "bij_betw ?T UNIV \<D>" |
|
2735 by (simp add: False \<D>(1) bij_betw_from_nat_into) |
|
2736 have TM: "\<And>n. ?T n \<in> lmeasurable" |
|
2737 by (metis False cbox finite.emptyI from_nat_into lmeasurable_cbox) |
|
2738 have TN: "\<And>m n. m \<noteq> n \<Longrightarrow> negligible (?T m \<inter> ?T n)" |
|
2739 by (simp add: False \<D>(1) from_nat_into infinite_imp_nonempty negl_int) |
|
2740 have TB: "(\<Sum>k\<le>n. ?\<mu> (?T k)) \<le> ?\<mu> S + e" for n |
|
2741 proof - |
|
2742 have "(\<Sum>k\<le>n. ?\<mu> (?T k)) = ?\<mu> (UNION {..n} ?T)" |
|
2743 by (simp add: pairwise_def TM TN measure_negligible_finite_Union_image) |
|
2744 also have "?\<mu> (UNION {..n} ?T) \<le> ?\<mu> S + e" |
|
2745 using fincase [of "?T ` {..n}"] T by (auto simp: bij_betw_def) |
|
2746 finally show ?thesis . |
|
2747 qed |
|
2748 have "\<Union>\<D> \<in> lmeasurable" |
|
2749 by (metis lmeasurable_compact T \<D>(2) bij_betw_def cbox compact_cbox countable_Un_Int(1) fmeasurableD fmeasurableI2 rangeI) |
|
2750 moreover |
|
2751 have "?\<mu> (\<Union>x. from_nat_into \<D> x) \<le> ?\<mu> S + e" |
|
2752 proof (rule measure_countable_Union_le [OF TM]) |
|
2753 show "?\<mu> (\<Union>x\<le>n. from_nat_into \<D> x) \<le> ?\<mu> S + e" for n |
|
2754 by (metis (mono_tags, lifting) False fincase finite.emptyI finite_atMost finite_imageI from_nat_into imageE subsetI) |
|
2755 qed |
|
2756 ultimately show ?thesis by (metis T bij_betw_def) |
|
2757 qed |
|
2758 then show "\<Union>\<D> \<in> lmeasurable" "measure lebesgue (\<Union>\<D>) \<le> ?\<mu> S + e" by blast+ |
|
2759 qed (use \<D> cbox djointish close covers in auto) |
|
2760 qed |
|
2761 |
2567 subsection\<open>Lemmas about absolute integrability\<close> |
2762 subsection\<open>Lemmas about absolute integrability\<close> |
2568 |
2763 |
2569 text\<open>Redundant!\<close> |
2764 text\<open>FIXME Redundant!\<close> |
2570 lemma absolutely_integrable_add[intro]: |
2765 lemma absolutely_integrable_add[intro]: |
2571 fixes f g :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
2766 fixes f g :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
2572 shows "f absolutely_integrable_on s \<Longrightarrow> g absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. f x + g x) absolutely_integrable_on s" |
2767 shows "f absolutely_integrable_on s \<Longrightarrow> g absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. f x + g x) absolutely_integrable_on s" |
2573 by (rule set_integral_add) |
2768 by (rule set_integral_add) |
2574 |
2769 |
2575 text\<open>Redundant!\<close> |
2770 text\<open>FIXME Redundant!\<close> |
2576 lemma absolutely_integrable_diff[intro]: |
2771 lemma absolutely_integrable_diff[intro]: |
2577 fixes f g :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
2772 fixes f g :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
2578 shows "f absolutely_integrable_on s \<Longrightarrow> g absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. f x - g x) absolutely_integrable_on s" |
2773 shows "f absolutely_integrable_on s \<Longrightarrow> g absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. f x - g x) absolutely_integrable_on s" |
2579 by (rule set_integral_diff) |
2774 by (rule set_integral_diff) |
2580 |
2775 |