683 also have "A \<union> (B - A) = B" |
699 also have "A \<union> (B - A) = B" |
684 using \<open>A \<subseteq> B\<close> by auto |
700 using \<open>A \<subseteq> B\<close> by auto |
685 finally show ?thesis . |
701 finally show ?thesis . |
686 qed |
702 qed |
687 |
703 |
|
704 lemma (in complete_measure) complete_sets_sandwich_fmeasurable: |
|
705 assumes [measurable]: "A \<in> fmeasurable M" "C \<in> fmeasurable M" and subset: "A \<subseteq> B" "B \<subseteq> C" |
|
706 and measure: "measure M A = measure M C" |
|
707 shows "B \<in> fmeasurable M" |
|
708 proof (rule fmeasurableI2) |
|
709 show "B \<subseteq> C" "C \<in> fmeasurable M" by fact+ |
|
710 show "B \<in> sets M" |
|
711 proof (rule complete_sets_sandwich) |
|
712 show "A \<in> sets M" "C \<in> sets M" "A \<subseteq> B" "B \<subseteq> C" |
|
713 using assms by auto |
|
714 show "emeasure M A < \<infinity>" |
|
715 using \<open>A \<in> fmeasurable M\<close> by (auto simp: fmeasurable_def) |
|
716 show "emeasure M A = emeasure M C" |
|
717 using assms by (simp add: emeasure_eq_measure2) |
|
718 qed |
|
719 qed |
|
720 |
|
721 lemma AE_completion_iff: "(AE x in completion M. P x) \<longleftrightarrow> (AE x in M. P x)" |
|
722 proof |
|
723 assume "AE x in completion M. P x" |
|
724 then obtain N where "N \<in> null_sets (completion M)" and P: "{x\<in>space M. \<not> P x} \<subseteq> N" |
|
725 unfolding eventually_ae_filter by auto |
|
726 then obtain N' where N': "N' \<in> null_sets M" and "N \<subseteq> N'" |
|
727 unfolding null_sets_completion_iff2 by auto |
|
728 from P \<open>N \<subseteq> N'\<close> have "{x\<in>space M. \<not> P x} \<subseteq> N'" |
|
729 by auto |
|
730 with N' show "AE x in M. P x" |
|
731 unfolding eventually_ae_filter by auto |
|
732 qed (rule AE_completion) |
|
733 |
|
734 lemma null_part_null_sets: "S \<in> completion M \<Longrightarrow> null_part M S \<in> null_sets (completion M)" |
|
735 by (auto dest!: null_part intro: null_sets_completionI null_sets_completion_subset) |
|
736 |
|
737 lemma AE_notin_null_part: "S \<in> completion M \<Longrightarrow> (AE x in M. x \<notin> null_part M S)" |
|
738 by (auto dest!: null_part_null_sets AE_not_in simp: AE_completion_iff) |
|
739 |
|
740 lemma completion_upper: |
|
741 assumes A: "A \<in> sets (completion M)" |
|
742 shows "\<exists>A'\<in>sets M. A \<subseteq> A' \<and> emeasure (completion M) A = emeasure M A'" |
|
743 proof - |
|
744 from AE_notin_null_part[OF A] obtain N where N: "N \<in> null_sets M" "null_part M A \<subseteq> N" |
|
745 unfolding eventually_ae_filter using null_part_null_sets[OF A, THEN null_setsD2, THEN sets.sets_into_space] by auto |
|
746 show ?thesis |
|
747 proof (intro bexI conjI) |
|
748 show "A \<subseteq> main_part M A \<union> N" |
|
749 using \<open>null_part M A \<subseteq> N\<close> by (subst main_part_null_part_Un[symmetric, OF A]) auto |
|
750 show "emeasure (completion M) A = emeasure M (main_part M A \<union> N)" |
|
751 using A \<open>N \<in> null_sets M\<close> by (simp add: emeasure_Un_null_set) |
|
752 qed (use A N in auto) |
|
753 qed |
|
754 |
|
755 lemma AE_in_main_part: |
|
756 assumes A: "A \<in> completion M" shows "AE x in M. x \<in> main_part M A \<longleftrightarrow> x \<in> A" |
|
757 using AE_notin_null_part[OF A] |
|
758 by (subst (2) main_part_null_part_Un[symmetric, OF A]) auto |
|
759 |
|
760 lemma completion_density_eq: |
|
761 assumes ae: "AE x in M. 0 < f x" and [measurable]: "f \<in> M \<rightarrow>\<^sub>M borel" |
|
762 shows "completion (density M f) = density (completion M) f" |
|
763 proof (intro measure_eqI) |
|
764 have "N' \<in> sets M \<and> (AE x\<in>N' in M. f x = 0) \<longleftrightarrow> N' \<in> null_sets M" for N' |
|
765 proof safe |
|
766 assume N': "N' \<in> sets M" and ae_N': "AE x\<in>N' in M. f x = 0" |
|
767 from ae_N' ae have "AE x in M. x \<notin> N'" |
|
768 by eventually_elim auto |
|
769 then show "N' \<in> null_sets M" |
|
770 using N' by (simp add: AE_iff_null_sets) |
|
771 next |
|
772 assume N': "N' \<in> null_sets M" then show "N' \<in> sets M" "AE x\<in>N' in M. f x = 0" |
|
773 using ae AE_not_in[OF N'] by (auto simp: less_le) |
|
774 qed |
|
775 then show sets_eq: "sets (completion (density M f)) = sets (density (completion M) f)" |
|
776 by (simp add: sets_completion null_sets_density_iff) |
|
777 |
|
778 fix A assume A: \<open>A \<in> completion (density M f)\<close> |
|
779 moreover |
|
780 have "A \<in> completion M" |
|
781 using A unfolding sets_eq by simp |
|
782 moreover |
|
783 have "main_part (density M f) A \<in> M" |
|
784 using A main_part_sets[of A "density M f"] unfolding sets_density sets_eq by simp |
|
785 moreover have "AE x in M. x \<in> main_part (density M f) A \<longleftrightarrow> x \<in> A" |
|
786 using AE_in_main_part[OF \<open>A \<in> completion (density M f)\<close>] ae by (auto simp add: AE_density) |
|
787 ultimately show "emeasure (completion (density M f)) A = emeasure (density (completion M) f) A" |
|
788 by (auto simp add: emeasure_density measurable_completion nn_integral_completion intro!: nn_integral_cong_AE) |
|
789 qed |
|
790 |
|
791 lemma null_sets_subset: "A \<subseteq> B \<Longrightarrow> A \<in> sets M \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> A \<in> null_sets M" |
|
792 using emeasure_mono[of A B M] by (simp add: null_sets_def) |
|
793 |
|
794 lemma (in complete_measure) complete2: "A \<subseteq> B \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> A \<in> null_sets M" |
|
795 using complete[of A B] null_sets_subset[of A B M] by simp |
|
796 |
|
797 lemma (in complete_measure) vimage_null_part_null_sets: |
|
798 assumes f: "f \<in> M \<rightarrow>\<^sub>M N" and eq: "null_sets N \<subseteq> null_sets (distr M N f)" |
|
799 and A: "A \<in> completion N" |
|
800 shows "f -` null_part N A \<inter> space M \<in> null_sets M" |
|
801 proof - |
|
802 obtain N' where "N' \<in> null_sets N" "null_part N A \<subseteq> N'" |
|
803 using null_part[OF A] by auto |
|
804 then have N': "N' \<in> null_sets (distr M N f)" |
|
805 using eq by auto |
|
806 show ?thesis |
|
807 proof (rule complete2) |
|
808 show "f -` null_part N A \<inter> space M \<subseteq> f -` N' \<inter> space M" |
|
809 using \<open>null_part N A \<subseteq> N'\<close> by auto |
|
810 show "f -` N' \<inter> space M \<in> null_sets M" |
|
811 using f N' by (auto simp: null_sets_def emeasure_distr) |
|
812 qed |
|
813 qed |
|
814 |
|
815 lemma (in complete_measure) vimage_null_part_sets: |
|
816 "f \<in> M \<rightarrow>\<^sub>M N \<Longrightarrow> null_sets N \<subseteq> null_sets (distr M N f) \<Longrightarrow> A \<in> completion N \<Longrightarrow> |
|
817 f -` null_part N A \<inter> space M \<in> sets M" |
|
818 using vimage_null_part_null_sets[of f N A] by auto |
|
819 |
|
820 lemma (in complete_measure) measurable_completion2: |
|
821 assumes f: "f \<in> M \<rightarrow>\<^sub>M N" and null_sets: "null_sets N \<subseteq> null_sets (distr M N f)" |
|
822 shows "f \<in> M \<rightarrow>\<^sub>M completion N" |
|
823 proof (rule measurableI) |
|
824 show "x \<in> space M \<Longrightarrow> f x \<in> space (completion N)" for x |
|
825 using f[THEN measurable_space] by auto |
|
826 fix A assume A: "A \<in> sets (completion N)" |
|
827 have "f -` A \<inter> space M = (f -` main_part N A \<inter> space M) \<union> (f -` null_part N A \<inter> space M)" |
|
828 using main_part_null_part_Un[OF A] by auto |
|
829 then show "f -` A \<inter> space M \<in> sets M" |
|
830 using f A null_sets by (auto intro: vimage_null_part_sets measurable_sets) |
|
831 qed |
|
832 |
|
833 lemma (in complete_measure) completion_distr_eq: |
|
834 assumes X: "X \<in> M \<rightarrow>\<^sub>M N" and null_sets: "null_sets (distr M N X) = null_sets N" |
|
835 shows "completion (distr M N X) = distr M (completion N) X" |
|
836 proof (rule measure_eqI) |
|
837 show eq: "sets (completion (distr M N X)) = sets (distr M (completion N) X)" |
|
838 by (simp add: sets_completion null_sets) |
|
839 |
|
840 fix A assume A: "A \<in> completion (distr M N X)" |
|
841 moreover have A': "A \<in> completion N" |
|
842 using A by (simp add: eq) |
|
843 moreover have "main_part (distr M N X) A \<in> sets N" |
|
844 using main_part_sets[OF A] by simp |
|
845 moreover have "X -` A \<inter> space M = (X -` main_part (distr M N X) A \<inter> space M) \<union> (X -` null_part (distr M N X) A \<inter> space M)" |
|
846 using main_part_null_part_Un[OF A] by auto |
|
847 moreover have "X -` null_part (distr M N X) A \<inter> space M \<in> null_sets M" |
|
848 using X A by (intro vimage_null_part_null_sets) (auto cong: distr_cong) |
|
849 ultimately show "emeasure (completion (distr M N X)) A = emeasure (distr M (completion N) X) A" |
|
850 using X by (auto simp: emeasure_distr measurable_completion null_sets measurable_completion2 |
|
851 intro!: emeasure_Un_null_set[symmetric]) |
|
852 qed |
|
853 |
|
854 lemma distr_completion: "X \<in> M \<rightarrow>\<^sub>M N \<Longrightarrow> distr (completion M) N X = distr M N X" |
|
855 by (intro measure_eqI) (auto simp: emeasure_distr measurable_completion) |
|
856 |
|
857 proposition (in complete_measure) fmeasurable_inner_outer: |
|
858 "S \<in> fmeasurable M \<longleftrightarrow> |
|
859 (\<forall>e>0. \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>measure M T - measure M U\<bar> < e)" |
|
860 (is "_ \<longleftrightarrow> ?approx") |
|
861 proof safe |
|
862 let ?\<mu> = "measure M" let ?D = "\<lambda>T U . \<bar>?\<mu> T - ?\<mu> U\<bar>" |
|
863 assume ?approx |
|
864 have "\<exists>A. \<forall>n. (fst (A n) \<in> fmeasurable M \<and> snd (A n) \<in> fmeasurable M \<and> fst (A n) \<subseteq> S \<and> S \<subseteq> snd (A n) \<and> |
|
865 ?D (fst (A n)) (snd (A n)) < 1/Suc n) \<and> (fst (A n) \<subseteq> fst (A (Suc n)) \<and> snd (A (Suc n)) \<subseteq> snd (A n))" |
|
866 (is "\<exists>A. \<forall>n. ?P n (A n) \<and> ?Q (A n) (A (Suc n))") |
|
867 proof (intro dependent_nat_choice) |
|
868 show "\<exists>A. ?P 0 A" |
|
869 using \<open>?approx\<close>[THEN spec, of 1] by auto |
|
870 next |
|
871 fix A n assume "?P n A" |
|
872 moreover |
|
873 from \<open>?approx\<close>[THEN spec, of "1/Suc (Suc n)"] |
|
874 obtain T U where *: "T \<in> fmeasurable M" "U \<in> fmeasurable M" "T \<subseteq> S" "S \<subseteq> U" "?D T U < 1 / Suc (Suc n)" |
|
875 by auto |
|
876 ultimately have "?\<mu> T \<le> ?\<mu> (T \<union> fst A)" "?\<mu> (U \<inter> snd A) \<le> ?\<mu> U" |
|
877 "?\<mu> T \<le> ?\<mu> U" "?\<mu> (T \<union> fst A) \<le> ?\<mu> (U \<inter> snd A)" |
|
878 by (auto intro!: measure_mono_fmeasurable) |
|
879 then have "?D (T \<union> fst A) (U \<inter> snd A) \<le> ?D T U" |
|
880 by auto |
|
881 also have "?D T U < 1/Suc (Suc n)" by fact |
|
882 finally show "\<exists>B. ?P (Suc n) B \<and> ?Q A B" |
|
883 using \<open>?P n A\<close> * |
|
884 by (intro exI[of _ "(T \<union> fst A, U \<inter> snd A)"] conjI) auto |
|
885 qed |
|
886 then obtain A |
|
887 where lm: "\<And>n. fst (A n) \<in> fmeasurable M" "\<And>n. snd (A n) \<in> fmeasurable M" |
|
888 and set_bound: "\<And>n. fst (A n) \<subseteq> S" "\<And>n. S \<subseteq> snd (A n)" |
|
889 and mono: "\<And>n. fst (A n) \<subseteq> fst (A (Suc n))" "\<And>n. snd (A (Suc n)) \<subseteq> snd (A n)" |
|
890 and bound: "\<And>n. ?D (fst (A n)) (snd (A n)) < 1/Suc n" |
|
891 by metis |
|
892 |
|
893 have INT_sA: "(\<Inter>n. snd (A n)) \<in> fmeasurable M" |
|
894 using lm by (intro fmeasurable_INT[of _ 0]) auto |
|
895 have UN_fA: "(\<Union>n. fst (A n)) \<in> fmeasurable M" |
|
896 using lm order_trans[OF set_bound(1) set_bound(2)[of 0]] by (intro fmeasurable_UN[of _ _ "snd (A 0)"]) auto |
|
897 |
|
898 have "(\<lambda>n. ?\<mu> (fst (A n)) - ?\<mu> (snd (A n))) \<longlonglongrightarrow> 0" |
|
899 using bound |
|
900 by (subst tendsto_rabs_zero_iff[symmetric]) |
|
901 (intro tendsto_sandwich[OF _ _ tendsto_const LIMSEQ_inverse_real_of_nat]; |
|
902 auto intro!: always_eventually less_imp_le simp: divide_inverse) |
|
903 moreover |
|
904 have "(\<lambda>n. ?\<mu> (fst (A n)) - ?\<mu> (snd (A n))) \<longlonglongrightarrow> ?\<mu> (\<Union>n. fst (A n)) - ?\<mu> (\<Inter>n. snd (A n))" |
|
905 proof (intro tendsto_diff Lim_measure_incseq Lim_measure_decseq) |
|
906 show "range (\<lambda>i. fst (A i)) \<subseteq> sets M" "range (\<lambda>i. snd (A i)) \<subseteq> sets M" |
|
907 "incseq (\<lambda>i. fst (A i))" "decseq (\<lambda>n. snd (A n))" |
|
908 using mono lm by (auto simp: incseq_Suc_iff decseq_Suc_iff intro!: measure_mono_fmeasurable) |
|
909 show "emeasure M (\<Union>x. fst (A x)) \<noteq> \<infinity>" "emeasure M (snd (A n)) \<noteq> \<infinity>" for n |
|
910 using lm(2)[of n] UN_fA by (auto simp: fmeasurable_def) |
|
911 qed |
|
912 ultimately have eq: "0 = ?\<mu> (\<Union>n. fst (A n)) - ?\<mu> (\<Inter>n. snd (A n))" |
|
913 by (rule LIMSEQ_unique) |
|
914 |
|
915 show "S \<in> fmeasurable M" |
|
916 using UN_fA INT_sA |
|
917 proof (rule complete_sets_sandwich_fmeasurable) |
|
918 show "(\<Union>n. fst (A n)) \<subseteq> S" "S \<subseteq> (\<Inter>n. snd (A n))" |
|
919 using set_bound by auto |
|
920 show "?\<mu> (\<Union>n. fst (A n)) = ?\<mu> (\<Inter>n. snd (A n))" |
|
921 using eq by auto |
|
922 qed |
|
923 qed (auto intro!: bexI[of _ S]) |
|
924 |
|
925 lemma (in complete_measure) fmeasurable_measure_inner_outer: |
|
926 "(S \<in> fmeasurable M \<and> m = measure M S) \<longleftrightarrow> |
|
927 (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T) \<and> |
|
928 (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)" |
|
929 (is "?lhs = ?rhs") |
|
930 proof |
|
931 assume RHS: ?rhs |
|
932 then have T: "\<And>e. 0 < e \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T)" |
|
933 and U: "\<And>e. 0 < e \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)" |
|
934 by auto |
|
935 have "S \<in> fmeasurable M" |
|
936 proof (subst fmeasurable_inner_outer, safe) |
|
937 fix e::real assume "0 < e" |
|
938 with RHS obtain T U where T: "T \<in> fmeasurable M" "T \<subseteq> S" "m - e/2 < measure M T" |
|
939 and U: "U \<in> fmeasurable M" "S \<subseteq> U" "measure M U < m + e/2" |
|
940 by (meson half_gt_zero)+ |
|
941 moreover have "measure M U - measure M T < (m + e/2) - (m - e/2)" |
|
942 by (intro diff_strict_mono) fact+ |
|
943 moreover have "measure M T \<le> measure M U" |
|
944 using T U by (intro measure_mono_fmeasurable) auto |
|
945 ultimately show "\<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>measure M T - measure M U\<bar> < e" |
|
946 apply (rule_tac bexI[OF _ \<open>T \<in> fmeasurable M\<close>]) |
|
947 apply (rule_tac bexI[OF _ \<open>U \<in> fmeasurable M\<close>]) |
|
948 by auto |
|
949 qed |
|
950 moreover have "m = measure M S" |
|
951 using \<open>S \<in> fmeasurable M\<close> U[of "measure M S - m"] T[of "m - measure M S"] |
|
952 by (cases m "measure M S" rule: linorder_cases) |
|
953 (auto simp: not_le[symmetric] measure_mono_fmeasurable) |
|
954 ultimately show ?lhs |
|
955 by simp |
|
956 qed (auto intro!: bexI[of _ S]) |
|
957 |
688 lemma (in cld_measure) notin_sets_outer_measure_of_cover: |
958 lemma (in cld_measure) notin_sets_outer_measure_of_cover: |
689 assumes E: "E \<subseteq> space M" "E \<notin> sets M" |
959 assumes E: "E \<subseteq> space M" "E \<notin> sets M" |
690 shows "\<exists>B\<in>sets M. 0 < emeasure M B \<and> emeasure M B < \<infinity> \<and> |
960 shows "\<exists>B\<in>sets M. 0 < emeasure M B \<and> emeasure M B < \<infinity> \<and> |
691 outer_measure_of M (B \<inter> E) = emeasure M B \<and> outer_measure_of M (B - E) = emeasure M B" |
961 outer_measure_of M (B \<inter> E) = emeasure M B \<and> outer_measure_of M (B - E) = emeasure M B" |
692 proof - |
962 proof - |