src/HOL/Analysis/Measure_Space.thy
changeset 70136 f03a01a18c6e
parent 69861 62e47f06d22c
child 70380 2b0dca68c3ee
equal deleted inserted replaced
70135:ad6d4a14adb5 70136:f03a01a18c6e
     9 theory Measure_Space
     9 theory Measure_Space
    10 imports
    10 imports
    11   Measurable "HOL-Library.Extended_Nonnegative_Real"
    11   Measurable "HOL-Library.Extended_Nonnegative_Real"
    12 begin
    12 begin
    13 
    13 
    14 subsection%unimportant "Relate extended reals and the indicator function"
    14 subsection\<^marker>\<open>tag unimportant\<close> "Relate extended reals and the indicator function"
    15 
    15 
    16 lemma suminf_cmult_indicator:
    16 lemma suminf_cmult_indicator:
    17   fixes f :: "nat \<Rightarrow> ennreal"
    17   fixes f :: "nat \<Rightarrow> ennreal"
    18   assumes "disjoint_family A" "x \<in> A i"
    18   assumes "disjoint_family A" "x \<in> A i"
    19   shows "(\<Sum>n. f n * indicator (A n) x) = f i"
    19   shows "(\<Sum>n. f n * indicator (A n) x) = f i"
    57 text \<open>
    57 text \<open>
    58   The type for emeasure spaces is already defined in \<^theory>\<open>HOL-Analysis.Sigma_Algebra\<close>, as it
    58   The type for emeasure spaces is already defined in \<^theory>\<open>HOL-Analysis.Sigma_Algebra\<close>, as it
    59   is also used to represent sigma algebras (with an arbitrary emeasure).
    59   is also used to represent sigma algebras (with an arbitrary emeasure).
    60 \<close>
    60 \<close>
    61 
    61 
    62 subsection%unimportant "Extend binary sets"
    62 subsection\<^marker>\<open>tag unimportant\<close> "Extend binary sets"
    63 
    63 
    64 lemma LIMSEQ_binaryset:
    64 lemma LIMSEQ_binaryset:
    65   assumes f: "f {} = 0"
    65   assumes f: "f {} = 0"
    66   shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) \<longlonglongrightarrow> f A + f B"
    66   shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) \<longlonglongrightarrow> f A + f B"
    67 proof -
    67 proof -
    89 lemma suminf_binaryset_eq:
    89 lemma suminf_binaryset_eq:
    90   fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
    90   fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
    91   shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
    91   shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
    92   by (metis binaryset_sums sums_unique)
    92   by (metis binaryset_sums sums_unique)
    93 
    93 
    94 subsection%unimportant \<open>Properties of a premeasure \<^term>\<open>\<mu>\<close>\<close>
    94 subsection\<^marker>\<open>tag unimportant\<close> \<open>Properties of a premeasure \<^term>\<open>\<mu>\<close>\<close>
    95 
    95 
    96 text \<open>
    96 text \<open>
    97   The definitions for \<^const>\<open>positive\<close> and \<^const>\<open>countably_additive\<close> should be here, by they are
    97   The definitions for \<^const>\<open>positive\<close> and \<^const>\<open>countably_additive\<close> should be here, by they are
    98   necessary to define \<^typ>\<open>'a measure\<close> in \<^theory>\<open>HOL-Analysis.Sigma_Algebra\<close>.
    98   necessary to define \<^typ>\<open>'a measure\<close> in \<^theory>\<open>HOL-Analysis.Sigma_Algebra\<close>.
    99 \<close>
    99 \<close>
   440   shows "countably_additive M f"
   440   shows "countably_additive M f"
   441   using countably_additive_iff_continuous_from_below[OF f]
   441   using countably_additive_iff_continuous_from_below[OF f]
   442   using empty_continuous_imp_continuous_from_below[OF f fin] cont
   442   using empty_continuous_imp_continuous_from_below[OF f fin] cont
   443   by blast
   443   by blast
   444 
   444 
   445 subsection%unimportant \<open>Properties of \<^const>\<open>emeasure\<close>\<close>
   445 subsection\<^marker>\<open>tag unimportant\<close> \<open>Properties of \<^const>\<open>emeasure\<close>\<close>
   446 
   446 
   447 lemma emeasure_positive: "positive (sets M) (emeasure M)"
   447 lemma emeasure_positive: "positive (sets M) (emeasure M)"
   448   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
   448   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
   449 
   449 
   450 lemma emeasure_empty[simp, intro]: "emeasure M {} = 0"
   450 lemma emeasure_empty[simp, intro]: "emeasure M {} = 0"
   879     by (simp add: emeasure_countably_additive)
   879     by (simp add: emeasure_countably_additive)
   880 qed simp_all
   880 qed simp_all
   881 
   881 
   882 subsection \<open>\<open>\<mu>\<close>-null sets\<close>
   882 subsection \<open>\<open>\<mu>\<close>-null sets\<close>
   883 
   883 
   884 definition%important null_sets :: "'a measure \<Rightarrow> 'a set set" where
   884 definition\<^marker>\<open>tag important\<close> null_sets :: "'a measure \<Rightarrow> 'a set set" where
   885   "null_sets M = {N\<in>sets M. emeasure M N = 0}"
   885   "null_sets M = {N\<in>sets M. emeasure M N = 0}"
   886 
   886 
   887 lemma null_setsD1[dest]: "A \<in> null_sets M \<Longrightarrow> emeasure M A = 0"
   887 lemma null_setsD1[dest]: "A \<in> null_sets M \<Longrightarrow> emeasure M A = 0"
   888   by (simp add: null_sets_def)
   888   by (simp add: null_sets_def)
   889 
   889 
   987     by (subst plus_emeasure[symmetric]) auto
   987     by (subst plus_emeasure[symmetric]) auto
   988 qed
   988 qed
   989 
   989 
   990 subsection \<open>The almost everywhere filter (i.e.\ quantifier)\<close>
   990 subsection \<open>The almost everywhere filter (i.e.\ quantifier)\<close>
   991 
   991 
   992 definition%important ae_filter :: "'a measure \<Rightarrow> 'a filter" where
   992 definition\<^marker>\<open>tag important\<close> ae_filter :: "'a measure \<Rightarrow> 'a filter" where
   993   "ae_filter M = (INF N\<in>null_sets M. principal (space M - N))"
   993   "ae_filter M = (INF N\<in>null_sets M. principal (space M - N))"
   994 
   994 
   995 abbreviation almost_everywhere :: "'a measure \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
   995 abbreviation almost_everywhere :: "'a measure \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
   996   "almost_everywhere M P \<equiv> eventually P (ae_filter M)"
   996   "almost_everywhere M P \<equiv> eventually P (ae_filter M)"
   997 
   997 
  1263   finally show ?thesis .
  1263   finally show ?thesis .
  1264 qed
  1264 qed
  1265 
  1265 
  1266 subsection \<open>\<open>\<sigma>\<close>-finite Measures\<close>
  1266 subsection \<open>\<open>\<sigma>\<close>-finite Measures\<close>
  1267 
  1267 
  1268 locale%important sigma_finite_measure =
  1268 locale\<^marker>\<open>tag important\<close> sigma_finite_measure =
  1269   fixes M :: "'a measure"
  1269   fixes M :: "'a measure"
  1270   assumes sigma_finite_countable:
  1270   assumes sigma_finite_countable:
  1271     "\<exists>A::'a set set. countable A \<and> A \<subseteq> sets M \<and> (\<Union>A) = space M \<and> (\<forall>a\<in>A. emeasure M a \<noteq> \<infinity>)"
  1271     "\<exists>A::'a set set. countable A \<and> A \<subseteq> sets M \<and> (\<Union>A) = space M \<and> (\<forall>a\<in>A. emeasure M a \<noteq> \<infinity>)"
  1272 
  1272 
  1273 lemma (in sigma_finite_measure) sigma_finite:
  1273 lemma (in sigma_finite_measure) sigma_finite:
  1385   then show ?thesis using that by blast
  1385   then show ?thesis using that by blast
  1386 qed
  1386 qed
  1387 
  1387 
  1388 subsection \<open>Measure space induced by distribution of \<^const>\<open>measurable\<close>-functions\<close>
  1388 subsection \<open>Measure space induced by distribution of \<^const>\<open>measurable\<close>-functions\<close>
  1389 
  1389 
  1390 definition%important distr :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
  1390 definition\<^marker>\<open>tag important\<close> distr :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
  1391 "distr M N f =
  1391 "distr M N f =
  1392   measure_of (space N) (sets N) (\<lambda>A. emeasure M (f -` A \<inter> space M))"
  1392   measure_of (space N) (sets N) (\<lambda>A. emeasure M (f -` A \<inter> space M))"
  1393 
  1393 
  1394 lemma
  1394 lemma
  1395   shows sets_distr[simp, measurable_cong]: "sets (distr M N f) = sets N"
  1395   shows sets_distr[simp, measurable_cong]: "sets (distr M N f) = sets N"
  1517 proposition distr_distr:
  1517 proposition distr_distr:
  1518   "g \<in> measurable N L \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> distr (distr M N f) L g = distr M L (g \<circ> f)"
  1518   "g \<in> measurable N L \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> distr (distr M N f) L g = distr M L (g \<circ> f)"
  1519   by (auto simp add: emeasure_distr measurable_space
  1519   by (auto simp add: emeasure_distr measurable_space
  1520            intro!: arg_cong[where f="emeasure M"] measure_eqI)
  1520            intro!: arg_cong[where f="emeasure M"] measure_eqI)
  1521 
  1521 
  1522 subsection%unimportant \<open>Real measure values\<close>
  1522 subsection\<^marker>\<open>tag unimportant\<close> \<open>Real measure values\<close>
  1523 
  1523 
  1524 lemma ring_of_finite_sets: "ring_of_sets (space M) {A\<in>sets M. emeasure M A \<noteq> top}"
  1524 lemma ring_of_finite_sets: "ring_of_sets (space M) {A\<in>sets M. emeasure M A \<noteq> top}"
  1525 proof (rule ring_of_setsI)
  1525 proof (rule ring_of_setsI)
  1526   show "a \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow> b \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow>
  1526   show "a \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow> b \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow>
  1527     a \<union> b \<in> {A \<in> sets M. emeasure M A \<noteq> top}" for a b
  1527     a \<union> b \<in> {A \<in> sets M. emeasure M A \<noteq> top}" for a b
  1707     using fin A by (auto intro!: Lim_emeasure_decseq)
  1707     using fin A by (auto intro!: Lim_emeasure_decseq)
  1708 qed auto
  1708 qed auto
  1709 
  1709 
  1710 subsection \<open>Set of measurable sets with finite measure\<close>
  1710 subsection \<open>Set of measurable sets with finite measure\<close>
  1711 
  1711 
  1712 definition%important fmeasurable :: "'a measure \<Rightarrow> 'a set set" where
  1712 definition\<^marker>\<open>tag important\<close> fmeasurable :: "'a measure \<Rightarrow> 'a set set" where
  1713 "fmeasurable M = {A\<in>sets M. emeasure M A < \<infinity>}"
  1713 "fmeasurable M = {A\<in>sets M. emeasure M A < \<infinity>}"
  1714 
  1714 
  1715 lemma fmeasurableD[dest, measurable_dest]: "A \<in> fmeasurable M \<Longrightarrow> A \<in> sets M"
  1715 lemma fmeasurableD[dest, measurable_dest]: "A \<in> fmeasurable M \<Longrightarrow> A \<in> sets M"
  1716   by (auto simp: fmeasurable_def)
  1716   by (auto simp: fmeasurable_def)
  1717 
  1717 
  1747     using * by (auto intro: fmeasurableI)
  1747     using * by (auto intro: fmeasurableI)
  1748   show "a - b \<in> fmeasurable M"
  1748   show "a - b \<in> fmeasurable M"
  1749     using emeasure_mono[of "a - b" a M] * by (auto simp: fmeasurable_def)
  1749     using emeasure_mono[of "a - b" a M] * by (auto simp: fmeasurable_def)
  1750 qed
  1750 qed
  1751 
  1751 
  1752 subsection%unimportant\<open>Measurable sets formed by unions and intersections\<close>
  1752 subsection\<^marker>\<open>tag unimportant\<close>\<open>Measurable sets formed by unions and intersections\<close>
  1753 
  1753 
  1754 lemma fmeasurable_Diff: "A \<in> fmeasurable M \<Longrightarrow> B \<in> sets M \<Longrightarrow> A - B \<in> fmeasurable M"
  1754 lemma fmeasurable_Diff: "A \<in> fmeasurable M \<Longrightarrow> B \<in> sets M \<Longrightarrow> A - B \<in> fmeasurable M"
  1755   using fmeasurableI2[of A M "A - B"] by auto
  1755   using fmeasurableI2[of A M "A - B"] by auto
  1756 
  1756 
  1757 lemma fmeasurable_Int_fmeasurable:
  1757 lemma fmeasurable_Int_fmeasurable:
  2071   ultimately show ?thesis by auto
  2071   ultimately show ?thesis by auto
  2072 qed
  2072 qed
  2073 
  2073 
  2074 subsection \<open>Measure spaces with \<^term>\<open>emeasure M (space M) < \<infinity>\<close>\<close>
  2074 subsection \<open>Measure spaces with \<^term>\<open>emeasure M (space M) < \<infinity>\<close>\<close>
  2075 
  2075 
  2076 locale%important finite_measure = sigma_finite_measure M for M +
  2076 locale\<^marker>\<open>tag important\<close> finite_measure = sigma_finite_measure M for M +
  2077   assumes finite_emeasure_space: "emeasure M (space M) \<noteq> top"
  2077   assumes finite_emeasure_space: "emeasure M (space M) \<noteq> top"
  2078 
  2078 
  2079 lemma finite_measureI[Pure.intro!]:
  2079 lemma finite_measureI[Pure.intro!]:
  2080   "emeasure M (space M) \<noteq> \<infinity> \<Longrightarrow> finite_measure M"
  2080   "emeasure M (space M) \<noteq> \<infinity> \<Longrightarrow> finite_measure M"
  2081   proof qed (auto intro!: exI[of _ "{space M}"])
  2081   proof qed (auto intro!: exI[of _ "{space M}"])
  2293 next
  2293 next
  2294   show "f x \<le> (\<lambda>s. emeasure (M s) {x \<in> space N. F top x})" for x
  2294   show "f x \<le> (\<lambda>s. emeasure (M s) {x \<in> space N. F top x})" for x
  2295     using bound[of x] sets_eq_imp_space_eq[OF sets] by (simp add: iter)
  2295     using bound[of x] sets_eq_imp_space_eq[OF sets] by (simp add: iter)
  2296 qed (auto simp add: iter le_fun_def INF_apply[abs_def] intro!: meas cont)
  2296 qed (auto simp add: iter le_fun_def INF_apply[abs_def] intro!: meas cont)
  2297 
  2297 
  2298 subsection%unimportant \<open>Counting space\<close>
  2298 subsection\<^marker>\<open>tag unimportant\<close> \<open>Counting space\<close>
  2299 
  2299 
  2300 lemma strict_monoI_Suc:
  2300 lemma strict_monoI_Suc:
  2301   assumes ord [simp]: "(\<And>n. f n < f (Suc n))" shows "strict_mono f"
  2301   assumes ord [simp]: "(\<And>n. f n < f (Suc n))" shows "strict_mono f"
  2302   unfolding strict_mono_def
  2302   unfolding strict_mono_def
  2303 proof safe
  2303 proof safe
  2442 proof -
  2442 proof -
  2443   interpret finite_measure "count_space A" using A by (rule finite_measure_count_space)
  2443   interpret finite_measure "count_space A" using A by (rule finite_measure_count_space)
  2444   show "sigma_finite_measure (count_space A)" ..
  2444   show "sigma_finite_measure (count_space A)" ..
  2445 qed
  2445 qed
  2446 
  2446 
  2447 subsection%unimportant \<open>Measure restricted to space\<close>
  2447 subsection\<^marker>\<open>tag unimportant\<close> \<open>Measure restricted to space\<close>
  2448 
  2448 
  2449 lemma emeasure_restrict_space:
  2449 lemma emeasure_restrict_space:
  2450   assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
  2450   assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
  2451   shows "emeasure (restrict_space M \<Omega>) A = emeasure M A"
  2451   shows "emeasure (restrict_space M \<Omega>) A = emeasure M A"
  2452 proof (cases "A \<in> sets M")
  2452 proof (cases "A \<in> sets M")
  2601   also have "emeasure (restrict_space N \<Omega>) (X \<inter> \<Omega>) = emeasure N X"
  2601   also have "emeasure (restrict_space N \<Omega>) (X \<inter> \<Omega>) = emeasure N X"
  2602     using X ae \<Omega> by (auto simp add: emeasure_restrict_space sets_eq intro!: emeasure_eq_AE)
  2602     using X ae \<Omega> by (auto simp add: emeasure_restrict_space sets_eq intro!: emeasure_eq_AE)
  2603   finally show "emeasure M X = emeasure N X" .
  2603   finally show "emeasure M X = emeasure N X" .
  2604 qed fact
  2604 qed fact
  2605 
  2605 
  2606 subsection%unimportant \<open>Null measure\<close>
  2606 subsection\<^marker>\<open>tag unimportant\<close> \<open>Null measure\<close>
  2607 
  2607 
  2608 definition null_measure :: "'a measure \<Rightarrow> 'a measure" where
  2608 definition null_measure :: "'a measure \<Rightarrow> 'a measure" where
  2609 "null_measure M = sigma (space M) (sets M)"
  2609 "null_measure M = sigma (space M) (sets M)"
  2610 
  2610 
  2611 lemma space_null_measure[simp]: "space (null_measure M) = space M"
  2611 lemma space_null_measure[simp]: "space (null_measure M) = space M"
  2625 lemma null_measure_idem [simp]: "null_measure (null_measure M) = null_measure M"
  2625 lemma null_measure_idem [simp]: "null_measure (null_measure M) = null_measure M"
  2626   by(rule measure_eqI) simp_all
  2626   by(rule measure_eqI) simp_all
  2627 
  2627 
  2628 subsection \<open>Scaling a measure\<close>
  2628 subsection \<open>Scaling a measure\<close>
  2629 
  2629 
  2630 definition%important scale_measure :: "ennreal \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  2630 definition\<^marker>\<open>tag important\<close> scale_measure :: "ennreal \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  2631 "scale_measure r M = measure_of (space M) (sets M) (\<lambda>A. r * emeasure M A)"
  2631 "scale_measure r M = measure_of (space M) (sets M) (\<lambda>A. r * emeasure M A)"
  2632 
  2632 
  2633 lemma space_scale_measure: "space (scale_measure r M) = space M"
  2633 lemma space_scale_measure: "space (scale_measure r M) = space M"
  2634   by (simp add: scale_measure_def)
  2634   by (simp add: scale_measure_def)
  2635 
  2635 
  2827       by (erule ballE[of _ _ X])  (auto simp add: Int_absorb1 ac_simps)
  2827       by (erule ballE[of _ _ X])  (auto simp add: Int_absorb1 ac_simps)
  2828     apply auto
  2828     apply auto
  2829     done
  2829     done
  2830 qed
  2830 qed
  2831 
  2831 
  2832 text%important \<open>
  2832 text\<^marker>\<open>tag important\<close> \<open>
  2833   Define a lexicographical order on \<^type>\<open>measure\<close>, in the order space, sets and measure. The parts
  2833   Define a lexicographical order on \<^type>\<open>measure\<close>, in the order space, sets and measure. The parts
  2834   of the lexicographical order are point-wise ordered.
  2834   of the lexicographical order are point-wise ordered.
  2835 \<close>
  2835 \<close>
  2836 
  2836 
  2837 instantiation measure :: (type) order_bot
  2837 instantiation measure :: (type) order_bot
  2845 lemma le_measure_iff:
  2845 lemma le_measure_iff:
  2846   "M \<le> N \<longleftrightarrow> (if space M = space N then
  2846   "M \<le> N \<longleftrightarrow> (if space M = space N then
  2847     if sets M = sets N then emeasure M \<le> emeasure N else sets M \<subseteq> sets N else space M \<subseteq> space N)"
  2847     if sets M = sets N then emeasure M \<le> emeasure N else sets M \<subseteq> sets N else space M \<subseteq> space N)"
  2848   by (auto elim: less_eq_measure.cases intro: less_eq_measure.intros)
  2848   by (auto elim: less_eq_measure.cases intro: less_eq_measure.intros)
  2849 
  2849 
  2850 definition%important less_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> bool" where
  2850 definition\<^marker>\<open>tag important\<close> less_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> bool" where
  2851   "less_measure M N \<longleftrightarrow> (M \<le> N \<and> \<not> N \<le> M)"
  2851   "less_measure M N \<longleftrightarrow> (M \<le> N \<and> \<not> N \<le> M)"
  2852 
  2852 
  2853 definition%important bot_measure :: "'a measure" where
  2853 definition\<^marker>\<open>tag important\<close> bot_measure :: "'a measure" where
  2854   "bot_measure = sigma {} {}"
  2854   "bot_measure = sigma {} {}"
  2855 
  2855 
  2856 lemma
  2856 lemma
  2857   shows space_bot[simp]: "space bot = {}"
  2857   shows space_bot[simp]: "space bot = {}"
  2858     and sets_bot[simp]: "sets bot = {{}}"
  2858     and sets_bot[simp]: "sets bot = {{}}"
  2872   apply (auto simp: le_measure_iff le_fun_def dest: sets_eq_imp_space_eq)
  2872   apply (auto simp: le_measure_iff le_fun_def dest: sets_eq_imp_space_eq)
  2873   subgoal for X
  2873   subgoal for X
  2874     by (cases "X \<in> sets M") (auto simp: emeasure_notin_sets)
  2874     by (cases "X \<in> sets M") (auto simp: emeasure_notin_sets)
  2875   done
  2875   done
  2876 
  2876 
  2877 definition%important sup_measure' :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  2877 definition\<^marker>\<open>tag important\<close> sup_measure' :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  2878 "sup_measure' A B =
  2878 "sup_measure' A B =
  2879   measure_of (space A) (sets A)
  2879   measure_of (space A) (sets A)
  2880     (\<lambda>X. SUP Y\<in>sets A. emeasure A (X \<inter> Y) + emeasure B (X \<inter> - Y))"
  2880     (\<lambda>X. SUP Y\<in>sets A. emeasure A (X \<inter> Y) + emeasure B (X \<inter> - Y))"
  2881 
  2881 
  2882 lemma assumes [simp]: "sets B = sets A"
  2882 lemma assumes [simp]: "sets B = sets A"
  3006       by (subst plus_emeasure) (auto simp: Diff_eq[symmetric])
  3006       by (subst plus_emeasure) (auto simp: Diff_eq[symmetric])
  3007     finally show "emeasure A (X \<inter> Y) + emeasure B (X \<inter> - Y) \<le> emeasure C X" .
  3007     finally show "emeasure A (X \<inter> Y) + emeasure B (X \<inter> - Y) \<le> emeasure C X" .
  3008   qed
  3008   qed
  3009 qed simp_all
  3009 qed simp_all
  3010 
  3010 
  3011 definition%important sup_lexord :: "'a \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b::order) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" where
  3011 definition\<^marker>\<open>tag important\<close> sup_lexord :: "'a \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b::order) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" where
  3012 "sup_lexord A B k s c =
  3012 "sup_lexord A B k s c =
  3013   (if k A = k B then c else
  3013   (if k A = k B then c else
  3014    if \<not> k A \<le> k B \<and> \<not> k B \<le> k A then s else
  3014    if \<not> k A \<le> k B \<and> \<not> k B \<le> k A then s else
  3015    if k B \<le> k A then A else B)"
  3015    if k B \<le> k A then A else B)"
  3016 
  3016 
  3036                     sigma_sets_superset_generator sigma_sets_le_sets_iff)
  3036                     sigma_sets_superset_generator sigma_sets_le_sets_iff)
  3037 
  3037 
  3038 instantiation measure :: (type) semilattice_sup
  3038 instantiation measure :: (type) semilattice_sup
  3039 begin
  3039 begin
  3040 
  3040 
  3041 definition%important sup_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  3041 definition\<^marker>\<open>tag important\<close> sup_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  3042   "sup_measure A B =
  3042   "sup_measure A B =
  3043     sup_lexord A B space (sigma (space A \<union> space B) {})
  3043     sup_lexord A B space (sigma (space A \<union> space B) {})
  3044       (sup_lexord A B sets (sigma (space A) (sets A \<union> sets B)) (sup_measure' A B))"
  3044       (sup_lexord A B sets (sigma (space A) (sets A \<union> sets B)) (sup_measure' A B))"
  3045 
  3045 
  3046 instance
  3046 instance
  3139   by (auto simp: le_measure_iff le_fun_def dest: sets_eq_imp_space_eq split: if_split_asm)
  3139   by (auto simp: le_measure_iff le_fun_def dest: sets_eq_imp_space_eq split: if_split_asm)
  3140 
  3140 
  3141 lemma UN_space_closed: "\<Union>(sets ` S) \<subseteq> Pow (\<Union>(space ` S))"
  3141 lemma UN_space_closed: "\<Union>(sets ` S) \<subseteq> Pow (\<Union>(space ` S))"
  3142   using sets.space_closed by auto
  3142   using sets.space_closed by auto
  3143 
  3143 
  3144 definition%important
  3144 definition\<^marker>\<open>tag important\<close>
  3145   Sup_lexord :: "('a \<Rightarrow> 'b::complete_lattice) \<Rightarrow> ('a set \<Rightarrow> 'a) \<Rightarrow> ('a set \<Rightarrow> 'a) \<Rightarrow> 'a set \<Rightarrow> 'a"
  3145   Sup_lexord :: "('a \<Rightarrow> 'b::complete_lattice) \<Rightarrow> ('a set \<Rightarrow> 'a) \<Rightarrow> ('a set \<Rightarrow> 'a) \<Rightarrow> 'a set \<Rightarrow> 'a"
  3146 where
  3146 where
  3147   "Sup_lexord k c s A =
  3147   "Sup_lexord k c s A =
  3148   (let U = (SUP a\<in>A. k a)
  3148   (let U = (SUP a\<in>A. k a)
  3149    in if \<exists>a\<in>A. k a = U then c {a\<in>A. k a = U} else s A)"
  3149    in if \<exists>a\<in>A. k a = U then c {a\<in>A. k a = U} else s A)"
  3201 
  3201 
  3202 lemma sets_sup_measure_F:
  3202 lemma sets_sup_measure_F:
  3203   "finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> sets i = sets M) \<Longrightarrow> sets (sup_measure.F id I) = sets M"
  3203   "finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> sets i = sets M) \<Longrightarrow> sets (sup_measure.F id I) = sets M"
  3204   by (induction I rule: finite_ne_induct) (simp_all add: sets_sup)
  3204   by (induction I rule: finite_ne_induct) (simp_all add: sets_sup)
  3205 
  3205 
  3206 definition%important Sup_measure' :: "'a measure set \<Rightarrow> 'a measure" where
  3206 definition\<^marker>\<open>tag important\<close> Sup_measure' :: "'a measure set \<Rightarrow> 'a measure" where
  3207 "Sup_measure' M =
  3207 "Sup_measure' M =
  3208   measure_of (\<Union>a\<in>M. space a) (\<Union>a\<in>M. sets a)
  3208   measure_of (\<Union>a\<in>M. space a) (\<Union>a\<in>M. sets a)
  3209     (\<lambda>X. (SUP P\<in>{P. finite P \<and> P \<subseteq> M }. sup_measure.F id P X))"
  3209     (\<lambda>X. (SUP P\<in>{P. finite P \<and> P \<subseteq> M }. sup_measure.F id P X))"
  3210 
  3210 
  3211 lemma space_Sup_measure'2: "space (Sup_measure' M) = (\<Union>m\<in>M. space m)"
  3211 lemma space_Sup_measure'2: "space (Sup_measure' M) = (\<Union>m\<in>M. space m)"
  3272     by (auto simp: positive_def bot_ennreal[symmetric])
  3272     by (auto simp: positive_def bot_ennreal[symmetric])
  3273   show "X \<in> sets (Sup_measure' M)"
  3273   show "X \<in> sets (Sup_measure' M)"
  3274     using assms * by auto
  3274     using assms * by auto
  3275 qed (rule UN_space_closed)
  3275 qed (rule UN_space_closed)
  3276 
  3276 
  3277 definition%important Sup_measure :: "'a measure set \<Rightarrow> 'a measure" where
  3277 definition\<^marker>\<open>tag important\<close> Sup_measure :: "'a measure set \<Rightarrow> 'a measure" where
  3278 "Sup_measure =
  3278 "Sup_measure =
  3279   Sup_lexord space
  3279   Sup_lexord space
  3280     (Sup_lexord sets Sup_measure'
  3280     (Sup_lexord sets Sup_measure'
  3281       (\<lambda>U. sigma (\<Union>u\<in>U. space u) (\<Union>u\<in>U. sets u)))
  3281       (\<lambda>U. sigma (\<Union>u\<in>U. space u) (\<Union>u\<in>U. sets u)))
  3282     (\<lambda>U. sigma (\<Union>u\<in>U. space u) {})"
  3282     (\<lambda>U. sigma (\<Union>u\<in>U. space u) {})"
  3283 
  3283 
  3284 definition%important Inf_measure :: "'a measure set \<Rightarrow> 'a measure" where
  3284 definition\<^marker>\<open>tag important\<close> Inf_measure :: "'a measure set \<Rightarrow> 'a measure" where
  3285   "Inf_measure A = Sup {x. \<forall>a\<in>A. x \<le> a}"
  3285   "Inf_measure A = Sup {x. \<forall>a\<in>A. x \<le> a}"
  3286 
  3286 
  3287 definition%important inf_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  3287 definition\<^marker>\<open>tag important\<close> inf_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure" where
  3288   "inf_measure a b = Inf {a, b}"
  3288   "inf_measure a b = Inf {a, b}"
  3289 
  3289 
  3290 definition%important top_measure :: "'a measure" where
  3290 definition\<^marker>\<open>tag important\<close> top_measure :: "'a measure" where
  3291   "top_measure = Inf {}"
  3291   "top_measure = Inf {}"
  3292 
  3292 
  3293 instance
  3293 instance
  3294 proof
  3294 proof
  3295   note UN_space_closed [simp]
  3295   note UN_space_closed [simp]
  3525     fix j assume "j\<in>A" then show "\<exists>i\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> A}. emeasure (M j) X \<le> emeasure (Sup (M ` i)) X"
  3525     fix j assume "j\<in>A" then show "\<exists>i\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> A}. emeasure (M j) X \<le> emeasure (Sup (M ` i)) X"
  3526       by (intro bexI[of _ "{j}"]) auto
  3526       by (intro bexI[of _ "{j}"]) auto
  3527   qed
  3527   qed
  3528 qed
  3528 qed
  3529 
  3529 
  3530 subsubsection%unimportant \<open>Supremum of a set of \<open>\<sigma>\<close>-algebras\<close>
  3530 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Supremum of a set of \<open>\<sigma>\<close>-algebras\<close>
  3531 
  3531 
  3532 lemma space_Sup_eq_UN: "space (Sup M) = (\<Union>x\<in>M. space x)"
  3532 lemma space_Sup_eq_UN: "space (Sup M) = (\<Union>x\<in>M. space x)"
  3533   unfolding Sup_measure_def
  3533   unfolding Sup_measure_def
  3534   apply (intro Sup_lexord[where P="\<lambda>x. space x = _"])
  3534   apply (intro Sup_lexord[where P="\<lambda>x. space x = _"])
  3535   apply (subst space_Sup_measure'2)
  3535   apply (subst space_Sup_measure'2)