src/HOL/Probability/Measure_Space.thy
 author hoelzl Mon Apr 23 12:14:35 2012 +0200 (2012-04-23) changeset 47694 05663f75964c child 47761 dfe747e72fa8 permissions -rw-r--r--
reworked Probability theory
```     1 (*  Title:      HOL/Probability/Measure_Space.thy
```
```     2     Author:     Lawrence C Paulson
```
```     3     Author:     Johannes Hölzl, TU München
```
```     4     Author:     Armin Heller, TU München
```
```     5 *)
```
```     6
```
```     7 header {* Measure spaces and their properties *}
```
```     8
```
```     9 theory Measure_Space
```
```    10 imports
```
```    11   Sigma_Algebra
```
```    12   "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits"
```
```    13 begin
```
```    14
```
```    15 lemma suminf_eq_setsum:
```
```    16   fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add, t2_space}"
```
```    17   assumes "finite {i. f i \<noteq> 0}" (is "finite ?P")
```
```    18   shows "(\<Sum>i. f i) = (\<Sum>i | f i \<noteq> 0. f i)"
```
```    19 proof cases
```
```    20   assume "?P \<noteq> {}"
```
```    21   have [dest!]: "\<And>i. Suc (Max ?P) \<le> i \<Longrightarrow> f i = 0"
```
```    22     using `finite ?P` `?P \<noteq> {}` by (auto simp: Suc_le_eq)
```
```    23   have "(\<Sum>i. f i) = (\<Sum>i<Suc (Max ?P). f i)"
```
```    24     by (rule suminf_finite) auto
```
```    25   also have "\<dots> = (\<Sum>i | f i \<noteq> 0. f i)"
```
```    26     using `finite ?P` `?P \<noteq> {}`
```
```    27     by (intro setsum_mono_zero_right) (auto simp: less_Suc_eq_le)
```
```    28   finally show ?thesis .
```
```    29 qed simp
```
```    30
```
```    31 lemma suminf_cmult_indicator:
```
```    32   fixes f :: "nat \<Rightarrow> ereal"
```
```    33   assumes "disjoint_family A" "x \<in> A i" "\<And>i. 0 \<le> f i"
```
```    34   shows "(\<Sum>n. f n * indicator (A n) x) = f i"
```
```    35 proof -
```
```    36   have **: "\<And>n. f n * indicator (A n) x = (if n = i then f n else 0 :: ereal)"
```
```    37     using `x \<in> A i` assms unfolding disjoint_family_on_def indicator_def by auto
```
```    38   then have "\<And>n. (\<Sum>j<n. f j * indicator (A j) x) = (if i < n then f i else 0 :: ereal)"
```
```    39     by (auto simp: setsum_cases)
```
```    40   moreover have "(SUP n. if i < n then f i else 0) = (f i :: ereal)"
```
```    41   proof (rule ereal_SUPI)
```
```    42     fix y :: ereal assume "\<And>n. n \<in> UNIV \<Longrightarrow> (if i < n then f i else 0) \<le> y"
```
```    43     from this[of "Suc i"] show "f i \<le> y" by auto
```
```    44   qed (insert assms, simp)
```
```    45   ultimately show ?thesis using assms
```
```    46     by (subst suminf_ereal_eq_SUPR) (auto simp: indicator_def)
```
```    47 qed
```
```    48
```
```    49 lemma suminf_indicator:
```
```    50   assumes "disjoint_family A"
```
```    51   shows "(\<Sum>n. indicator (A n) x :: ereal) = indicator (\<Union>i. A i) x"
```
```    52 proof cases
```
```    53   assume *: "x \<in> (\<Union>i. A i)"
```
```    54   then obtain i where "x \<in> A i" by auto
```
```    55   from suminf_cmult_indicator[OF assms(1), OF `x \<in> A i`, of "\<lambda>k. 1"]
```
```    56   show ?thesis using * by simp
```
```    57 qed simp
```
```    58
```
```    59 text {*
```
```    60   The type for emeasure spaces is already defined in @{theory Sigma_Algebra}, as it is also used to
```
```    61   represent sigma algebras (with an arbitrary emeasure).
```
```    62 *}
```
```    63
```
```    64 section "Extend binary sets"
```
```    65
```
```    66 lemma LIMSEQ_binaryset:
```
```    67   assumes f: "f {} = 0"
```
```    68   shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) ----> f A + f B"
```
```    69 proof -
```
```    70   have "(\<lambda>n. \<Sum>i < Suc (Suc n). f (binaryset A B i)) = (\<lambda>n. f A + f B)"
```
```    71     proof
```
```    72       fix n
```
```    73       show "(\<Sum>i < Suc (Suc n). f (binaryset A B i)) = f A + f B"
```
```    74         by (induct n)  (auto simp add: binaryset_def f)
```
```    75     qed
```
```    76   moreover
```
```    77   have "... ----> f A + f B" by (rule tendsto_const)
```
```    78   ultimately
```
```    79   have "(\<lambda>n. \<Sum>i< Suc (Suc n). f (binaryset A B i)) ----> f A + f B"
```
```    80     by metis
```
```    81   hence "(\<lambda>n. \<Sum>i< n+2. f (binaryset A B i)) ----> f A + f B"
```
```    82     by simp
```
```    83   thus ?thesis by (rule LIMSEQ_offset [where k=2])
```
```    84 qed
```
```    85
```
```    86 lemma binaryset_sums:
```
```    87   assumes f: "f {} = 0"
```
```    88   shows  "(\<lambda>n. f (binaryset A B n)) sums (f A + f B)"
```
```    89     by (simp add: sums_def LIMSEQ_binaryset [where f=f, OF f] atLeast0LessThan)
```
```    90
```
```    91 lemma suminf_binaryset_eq:
```
```    92   fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
```
```    93   shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
```
```    94   by (metis binaryset_sums sums_unique)
```
```    95
```
```    96 section {* Properties of a premeasure @{term \<mu>} *}
```
```    97
```
```    98 text {*
```
```    99   The definitions for @{const positive} and @{const countably_additive} should be here, by they are
```
```   100   necessary to define @{typ "'a measure"} in @{theory Sigma_Algebra}.
```
```   101 *}
```
```   102
```
```   103 definition additive where
```
```   104   "additive M \<mu> \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<inter> y = {} \<longrightarrow> \<mu> (x \<union> y) = \<mu> x + \<mu> y)"
```
```   105
```
```   106 definition increasing where
```
```   107   "increasing M \<mu> \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<subseteq> y \<longrightarrow> \<mu> x \<le> \<mu> y)"
```
```   108
```
```   109 lemma positiveD_empty:
```
```   110   "positive M f \<Longrightarrow> f {} = 0"
```
```   111   by (auto simp add: positive_def)
```
```   112
```
```   113 lemma additiveD:
```
```   114   "additive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> M \<Longrightarrow> y \<in> M \<Longrightarrow> f (x \<union> y) = f x + f y"
```
```   115   by (auto simp add: additive_def)
```
```   116
```
```   117 lemma increasingD:
```
```   118   "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>M \<Longrightarrow> y\<in>M \<Longrightarrow> f x \<le> f y"
```
```   119   by (auto simp add: increasing_def)
```
```   120
```
```   121 lemma countably_additiveI:
```
```   122   "(\<And>A. range A \<subseteq> M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i. A i) \<in> M \<Longrightarrow> (\<Sum>i. f (A i)) = f (\<Union>i. A i))
```
```   123   \<Longrightarrow> countably_additive M f"
```
```   124   by (simp add: countably_additive_def)
```
```   125
```
```   126 lemma (in ring_of_sets) disjointed_additive:
```
```   127   assumes f: "positive M f" "additive M f" and A: "range A \<subseteq> M" "incseq A"
```
```   128   shows "(\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
```
```   129 proof (induct n)
```
```   130   case (Suc n)
```
```   131   then have "(\<Sum>i\<le>Suc n. f (disjointed A i)) = f (A n) + f (disjointed A (Suc n))"
```
```   132     by simp
```
```   133   also have "\<dots> = f (A n \<union> disjointed A (Suc n))"
```
```   134     using A by (subst f(2)[THEN additiveD]) (auto simp: disjointed_incseq)
```
```   135   also have "A n \<union> disjointed A (Suc n) = A (Suc n)"
```
```   136     using `incseq A` by (auto dest: incseq_SucD simp: disjointed_incseq)
```
```   137   finally show ?case .
```
```   138 qed simp
```
```   139
```
```   140 lemma (in ring_of_sets) additive_sum:
```
```   141   fixes A:: "'i \<Rightarrow> 'a set"
```
```   142   assumes f: "positive M f" and ad: "additive M f" and "finite S"
```
```   143       and A: "A`S \<subseteq> M"
```
```   144       and disj: "disjoint_family_on A S"
```
```   145   shows  "(\<Sum>i\<in>S. f (A i)) = f (\<Union>i\<in>S. A i)"
```
```   146 using `finite S` disj A proof induct
```
```   147   case empty show ?case using f by (simp add: positive_def)
```
```   148 next
```
```   149   case (insert s S)
```
```   150   then have "A s \<inter> (\<Union>i\<in>S. A i) = {}"
```
```   151     by (auto simp add: disjoint_family_on_def neq_iff)
```
```   152   moreover
```
```   153   have "A s \<in> M" using insert by blast
```
```   154   moreover have "(\<Union>i\<in>S. A i) \<in> M"
```
```   155     using insert `finite S` by auto
```
```   156   moreover
```
```   157   ultimately have "f (A s \<union> (\<Union>i\<in>S. A i)) = f (A s) + f(\<Union>i\<in>S. A i)"
```
```   158     using ad UNION_in_sets A by (auto simp add: additive_def)
```
```   159   with insert show ?case using ad disjoint_family_on_mono[of S "insert s S" A]
```
```   160     by (auto simp add: additive_def subset_insertI)
```
```   161 qed
```
```   162
```
```   163 lemma (in ring_of_sets) additive_increasing:
```
```   164   assumes posf: "positive M f" and addf: "additive M f"
```
```   165   shows "increasing M f"
```
```   166 proof (auto simp add: increasing_def)
```
```   167   fix x y
```
```   168   assume xy: "x \<in> M" "y \<in> M" "x \<subseteq> y"
```
```   169   then have "y - x \<in> M" by auto
```
```   170   then have "0 \<le> f (y-x)" using posf[unfolded positive_def] by auto
```
```   171   then have "f x + 0 \<le> f x + f (y-x)" by (intro add_left_mono) auto
```
```   172   also have "... = f (x \<union> (y-x))" using addf
```
```   173     by (auto simp add: additive_def) (metis Diff_disjoint Un_Diff_cancel Diff xy(1,2))
```
```   174   also have "... = f y"
```
```   175     by (metis Un_Diff_cancel Un_absorb1 xy(3))
```
```   176   finally show "f x \<le> f y" by simp
```
```   177 qed
```
```   178
```
```   179 lemma (in ring_of_sets) countably_additive_additive:
```
```   180   assumes posf: "positive M f" and ca: "countably_additive M f"
```
```   181   shows "additive M f"
```
```   182 proof (auto simp add: additive_def)
```
```   183   fix x y
```
```   184   assume x: "x \<in> M" and y: "y \<in> M" and "x \<inter> y = {}"
```
```   185   hence "disjoint_family (binaryset x y)"
```
```   186     by (auto simp add: disjoint_family_on_def binaryset_def)
```
```   187   hence "range (binaryset x y) \<subseteq> M \<longrightarrow>
```
```   188          (\<Union>i. binaryset x y i) \<in> M \<longrightarrow>
```
```   189          f (\<Union>i. binaryset x y i) = (\<Sum> n. f (binaryset x y n))"
```
```   190     using ca
```
```   191     by (simp add: countably_additive_def)
```
```   192   hence "{x,y,{}} \<subseteq> M \<longrightarrow> x \<union> y \<in> M \<longrightarrow>
```
```   193          f (x \<union> y) = (\<Sum>n. f (binaryset x y n))"
```
```   194     by (simp add: range_binaryset_eq UN_binaryset_eq)
```
```   195   thus "f (x \<union> y) = f x + f y" using posf x y
```
```   196     by (auto simp add: Un suminf_binaryset_eq positive_def)
```
```   197 qed
```
```   198
```
```   199 lemma (in algebra) increasing_additive_bound:
```
```   200   fixes A:: "nat \<Rightarrow> 'a set" and  f :: "'a set \<Rightarrow> ereal"
```
```   201   assumes f: "positive M f" and ad: "additive M f"
```
```   202       and inc: "increasing M f"
```
```   203       and A: "range A \<subseteq> M"
```
```   204       and disj: "disjoint_family A"
```
```   205   shows  "(\<Sum>i. f (A i)) \<le> f \<Omega>"
```
```   206 proof (safe intro!: suminf_bound)
```
```   207   fix N
```
```   208   note disj_N = disjoint_family_on_mono[OF _ disj, of "{..<N}"]
```
```   209   have "(\<Sum>i<N. f (A i)) = f (\<Union>i\<in>{..<N}. A i)"
```
```   210     using A by (intro additive_sum [OF f ad _ _]) (auto simp: disj_N)
```
```   211   also have "... \<le> f \<Omega>" using space_closed A
```
```   212     by (intro increasingD[OF inc] finite_UN) auto
```
```   213   finally show "(\<Sum>i<N. f (A i)) \<le> f \<Omega>" by simp
```
```   214 qed (insert f A, auto simp: positive_def)
```
```   215
```
```   216 lemma (in ring_of_sets) countably_additiveI_finite:
```
```   217   assumes "finite \<Omega>" "positive M \<mu>" "additive M \<mu>"
```
```   218   shows "countably_additive M \<mu>"
```
```   219 proof (rule countably_additiveI)
```
```   220   fix F :: "nat \<Rightarrow> 'a set" assume F: "range F \<subseteq> M" "(\<Union>i. F i) \<in> M" and disj: "disjoint_family F"
```
```   221
```
```   222   have "\<forall>i\<in>{i. F i \<noteq> {}}. \<exists>x. x \<in> F i" by auto
```
```   223   from bchoice[OF this] obtain f where f: "\<And>i. F i \<noteq> {} \<Longrightarrow> f i \<in> F i" by auto
```
```   224
```
```   225   have inj_f: "inj_on f {i. F i \<noteq> {}}"
```
```   226   proof (rule inj_onI, simp)
```
```   227     fix i j a b assume *: "f i = f j" "F i \<noteq> {}" "F j \<noteq> {}"
```
```   228     then have "f i \<in> F i" "f j \<in> F j" using f by force+
```
```   229     with disj * show "i = j" by (auto simp: disjoint_family_on_def)
```
```   230   qed
```
```   231   have "finite (\<Union>i. F i)"
```
```   232     by (metis F(2) assms(1) infinite_super sets_into_space)
```
```   233
```
```   234   have F_subset: "{i. \<mu> (F i) \<noteq> 0} \<subseteq> {i. F i \<noteq> {}}"
```
```   235     by (auto simp: positiveD_empty[OF `positive M \<mu>`])
```
```   236   moreover have fin_not_empty: "finite {i. F i \<noteq> {}}"
```
```   237   proof (rule finite_imageD)
```
```   238     from f have "f`{i. F i \<noteq> {}} \<subseteq> (\<Union>i. F i)" by auto
```
```   239     then show "finite (f`{i. F i \<noteq> {}})"
```
```   240       by (rule finite_subset) fact
```
```   241   qed fact
```
```   242   ultimately have fin_not_0: "finite {i. \<mu> (F i) \<noteq> 0}"
```
```   243     by (rule finite_subset)
```
```   244
```
```   245   have disj_not_empty: "disjoint_family_on F {i. F i \<noteq> {}}"
```
```   246     using disj by (auto simp: disjoint_family_on_def)
```
```   247
```
```   248   from fin_not_0 have "(\<Sum>i. \<mu> (F i)) = (\<Sum>i | \<mu> (F i) \<noteq> 0. \<mu> (F i))"
```
```   249     by (rule suminf_eq_setsum)
```
```   250   also have "\<dots> = (\<Sum>i | F i \<noteq> {}. \<mu> (F i))"
```
```   251     using fin_not_empty F_subset by (rule setsum_mono_zero_left) auto
```
```   252   also have "\<dots> = \<mu> (\<Union>i\<in>{i. F i \<noteq> {}}. F i)"
```
```   253     using `positive M \<mu>` `additive M \<mu>` fin_not_empty disj_not_empty F by (intro additive_sum) auto
```
```   254   also have "\<dots> = \<mu> (\<Union>i. F i)"
```
```   255     by (rule arg_cong[where f=\<mu>]) auto
```
```   256   finally show "(\<Sum>i. \<mu> (F i)) = \<mu> (\<Union>i. F i)" .
```
```   257 qed
```
```   258
```
```   259 section {* Properties of @{const emeasure} *}
```
```   260
```
```   261 lemma emeasure_positive: "positive (sets M) (emeasure M)"
```
```   262   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
```
```   263
```
```   264 lemma emeasure_empty[simp, intro]: "emeasure M {} = 0"
```
```   265   using emeasure_positive[of M] by (simp add: positive_def)
```
```   266
```
```   267 lemma emeasure_nonneg[intro!]: "0 \<le> emeasure M A"
```
```   268   using emeasure_notin_sets[of A M] emeasure_positive[of M]
```
```   269   by (cases "A \<in> sets M") (auto simp: positive_def)
```
```   270
```
```   271 lemma emeasure_not_MInf[simp]: "emeasure M A \<noteq> - \<infinity>"
```
```   272   using emeasure_nonneg[of M A] by auto
```
```   273
```
```   274 lemma emeasure_countably_additive: "countably_additive (sets M) (emeasure M)"
```
```   275   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
```
```   276
```
```   277 lemma suminf_emeasure:
```
```   278   "range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
```
```   279   using countable_UN[of A UNIV M] emeasure_countably_additive[of M]
```
```   280   by (simp add: countably_additive_def)
```
```   281
```
```   282 lemma emeasure_additive: "additive (sets M) (emeasure M)"
```
```   283   by (metis countably_additive_additive emeasure_positive emeasure_countably_additive)
```
```   284
```
```   285 lemma plus_emeasure:
```
```   286   "a \<in> sets M \<Longrightarrow> b \<in> sets M \<Longrightarrow> a \<inter> b = {} \<Longrightarrow> emeasure M a + emeasure M b = emeasure M (a \<union> b)"
```
```   287   using additiveD[OF emeasure_additive] ..
```
```   288
```
```   289 lemma setsum_emeasure:
```
```   290   "F`I \<subseteq> sets M \<Longrightarrow> disjoint_family_on F I \<Longrightarrow> finite I \<Longrightarrow>
```
```   291     (\<Sum>i\<in>I. emeasure M (F i)) = emeasure M (\<Union>i\<in>I. F i)"
```
```   292   by (metis additive_sum emeasure_positive emeasure_additive)
```
```   293
```
```   294 lemma emeasure_mono:
```
```   295   "a \<subseteq> b \<Longrightarrow> b \<in> sets M \<Longrightarrow> emeasure M a \<le> emeasure M b"
```
```   296   by (metis additive_increasing emeasure_additive emeasure_nonneg emeasure_notin_sets
```
```   297             emeasure_positive increasingD)
```
```   298
```
```   299 lemma emeasure_space:
```
```   300   "emeasure M A \<le> emeasure M (space M)"
```
```   301   by (metis emeasure_mono emeasure_nonneg emeasure_notin_sets sets_into_space top)
```
```   302
```
```   303 lemma emeasure_compl:
```
```   304   assumes s: "s \<in> sets M" and fin: "emeasure M s \<noteq> \<infinity>"
```
```   305   shows "emeasure M (space M - s) = emeasure M (space M) - emeasure M s"
```
```   306 proof -
```
```   307   from s have "0 \<le> emeasure M s" by auto
```
```   308   have "emeasure M (space M) = emeasure M (s \<union> (space M - s))" using s
```
```   309     by (metis Un_Diff_cancel Un_absorb1 s sets_into_space)
```
```   310   also have "... = emeasure M s + emeasure M (space M - s)"
```
```   311     by (rule plus_emeasure[symmetric]) (auto simp add: s)
```
```   312   finally have "emeasure M (space M) = emeasure M s + emeasure M (space M - s)" .
```
```   313   then show ?thesis
```
```   314     using fin `0 \<le> emeasure M s`
```
```   315     unfolding ereal_eq_minus_iff by (auto simp: ac_simps)
```
```   316 qed
```
```   317
```
```   318 lemma emeasure_Diff:
```
```   319   assumes finite: "emeasure M B \<noteq> \<infinity>"
```
```   320   and measurable: "A \<in> sets M" "B \<in> sets M" "B \<subseteq> A"
```
```   321   shows "emeasure M (A - B) = emeasure M A - emeasure M B"
```
```   322 proof -
```
```   323   have "0 \<le> emeasure M B" using assms by auto
```
```   324   have "(A - B) \<union> B = A" using `B \<subseteq> A` by auto
```
```   325   then have "emeasure M A = emeasure M ((A - B) \<union> B)" by simp
```
```   326   also have "\<dots> = emeasure M (A - B) + emeasure M B"
```
```   327     using measurable by (subst plus_emeasure[symmetric]) auto
```
```   328   finally show "emeasure M (A - B) = emeasure M A - emeasure M B"
```
```   329     unfolding ereal_eq_minus_iff
```
```   330     using finite `0 \<le> emeasure M B` by auto
```
```   331 qed
```
```   332
```
```   333 lemma emeasure_countable_increasing:
```
```   334   assumes A: "range A \<subseteq> sets M"
```
```   335       and A0: "A 0 = {}"
```
```   336       and ASuc: "\<And>n. A n \<subseteq> A (Suc n)"
```
```   337   shows "(SUP n. emeasure M (A n)) = emeasure M (\<Union>i. A i)"
```
```   338 proof -
```
```   339   { fix n
```
```   340     have "emeasure M (A n) = (\<Sum>i<n. emeasure M (A (Suc i) - A i))"
```
```   341       proof (induct n)
```
```   342         case 0 thus ?case by (auto simp add: A0)
```
```   343       next
```
```   344         case (Suc m)
```
```   345         have "A (Suc m) = A m \<union> (A (Suc m) - A m)"
```
```   346           by (metis ASuc Un_Diff_cancel Un_absorb1)
```
```   347         hence "emeasure M (A (Suc m)) =
```
```   348                emeasure M (A m) + emeasure M (A (Suc m) - A m)"
```
```   349           by (subst plus_emeasure)
```
```   350              (auto simp add: emeasure_additive range_subsetD [OF A])
```
```   351         with Suc show ?case
```
```   352           by simp
```
```   353       qed }
```
```   354   note Meq = this
```
```   355   have Aeq: "(\<Union>i. A (Suc i) - A i) = (\<Union>i. A i)"
```
```   356     proof (rule UN_finite2_eq [where k=1], simp)
```
```   357       fix i
```
```   358       show "(\<Union>i\<in>{0..<i}. A (Suc i) - A i) = (\<Union>i\<in>{0..<Suc i}. A i)"
```
```   359         proof (induct i)
```
```   360           case 0 thus ?case by (simp add: A0)
```
```   361         next
```
```   362           case (Suc i)
```
```   363           thus ?case
```
```   364             by (auto simp add: atLeastLessThanSuc intro: subsetD [OF ASuc])
```
```   365         qed
```
```   366     qed
```
```   367   have A1: "\<And>i. A (Suc i) - A i \<in> sets M"
```
```   368     by (metis A Diff range_subsetD)
```
```   369   have A2: "(\<Union>i. A (Suc i) - A i) \<in> sets M"
```
```   370     by (blast intro: range_subsetD [OF A])
```
```   371   have "(SUP n. \<Sum>i<n. emeasure M (A (Suc i) - A i)) = (\<Sum>i. emeasure M (A (Suc i) - A i))"
```
```   372     using A by (auto intro!: suminf_ereal_eq_SUPR[symmetric])
```
```   373   also have "\<dots> = emeasure M (\<Union>i. A (Suc i) - A i)"
```
```   374     by (rule suminf_emeasure)
```
```   375        (auto simp add: disjoint_family_Suc ASuc A1 A2)
```
```   376   also have "... =  emeasure M (\<Union>i. A i)"
```
```   377     by (simp add: Aeq)
```
```   378   finally have "(SUP n. \<Sum>i<n. emeasure M (A (Suc i) - A i)) = emeasure M (\<Union>i. A i)" .
```
```   379   then show ?thesis by (auto simp add: Meq)
```
```   380 qed
```
```   381
```
```   382 lemma SUP_emeasure_incseq:
```
```   383   assumes A: "range A \<subseteq> sets M" and "incseq A"
```
```   384   shows "(SUP n. emeasure M (A n)) = emeasure M (\<Union>i. A i)"
```
```   385 proof -
```
```   386   have *: "(SUP n. emeasure M (nat_case {} A (Suc n))) = (SUP n. emeasure M (nat_case {} A n))"
```
```   387     using A by (auto intro!: SUPR_eq exI split: nat.split)
```
```   388   have ueq: "(\<Union>i. nat_case {} A i) = (\<Union>i. A i)"
```
```   389     by (auto simp add: split: nat.splits)
```
```   390   have meq: "\<And>n. emeasure M (A n) = (emeasure M \<circ> nat_case {} A) (Suc n)"
```
```   391     by simp
```
```   392   have "(SUP n. emeasure M (nat_case {} A n)) = emeasure M (\<Union>i. nat_case {} A i)"
```
```   393     using range_subsetD[OF A] incseq_SucD[OF `incseq A`]
```
```   394     by (force split: nat.splits intro!: emeasure_countable_increasing)
```
```   395   also have "emeasure M (\<Union>i. nat_case {} A i) = emeasure M (\<Union>i. A i)"
```
```   396     by (simp add: ueq)
```
```   397   finally have "(SUP n. emeasure M (nat_case {} A n)) = emeasure M (\<Union>i. A i)" .
```
```   398   thus ?thesis unfolding meq * comp_def .
```
```   399 qed
```
```   400
```
```   401 lemma incseq_emeasure:
```
```   402   assumes "range B \<subseteq> sets M" "incseq B"
```
```   403   shows "incseq (\<lambda>i. emeasure M (B i))"
```
```   404   using assms by (auto simp: incseq_def intro!: emeasure_mono)
```
```   405
```
```   406 lemma Lim_emeasure_incseq:
```
```   407   assumes A: "range A \<subseteq> sets M" "incseq A"
```
```   408   shows "(\<lambda>i. (emeasure M (A i))) ----> emeasure M (\<Union>i. A i)"
```
```   409   using LIMSEQ_ereal_SUPR[OF incseq_emeasure, OF A]
```
```   410     SUP_emeasure_incseq[OF A] by simp
```
```   411
```
```   412 lemma decseq_emeasure:
```
```   413   assumes "range B \<subseteq> sets M" "decseq B"
```
```   414   shows "decseq (\<lambda>i. emeasure M (B i))"
```
```   415   using assms by (auto simp: decseq_def intro!: emeasure_mono)
```
```   416
```
```   417 lemma INF_emeasure_decseq:
```
```   418   assumes A: "range A \<subseteq> sets M" and "decseq A"
```
```   419   and finite: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
```
```   420   shows "(INF n. emeasure M (A n)) = emeasure M (\<Inter>i. A i)"
```
```   421 proof -
```
```   422   have le_MI: "emeasure M (\<Inter>i. A i) \<le> emeasure M (A 0)"
```
```   423     using A by (auto intro!: emeasure_mono)
```
```   424   hence *: "emeasure M (\<Inter>i. A i) \<noteq> \<infinity>" using finite[of 0] by auto
```
```   425
```
```   426   have A0: "0 \<le> emeasure M (A 0)" using A by auto
```
```   427
```
```   428   have "emeasure M (A 0) - (INF n. emeasure M (A n)) = emeasure M (A 0) + (SUP n. - emeasure M (A n))"
```
```   429     by (simp add: ereal_SUPR_uminus minus_ereal_def)
```
```   430   also have "\<dots> = (SUP n. emeasure M (A 0) - emeasure M (A n))"
```
```   431     unfolding minus_ereal_def using A0 assms
```
```   432     by (subst SUPR_ereal_add) (auto simp add: decseq_emeasure)
```
```   433   also have "\<dots> = (SUP n. emeasure M (A 0 - A n))"
```
```   434     using A finite `decseq A`[unfolded decseq_def] by (subst emeasure_Diff) auto
```
```   435   also have "\<dots> = emeasure M (\<Union>i. A 0 - A i)"
```
```   436   proof (rule SUP_emeasure_incseq)
```
```   437     show "range (\<lambda>n. A 0 - A n) \<subseteq> sets M"
```
```   438       using A by auto
```
```   439     show "incseq (\<lambda>n. A 0 - A n)"
```
```   440       using `decseq A` by (auto simp add: incseq_def decseq_def)
```
```   441   qed
```
```   442   also have "\<dots> = emeasure M (A 0) - emeasure M (\<Inter>i. A i)"
```
```   443     using A finite * by (simp, subst emeasure_Diff) auto
```
```   444   finally show ?thesis
```
```   445     unfolding ereal_minus_eq_minus_iff using finite A0 by auto
```
```   446 qed
```
```   447
```
```   448 lemma Lim_emeasure_decseq:
```
```   449   assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
```
```   450   shows "(\<lambda>i. emeasure M (A i)) ----> emeasure M (\<Inter>i. A i)"
```
```   451   using LIMSEQ_ereal_INFI[OF decseq_emeasure, OF A]
```
```   452   using INF_emeasure_decseq[OF A fin] by simp
```
```   453
```
```   454 lemma emeasure_subadditive:
```
```   455   assumes measurable: "A \<in> sets M" "B \<in> sets M"
```
```   456   shows "emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
```
```   457 proof -
```
```   458   from plus_emeasure[of A M "B - A"]
```
```   459   have "emeasure M (A \<union> B) = emeasure M A + emeasure M (B - A)"
```
```   460     using assms by (simp add: Diff)
```
```   461   also have "\<dots> \<le> emeasure M A + emeasure M B"
```
```   462     using assms by (auto intro!: add_left_mono emeasure_mono)
```
```   463   finally show ?thesis .
```
```   464 qed
```
```   465
```
```   466 lemma emeasure_subadditive_finite:
```
```   467   assumes "finite I" "A ` I \<subseteq> sets M"
```
```   468   shows "emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
```
```   469 using assms proof induct
```
```   470   case (insert i I)
```
```   471   then have "emeasure M (\<Union>i\<in>insert i I. A i) = emeasure M (A i \<union> (\<Union>i\<in>I. A i))"
```
```   472     by simp
```
```   473   also have "\<dots> \<le> emeasure M (A i) + emeasure M (\<Union>i\<in>I. A i)"
```
```   474     using insert by (intro emeasure_subadditive finite_UN) auto
```
```   475   also have "\<dots> \<le> emeasure M (A i) + (\<Sum>i\<in>I. emeasure M (A i))"
```
```   476     using insert by (intro add_mono) auto
```
```   477   also have "\<dots> = (\<Sum>i\<in>insert i I. emeasure M (A i))"
```
```   478     using insert by auto
```
```   479   finally show ?case .
```
```   480 qed simp
```
```   481
```
```   482 lemma emeasure_subadditive_countably:
```
```   483   assumes "range f \<subseteq> sets M"
```
```   484   shows "emeasure M (\<Union>i. f i) \<le> (\<Sum>i. emeasure M (f i))"
```
```   485 proof -
```
```   486   have "emeasure M (\<Union>i. f i) = emeasure M (\<Union>i. disjointed f i)"
```
```   487     unfolding UN_disjointed_eq ..
```
```   488   also have "\<dots> = (\<Sum>i. emeasure M (disjointed f i))"
```
```   489     using range_disjointed_sets[OF assms] suminf_emeasure[of "disjointed f"]
```
```   490     by (simp add:  disjoint_family_disjointed comp_def)
```
```   491   also have "\<dots> \<le> (\<Sum>i. emeasure M (f i))"
```
```   492     using range_disjointed_sets[OF assms] assms
```
```   493     by (auto intro!: suminf_le_pos emeasure_mono disjointed_subset)
```
```   494   finally show ?thesis .
```
```   495 qed
```
```   496
```
```   497 lemma emeasure_insert:
```
```   498   assumes sets: "{x} \<in> sets M" "A \<in> sets M" and "x \<notin> A"
```
```   499   shows "emeasure M (insert x A) = emeasure M {x} + emeasure M A"
```
```   500 proof -
```
```   501   have "{x} \<inter> A = {}" using `x \<notin> A` by auto
```
```   502   from plus_emeasure[OF sets this] show ?thesis by simp
```
```   503 qed
```
```   504
```
```   505 lemma emeasure_eq_setsum_singleton:
```
```   506   assumes "finite S" "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
```
```   507   shows "emeasure M S = (\<Sum>x\<in>S. emeasure M {x})"
```
```   508   using setsum_emeasure[of "\<lambda>x. {x}" S M] assms
```
```   509   by (auto simp: disjoint_family_on_def subset_eq)
```
```   510
```
```   511 lemma setsum_emeasure_cover:
```
```   512   assumes "finite S" and "A \<in> sets M" and br_in_M: "B ` S \<subseteq> sets M"
```
```   513   assumes A: "A \<subseteq> (\<Union>i\<in>S. B i)"
```
```   514   assumes disj: "disjoint_family_on B S"
```
```   515   shows "emeasure M A = (\<Sum>i\<in>S. emeasure M (A \<inter> (B i)))"
```
```   516 proof -
```
```   517   have "(\<Sum>i\<in>S. emeasure M (A \<inter> (B i))) = emeasure M (\<Union>i\<in>S. A \<inter> (B i))"
```
```   518   proof (rule setsum_emeasure)
```
```   519     show "disjoint_family_on (\<lambda>i. A \<inter> B i) S"
```
```   520       using `disjoint_family_on B S`
```
```   521       unfolding disjoint_family_on_def by auto
```
```   522   qed (insert assms, auto)
```
```   523   also have "(\<Union>i\<in>S. A \<inter> (B i)) = A"
```
```   524     using A by auto
```
```   525   finally show ?thesis by simp
```
```   526 qed
```
```   527
```
```   528 lemma emeasure_eq_0:
```
```   529   "N \<in> sets M \<Longrightarrow> emeasure M N = 0 \<Longrightarrow> K \<subseteq> N \<Longrightarrow> emeasure M K = 0"
```
```   530   by (metis emeasure_mono emeasure_nonneg order_eq_iff)
```
```   531
```
```   532 lemma emeasure_UN_eq_0:
```
```   533   assumes "\<And>i::nat. emeasure M (N i) = 0" and "range N \<subseteq> sets M"
```
```   534   shows "emeasure M (\<Union> i. N i) = 0"
```
```   535 proof -
```
```   536   have "0 \<le> emeasure M (\<Union> i. N i)" using assms by auto
```
```   537   moreover have "emeasure M (\<Union> i. N i) \<le> 0"
```
```   538     using emeasure_subadditive_countably[OF assms(2)] assms(1) by simp
```
```   539   ultimately show ?thesis by simp
```
```   540 qed
```
```   541
```
```   542 lemma measure_eqI_finite:
```
```   543   assumes [simp]: "sets M = Pow A" "sets N = Pow A" and "finite A"
```
```   544   assumes eq: "\<And>a. a \<in> A \<Longrightarrow> emeasure M {a} = emeasure N {a}"
```
```   545   shows "M = N"
```
```   546 proof (rule measure_eqI)
```
```   547   fix X assume "X \<in> sets M"
```
```   548   then have X: "X \<subseteq> A" by auto
```
```   549   then have "emeasure M X = (\<Sum>a\<in>X. emeasure M {a})"
```
```   550     using `finite A` by (subst emeasure_eq_setsum_singleton) (auto dest: finite_subset)
```
```   551   also have "\<dots> = (\<Sum>a\<in>X. emeasure N {a})"
```
```   552     using X eq by (auto intro!: setsum_cong)
```
```   553   also have "\<dots> = emeasure N X"
```
```   554     using X `finite A` by (subst emeasure_eq_setsum_singleton) (auto dest: finite_subset)
```
```   555   finally show "emeasure M X = emeasure N X" .
```
```   556 qed simp
```
```   557
```
```   558 lemma measure_eqI_generator_eq:
```
```   559   fixes M N :: "'a measure" and E :: "'a set set" and A :: "nat \<Rightarrow> 'a set"
```
```   560   assumes "Int_stable E" "E \<subseteq> Pow \<Omega>"
```
```   561   and eq: "\<And>X. X \<in> E \<Longrightarrow> emeasure M X = emeasure N X"
```
```   562   and M: "sets M = sigma_sets \<Omega> E"
```
```   563   and N: "sets N = sigma_sets \<Omega> E"
```
```   564   and A: "range A \<subseteq> E" "incseq A" "(\<Union>i. A i) = \<Omega>" "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
```
```   565   shows "M = N"
```
```   566 proof -
```
```   567   let ?D = "\<lambda>F. {D. D \<in> sigma_sets \<Omega> E \<and> emeasure M (F \<inter> D) = emeasure N (F \<inter> D)}"
```
```   568   interpret S: sigma_algebra \<Omega> "sigma_sets \<Omega> E" by (rule sigma_algebra_sigma_sets) fact
```
```   569   { fix F assume "F \<in> E" and "emeasure M F \<noteq> \<infinity>"
```
```   570     then have [intro]: "F \<in> sigma_sets \<Omega> E" by auto
```
```   571     have "emeasure N F \<noteq> \<infinity>" using `emeasure M F \<noteq> \<infinity>` `F \<in> E` eq by simp
```
```   572     interpret D: dynkin_system \<Omega> "?D F"
```
```   573     proof (rule dynkin_systemI, simp_all)
```
```   574       fix A assume "A \<in> sigma_sets \<Omega> E \<and> emeasure M (F \<inter> A) = emeasure N (F \<inter> A)"
```
```   575       then show "A \<subseteq> \<Omega>" using S.sets_into_space by auto
```
```   576     next
```
```   577       have "F \<inter> \<Omega> = F" using `F \<in> E` `E \<subseteq> Pow \<Omega>` by auto
```
```   578       then show "emeasure M (F \<inter> \<Omega>) = emeasure N (F \<inter> \<Omega>)"
```
```   579         using `F \<in> E` eq by (auto intro: sigma_sets_top)
```
```   580     next
```
```   581       fix A assume *: "A \<in> sigma_sets \<Omega> E \<and> emeasure M (F \<inter> A) = emeasure N (F \<inter> A)"
```
```   582       then have **: "F \<inter> (\<Omega> - A) = F - (F \<inter> A)"
```
```   583         and [intro]: "F \<inter> A \<in> sigma_sets \<Omega> E"
```
```   584         using `F \<in> E` S.sets_into_space by auto
```
```   585       have "emeasure N (F \<inter> A) \<le> emeasure N F" by (auto intro!: emeasure_mono simp: M N)
```
```   586       then have "emeasure N (F \<inter> A) \<noteq> \<infinity>" using `emeasure N F \<noteq> \<infinity>` by auto
```
```   587       have "emeasure M (F \<inter> A) \<le> emeasure M F" by (auto intro!: emeasure_mono simp: M N)
```
```   588       then have "emeasure M (F \<inter> A) \<noteq> \<infinity>" using `emeasure M F \<noteq> \<infinity>` by auto
```
```   589       then have "emeasure M (F \<inter> (\<Omega> - A)) = emeasure M F - emeasure M (F \<inter> A)" unfolding **
```
```   590         using `F \<inter> A \<in> sigma_sets \<Omega> E` by (auto intro!: emeasure_Diff simp: M N)
```
```   591       also have "\<dots> = emeasure N F - emeasure N (F \<inter> A)" using eq `F \<in> E` * by simp
```
```   592       also have "\<dots> = emeasure N (F \<inter> (\<Omega> - A))" unfolding **
```
```   593         using `F \<inter> A \<in> sigma_sets \<Omega> E` `emeasure N (F \<inter> A) \<noteq> \<infinity>`
```
```   594         by (auto intro!: emeasure_Diff[symmetric] simp: M N)
```
```   595       finally show "\<Omega> - A \<in> sigma_sets \<Omega> E \<and> emeasure M (F \<inter> (\<Omega> - A)) = emeasure N (F \<inter> (\<Omega> - A))"
```
```   596         using * by auto
```
```   597     next
```
```   598       fix A :: "nat \<Rightarrow> 'a set"
```
```   599       assume "disjoint_family A" "range A \<subseteq> {X \<in> sigma_sets \<Omega> E. emeasure M (F \<inter> X) = emeasure N (F \<inter> X)}"
```
```   600       then have A: "range (\<lambda>i. F \<inter> A i) \<subseteq> sigma_sets \<Omega> E" "F \<inter> (\<Union>x. A x) = (\<Union>x. F \<inter> A x)"
```
```   601         "disjoint_family (\<lambda>i. F \<inter> A i)" "\<And>i. emeasure M (F \<inter> A i) = emeasure N (F \<inter> A i)" "range A \<subseteq> sigma_sets \<Omega> E"
```
```   602         by (auto simp: disjoint_family_on_def subset_eq)
```
```   603       then show "(\<Union>x. A x) \<in> sigma_sets \<Omega> E \<and> emeasure M (F \<inter> (\<Union>x. A x)) = emeasure N (F \<inter> (\<Union>x. A x))"
```
```   604         by (auto simp: M N suminf_emeasure[symmetric] simp del: UN_simps)
```
```   605     qed
```
```   606     have *: "sigma_sets \<Omega> E = ?D F"
```
```   607       using `F \<in> E` `Int_stable E`
```
```   608       by (intro D.dynkin_lemma) (auto simp add: Int_stable_def eq)
```
```   609     have "\<And>D. D \<in> sigma_sets \<Omega> E \<Longrightarrow> emeasure M (F \<inter> D) = emeasure N (F \<inter> D)"
```
```   610       by (subst (asm) *) auto }
```
```   611   note * = this
```
```   612   show "M = N"
```
```   613   proof (rule measure_eqI)
```
```   614     show "sets M = sets N"
```
```   615       using M N by simp
```
```   616     fix X assume "X \<in> sets M"
```
```   617     then have "X \<in> sigma_sets \<Omega> E"
```
```   618       using M by simp
```
```   619     let ?A = "\<lambda>i. A i \<inter> X"
```
```   620     have "range ?A \<subseteq> sigma_sets \<Omega> E" "incseq ?A"
```
```   621       using A(1,2) `X \<in> sigma_sets \<Omega> E` by (auto simp: incseq_def)
```
```   622     moreover
```
```   623     { fix i have "emeasure M (?A i) = emeasure N (?A i)"
```
```   624         using *[of "A i" X] `X \<in> sigma_sets \<Omega> E` A finite by auto }
```
```   625     ultimately show "emeasure M X = emeasure N X"
```
```   626       using SUP_emeasure_incseq[of ?A M] SUP_emeasure_incseq[of ?A N] A(3) `X \<in> sigma_sets \<Omega> E`
```
```   627       by (auto simp: M N SUP_emeasure_incseq)
```
```   628   qed
```
```   629 qed
```
```   630
```
```   631 lemma measure_of_of_measure: "measure_of (space M) (sets M) (emeasure M) = M"
```
```   632 proof (intro measure_eqI emeasure_measure_of_sigma)
```
```   633   show "sigma_algebra (space M) (sets M)" ..
```
```   634   show "positive (sets M) (emeasure M)"
```
```   635     by (simp add: positive_def emeasure_nonneg)
```
```   636   show "countably_additive (sets M) (emeasure M)"
```
```   637     by (simp add: emeasure_countably_additive)
```
```   638 qed simp_all
```
```   639
```
```   640 section "@{text \<mu>}-null sets"
```
```   641
```
```   642 definition null_sets :: "'a measure \<Rightarrow> 'a set set" where
```
```   643   "null_sets M = {N\<in>sets M. emeasure M N = 0}"
```
```   644
```
```   645 lemma null_setsD1[dest]: "A \<in> null_sets M \<Longrightarrow> emeasure M A = 0"
```
```   646   by (simp add: null_sets_def)
```
```   647
```
```   648 lemma null_setsD2[dest]: "A \<in> null_sets M \<Longrightarrow> A \<in> sets M"
```
```   649   unfolding null_sets_def by simp
```
```   650
```
```   651 lemma null_setsI[intro]: "emeasure M A = 0 \<Longrightarrow> A \<in> sets M \<Longrightarrow> A \<in> null_sets M"
```
```   652   unfolding null_sets_def by simp
```
```   653
```
```   654 interpretation null_sets: ring_of_sets "space M" "null_sets M" for M
```
```   655 proof
```
```   656   show "null_sets M \<subseteq> Pow (space M)"
```
```   657     using sets_into_space by auto
```
```   658   show "{} \<in> null_sets M"
```
```   659     by auto
```
```   660   fix A B assume sets: "A \<in> null_sets M" "B \<in> null_sets M"
```
```   661   then have "A \<in> sets M" "B \<in> sets M"
```
```   662     by auto
```
```   663   moreover then have "emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
```
```   664     "emeasure M (A - B) \<le> emeasure M A"
```
```   665     by (auto intro!: emeasure_subadditive emeasure_mono)
```
```   666   moreover have "emeasure M B = 0" "emeasure M A = 0"
```
```   667     using sets by auto
```
```   668   ultimately show "A - B \<in> null_sets M" "A \<union> B \<in> null_sets M"
```
```   669     by (auto intro!: antisym)
```
```   670 qed
```
```   671
```
```   672 lemma UN_from_nat: "(\<Union>i. N i) = (\<Union>i. N (Countable.from_nat i))"
```
```   673 proof -
```
```   674   have "(\<Union>i. N i) = (\<Union>i. (N \<circ> Countable.from_nat) i)"
```
```   675     unfolding SUP_def image_compose
```
```   676     unfolding surj_from_nat ..
```
```   677   then show ?thesis by simp
```
```   678 qed
```
```   679
```
```   680 lemma null_sets_UN[intro]:
```
```   681   assumes "\<And>i::'i::countable. N i \<in> null_sets M"
```
```   682   shows "(\<Union>i. N i) \<in> null_sets M"
```
```   683 proof (intro conjI CollectI null_setsI)
```
```   684   show "(\<Union>i. N i) \<in> sets M" using assms by auto
```
```   685   have "0 \<le> emeasure M (\<Union>i. N i)" by (rule emeasure_nonneg)
```
```   686   moreover have "emeasure M (\<Union>i. N i) \<le> (\<Sum>n. emeasure M (N (Countable.from_nat n)))"
```
```   687     unfolding UN_from_nat[of N]
```
```   688     using assms by (intro emeasure_subadditive_countably) auto
```
```   689   ultimately show "emeasure M (\<Union>i. N i) = 0"
```
```   690     using assms by (auto simp: null_setsD1)
```
```   691 qed
```
```   692
```
```   693 lemma null_set_Int1:
```
```   694   assumes "B \<in> null_sets M" "A \<in> sets M" shows "A \<inter> B \<in> null_sets M"
```
```   695 proof (intro CollectI conjI null_setsI)
```
```   696   show "emeasure M (A \<inter> B) = 0" using assms
```
```   697     by (intro emeasure_eq_0[of B _ "A \<inter> B"]) auto
```
```   698 qed (insert assms, auto)
```
```   699
```
```   700 lemma null_set_Int2:
```
```   701   assumes "B \<in> null_sets M" "A \<in> sets M" shows "B \<inter> A \<in> null_sets M"
```
```   702   using assms by (subst Int_commute) (rule null_set_Int1)
```
```   703
```
```   704 lemma emeasure_Diff_null_set:
```
```   705   assumes "B \<in> null_sets M" "A \<in> sets M"
```
```   706   shows "emeasure M (A - B) = emeasure M A"
```
```   707 proof -
```
```   708   have *: "A - B = (A - (A \<inter> B))" by auto
```
```   709   have "A \<inter> B \<in> null_sets M" using assms by (rule null_set_Int1)
```
```   710   then show ?thesis
```
```   711     unfolding * using assms
```
```   712     by (subst emeasure_Diff) auto
```
```   713 qed
```
```   714
```
```   715 lemma null_set_Diff:
```
```   716   assumes "B \<in> null_sets M" "A \<in> sets M" shows "B - A \<in> null_sets M"
```
```   717 proof (intro CollectI conjI null_setsI)
```
```   718   show "emeasure M (B - A) = 0" using assms by (intro emeasure_eq_0[of B _ "B - A"]) auto
```
```   719 qed (insert assms, auto)
```
```   720
```
```   721 lemma emeasure_Un_null_set:
```
```   722   assumes "A \<in> sets M" "B \<in> null_sets M"
```
```   723   shows "emeasure M (A \<union> B) = emeasure M A"
```
```   724 proof -
```
```   725   have *: "A \<union> B = A \<union> (B - A)" by auto
```
```   726   have "B - A \<in> null_sets M" using assms(2,1) by (rule null_set_Diff)
```
```   727   then show ?thesis
```
```   728     unfolding * using assms
```
```   729     by (subst plus_emeasure[symmetric]) auto
```
```   730 qed
```
```   731
```
```   732 section "Formalize almost everywhere"
```
```   733
```
```   734 definition ae_filter :: "'a measure \<Rightarrow> 'a filter" where
```
```   735   "ae_filter M = Abs_filter (\<lambda>P. \<exists>N\<in>null_sets M. {x \<in> space M. \<not> P x} \<subseteq> N)"
```
```   736
```
```   737 abbreviation
```
```   738   almost_everywhere :: "'a measure \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
```
```   739   "almost_everywhere M P \<equiv> eventually P (ae_filter M)"
```
```   740
```
```   741 syntax
```
```   742   "_almost_everywhere" :: "pttrn \<Rightarrow> 'a \<Rightarrow> bool \<Rightarrow> bool" ("AE _ in _. _" [0,0,10] 10)
```
```   743
```
```   744 translations
```
```   745   "AE x in M. P" == "CONST almost_everywhere M (%x. P)"
```
```   746
```
```   747 lemma eventually_ae_filter:
```
```   748   fixes M P
```
```   749   defines [simp]: "F \<equiv> \<lambda>P. \<exists>N\<in>null_sets M. {x \<in> space M. \<not> P x} \<subseteq> N"
```
```   750   shows "eventually P (ae_filter M) \<longleftrightarrow> F P"
```
```   751   unfolding ae_filter_def F_def[symmetric]
```
```   752 proof (rule eventually_Abs_filter)
```
```   753   show "is_filter F"
```
```   754   proof
```
```   755     fix P Q assume "F P" "F Q"
```
```   756     then obtain N L where N: "N \<in> null_sets M" "{x \<in> space M. \<not> P x} \<subseteq> N"
```
```   757       and L: "L \<in> null_sets M" "{x \<in> space M. \<not> Q x} \<subseteq> L"
```
```   758       by auto
```
```   759     then have "L \<union> N \<in> null_sets M" "{x \<in> space M. \<not> (P x \<and> Q x)} \<subseteq> L \<union> N" by auto
```
```   760     then show "F (\<lambda>x. P x \<and> Q x)" by auto
```
```   761   next
```
```   762     fix P Q assume "F P"
```
```   763     then obtain N where N: "N \<in> null_sets M" "{x \<in> space M. \<not> P x} \<subseteq> N" by auto
```
```   764     moreover assume "\<forall>x. P x \<longrightarrow> Q x"
```
```   765     ultimately have "N \<in> null_sets M" "{x \<in> space M. \<not> Q x} \<subseteq> N" by auto
```
```   766     then show "F Q" by auto
```
```   767   qed auto
```
```   768 qed
```
```   769
```
```   770 lemma AE_I':
```
```   771   "N \<in> null_sets M \<Longrightarrow> {x\<in>space M. \<not> P x} \<subseteq> N \<Longrightarrow> (AE x in M. P x)"
```
```   772   unfolding eventually_ae_filter by auto
```
```   773
```
```   774 lemma AE_iff_null:
```
```   775   assumes "{x\<in>space M. \<not> P x} \<in> sets M" (is "?P \<in> sets M")
```
```   776   shows "(AE x in M. P x) \<longleftrightarrow> {x\<in>space M. \<not> P x} \<in> null_sets M"
```
```   777 proof
```
```   778   assume "AE x in M. P x" then obtain N where N: "N \<in> sets M" "?P \<subseteq> N" "emeasure M N = 0"
```
```   779     unfolding eventually_ae_filter by auto
```
```   780   have "0 \<le> emeasure M ?P" by auto
```
```   781   moreover have "emeasure M ?P \<le> emeasure M N"
```
```   782     using assms N(1,2) by (auto intro: emeasure_mono)
```
```   783   ultimately have "emeasure M ?P = 0" unfolding `emeasure M N = 0` by auto
```
```   784   then show "?P \<in> null_sets M" using assms by auto
```
```   785 next
```
```   786   assume "?P \<in> null_sets M" with assms show "AE x in M. P x" by (auto intro: AE_I')
```
```   787 qed
```
```   788
```
```   789 lemma AE_iff_null_sets:
```
```   790   "N \<in> sets M \<Longrightarrow> N \<in> null_sets M \<longleftrightarrow> (AE x in M. x \<notin> N)"
```
```   791   using Int_absorb1[OF sets_into_space, of N M]
```
```   792   by (subst AE_iff_null) (auto simp: Int_def[symmetric])
```
```   793
```
```   794 lemma AE_iff_measurable:
```
```   795   "N \<in> sets M \<Longrightarrow> {x\<in>space M. \<not> P x} = N \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> emeasure M N = 0"
```
```   796   using AE_iff_null[of _ P] by auto
```
```   797
```
```   798 lemma AE_E[consumes 1]:
```
```   799   assumes "AE x in M. P x"
```
```   800   obtains N where "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
```
```   801   using assms unfolding eventually_ae_filter by auto
```
```   802
```
```   803 lemma AE_E2:
```
```   804   assumes "AE x in M. P x" "{x\<in>space M. P x} \<in> sets M"
```
```   805   shows "emeasure M {x\<in>space M. \<not> P x} = 0" (is "emeasure M ?P = 0")
```
```   806 proof -
```
```   807   have "{x\<in>space M. \<not> P x} = space M - {x\<in>space M. P x}" by auto
```
```   808   with AE_iff_null[of M P] assms show ?thesis by auto
```
```   809 qed
```
```   810
```
```   811 lemma AE_I:
```
```   812   assumes "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
```
```   813   shows "AE x in M. P x"
```
```   814   using assms unfolding eventually_ae_filter by auto
```
```   815
```
```   816 lemma AE_mp[elim!]:
```
```   817   assumes AE_P: "AE x in M. P x" and AE_imp: "AE x in M. P x \<longrightarrow> Q x"
```
```   818   shows "AE x in M. Q x"
```
```   819 proof -
```
```   820   from AE_P obtain A where P: "{x\<in>space M. \<not> P x} \<subseteq> A"
```
```   821     and A: "A \<in> sets M" "emeasure M A = 0"
```
```   822     by (auto elim!: AE_E)
```
```   823
```
```   824   from AE_imp obtain B where imp: "{x\<in>space M. P x \<and> \<not> Q x} \<subseteq> B"
```
```   825     and B: "B \<in> sets M" "emeasure M B = 0"
```
```   826     by (auto elim!: AE_E)
```
```   827
```
```   828   show ?thesis
```
```   829   proof (intro AE_I)
```
```   830     have "0 \<le> emeasure M (A \<union> B)" using A B by auto
```
```   831     moreover have "emeasure M (A \<union> B) \<le> 0"
```
```   832       using emeasure_subadditive[of A M B] A B by auto
```
```   833     ultimately show "A \<union> B \<in> sets M" "emeasure M (A \<union> B) = 0" using A B by auto
```
```   834     show "{x\<in>space M. \<not> Q x} \<subseteq> A \<union> B"
```
```   835       using P imp by auto
```
```   836   qed
```
```   837 qed
```
```   838
```
```   839 (* depricated replace by laws about eventually *)
```
```   840 lemma
```
```   841   shows AE_iffI: "AE x in M. P x \<Longrightarrow> AE x in M. P x \<longleftrightarrow> Q x \<Longrightarrow> AE x in M. Q x"
```
```   842     and AE_disjI1: "AE x in M. P x \<Longrightarrow> AE x in M. P x \<or> Q x"
```
```   843     and AE_disjI2: "AE x in M. Q x \<Longrightarrow> AE x in M. P x \<or> Q x"
```
```   844     and AE_conjI: "AE x in M. P x \<Longrightarrow> AE x in M. Q x \<Longrightarrow> AE x in M. P x \<and> Q x"
```
```   845     and AE_conj_iff[simp]: "(AE x in M. P x \<and> Q x) \<longleftrightarrow> (AE x in M. P x) \<and> (AE x in M. Q x)"
```
```   846   by auto
```
```   847
```
```   848 lemma AE_impI:
```
```   849   "(P \<Longrightarrow> AE x in M. Q x) \<Longrightarrow> AE x in M. P \<longrightarrow> Q x"
```
```   850   by (cases P) auto
```
```   851
```
```   852 lemma AE_measure:
```
```   853   assumes AE: "AE x in M. P x" and sets: "{x\<in>space M. P x} \<in> sets M" (is "?P \<in> sets M")
```
```   854   shows "emeasure M {x\<in>space M. P x} = emeasure M (space M)"
```
```   855 proof -
```
```   856   from AE_E[OF AE] guess N . note N = this
```
```   857   with sets have "emeasure M (space M) \<le> emeasure M (?P \<union> N)"
```
```   858     by (intro emeasure_mono) auto
```
```   859   also have "\<dots> \<le> emeasure M ?P + emeasure M N"
```
```   860     using sets N by (intro emeasure_subadditive) auto
```
```   861   also have "\<dots> = emeasure M ?P" using N by simp
```
```   862   finally show "emeasure M ?P = emeasure M (space M)"
```
```   863     using emeasure_space[of M "?P"] by auto
```
```   864 qed
```
```   865
```
```   866 lemma AE_space: "AE x in M. x \<in> space M"
```
```   867   by (rule AE_I[where N="{}"]) auto
```
```   868
```
```   869 lemma AE_I2[simp, intro]:
```
```   870   "(\<And>x. x \<in> space M \<Longrightarrow> P x) \<Longrightarrow> AE x in M. P x"
```
```   871   using AE_space by force
```
```   872
```
```   873 lemma AE_Ball_mp:
```
```   874   "\<forall>x\<in>space M. P x \<Longrightarrow> AE x in M. P x \<longrightarrow> Q x \<Longrightarrow> AE x in M. Q x"
```
```   875   by auto
```
```   876
```
```   877 lemma AE_cong[cong]:
```
```   878   "(\<And>x. x \<in> space M \<Longrightarrow> P x \<longleftrightarrow> Q x) \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> (AE x in M. Q x)"
```
```   879   by auto
```
```   880
```
```   881 lemma AE_all_countable:
```
```   882   "(AE x in M. \<forall>i. P i x) \<longleftrightarrow> (\<forall>i::'i::countable. AE x in M. P i x)"
```
```   883 proof
```
```   884   assume "\<forall>i. AE x in M. P i x"
```
```   885   from this[unfolded eventually_ae_filter Bex_def, THEN choice]
```
```   886   obtain N where N: "\<And>i. N i \<in> null_sets M" "\<And>i. {x\<in>space M. \<not> P i x} \<subseteq> N i" by auto
```
```   887   have "{x\<in>space M. \<not> (\<forall>i. P i x)} \<subseteq> (\<Union>i. {x\<in>space M. \<not> P i x})" by auto
```
```   888   also have "\<dots> \<subseteq> (\<Union>i. N i)" using N by auto
```
```   889   finally have "{x\<in>space M. \<not> (\<forall>i. P i x)} \<subseteq> (\<Union>i. N i)" .
```
```   890   moreover from N have "(\<Union>i. N i) \<in> null_sets M"
```
```   891     by (intro null_sets_UN) auto
```
```   892   ultimately show "AE x in M. \<forall>i. P i x"
```
```   893     unfolding eventually_ae_filter by auto
```
```   894 qed auto
```
```   895
```
```   896 lemma AE_finite_all:
```
```   897   assumes f: "finite S" shows "(AE x in M. \<forall>i\<in>S. P i x) \<longleftrightarrow> (\<forall>i\<in>S. AE x in M. P i x)"
```
```   898   using f by induct auto
```
```   899
```
```   900 lemma AE_finite_allI:
```
```   901   assumes "finite S"
```
```   902   shows "(\<And>s. s \<in> S \<Longrightarrow> AE x in M. Q s x) \<Longrightarrow> AE x in M. \<forall>s\<in>S. Q s x"
```
```   903   using AE_finite_all[OF `finite S`] by auto
```
```   904
```
```   905 lemma emeasure_mono_AE:
```
```   906   assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B"
```
```   907     and B: "B \<in> sets M"
```
```   908   shows "emeasure M A \<le> emeasure M B"
```
```   909 proof cases
```
```   910   assume A: "A \<in> sets M"
```
```   911   from imp obtain N where N: "{x\<in>space M. \<not> (x \<in> A \<longrightarrow> x \<in> B)} \<subseteq> N" "N \<in> null_sets M"
```
```   912     by (auto simp: eventually_ae_filter)
```
```   913   have "emeasure M A = emeasure M (A - N)"
```
```   914     using N A by (subst emeasure_Diff_null_set) auto
```
```   915   also have "emeasure M (A - N) \<le> emeasure M (B - N)"
```
```   916     using N A B sets_into_space by (auto intro!: emeasure_mono)
```
```   917   also have "emeasure M (B - N) = emeasure M B"
```
```   918     using N B by (subst emeasure_Diff_null_set) auto
```
```   919   finally show ?thesis .
```
```   920 qed (simp add: emeasure_nonneg emeasure_notin_sets)
```
```   921
```
```   922 lemma emeasure_eq_AE:
```
```   923   assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
```
```   924   assumes A: "A \<in> sets M" and B: "B \<in> sets M"
```
```   925   shows "emeasure M A = emeasure M B"
```
```   926   using assms by (safe intro!: antisym emeasure_mono_AE) auto
```
```   927
```
```   928 section {* @{text \<sigma>}-finite Measures *}
```
```   929
```
```   930 locale sigma_finite_measure =
```
```   931   fixes M :: "'a measure"
```
```   932   assumes sigma_finite: "\<exists>A::nat \<Rightarrow> 'a set.
```
```   933     range A \<subseteq> sets M \<and> (\<Union>i. A i) = space M \<and> (\<forall>i. emeasure M (A i) \<noteq> \<infinity>)"
```
```   934
```
```   935 lemma (in sigma_finite_measure) sigma_finite_disjoint:
```
```   936   obtains A :: "nat \<Rightarrow> 'a set"
```
```   937   where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "disjoint_family A"
```
```   938 proof atomize_elim
```
```   939   case goal1
```
```   940   obtain A :: "nat \<Rightarrow> 'a set" where
```
```   941     range: "range A \<subseteq> sets M" and
```
```   942     space: "(\<Union>i. A i) = space M" and
```
```   943     measure: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
```
```   944     using sigma_finite by auto
```
```   945   note range' = range_disjointed_sets[OF range] range
```
```   946   { fix i
```
```   947     have "emeasure M (disjointed A i) \<le> emeasure M (A i)"
```
```   948       using range' disjointed_subset[of A i] by (auto intro!: emeasure_mono)
```
```   949     then have "emeasure M (disjointed A i) \<noteq> \<infinity>"
```
```   950       using measure[of i] by auto }
```
```   951   with disjoint_family_disjointed UN_disjointed_eq[of A] space range'
```
```   952   show ?case by (auto intro!: exI[of _ "disjointed A"])
```
```   953 qed
```
```   954
```
```   955 lemma (in sigma_finite_measure) sigma_finite_incseq:
```
```   956   obtains A :: "nat \<Rightarrow> 'a set"
```
```   957   where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "incseq A"
```
```   958 proof atomize_elim
```
```   959   case goal1
```
```   960   obtain F :: "nat \<Rightarrow> 'a set" where
```
```   961     F: "range F \<subseteq> sets M" "(\<Union>i. F i) = space M" "\<And>i. emeasure M (F i) \<noteq> \<infinity>"
```
```   962     using sigma_finite by auto
```
```   963   then show ?case
```
```   964   proof (intro exI[of _ "\<lambda>n. \<Union>i\<le>n. F i"] conjI allI)
```
```   965     from F have "\<And>x. x \<in> space M \<Longrightarrow> \<exists>i. x \<in> F i" by auto
```
```   966     then show "(\<Union>n. \<Union> i\<le>n. F i) = space M"
```
```   967       using F by fastforce
```
```   968   next
```
```   969     fix n
```
```   970     have "emeasure M (\<Union> i\<le>n. F i) \<le> (\<Sum>i\<le>n. emeasure M (F i))" using F
```
```   971       by (auto intro!: emeasure_subadditive_finite)
```
```   972     also have "\<dots> < \<infinity>"
```
```   973       using F by (auto simp: setsum_Pinfty)
```
```   974     finally show "emeasure M (\<Union> i\<le>n. F i) \<noteq> \<infinity>" by simp
```
```   975   qed (force simp: incseq_def)+
```
```   976 qed
```
```   977
```
```   978 section {* Measure space induced by distribution of @{const measurable}-functions *}
```
```   979
```
```   980 definition distr :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
```
```   981   "distr M N f = measure_of (space N) (sets N) (\<lambda>A. emeasure M (f -` A \<inter> space M))"
```
```   982
```
```   983 lemma
```
```   984   shows sets_distr[simp]: "sets (distr M N f) = sets N"
```
```   985     and space_distr[simp]: "space (distr M N f) = space N"
```
```   986   by (auto simp: distr_def)
```
```   987
```
```   988 lemma
```
```   989   shows measurable_distr_eq1[simp]: "measurable (distr Mf Nf f) Mf' = measurable Nf Mf'"
```
```   990     and measurable_distr_eq2[simp]: "measurable Mg' (distr Mg Ng g) = measurable Mg' Ng"
```
```   991   by (auto simp: measurable_def)
```
```   992
```
```   993 lemma emeasure_distr:
```
```   994   fixes f :: "'a \<Rightarrow> 'b"
```
```   995   assumes f: "f \<in> measurable M N" and A: "A \<in> sets N"
```
```   996   shows "emeasure (distr M N f) A = emeasure M (f -` A \<inter> space M)" (is "_ = ?\<mu> A")
```
```   997   unfolding distr_def
```
```   998 proof (rule emeasure_measure_of_sigma)
```
```   999   show "positive (sets N) ?\<mu>"
```
```  1000     by (auto simp: positive_def)
```
```  1001
```
```  1002   show "countably_additive (sets N) ?\<mu>"
```
```  1003   proof (intro countably_additiveI)
```
```  1004     fix A :: "nat \<Rightarrow> 'b set" assume "range A \<subseteq> sets N" "disjoint_family A"
```
```  1005     then have A: "\<And>i. A i \<in> sets N" "(\<Union>i. A i) \<in> sets N" by auto
```
```  1006     then have *: "range (\<lambda>i. f -` (A i) \<inter> space M) \<subseteq> sets M"
```
```  1007       using f by (auto simp: measurable_def)
```
```  1008     moreover have "(\<Union>i. f -`  A i \<inter> space M) \<in> sets M"
```
```  1009       using * by blast
```
```  1010     moreover have **: "disjoint_family (\<lambda>i. f -` A i \<inter> space M)"
```
```  1011       using `disjoint_family A` by (auto simp: disjoint_family_on_def)
```
```  1012     ultimately show "(\<Sum>i. ?\<mu> (A i)) = ?\<mu> (\<Union>i. A i)"
```
```  1013       using suminf_emeasure[OF _ **] A f
```
```  1014       by (auto simp: comp_def vimage_UN)
```
```  1015   qed
```
```  1016   show "sigma_algebra (space N) (sets N)" ..
```
```  1017 qed fact
```
```  1018
```
```  1019 lemma AE_distrD:
```
```  1020   assumes f: "f \<in> measurable M M'"
```
```  1021     and AE: "AE x in distr M M' f. P x"
```
```  1022   shows "AE x in M. P (f x)"
```
```  1023 proof -
```
```  1024   from AE[THEN AE_E] guess N .
```
```  1025   with f show ?thesis
```
```  1026     unfolding eventually_ae_filter
```
```  1027     by (intro bexI[of _ "f -` N \<inter> space M"])
```
```  1028        (auto simp: emeasure_distr measurable_def)
```
```  1029 qed
```
```  1030
```
```  1031 lemma null_sets_distr_iff:
```
```  1032   "f \<in> measurable M N \<Longrightarrow> A \<in> null_sets (distr M N f) \<longleftrightarrow> f -` A \<inter> space M \<in> null_sets M \<and> A \<in> sets N"
```
```  1033   by (auto simp add: null_sets_def emeasure_distr measurable_sets)
```
```  1034
```
```  1035 lemma distr_distr:
```
```  1036   assumes f: "g \<in> measurable N L" and g: "f \<in> measurable M N"
```
```  1037   shows "distr (distr M N f) L g = distr M L (g \<circ> f)" (is "?L = ?R")
```
```  1038   using measurable_comp[OF g f] f g
```
```  1039   by (auto simp add: emeasure_distr measurable_sets measurable_space
```
```  1040            intro!: arg_cong[where f="emeasure M"] measure_eqI)
```
```  1041
```
```  1042 section {* Real measure values *}
```
```  1043
```
```  1044 lemma measure_nonneg: "0 \<le> measure M A"
```
```  1045   using emeasure_nonneg[of M A] unfolding measure_def by (auto intro: real_of_ereal_pos)
```
```  1046
```
```  1047 lemma measure_empty[simp]: "measure M {} = 0"
```
```  1048   unfolding measure_def by simp
```
```  1049
```
```  1050 lemma emeasure_eq_ereal_measure:
```
```  1051   "emeasure M A \<noteq> \<infinity> \<Longrightarrow> emeasure M A = ereal (measure M A)"
```
```  1052   using emeasure_nonneg[of M A]
```
```  1053   by (cases "emeasure M A") (auto simp: measure_def)
```
```  1054
```
```  1055 lemma measure_Union:
```
```  1056   assumes finite: "emeasure M A \<noteq> \<infinity>" "emeasure M B \<noteq> \<infinity>"
```
```  1057   and measurable: "A \<in> sets M" "B \<in> sets M" "A \<inter> B = {}"
```
```  1058   shows "measure M (A \<union> B) = measure M A + measure M B"
```
```  1059   unfolding measure_def
```
```  1060   using plus_emeasure[OF measurable, symmetric] finite
```
```  1061   by (simp add: emeasure_eq_ereal_measure)
```
```  1062
```
```  1063 lemma measure_finite_Union:
```
```  1064   assumes measurable: "A`S \<subseteq> sets M" "disjoint_family_on A S" "finite S"
```
```  1065   assumes finite: "\<And>i. i \<in> S \<Longrightarrow> emeasure M (A i) \<noteq> \<infinity>"
```
```  1066   shows "measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
```
```  1067   unfolding measure_def
```
```  1068   using setsum_emeasure[OF measurable, symmetric] finite
```
```  1069   by (simp add: emeasure_eq_ereal_measure)
```
```  1070
```
```  1071 lemma measure_Diff:
```
```  1072   assumes finite: "emeasure M A \<noteq> \<infinity>"
```
```  1073   and measurable: "A \<in> sets M" "B \<in> sets M" "B \<subseteq> A"
```
```  1074   shows "measure M (A - B) = measure M A - measure M B"
```
```  1075 proof -
```
```  1076   have "emeasure M (A - B) \<le> emeasure M A" "emeasure M B \<le> emeasure M A"
```
```  1077     using measurable by (auto intro!: emeasure_mono)
```
```  1078   hence "measure M ((A - B) \<union> B) = measure M (A - B) + measure M B"
```
```  1079     using measurable finite by (rule_tac measure_Union) auto
```
```  1080   thus ?thesis using `B \<subseteq> A` by (auto simp: Un_absorb2)
```
```  1081 qed
```
```  1082
```
```  1083 lemma measure_UNION:
```
```  1084   assumes measurable: "range A \<subseteq> sets M" "disjoint_family A"
```
```  1085   assumes finite: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
```
```  1086   shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
```
```  1087 proof -
```
```  1088   from summable_sums[OF summable_ereal_pos, of "\<lambda>i. emeasure M (A i)"]
```
```  1089        suminf_emeasure[OF measurable] emeasure_nonneg[of M]
```
```  1090   have "(\<lambda>i. emeasure M (A i)) sums (emeasure M (\<Union>i. A i))" by simp
```
```  1091   moreover
```
```  1092   { fix i
```
```  1093     have "emeasure M (A i) \<le> emeasure M (\<Union>i. A i)"
```
```  1094       using measurable by (auto intro!: emeasure_mono)
```
```  1095     then have "emeasure M (A i) = ereal ((measure M (A i)))"
```
```  1096       using finite by (intro emeasure_eq_ereal_measure) auto }
```
```  1097   ultimately show ?thesis using finite
```
```  1098     unfolding sums_ereal[symmetric] by (simp add: emeasure_eq_ereal_measure)
```
```  1099 qed
```
```  1100
```
```  1101 lemma measure_subadditive:
```
```  1102   assumes measurable: "A \<in> sets M" "B \<in> sets M"
```
```  1103   and fin: "emeasure M A \<noteq> \<infinity>" "emeasure M B \<noteq> \<infinity>"
```
```  1104   shows "(measure M (A \<union> B)) \<le> (measure M A) + (measure M B)"
```
```  1105 proof -
```
```  1106   have "emeasure M (A \<union> B) \<noteq> \<infinity>"
```
```  1107     using emeasure_subadditive[OF measurable] fin by auto
```
```  1108   then show "(measure M (A \<union> B)) \<le> (measure M A) + (measure M B)"
```
```  1109     using emeasure_subadditive[OF measurable] fin
```
```  1110     by (auto simp: emeasure_eq_ereal_measure)
```
```  1111 qed
```
```  1112
```
```  1113 lemma measure_subadditive_finite:
```
```  1114   assumes A: "finite I" "A`I \<subseteq> sets M" and fin: "\<And>i. i \<in> I \<Longrightarrow> emeasure M (A i) \<noteq> \<infinity>"
```
```  1115   shows "measure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. measure M (A i))"
```
```  1116 proof -
```
```  1117   { have "emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
```
```  1118       using emeasure_subadditive_finite[OF A] .
```
```  1119     also have "\<dots> < \<infinity>"
```
```  1120       using fin by (simp add: setsum_Pinfty)
```
```  1121     finally have "emeasure M (\<Union>i\<in>I. A i) \<noteq> \<infinity>" by simp }
```
```  1122   then show ?thesis
```
```  1123     using emeasure_subadditive_finite[OF A] fin
```
```  1124     unfolding measure_def by (simp add: emeasure_eq_ereal_measure suminf_ereal measure_nonneg)
```
```  1125 qed
```
```  1126
```
```  1127 lemma measure_subadditive_countably:
```
```  1128   assumes A: "range A \<subseteq> sets M" and fin: "(\<Sum>i. emeasure M (A i)) \<noteq> \<infinity>"
```
```  1129   shows "measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
```
```  1130 proof -
```
```  1131   from emeasure_nonneg fin have "\<And>i. emeasure M (A i) \<noteq> \<infinity>" by (rule suminf_PInfty)
```
```  1132   moreover
```
```  1133   { have "emeasure M (\<Union>i. A i) \<le> (\<Sum>i. emeasure M (A i))"
```
```  1134       using emeasure_subadditive_countably[OF A] .
```
```  1135     also have "\<dots> < \<infinity>"
```
```  1136       using fin by simp
```
```  1137     finally have "emeasure M (\<Union>i. A i) \<noteq> \<infinity>" by simp }
```
```  1138   ultimately  show ?thesis
```
```  1139     using emeasure_subadditive_countably[OF A] fin
```
```  1140     unfolding measure_def by (simp add: emeasure_eq_ereal_measure suminf_ereal measure_nonneg)
```
```  1141 qed
```
```  1142
```
```  1143 lemma measure_eq_setsum_singleton:
```
```  1144   assumes S: "finite S" "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
```
```  1145   and fin: "\<And>x. x \<in> S \<Longrightarrow> emeasure M {x} \<noteq> \<infinity>"
```
```  1146   shows "(measure M S) = (\<Sum>x\<in>S. (measure M {x}))"
```
```  1147   unfolding measure_def
```
```  1148   using emeasure_eq_setsum_singleton[OF S] fin
```
```  1149   by simp (simp add: emeasure_eq_ereal_measure)
```
```  1150
```
```  1151 lemma Lim_measure_incseq:
```
```  1152   assumes A: "range A \<subseteq> sets M" "incseq A" and fin: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
```
```  1153   shows "(\<lambda>i. (measure M (A i))) ----> (measure M (\<Union>i. A i))"
```
```  1154 proof -
```
```  1155   have "ereal ((measure M (\<Union>i. A i))) = emeasure M (\<Union>i. A i)"
```
```  1156     using fin by (auto simp: emeasure_eq_ereal_measure)
```
```  1157   then show ?thesis
```
```  1158     using Lim_emeasure_incseq[OF A]
```
```  1159     unfolding measure_def
```
```  1160     by (intro lim_real_of_ereal) simp
```
```  1161 qed
```
```  1162
```
```  1163 lemma Lim_measure_decseq:
```
```  1164   assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
```
```  1165   shows "(\<lambda>n. measure M (A n)) ----> measure M (\<Inter>i. A i)"
```
```  1166 proof -
```
```  1167   have "emeasure M (\<Inter>i. A i) \<le> emeasure M (A 0)"
```
```  1168     using A by (auto intro!: emeasure_mono)
```
```  1169   also have "\<dots> < \<infinity>"
```
```  1170     using fin[of 0] by auto
```
```  1171   finally have "ereal ((measure M (\<Inter>i. A i))) = emeasure M (\<Inter>i. A i)"
```
```  1172     by (auto simp: emeasure_eq_ereal_measure)
```
```  1173   then show ?thesis
```
```  1174     unfolding measure_def
```
```  1175     using Lim_emeasure_decseq[OF A fin]
```
```  1176     by (intro lim_real_of_ereal) simp
```
```  1177 qed
```
```  1178
```
```  1179 section {* Measure spaces with @{term "emeasure M (space M) < \<infinity>"} *}
```
```  1180
```
```  1181 locale finite_measure = sigma_finite_measure M for M +
```
```  1182   assumes finite_emeasure_space: "emeasure M (space M) \<noteq> \<infinity>"
```
```  1183
```
```  1184 lemma finite_measureI[Pure.intro!]:
```
```  1185   assumes *: "emeasure M (space M) \<noteq> \<infinity>"
```
```  1186   shows "finite_measure M"
```
```  1187 proof
```
```  1188   show "\<exists>A. range A \<subseteq> sets M \<and> (\<Union>i. A i) = space M \<and> (\<forall>i. emeasure M (A i) \<noteq> \<infinity>)"
```
```  1189     using * by (auto intro!: exI[of _ "\<lambda>_. space M"])
```
```  1190 qed fact
```
```  1191
```
```  1192 lemma (in finite_measure) emeasure_finite[simp, intro]: "emeasure M A \<noteq> \<infinity>"
```
```  1193   using finite_emeasure_space emeasure_space[of M A] by auto
```
```  1194
```
```  1195 lemma (in finite_measure) emeasure_eq_measure: "emeasure M A = ereal (measure M A)"
```
```  1196   unfolding measure_def by (simp add: emeasure_eq_ereal_measure)
```
```  1197
```
```  1198 lemma (in finite_measure) emeasure_real: "\<exists>r. 0 \<le> r \<and> emeasure M A = ereal r"
```
```  1199   using emeasure_finite[of A] emeasure_nonneg[of M A] by (cases "emeasure M A") auto
```
```  1200
```
```  1201 lemma (in finite_measure) bounded_measure: "measure M A \<le> measure M (space M)"
```
```  1202   using emeasure_space[of M A] emeasure_real[of A] emeasure_real[of "space M"] by (auto simp: measure_def)
```
```  1203
```
```  1204 lemma (in finite_measure) finite_measure_Diff:
```
```  1205   assumes sets: "A \<in> sets M" "B \<in> sets M" and "B \<subseteq> A"
```
```  1206   shows "measure M (A - B) = measure M A - measure M B"
```
```  1207   using measure_Diff[OF _ assms] by simp
```
```  1208
```
```  1209 lemma (in finite_measure) finite_measure_Union:
```
```  1210   assumes sets: "A \<in> sets M" "B \<in> sets M" and "A \<inter> B = {}"
```
```  1211   shows "measure M (A \<union> B) = measure M A + measure M B"
```
```  1212   using measure_Union[OF _ _ assms] by simp
```
```  1213
```
```  1214 lemma (in finite_measure) finite_measure_finite_Union:
```
```  1215   assumes measurable: "A`S \<subseteq> sets M" "disjoint_family_on A S" "finite S"
```
```  1216   shows "measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
```
```  1217   using measure_finite_Union[OF assms] by simp
```
```  1218
```
```  1219 lemma (in finite_measure) finite_measure_UNION:
```
```  1220   assumes A: "range A \<subseteq> sets M" "disjoint_family A"
```
```  1221   shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
```
```  1222   using measure_UNION[OF A] by simp
```
```  1223
```
```  1224 lemma (in finite_measure) finite_measure_mono:
```
```  1225   assumes "A \<subseteq> B" "B \<in> sets M" shows "measure M A \<le> measure M B"
```
```  1226   using emeasure_mono[OF assms] emeasure_real[of A] emeasure_real[of B] by (auto simp: measure_def)
```
```  1227
```
```  1228 lemma (in finite_measure) finite_measure_subadditive:
```
```  1229   assumes m: "A \<in> sets M" "B \<in> sets M"
```
```  1230   shows "measure M (A \<union> B) \<le> measure M A + measure M B"
```
```  1231   using measure_subadditive[OF m] by simp
```
```  1232
```
```  1233 lemma (in finite_measure) finite_measure_subadditive_finite:
```
```  1234   assumes "finite I" "A`I \<subseteq> sets M" shows "measure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. measure M (A i))"
```
```  1235   using measure_subadditive_finite[OF assms] by simp
```
```  1236
```
```  1237 lemma (in finite_measure) finite_measure_subadditive_countably:
```
```  1238   assumes A: "range A \<subseteq> sets M" and sum: "summable (\<lambda>i. measure M (A i))"
```
```  1239   shows "measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
```
```  1240 proof -
```
```  1241   from `summable (\<lambda>i. measure M (A i))`
```
```  1242   have "(\<lambda>i. ereal (measure M (A i))) sums ereal (\<Sum>i. measure M (A i))"
```
```  1243     by (simp add: sums_ereal) (rule summable_sums)
```
```  1244   from sums_unique[OF this, symmetric]
```
```  1245        measure_subadditive_countably[OF A]
```
```  1246   show ?thesis by (simp add: emeasure_eq_measure)
```
```  1247 qed
```
```  1248
```
```  1249 lemma (in finite_measure) finite_measure_eq_setsum_singleton:
```
```  1250   assumes "finite S" and *: "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
```
```  1251   shows "measure M S = (\<Sum>x\<in>S. measure M {x})"
```
```  1252   using measure_eq_setsum_singleton[OF assms] by simp
```
```  1253
```
```  1254 lemma (in finite_measure) finite_Lim_measure_incseq:
```
```  1255   assumes A: "range A \<subseteq> sets M" "incseq A"
```
```  1256   shows "(\<lambda>i. measure M (A i)) ----> measure M (\<Union>i. A i)"
```
```  1257   using Lim_measure_incseq[OF A] by simp
```
```  1258
```
```  1259 lemma (in finite_measure) finite_Lim_measure_decseq:
```
```  1260   assumes A: "range A \<subseteq> sets M" "decseq A"
```
```  1261   shows "(\<lambda>n. measure M (A n)) ----> measure M (\<Inter>i. A i)"
```
```  1262   using Lim_measure_decseq[OF A] by simp
```
```  1263
```
```  1264 lemma (in finite_measure) finite_measure_compl:
```
```  1265   assumes S: "S \<in> sets M"
```
```  1266   shows "measure M (space M - S) = measure M (space M) - measure M S"
```
```  1267   using measure_Diff[OF _ top S sets_into_space] S by simp
```
```  1268
```
```  1269 lemma (in finite_measure) finite_measure_mono_AE:
```
```  1270   assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B" and B: "B \<in> sets M"
```
```  1271   shows "measure M A \<le> measure M B"
```
```  1272   using assms emeasure_mono_AE[OF imp B]
```
```  1273   by (simp add: emeasure_eq_measure)
```
```  1274
```
```  1275 lemma (in finite_measure) finite_measure_eq_AE:
```
```  1276   assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
```
```  1277   assumes A: "A \<in> sets M" and B: "B \<in> sets M"
```
```  1278   shows "measure M A = measure M B"
```
```  1279   using assms emeasure_eq_AE[OF assms] by (simp add: emeasure_eq_measure)
```
```  1280
```
```  1281 section {* Counting space *}
```
```  1282
```
```  1283 definition count_space :: "'a set \<Rightarrow> 'a measure" where
```
```  1284   "count_space \<Omega> = measure_of \<Omega> (Pow \<Omega>) (\<lambda>A. if finite A then ereal (card A) else \<infinity>)"
```
```  1285
```
```  1286 lemma
```
```  1287   shows space_count_space[simp]: "space (count_space \<Omega>) = \<Omega>"
```
```  1288     and sets_count_space[simp]: "sets (count_space \<Omega>) = Pow \<Omega>"
```
```  1289   using sigma_sets_into_sp[of "Pow \<Omega>" \<Omega>]
```
```  1290   by (auto simp: count_space_def)
```
```  1291
```
```  1292 lemma measurable_count_space_eq1[simp]:
```
```  1293   "f \<in> measurable (count_space A) M \<longleftrightarrow> f \<in> A \<rightarrow> space M"
```
```  1294  unfolding measurable_def by simp
```
```  1295
```
```  1296 lemma measurable_count_space_eq2[simp]:
```
```  1297   assumes "finite A"
```
```  1298   shows "f \<in> measurable M (count_space A) \<longleftrightarrow> (f \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M))"
```
```  1299 proof -
```
```  1300   { fix X assume "X \<subseteq> A" "f \<in> space M \<rightarrow> A"
```
```  1301     with `finite A` have "f -` X \<inter> space M = (\<Union>a\<in>X. f -` {a} \<inter> space M)" "finite X"
```
```  1302       by (auto dest: finite_subset)
```
```  1303     moreover assume "\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M"
```
```  1304     ultimately have "f -` X \<inter> space M \<in> sets M"
```
```  1305       using `X \<subseteq> A` by (auto intro!: finite_UN simp del: UN_simps) }
```
```  1306   then show ?thesis
```
```  1307     unfolding measurable_def by auto
```
```  1308 qed
```
```  1309
```
```  1310 lemma emeasure_count_space:
```
```  1311   assumes "X \<subseteq> A" shows "emeasure (count_space A) X = (if finite X then ereal (card X) else \<infinity>)"
```
```  1312     (is "_ = ?M X")
```
```  1313   unfolding count_space_def
```
```  1314 proof (rule emeasure_measure_of_sigma)
```
```  1315   show "sigma_algebra A (Pow A)" by (rule sigma_algebra_Pow)
```
```  1316
```
```  1317   show "positive (Pow A) ?M"
```
```  1318     by (auto simp: positive_def)
```
```  1319
```
```  1320   show "countably_additive (Pow A) ?M"
```
```  1321   proof (unfold countably_additive_def, safe)
```
```  1322       fix F :: "nat \<Rightarrow> 'a set" assume disj: "disjoint_family F"
```
```  1323       show "(\<Sum>i. ?M (F i)) = ?M (\<Union>i. F i)"
```
```  1324       proof cases
```
```  1325         assume "\<forall>i. finite (F i)"
```
```  1326         then have finite_F: "\<And>i. finite (F i)" by auto
```
```  1327         have "\<forall>i\<in>{i. F i \<noteq> {}}. \<exists>x. x \<in> F i" by auto
```
```  1328         from bchoice[OF this] obtain f where f: "\<And>i. F i \<noteq> {} \<Longrightarrow> f i \<in> F i" by auto
```
```  1329
```
```  1330         have inj_f: "inj_on f {i. F i \<noteq> {}}"
```
```  1331         proof (rule inj_onI, simp)
```
```  1332           fix i j a b assume *: "f i = f j" "F i \<noteq> {}" "F j \<noteq> {}"
```
```  1333           then have "f i \<in> F i" "f j \<in> F j" using f by force+
```
```  1334           with disj * show "i = j" by (auto simp: disjoint_family_on_def)
```
```  1335         qed
```
```  1336         have fin_eq: "finite (\<Union>i. F i) \<longleftrightarrow> finite {i. F i \<noteq> {}}"
```
```  1337         proof
```
```  1338           assume "finite (\<Union>i. F i)"
```
```  1339           show "finite {i. F i \<noteq> {}}"
```
```  1340           proof (rule finite_imageD)
```
```  1341             from f have "f`{i. F i \<noteq> {}} \<subseteq> (\<Union>i. F i)" by auto
```
```  1342             then show "finite (f`{i. F i \<noteq> {}})"
```
```  1343               by (rule finite_subset) fact
```
```  1344           qed fact
```
```  1345         next
```
```  1346           assume "finite {i. F i \<noteq> {}}"
```
```  1347           with finite_F have "finite (\<Union>i\<in>{i. F i \<noteq> {}}. F i)"
```
```  1348             by auto
```
```  1349           also have "(\<Union>i\<in>{i. F i \<noteq> {}}. F i) = (\<Union>i. F i)"
```
```  1350             by auto
```
```  1351           finally show "finite (\<Union>i. F i)" .
```
```  1352         qed
```
```  1353
```
```  1354         show ?thesis
```
```  1355         proof cases
```
```  1356           assume *: "finite (\<Union>i. F i)"
```
```  1357           with finite_F have "finite {i. ?M (F i) \<noteq> 0} "
```
```  1358             by (simp add: fin_eq)
```
```  1359           then have "(\<Sum>i. ?M (F i)) = (\<Sum>i | ?M (F i) \<noteq> 0. ?M (F i))"
```
```  1360             by (rule suminf_eq_setsum)
```
```  1361           also have "\<dots> = ereal (\<Sum>i | F i \<noteq> {}. card (F i))"
```
```  1362             using finite_F by simp
```
```  1363           also have "\<dots> = ereal (card (\<Union>i \<in> {i. F i \<noteq> {}}. F i))"
```
```  1364             using * finite_F disj
```
```  1365             by (subst card_UN_disjoint) (auto simp: disjoint_family_on_def fin_eq)
```
```  1366           also have "\<dots> = ?M (\<Union>i. F i)"
```
```  1367             using * by (auto intro!: arg_cong[where f=card])
```
```  1368           finally show ?thesis .
```
```  1369         next
```
```  1370           assume inf: "infinite (\<Union>i. F i)"
```
```  1371           { fix i
```
```  1372             have "\<exists>N. i \<le> (\<Sum>i<N. card (F i))"
```
```  1373             proof (induct i)
```
```  1374               case (Suc j)
```
```  1375               from Suc obtain N where N: "j \<le> (\<Sum>i<N. card (F i))" by auto
```
```  1376               have "infinite ({i. F i \<noteq> {}} - {..< N})"
```
```  1377                 using inf by (auto simp: fin_eq)
```
```  1378               then have "{i. F i \<noteq> {}} - {..< N} \<noteq> {}"
```
```  1379                 by (metis finite.emptyI)
```
```  1380               then obtain i where i: "F i \<noteq> {}" "N \<le> i"
```
```  1381                 by (auto simp: not_less[symmetric])
```
```  1382
```
```  1383               note N
```
```  1384               also have "(\<Sum>i<N. card (F i)) \<le> (\<Sum>i<i. card (F i))"
```
```  1385                 by (rule setsum_mono2) (auto simp: i)
```
```  1386               also have "\<dots> < (\<Sum>i<i. card (F i)) + card (F i)"
```
```  1387                 using finite_F `F i \<noteq> {}` by (simp add: card_gt_0_iff)
```
```  1388               finally have "j < (\<Sum>i<Suc i. card (F i))"
```
```  1389                 by simp
```
```  1390               then show ?case unfolding Suc_le_eq by blast
```
```  1391             qed simp }
```
```  1392           with finite_F inf show ?thesis
```
```  1393             by (auto simp del: real_of_nat_setsum intro!: SUP_PInfty
```
```  1394                      simp add: suminf_ereal_eq_SUPR real_of_nat_setsum[symmetric])
```
```  1395         qed
```
```  1396       next
```
```  1397         assume "\<not> (\<forall>i. finite (F i))"
```
```  1398         then obtain j where j: "infinite (F j)" by auto
```
```  1399         then have "infinite (\<Union>i. F i)"
```
```  1400           using finite_subset[of "F j" "\<Union>i. F i"] by auto
```
```  1401         moreover have "\<And>i. 0 \<le> ?M (F i)" by auto
```
```  1402         ultimately show ?thesis
```
```  1403           using suminf_PInfty[of "\<lambda>i. ?M (F i)" j] j by auto
```
```  1404       qed
```
```  1405   qed
```
```  1406   show "X \<in> Pow A" using `X \<subseteq> A` by simp
```
```  1407 qed
```
```  1408
```
```  1409 lemma emeasure_count_space_finite[simp]:
```
```  1410   "X \<subseteq> A \<Longrightarrow> finite X \<Longrightarrow> emeasure (count_space A) X = ereal (card X)"
```
```  1411   using emeasure_count_space[of X A] by simp
```
```  1412
```
```  1413 lemma emeasure_count_space_infinite[simp]:
```
```  1414   "X \<subseteq> A \<Longrightarrow> infinite X \<Longrightarrow> emeasure (count_space A) X = \<infinity>"
```
```  1415   using emeasure_count_space[of X A] by simp
```
```  1416
```
```  1417 lemma emeasure_count_space_eq_0:
```
```  1418   "emeasure (count_space A) X = 0 \<longleftrightarrow> (X \<subseteq> A \<longrightarrow> X = {})"
```
```  1419 proof cases
```
```  1420   assume X: "X \<subseteq> A"
```
```  1421   then show ?thesis
```
```  1422   proof (intro iffI impI)
```
```  1423     assume "emeasure (count_space A) X = 0"
```
```  1424     with X show "X = {}"
```
```  1425       by (subst (asm) emeasure_count_space) (auto split: split_if_asm)
```
```  1426   qed simp
```
```  1427 qed (simp add: emeasure_notin_sets)
```
```  1428
```
```  1429 lemma null_sets_count_space: "null_sets (count_space A) = { {} }"
```
```  1430   unfolding null_sets_def by (auto simp add: emeasure_count_space_eq_0)
```
```  1431
```
```  1432 lemma AE_count_space: "(AE x in count_space A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
```
```  1433   unfolding eventually_ae_filter by (auto simp add: null_sets_count_space)
```
```  1434
```
```  1435 lemma sigma_finite_measure_count_space:
```
```  1436   fixes A :: "'a::countable set"
```
```  1437   shows "sigma_finite_measure (count_space A)"
```
```  1438 proof
```
```  1439   show "\<exists>F::nat \<Rightarrow> 'a set. range F \<subseteq> sets (count_space A) \<and> (\<Union>i. F i) = space (count_space A) \<and>
```
```  1440      (\<forall>i. emeasure (count_space A) (F i) \<noteq> \<infinity>)"
```
```  1441      using surj_from_nat by (intro exI[of _ "\<lambda>i. {from_nat i} \<inter> A"]) (auto simp del: surj_from_nat)
```
```  1442 qed
```
```  1443
```
```  1444 lemma finite_measure_count_space:
```
```  1445   assumes [simp]: "finite A"
```
```  1446   shows "finite_measure (count_space A)"
```
```  1447   by rule simp
```
```  1448
```
```  1449 lemma sigma_finite_measure_count_space_finite:
```
```  1450   assumes A: "finite A" shows "sigma_finite_measure (count_space A)"
```
```  1451 proof -
```
```  1452   interpret finite_measure "count_space A" using A by (rule finite_measure_count_space)
```
```  1453   show "sigma_finite_measure (count_space A)" ..
```
```  1454 qed
```
```  1455
```
```  1456 end
```
```  1457
```