author hoelzl Wed Feb 02 12:34:45 2011 +0100 (2011-02-02) changeset 41689 3e39b0e730d6 parent 41688 f9ff311992b6 child 41690 53b1da988e75 child 41691 8f0531cf34f8
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
changed syntax for simple_function, simple_integral, positive_integral, integral and RN_deriv.
introduced binder variants for simple_integral, positive_integral and integral.
     1.1 --- a/src/HOL/Probability/Caratheodory.thy	Wed Feb 02 10:35:41 2011 +0100
1.2 +++ b/src/HOL/Probability/Caratheodory.thy	Wed Feb 02 12:34:45 2011 +0100
1.3 @@ -8,77 +8,72 @@
1.4
1.5  subsection {* Measure Spaces *}
1.6
1.7 -definition "positive f \<longleftrightarrow> f {} = (0::pextreal)" -- "Positive is enforced by the type"
1.8 +record 'a measure_space = "'a algebra" +
1.9 +  measure :: "'a set \<Rightarrow> pextreal"
1.10
1.11 -definition
1.13 -  "additive M f \<longleftrightarrow>
1.14 -    (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {}
1.15 -    \<longrightarrow> f (x \<union> y) = f x + f y)"
1.16 +definition positive where "positive M f \<longleftrightarrow> f {} = (0::pextreal)"
1.17 +  -- "Positive is enforced by the type"
1.18
1.19 -definition
1.21 -  "countably_additive M f \<longleftrightarrow>
1.22 -    (\<forall>A. range A \<subseteq> sets M \<longrightarrow>
1.23 -         disjoint_family A \<longrightarrow>
1.24 -         (\<Union>i. A i) \<in> sets M \<longrightarrow>
1.25 -         (\<Sum>\<^isub>\<infinity> n. f (A n)) = f (\<Union>i. A i))"
1.27 +  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {} \<longrightarrow> f (x \<union> y) = f x + f y)"
1.28
1.29 -definition
1.30 -  increasing  where
1.31 -  "increasing M f \<longleftrightarrow> (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<subseteq> y \<longrightarrow> f x \<le> f y)"
1.33 +  (\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow>
1.34 +    (\<Sum>\<^isub>\<infinity> n. f (A n)) = f (\<Union>i. A i))"
1.35
1.36 -definition
1.38 -  "subadditive M f \<longleftrightarrow>
1.39 -    (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {}
1.40 -    \<longrightarrow> f (x \<union> y) \<le> f x + f y)"
1.41 +definition increasing where "increasing M f \<longleftrightarrow>
1.42 +  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<subseteq> y \<longrightarrow> f x \<le> f y)"
1.43
1.44 -definition
1.46 -  "countably_subadditive M f \<longleftrightarrow>
1.47 -    (\<forall>A. range A \<subseteq> sets M \<longrightarrow>
1.48 -         disjoint_family A \<longrightarrow>
1.49 -         (\<Union>i. A i) \<in> sets M \<longrightarrow>
1.50 -         f (\<Union>i. A i) \<le> psuminf (\<lambda>n. f (A n)))"
1.52 +  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {} \<longrightarrow>
1.53 +    f (x \<union> y) \<le> f x + f y)"
1.54
1.55 -definition
1.56 -  lambda_system where
1.57 -  "lambda_system M f =
1.58 -    {l. l \<in> sets M & (\<forall>x \<in> sets M. f (l \<inter> x) + f ((space M - l) \<inter> x) = f x)}"
1.60 +  (\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow>
1.61 +    f (\<Union>i. A i) \<le> (\<Sum>\<^isub>\<infinity> n. f (A n)))"
1.62 +
1.63 +definition lambda_system where "lambda_system M f = {l \<in> sets M.
1.64 +  \<forall>x \<in> sets M. f (l \<inter> x) + f ((space M - l) \<inter> x) = f x}"
1.65
1.66 -definition
1.67 -  outer_measure_space where
1.68 -  "outer_measure_space M f  \<longleftrightarrow>
1.69 -     positive f \<and> increasing M f \<and> countably_subadditive M f"
1.70 +definition outer_measure_space where "outer_measure_space M f \<longleftrightarrow>
1.71 +  positive M f \<and> increasing M f \<and> countably_subadditive M f"
1.72 +
1.73 +definition measure_set where "measure_set M f X = {r.
1.74 +  \<exists>A. range A \<subseteq> sets M \<and> disjoint_family A \<and> X \<subseteq> (\<Union>i. A i) \<and> (\<Sum>\<^isub>\<infinity> i. f (A i)) = r}"
1.75
1.76 -definition
1.77 -  measure_set where
1.78 -  "measure_set M f X =
1.79 -     {r . \<exists>A. range A \<subseteq> sets M \<and> disjoint_family A \<and> X \<subseteq> (\<Union>i. A i) \<and> (\<Sum>\<^isub>\<infinity> i. f (A i)) = r}"
1.80 +locale measure_space = sigma_algebra M for M :: "('a, 'b) measure_space_scheme" +
1.81 +  assumes empty_measure [simp]: "measure M {} = 0"
1.82 +      and ca: "countably_additive M (measure M)"
1.83
1.84 -locale measure_space = sigma_algebra +
1.85 -  fixes \<mu> :: "'a set \<Rightarrow> pextreal"
1.86 -  assumes empty_measure [simp]: "\<mu> {} = 0"
1.87 -      and ca: "countably_additive M \<mu>"
1.88 +abbreviation (in measure_space) "\<mu> \<equiv> measure M"
1.89
1.90  lemma increasingD:
1.91 -     "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>sets M \<Longrightarrow> y\<in>sets M \<Longrightarrow> f x \<le> f y"
1.92 +  "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>sets M \<Longrightarrow> y\<in>sets M \<Longrightarrow> f x \<le> f y"
1.93    by (auto simp add: increasing_def)
1.94
1.96 -     "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x\<in>sets M \<Longrightarrow> y\<in>sets M
1.97 -      \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
1.98 +  "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> sets M \<Longrightarrow> y \<in> sets M
1.99 +    \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
1.101
1.103 -     "additive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x\<in>sets M \<Longrightarrow> y\<in>sets M
1.104 -      \<Longrightarrow> f (x \<union> y) = f x + f y"
1.105 +  "additive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> sets M \<Longrightarrow> y \<in> sets M
1.106 +    \<Longrightarrow> f (x \<union> y) = f x + f y"
1.108
1.110    "countably_additive M f \<Longrightarrow> range A \<subseteq> sets M \<Longrightarrow> disjoint_family A
1.111 -   \<Longrightarrow> (\<Union>i. A i) \<in> sets M \<Longrightarrow> (\<Sum>\<^isub>\<infinity> n. f (A n)) = f (\<Union>i. A i)"
1.112 +    \<Longrightarrow> (\<Union>i. A i) \<in> sets M \<Longrightarrow> (\<Sum>\<^isub>\<infinity> n. f (A n)) = f (\<Union>i. A i)"
1.114 +
1.116 +  "countably_subadditive M f \<Longrightarrow> range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow>
1.117 +   (\<Union>i. A i) \<in> sets M \<Longrightarrow> f (\<Union>i. A i) \<le> psuminf (f o A)"
1.119 +
1.121 +  "(\<And>A. range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i. A i) \<in> sets M
1.122 +    \<Longrightarrow> (\<Sum>\<^isub>\<infinity> n. f (A n)) = f (\<Union>i. A i)) \<Longrightarrow> countably_additive M f"
1.124
1.125  section "Extend binary sets"
1.126 @@ -109,7 +104,8 @@
1.127      by (simp add: sums_def LIMSEQ_binaryset [where f=f, OF f])
1.128
1.129  lemma suminf_binaryset_eq:
1.130 -     "f {} = 0 \<Longrightarrow> suminf (\<lambda>n. f (binaryset A B n)) = f A + f B"
1.131 +  fixes f :: "'a set \<Rightarrow> real"
1.132 +  shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
1.133    by (metis binaryset_sums sums_unique)
1.134
1.135  lemma binaryset_psuminf:
1.136 @@ -130,8 +126,8 @@
1.137  subsection {* Lambda Systems *}
1.138
1.139  lemma (in algebra) lambda_system_eq:
1.140 -    "lambda_system M f =
1.141 -        {l. l \<in> sets M & (\<forall>x \<in> sets M. f (x \<inter> l) + f (x - l) = f x)}"
1.142 +  shows "lambda_system M f = {l \<in> sets M.
1.143 +    \<forall>x \<in> sets M. f (x \<inter> l) + f (x - l) = f x}"
1.144  proof -
1.145    have [simp]: "!!l x. l \<in> sets M \<Longrightarrow> x \<in> sets M \<Longrightarrow> (space M - l) \<inter> x = x - l"
1.146      by (metis Int_Diff Int_absorb1 Int_commute sets_into_space)
1.147 @@ -140,60 +136,59 @@
1.148  qed
1.149
1.150  lemma (in algebra) lambda_system_empty:
1.151 -  "positive f \<Longrightarrow> {} \<in> lambda_system M f"
1.152 -  by (auto simp add: positive_def lambda_system_eq)
1.153 +  "positive M f \<Longrightarrow> {} \<in> lambda_system M f"
1.154 +  by (auto simp add: positive_def lambda_system_eq algebra_def)
1.155
1.156  lemma lambda_system_sets:
1.157 -    "x \<in> lambda_system M f \<Longrightarrow> x \<in> sets M"
1.158 -  by (simp add:  lambda_system_def)
1.159 +  "x \<in> lambda_system M f \<Longrightarrow> x \<in> sets M"
1.160 +  by (simp add: lambda_system_def)
1.161
1.162  lemma (in algebra) lambda_system_Compl:
1.163    fixes f:: "'a set \<Rightarrow> pextreal"
1.164    assumes x: "x \<in> lambda_system M f"
1.165    shows "space M - x \<in> lambda_system M f"
1.166 -  proof -
1.167 -    have "x \<subseteq> space M"
1.168 -      by (metis sets_into_space lambda_system_sets x)
1.169 -    hence "space M - (space M - x) = x"
1.170 -      by (metis double_diff equalityE)
1.171 -    with x show ?thesis
1.172 -      by (force simp add: lambda_system_def ac_simps)
1.173 -  qed
1.174 +proof -
1.175 +  have "x \<subseteq> space M"
1.176 +    by (metis sets_into_space lambda_system_sets x)
1.177 +  hence "space M - (space M - x) = x"
1.178 +    by (metis double_diff equalityE)
1.179 +  with x show ?thesis
1.180 +    by (force simp add: lambda_system_def ac_simps)
1.181 +qed
1.182
1.183  lemma (in algebra) lambda_system_Int:
1.184    fixes f:: "'a set \<Rightarrow> pextreal"
1.185    assumes xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
1.186    shows "x \<inter> y \<in> lambda_system M f"
1.187 -  proof -
1.188 -    from xl yl show ?thesis
1.189 -      proof (auto simp add: positive_def lambda_system_eq Int)
1.190 -        fix u
1.191 -        assume x: "x \<in> sets M" and y: "y \<in> sets M" and u: "u \<in> sets M"
1.192 -           and fx: "\<forall>z\<in>sets M. f (z \<inter> x) + f (z - x) = f z"
1.193 -           and fy: "\<forall>z\<in>sets M. f (z \<inter> y) + f (z - y) = f z"
1.194 -        have "u - x \<inter> y \<in> sets M"
1.195 -          by (metis Diff Diff_Int Un u x y)
1.196 -        moreover
1.197 -        have "(u - (x \<inter> y)) \<inter> y = u \<inter> y - x" by blast
1.198 -        moreover
1.199 -        have "u - x \<inter> y - y = u - y" by blast
1.200 -        ultimately
1.201 -        have ey: "f (u - x \<inter> y) = f (u \<inter> y - x) + f (u - y)" using fy
1.202 -          by force
1.203 -        have "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y)
1.204 -              = (f (u \<inter> (x \<inter> y)) + f (u \<inter> y - x)) + f (u - y)"
1.205 -          by (simp add: ey ac_simps)
1.206 -        also have "... =  (f ((u \<inter> y) \<inter> x) + f (u \<inter> y - x)) + f (u - y)"
1.207 -          by (simp add: Int_ac)
1.208 -        also have "... = f (u \<inter> y) + f (u - y)"
1.209 -          using fx [THEN bspec, of "u \<inter> y"] Int y u
1.210 -          by force
1.211 -        also have "... = f u"
1.212 -          by (metis fy u)
1.213 -        finally show "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y) = f u" .
1.214 -      qed
1.215 +proof -
1.216 +  from xl yl show ?thesis
1.217 +  proof (auto simp add: positive_def lambda_system_eq Int)
1.218 +    fix u
1.219 +    assume x: "x \<in> sets M" and y: "y \<in> sets M" and u: "u \<in> sets M"
1.220 +       and fx: "\<forall>z\<in>sets M. f (z \<inter> x) + f (z - x) = f z"
1.221 +       and fy: "\<forall>z\<in>sets M. f (z \<inter> y) + f (z - y) = f z"
1.222 +    have "u - x \<inter> y \<in> sets M"
1.223 +      by (metis Diff Diff_Int Un u x y)
1.224 +    moreover
1.225 +    have "(u - (x \<inter> y)) \<inter> y = u \<inter> y - x" by blast
1.226 +    moreover
1.227 +    have "u - x \<inter> y - y = u - y" by blast
1.228 +    ultimately
1.229 +    have ey: "f (u - x \<inter> y) = f (u \<inter> y - x) + f (u - y)" using fy
1.230 +      by force
1.231 +    have "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y)
1.232 +          = (f (u \<inter> (x \<inter> y)) + f (u \<inter> y - x)) + f (u - y)"
1.233 +      by (simp add: ey ac_simps)
1.234 +    also have "... =  (f ((u \<inter> y) \<inter> x) + f (u \<inter> y - x)) + f (u - y)"
1.235 +      by (simp add: Int_ac)
1.236 +    also have "... = f (u \<inter> y) + f (u - y)"
1.237 +      using fx [THEN bspec, of "u \<inter> y"] Int y u
1.238 +      by force
1.239 +    also have "... = f u"
1.240 +      by (metis fy u)
1.241 +    finally show "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y) = f u" .
1.242    qed
1.243 -
1.244 +qed
1.245
1.246  lemma (in algebra) lambda_system_Un:
1.247    fixes f:: "'a set \<Rightarrow> pextreal"
1.248 @@ -210,7 +205,7 @@
1.249  qed
1.250
1.251  lemma (in algebra) lambda_system_algebra:
1.252 -  "positive f \<Longrightarrow> algebra (M (|sets := lambda_system M f|))"
1.253 +  "positive M f \<Longrightarrow> algebra (M\<lparr>sets := lambda_system M f\<rparr>)"
1.254    apply (auto simp add: algebra_def)
1.255    apply (metis lambda_system_sets set_mp sets_into_space)
1.256    apply (metis lambda_system_empty)
1.257 @@ -222,32 +217,31 @@
1.258    assumes z: "z \<in> sets M" and disj: "x \<inter> y = {}"
1.259        and xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
1.260    shows "f (z \<inter> (x \<union> y)) = f (z \<inter> x) + f (z \<inter> y)"
1.261 -  proof -
1.262 -    have "z \<inter> x = (z \<inter> (x \<union> y)) \<inter> x" using disj by blast
1.263 -    moreover
1.264 -    have "z \<inter> y = (z \<inter> (x \<union> y)) - x" using disj by blast
1.265 -    moreover
1.266 -    have "(z \<inter> (x \<union> y)) \<in> sets M"
1.267 -      by (metis Int Un lambda_system_sets xl yl z)
1.268 -    ultimately show ?thesis using xl yl
1.269 -      by (simp add: lambda_system_eq)
1.270 -  qed
1.271 +proof -
1.272 +  have "z \<inter> x = (z \<inter> (x \<union> y)) \<inter> x" using disj by blast
1.273 +  moreover
1.274 +  have "z \<inter> y = (z \<inter> (x \<union> y)) - x" using disj by blast
1.275 +  moreover
1.276 +  have "(z \<inter> (x \<union> y)) \<in> sets M"
1.277 +    by (metis Int Un lambda_system_sets xl yl z)
1.278 +  ultimately show ?thesis using xl yl
1.279 +    by (simp add: lambda_system_eq)
1.280 +qed
1.281
1.283       "additive (M (|sets := lambda_system M f|)) f"
1.285 -    fix x and y
1.286 -    assume disj: "x \<inter> y = {}"
1.287 -       and xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
1.288 -    hence  "x \<in> sets M" "y \<in> sets M" by (blast intro: lambda_system_sets)+
1.289 -    thus "f (x \<union> y) = f x + f y"
1.290 -      using lambda_system_strong_additive [OF top disj xl yl]
1.291 -      by (simp add: Un)
1.292 -  qed
1.293 -
1.295 +  fix x and y
1.296 +  assume disj: "x \<inter> y = {}"
1.297 +     and xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
1.298 +  hence  "x \<in> sets M" "y \<in> sets M" by (blast intro: lambda_system_sets)+
1.299 +  thus "f (x \<union> y) = f x + f y"
1.300 +    using lambda_system_strong_additive [OF top disj xl yl]
1.301 +    by (simp add: Un)
1.302 +qed
1.303
1.305 -  assumes f: "positive f" and cs: "countably_subadditive M f"
1.306 +  assumes f: "positive M f" and cs: "countably_subadditive M f"
1.309    fix x y
1.310 @@ -267,7 +261,7 @@
1.311
1.313    fixes A:: "nat \<Rightarrow> 'a set"
1.315 +  assumes f: "positive M f" and ad: "additive M f"
1.316        and A: "range A \<subseteq> sets M"
1.317        and disj: "disjoint_family A"
1.318    shows  "setsum (f \<circ> A) {0..<n} = f (\<Union>i\<in>{0..<n}. A i)"
1.319 @@ -288,15 +282,9 @@
1.321  qed
1.322
1.323 -
1.325 -  "countably_subadditive M f \<Longrightarrow> range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow>
1.326 -   (\<Union>i. A i) \<in> sets M \<Longrightarrow> f (\<Union>i. A i) \<le> psuminf (f o A)"
1.328 -
1.330    fixes A:: "nat \<Rightarrow> 'a set" and  f :: "'a set \<Rightarrow> pextreal"
1.332 +  assumes f: "positive M f" and ad: "additive M f"
1.333        and inc: "increasing M f"
1.334        and A: "range A \<subseteq> sets M"
1.335        and disj: "disjoint_family A"
1.336 @@ -311,12 +299,16 @@
1.337  qed
1.338
1.339  lemma lambda_system_increasing:
1.340 -   "increasing M f \<Longrightarrow> increasing (M (|sets := lambda_system M f|)) f"
1.341 + "increasing M f \<Longrightarrow> increasing (M (|sets := lambda_system M f|)) f"
1.342    by (simp add: increasing_def lambda_system_def)
1.343
1.344 +lemma lambda_system_positive:
1.345 +  "positive M f \<Longrightarrow> positive (M (|sets := lambda_system M f|)) f"
1.346 +  by (simp add: positive_def lambda_system_def)
1.347 +
1.348  lemma (in algebra) lambda_system_strong_sum:
1.349    fixes A:: "nat \<Rightarrow> 'a set" and f :: "'a set \<Rightarrow> pextreal"
1.350 -  assumes f: "positive f" and a: "a \<in> sets M"
1.351 +  assumes f: "positive M f" and a: "a \<in> sets M"
1.352        and A: "range A \<subseteq> lambda_system M f"
1.353        and disj: "disjoint_family A"
1.354    shows  "(\<Sum>i = 0..<n. f (a \<inter>A i)) = f (a \<inter> (\<Union>i\<in>{0..<n}. A i))"
1.355 @@ -335,14 +327,13 @@
1.357  qed
1.358
1.359 -
1.360  lemma (in sigma_algebra) lambda_system_caratheodory:
1.361    assumes oms: "outer_measure_space M f"
1.362        and A: "range A \<subseteq> lambda_system M f"
1.363        and disj: "disjoint_family A"
1.364    shows  "(\<Union>i. A i) \<in> lambda_system M f \<and> psuminf (f \<circ> A) = f (\<Union>i. A i)"
1.365  proof -
1.366 -  have pos: "positive f" and inc: "increasing M f"
1.367 +  have pos: "positive M f" and inc: "increasing M f"
1.368     and csa: "countably_subadditive M f"
1.369      by (metis oms outer_measure_space_def)+
1.370    have sa: "subadditive M f"
1.371 @@ -357,15 +348,15 @@
1.372    have U_in: "(\<Union>i. A i) \<in> sets M"
1.373      by (metis A'' countable_UN)
1.374    have U_eq: "f (\<Union>i. A i) = psuminf (f o A)"
1.375 -    proof (rule antisym)
1.376 -      show "f (\<Union>i. A i) \<le> psuminf (f \<circ> A)"
1.377 -        by (rule countably_subadditiveD [OF csa A'' disj U_in])
1.378 -      show "psuminf (f \<circ> A) \<le> f (\<Union>i. A i)"
1.379 -        by (rule psuminf_bound, unfold atLeast0LessThan[symmetric])
1.380 -           (metis algebra.additive_sum [OF alg_ls] pos disj UN_Un Un_UNIV_right
1.381 -                  lambda_system_additive subset_Un_eq increasingD [OF inc]
1.382 -                  A' A'' UNION_in_sets U_in)
1.383 -    qed
1.384 +  proof (rule antisym)
1.385 +    show "f (\<Union>i. A i) \<le> psuminf (f \<circ> A)"
1.386 +      by (rule countably_subadditiveD [OF csa A'' disj U_in])
1.387 +    show "psuminf (f \<circ> A) \<le> f (\<Union>i. A i)"
1.388 +      by (rule psuminf_bound, unfold atLeast0LessThan[symmetric])
1.389 +         (metis algebra.additive_sum [OF alg_ls] pos disj UN_Un Un_UNIV_right
1.391 +                subset_Un_eq increasingD [OF inc] A' A'' UNION_in_sets U_in)
1.392 +  qed
1.393    {
1.394      fix a
1.395      assume a [iff]: "a \<in> sets M"
1.396 @@ -424,19 +415,20 @@
1.397
1.398  lemma (in sigma_algebra) caratheodory_lemma:
1.399    assumes oms: "outer_measure_space M f"
1.400 -  shows "measure_space (|space = space M, sets = lambda_system M f|) f"
1.401 +  shows "measure_space \<lparr> space = space M, sets = lambda_system M f, measure = f \<rparr>"
1.402 +    (is "measure_space ?M")
1.403  proof -
1.404 -  have pos: "positive f"
1.405 +  have pos: "positive M f"
1.406      by (metis oms outer_measure_space_def)
1.407 -  have alg: "algebra (|space = space M, sets = lambda_system M f|)"
1.408 +  have alg: "algebra ?M"
1.409      using lambda_system_algebra [of f, OF pos]
1.411    then moreover
1.412 -  have "sigma_algebra (|space = space M, sets = lambda_system M f|)"
1.413 +  have "sigma_algebra ?M"
1.414      using lambda_system_caratheodory [OF oms]
1.416    moreover
1.417 -  have "measure_space_axioms (|space = space M, sets = lambda_system M f|) f"
1.418 +  have "measure_space_axioms ?M"
1.419      using pos lambda_system_caratheodory [OF oms]
1.420      by (simp add: measure_space_axioms_def positive_def lambda_system_sets
1.422 @@ -446,7 +438,7 @@
1.423  qed
1.424
1.427 +  assumes posf: "positive M f" and addf: "additive M f"
1.428    shows "increasing M f"
1.429  proof (auto simp add: increasing_def)
1.430    fix x y
1.431 @@ -460,7 +452,7 @@
1.432  qed
1.433
1.435 -  assumes posf: "positive f" and ca: "countably_additive M f"
1.436 +  assumes posf: "positive M f" and ca: "countably_additive M f"
1.439    fix x y
1.440 @@ -480,7 +472,7 @@
1.441  qed
1.442
1.443  lemma inf_measure_nonempty:
1.444 -  assumes f: "positive f" and b: "b \<in> sets M" and a: "a \<subseteq> b" "{} \<in> sets M"
1.445 +  assumes f: "positive M f" and b: "b \<in> sets M" and a: "a \<subseteq> b" "{} \<in> sets M"
1.446    shows "f b \<in> measure_set M f a"
1.447  proof -
1.448    have "psuminf (f \<circ> (\<lambda>i. {})(0 := b)) = setsum (f \<circ> (\<lambda>i. {})(0 := b)) {..<1::nat}"
1.449 @@ -494,7 +486,7 @@
1.450  qed
1.451
1.452  lemma (in algebra) inf_measure_agrees:
1.453 -  assumes posf: "positive f" and ca: "countably_additive M f"
1.454 +  assumes posf: "positive M f" and ca: "countably_additive M f"
1.455        and s: "s \<in> sets M"
1.456    shows "Inf (measure_set M f s) = f s"
1.457    unfolding Inf_pextreal_def
1.458 @@ -530,25 +522,25 @@
1.459    fix y
1.460    assume y: "\<forall>u \<in> measure_set M f s. y \<le> u"
1.461    thus "y \<le> f s"
1.462 -    by (blast intro: inf_measure_nonempty [of f, OF posf s subset_refl])
1.463 +    by (blast intro: inf_measure_nonempty [of _ f, OF posf s subset_refl])
1.464  qed
1.465
1.466 -lemma (in algebra) inf_measure_empty:
1.467 -  assumes posf: "positive f"  "{} \<in> sets M"
1.468 +lemma inf_measure_empty:
1.469 +  assumes posf: "positive M f" "{} \<in> sets M"
1.470    shows "Inf (measure_set M f {}) = 0"
1.471  proof (rule antisym)
1.472    show "Inf (measure_set M f {}) \<le> 0"
1.473 -    by (metis complete_lattice_class.Inf_lower {} \<in> sets M inf_measure_nonempty[OF posf] subset_refl posf[unfolded positive_def])
1.474 +    by (metis complete_lattice_class.Inf_lower {} \<in> sets M
1.475 +              inf_measure_nonempty[OF posf] subset_refl posf[unfolded positive_def])
1.476  qed simp
1.477
1.478  lemma (in algebra) inf_measure_positive:
1.479 -  "positive f \<Longrightarrow>
1.480 -   positive (\<lambda>x. Inf (measure_set M f x))"
1.481 -  by (simp add: positive_def inf_measure_empty)
1.482 +  "positive M f \<Longrightarrow> positive M (\<lambda>x. Inf (measure_set M f x))"
1.483 +  by (simp add: positive_def inf_measure_empty)
1.484
1.485  lemma (in algebra) inf_measure_increasing:
1.486 -  assumes posf: "positive f"
1.487 -  shows "increasing (| space = space M, sets = Pow (space M) |)
1.488 +  assumes posf: "positive M f"
1.489 +  shows "increasing \<lparr> space = space M, sets = Pow (space M) \<rparr>
1.490                      (\<lambda>x. Inf (measure_set M f x))"
1.491  apply (auto simp add: increasing_def)
1.492  apply (rule complete_lattice_class.Inf_greatest)
1.493 @@ -558,7 +550,7 @@
1.494
1.495
1.496  lemma (in algebra) inf_measure_le:
1.497 -  assumes posf: "positive f" and inc: "increasing M f"
1.498 +  assumes posf: "positive M f" and inc: "increasing M f"
1.499        and x: "x \<in> {r . \<exists>A. range A \<subseteq> sets M \<and> s \<subseteq> (\<Union>i. A i) \<and> psuminf (f \<circ> A) = r}"
1.500    shows "Inf (measure_set M f s) \<le> x"
1.501  proof -
1.502 @@ -584,7 +576,7 @@
1.503  qed
1.504
1.505  lemma (in algebra) inf_measure_close:
1.506 -  assumes posf: "positive f" and e: "0 < e" and ss: "s \<subseteq> (space M)"
1.507 +  assumes posf: "positive M f" and e: "0 < e" and ss: "s \<subseteq> (space M)"
1.508    shows "\<exists>A. range A \<subseteq> sets M \<and> disjoint_family A \<and> s \<subseteq> (\<Union>i. A i) \<and>
1.509                 psuminf (f \<circ> A) \<le> Inf (measure_set M f s) + e"
1.510  proof (cases "Inf (measure_set M f s) = \<omega>")
1.511 @@ -596,7 +588,7 @@
1.512  next
1.513    case True
1.514    have "measure_set M f s \<noteq> {}"
1.515 -    by (metis emptyE ss inf_measure_nonempty [of f, OF posf top _ empty_sets])
1.516 +    by (metis emptyE ss inf_measure_nonempty [of _ f, OF posf top _ empty_sets])
1.517    then obtain l where "l \<in> measure_set M f s" by auto
1.518    moreover from True have "l \<le> Inf (measure_set M f s) + e" by simp
1.519    ultimately show ?thesis
1.520 @@ -604,7 +596,7 @@
1.521  qed
1.522
1.524 -  assumes posf: "positive f" and inc: "increasing M f"
1.525 +  assumes posf: "positive M f" and inc: "increasing M f"
1.526    shows "countably_subadditive (| space = space M, sets = Pow (space M) |)
1.527                    (\<lambda>x. Inf (measure_set M f x))"
1.529 @@ -666,8 +658,8 @@
1.530  qed
1.531
1.532  lemma (in algebra) inf_measure_outer:
1.533 -  "\<lbrakk> positive f ; increasing M f \<rbrakk>
1.534 -   \<Longrightarrow> outer_measure_space (| space = space M, sets = Pow (space M) |)
1.535 +  "\<lbrakk> positive M f ; increasing M f \<rbrakk>
1.536 +   \<Longrightarrow> outer_measure_space \<lparr> space = space M, sets = Pow (space M) \<rparr>
1.537                            (\<lambda>x. Inf (measure_set M f x))"
1.538    by (simp add: outer_measure_space_def inf_measure_empty
1.540 @@ -675,7 +667,7 @@
1.541  (*MOVE UP*)
1.542
1.543  lemma (in algebra) algebra_subset_lambda_system:
1.544 -  assumes posf: "positive f" and inc: "increasing M f"
1.545 +  assumes posf: "positive M f" and inc: "increasing M f"
1.547    shows "sets M \<subseteq> lambda_system (| space = space M, sets = Pow (space M) |)
1.548                                  (\<lambda>x. Inf (measure_set M f x))"
1.549 @@ -739,10 +731,10 @@
1.550        by (metis Un_Diff_Int Un_commute)
1.551      also have "... \<le> Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))"
1.554 -               inf_measure_positive inf_measure_countably_subadditive posf inc)
1.555 -      apply (auto simp add: subsetD [OF s])
1.556 -      done
1.558 +      apply (simp add: positive_def inf_measure_empty[OF posf])
1.560 +      using s by (auto intro!: posf inc)
1.561      finally show ?thesis .
1.562      qed
1.563    ultimately
1.564 @@ -752,37 +744,38 @@
1.565  qed
1.566
1.567  lemma measure_down:
1.568 -     "measure_space N \<mu> \<Longrightarrow> sigma_algebra M \<Longrightarrow> sets M \<subseteq> sets N \<Longrightarrow>
1.569 -      (\<nu> = \<mu>) \<Longrightarrow> measure_space M \<nu>"
1.570 +  "measure_space N \<Longrightarrow> sigma_algebra M \<Longrightarrow> sets M \<subseteq> sets N \<Longrightarrow> measure N = measure M \<Longrightarrow> measure_space M"
1.571    by (simp add: measure_space_def measure_space_axioms_def positive_def
1.573       blast
1.574
1.575  theorem (in algebra) caratheodory:
1.576 -  assumes posf: "positive f" and ca: "countably_additive M f"
1.577 -  shows "\<exists>\<mu> :: 'a set \<Rightarrow> pextreal. (\<forall>s \<in> sets M. \<mu> s = f s) \<and> measure_space (sigma M) \<mu>"
1.578 -  proof -
1.579 -    have inc: "increasing M f"
1.581 -    let ?infm = "(\<lambda>x. Inf (measure_set M f x))"
1.582 -    def ls \<equiv> "lambda_system (|space = space M, sets = Pow (space M)|) ?infm"
1.583 -    have mls: "measure_space \<lparr>space = space M, sets = ls\<rparr> ?infm"
1.584 -      using sigma_algebra.caratheodory_lemma
1.585 -              [OF sigma_algebra_Pow  inf_measure_outer [OF posf inc]]
1.586 -      by (simp add: ls_def)
1.587 -    hence sls: "sigma_algebra (|space = space M, sets = ls|)"
1.588 -      by (simp add: measure_space_def)
1.589 -    have "sets M \<subseteq> ls"
1.590 -      by (simp add: ls_def)
1.592 -    hence sgs_sb: "sigma_sets (space M) (sets M) \<subseteq> ls"
1.593 -      using sigma_algebra.sigma_sets_subset [OF sls, of "sets M"]
1.594 -      by simp
1.595 -    have "measure_space (sigma M) ?infm"
1.596 -      unfolding sigma_def
1.597 -      by (rule measure_down [OF mls], rule sigma_algebra_sigma_sets)
1.598 -         (simp_all add: sgs_sb space_closed)
1.599 -    thus ?thesis using inf_measure_agrees [OF posf ca] by (auto intro!: exI[of _ ?infm])
1.600 -  qed
1.601 +  assumes posf: "positive M f" and ca: "countably_additive M f"
1.602 +  shows "\<exists>\<mu> :: 'a set \<Rightarrow> pextreal. (\<forall>s \<in> sets M. \<mu> s = f s) \<and>
1.603 +            measure_space \<lparr> space = space M, sets = sets (sigma M), measure = \<mu> \<rparr>"
1.604 +proof -
1.605 +  have inc: "increasing M f"
1.607 +  let ?infm = "(\<lambda>x. Inf (measure_set M f x))"
1.608 +  def ls \<equiv> "lambda_system (|space = space M, sets = Pow (space M)|) ?infm"
1.609 +  have mls: "measure_space \<lparr>space = space M, sets = ls, measure = ?infm\<rparr>"
1.610 +    using sigma_algebra.caratheodory_lemma
1.611 +            [OF sigma_algebra_Pow  inf_measure_outer [OF posf inc]]
1.612 +    by (simp add: ls_def)
1.613 +  hence sls: "sigma_algebra (|space = space M, sets = ls, measure = ?infm|)"
1.614 +    by (simp add: measure_space_def)
1.615 +  have "sets M \<subseteq> ls"
1.616 +    by (simp add: ls_def)
1.618 +  hence sgs_sb: "sigma_sets (space M) (sets M) \<subseteq> ls"
1.619 +    using sigma_algebra.sigma_sets_subset [OF sls, of "sets M"]
1.620 +    by simp
1.621 +  have "measure_space \<lparr> space = space M, sets = sets (sigma M), measure = ?infm \<rparr>"
1.622 +    unfolding sigma_def
1.623 +    by (rule measure_down [OF mls], rule sigma_algebra_sigma_sets)
1.624 +       (simp_all add: sgs_sb space_closed)
1.625 +  thus ?thesis using inf_measure_agrees [OF posf ca]
1.626 +    by (intro exI[of _ ?infm]) auto
1.627 +qed
1.628
1.629  end

     2.1 --- a/src/HOL/Probability/Complete_Measure.thy	Wed Feb 02 10:35:41 2011 +0100
2.2 +++ b/src/HOL/Probability/Complete_Measure.thy	Wed Feb 02 12:34:45 2011 +0100
2.3 @@ -7,9 +7,24 @@
2.4
2.5  locale completeable_measure_space = measure_space
2.6
2.7 -definition (in completeable_measure_space) completion :: "'a algebra" where
2.8 +definition (in completeable_measure_space)
2.9 +  "split_completion A p = (\<exists>N'. A = fst p \<union> snd p \<and> fst p \<inter> snd p = {} \<and>
2.10 +    fst p \<in> sets M \<and> snd p \<subseteq> N' \<and> N' \<in> null_sets)"
2.11 +
2.12 +definition (in completeable_measure_space)
2.13 +  "main_part A = fst (Eps (split_completion A))"
2.14 +
2.15 +definition (in completeable_measure_space)
2.16 +  "null_part A = snd (Eps (split_completion A))"
2.17 +
2.18 +abbreviation (in completeable_measure_space) "\<mu>' A \<equiv> \<mu> (main_part A)"
2.19 +
2.20 +definition (in completeable_measure_space) completion :: "('a, 'b) measure_space_scheme" where
2.21    "completion = \<lparr> space = space M,
2.22 -    sets = { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets \<and> N \<subseteq> N' } \<rparr>"
2.23 +                  sets = { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets \<and> N \<subseteq> N' },
2.24 +                  measure = \<mu>',
2.25 +                  \<dots> = more M \<rparr>"
2.26 +
2.27
2.28  lemma (in completeable_measure_space) space_completion[simp]:
2.29    "space completion = space M" unfolding completion_def by simp
2.30 @@ -58,16 +73,6 @@
2.31         auto
2.32  qed auto
2.33
2.34 -definition (in completeable_measure_space)
2.35 -  "split_completion A p = (\<exists>N'. A = fst p \<union> snd p \<and> fst p \<inter> snd p = {} \<and>
2.36 -    fst p \<in> sets M \<and> snd p \<subseteq> N' \<and> N' \<in> null_sets)"
2.37 -
2.38 -definition (in completeable_measure_space)
2.39 -  "main_part A = fst (Eps (split_completion A))"
2.40 -
2.41 -definition (in completeable_measure_space)
2.42 -  "null_part A = snd (Eps (split_completion A))"
2.43 -
2.44  lemma (in completeable_measure_space) split_completion:
2.45    assumes "A \<in> sets completion"
2.46    shows "split_completion A (main_part A, null_part A)"
2.47 @@ -108,17 +113,15 @@
2.48    show "\<mu> (null_part S) = 0" by auto
2.49  qed
2.50
2.51 -definition (in completeable_measure_space) "\<mu>' A = \<mu> (main_part A)"
2.52 -
2.53  lemma (in completeable_measure_space) \<mu>'_set[simp]:
2.54    assumes "S \<in> sets M" shows "\<mu>' S = \<mu> S"
2.55  proof -
2.56    have S: "S \<in> sets completion" using assms by auto
2.57    then have "\<mu> S = \<mu> (main_part S \<union> null_part S)" by simp
2.58 -  also have "\<dots> = \<mu> (main_part S)"
2.59 +  also have "\<dots> = \<mu>' S"
2.60      using S assms measure_additive[of "main_part S" "null_part S"]
2.62 -  finally show ?thesis unfolding \<mu>'_def by simp
2.63 +  finally show ?thesis by simp
2.64  qed
2.65
2.66  lemma (in completeable_measure_space) sets_completionI_sub:
2.67 @@ -154,7 +157,7 @@
2.68      unfolding * ..
2.69    also have "\<dots> = \<mu> (\<Union>i. main_part (S i))"
2.70      using null_set S by (intro measure_Un_null_set) auto
2.71 -  finally show ?thesis unfolding \<mu>'_def .
2.72 +  finally show ?thesis .
2.73  qed
2.74
2.75  lemma (in completeable_measure_space) \<mu>_main_part_Un:
2.76 @@ -168,30 +171,35 @@
2.77      unfolding range_binary_eq Un_range_binary UN by auto
2.78  qed
2.79
2.80 -sublocale completeable_measure_space \<subseteq> completion!: measure_space completion \<mu>'
2.81 -proof
2.82 -  show "\<mu>' {} = 0" by auto
2.83 -next
2.84 -  show "countably_additive completion \<mu>'"
2.85 -  proof (unfold countably_additive_def, intro allI conjI impI)
2.86 -    fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets completion" "disjoint_family A"
2.87 -    have "disjoint_family (\<lambda>i. main_part (A i))"
2.88 -    proof (intro disjoint_family_on_bisimulation[OF A(2)])
2.89 -      fix n m assume "A n \<inter> A m = {}"
2.90 -      then have "(main_part (A n) \<union> null_part (A n)) \<inter> (main_part (A m) \<union> null_part (A m)) = {}"
2.91 -        using A by (subst (1 2) main_part_null_part_Un) auto
2.92 -      then show "main_part (A n) \<inter> main_part (A m) = {}" by auto
2.93 +sublocale completeable_measure_space \<subseteq> completion!: measure_space completion
2.94 +  where "measure completion = \<mu>'"
2.95 +proof -
2.96 +  show "measure_space completion"
2.97 +  proof
2.98 +    show "measure completion {} = 0" by (auto simp: completion_def)
2.99 +  next
2.100 +    show "countably_additive completion (measure completion)"
2.102 +      fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets completion" "disjoint_family A"
2.103 +      have "disjoint_family (\<lambda>i. main_part (A i))"
2.104 +      proof (intro disjoint_family_on_bisimulation[OF A(2)])
2.105 +        fix n m assume "A n \<inter> A m = {}"
2.106 +        then have "(main_part (A n) \<union> null_part (A n)) \<inter> (main_part (A m) \<union> null_part (A m)) = {}"
2.107 +          using A by (subst (1 2) main_part_null_part_Un) auto
2.108 +        then show "main_part (A n) \<inter> main_part (A m) = {}" by auto
2.109 +      qed
2.110 +      then have "(\<Sum>\<^isub>\<infinity>n. measure completion (A n)) = \<mu> (\<Union>i. main_part (A i))"
2.111 +        unfolding completion_def using A by (auto intro!: measure_countably_additive)
2.112 +      then show "(\<Sum>\<^isub>\<infinity>n. measure completion (A n)) = measure completion (UNION UNIV A)"
2.113 +        by (simp add: completion_def \<mu>_main_part_UN[OF A(1)])
2.114      qed
2.115 -    then have "(\<Sum>\<^isub>\<infinity>n. \<mu>' (A n)) = \<mu> (\<Union>i. main_part (A i))"
2.116 -      unfolding \<mu>'_def using A by (intro measure_countably_additive) auto
2.117 -    then show "(\<Sum>\<^isub>\<infinity>n. \<mu>' (A n)) = \<mu>' (UNION UNIV A)"
2.118 -      unfolding \<mu>_main_part_UN[OF A(1)] .
2.119    qed
2.120 +  show "measure completion = \<mu>'" unfolding completion_def by simp
2.121  qed
2.122
2.123  lemma (in completeable_measure_space) completion_ex_simple_function:
2.124 -  assumes f: "completion.simple_function f"
2.125 -  shows "\<exists>f'. simple_function f' \<and> (AE x. f x = f' x)"
2.126 +  assumes f: "simple_function completion f"
2.127 +  shows "\<exists>f'. simple_function M f' \<and> (AE x. f x = f' x)"
2.128  proof -
2.129    let "?F x" = "f - {x} \<inter> space M"
2.130    have F: "\<And>x. ?F x \<in> sets completion" and fin: "finite (fspace M)"
2.131 @@ -248,11 +256,11 @@
2.132    shows "\<exists>g'\<in>borel_measurable M. (AE x. g x = g' x)"
2.133  proof -
2.134    from g[THEN completion.borel_measurable_implies_simple_function_sequence]
2.135 -  obtain f where "\<And>i. completion.simple_function (f i)" "f \<up> g" by auto
2.136 -  then have "\<forall>i. \<exists>f'. simple_function f' \<and> (AE x. f i x = f' x)"
2.137 +  obtain f where "\<And>i. simple_function completion (f i)" "f \<up> g" by auto
2.138 +  then have "\<forall>i. \<exists>f'. simple_function M f' \<and> (AE x. f i x = f' x)"
2.139      using completion_ex_simple_function by auto
2.140    from this[THEN choice] obtain f' where
2.141 -    sf: "\<And>i. simple_function (f' i)" and
2.142 +    sf: "\<And>i. simple_function M (f' i)" and
2.143      AE: "\<forall>i. AE x. f i x = f' i x" by auto
2.144    show ?thesis
2.145    proof (intro bexI)

     3.1 --- a/src/HOL/Probability/Information.thy	Wed Feb 02 10:35:41 2011 +0100
3.2 +++ b/src/HOL/Probability/Information.thy	Wed Feb 02 12:34:45 2011 +0100
3.3 @@ -165,43 +165,45 @@
3.4  Kullback$-$Leibler distance. *}
3.5
3.6  definition
3.7 -  "KL_divergence b M \<mu> \<nu> =
3.8 -    measure_space.integral M \<mu> (\<lambda>x. log b (real (sigma_finite_measure.RN_deriv M \<nu> \<mu> x)))"
3.9 +  "KL_divergence b M \<nu> = \<integral>x. log b (real (RN_deriv M \<nu> x)) \<partial>M\<lparr>measure := \<nu>\<rparr>"
3.10
3.11  lemma (in sigma_finite_measure) KL_divergence_cong:
3.12 -  assumes "measure_space M \<nu>"
3.13 -  and cong: "\<And>A. A \<in> sets M \<Longrightarrow> \<mu>' A = \<mu> A" "\<And>A. A \<in> sets M \<Longrightarrow> \<nu>' A = \<nu> A"
3.14 -  shows "KL_divergence b M \<nu>' \<mu>' = KL_divergence b M \<nu> \<mu>"
3.15 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)" (is "measure_space ?\<nu>")
3.16 +  assumes [simp]: "sets N = sets M" "space N = space M"
3.17 +    "\<And>A. A \<in> sets M \<Longrightarrow> measure N A = \<mu> A"
3.18 +    "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = \<nu>' A"
3.19 +  shows "KL_divergence b M \<nu> = KL_divergence b N \<nu>'"
3.20  proof -
3.21 -  interpret \<nu>: measure_space M \<nu> by fact
3.22 -  show ?thesis
3.23 -    unfolding KL_divergence_def
3.24 -    using RN_deriv_cong[OF cong, of "\<lambda>A. A"]
3.25 -    by (simp add: cong \<nu>.integral_cong_measure[OF cong(2)])
3.26 +  interpret \<nu>: measure_space ?\<nu> by fact
3.27 +  have "KL_divergence b M \<nu> = \<integral>x. log b (real (RN_deriv N \<nu>' x)) \<partial>?\<nu>"
3.28 +    by (simp cong: RN_deriv_cong \<nu>.integral_cong add: KL_divergence_def)
3.29 +  also have "\<dots> = KL_divergence b N \<nu>'"
3.30 +    by (auto intro!: \<nu>.integral_cong_measure[symmetric] simp: KL_divergence_def)
3.31 +  finally show ?thesis .
3.32  qed
3.33
3.34  lemma (in finite_measure_space) KL_divergence_eq_finite:
3.35 -  assumes v: "finite_measure_space M \<nu>"
3.36 +  assumes v: "finite_measure_space (M\<lparr>measure := \<nu>\<rparr>)"
3.37    assumes ac: "absolutely_continuous \<nu>"
3.38 -  shows "KL_divergence b M \<nu> \<mu> = (\<Sum>x\<in>space M. real (\<nu> {x}) * log b (real (\<nu> {x}) / real (\<mu> {x})))" (is "_ = ?sum")
3.39 +  shows "KL_divergence b M \<nu> = (\<Sum>x\<in>space M. real (\<nu> {x}) * log b (real (\<nu> {x}) / real (\<mu> {x})))" (is "_ = ?sum")
3.40  proof (simp add: KL_divergence_def finite_measure_space.integral_finite_singleton[OF v])
3.41 -  interpret v: finite_measure_space M \<nu> by fact
3.42 -  have ms: "measure_space M \<nu>" by fact
3.43 -  show "(\<Sum>x \<in> space M. log b (real (RN_deriv \<nu> x)) * real (\<nu> {x})) = ?sum"
3.44 +  interpret v: finite_measure_space "M\<lparr>measure := \<nu>\<rparr>" by fact
3.45 +  have ms: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" by default
3.46 +  show "(\<Sum>x \<in> space M. log b (real (RN_deriv M \<nu> x)) * real (\<nu> {x})) = ?sum"
3.47      using RN_deriv_finite_measure[OF ms ac]
3.48      by (auto intro!: setsum_cong simp: field_simps real_of_pextreal_mult[symmetric])
3.49  qed
3.50
3.51  lemma (in finite_prob_space) KL_divergence_positive_finite:
3.52 -  assumes v: "finite_prob_space M \<nu>"
3.53 +  assumes v: "finite_prob_space (M\<lparr>measure := \<nu>\<rparr>)"
3.54    assumes ac: "absolutely_continuous \<nu>"
3.55    and "1 < b"
3.56 -  shows "0 \<le> KL_divergence b M \<nu> \<mu>"
3.57 +  shows "0 \<le> KL_divergence b M \<nu>"
3.58  proof -
3.59 -  interpret v: finite_prob_space M \<nu> using v .
3.60 -  have ms: "finite_measure_space M \<nu>" by default
3.61 +  interpret v: finite_prob_space "M\<lparr>measure := \<nu>\<rparr>" by fact
3.62 +  have ms: "finite_measure_space (M\<lparr>measure := \<nu>\<rparr>)" by default
3.63
3.64 -  have "- (KL_divergence b M \<nu> \<mu>) \<le> log b (\<Sum>x\<in>space M. real (\<mu> {x}))"
3.65 +  have "- (KL_divergence b M \<nu>) \<le> log b (\<Sum>x\<in>space M. real (\<mu> {x}))"
3.66    proof (subst KL_divergence_eq_finite[OF ms ac], safe intro!: log_setsum_divide not_empty)
3.67      show "finite (space M)" using finite_space by simp
3.68      show "1 < b" by fact
3.69 @@ -215,16 +217,15 @@
3.70          using ac[unfolded absolutely_continuous_def, THEN bspec, of "{x}"] x by auto
3.71        thus "0 < prob {x}" using finite_measure[of "{x}"] x by auto }
3.72    qed auto
3.73 -  thus "0 \<le> KL_divergence b M \<nu> \<mu>" using finite_sum_over_space_eq_1 by simp
3.74 +  thus "0 \<le> KL_divergence b M \<nu>" using finite_sum_over_space_eq_1 by simp
3.75  qed
3.76
3.77  subsection {* Mutual Information *}
3.78
3.79  definition (in prob_space)
3.80    "mutual_information b S T X Y =
3.81 -    KL_divergence b (sigma (pair_algebra S T))
3.82 -      (joint_distribution X Y)
3.83 -      (pair_sigma_finite.pair_measure S (distribution X) T (distribution Y))"
3.84 +    KL_divergence b (S\<lparr>measure := distribution X\<rparr> \<Otimes>\<^isub>M T\<lparr>measure := distribution Y\<rparr>)
3.85 +      (joint_distribution X Y)"
3.86
3.87  definition (in prob_space)
3.88    "entropy b s X = mutual_information b s s X X"
3.89 @@ -232,32 +233,49 @@
3.90  abbreviation (in information_space)
3.91    mutual_information_Pow ("\<I>'(_ ; _')") where
3.92    "\<I>(X ; Y) \<equiv> mutual_information b
3.93 -    \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr>
3.94 -    \<lparr> space = Yspace M, sets = Pow (Yspace M) \<rparr> X Y"
3.95 +    \<lparr> space = Xspace M, sets = Pow (Xspace M), measure = distribution X \<rparr>
3.96 +    \<lparr> space = Yspace M, sets = Pow (Yspace M), measure = distribution Y \<rparr> X Y"
3.97 +
3.98 +lemma algebra_measure_update[simp]:
3.99 +  "algebra (M'\<lparr>measure := m\<rparr>) \<longleftrightarrow> algebra M'"
3.100 +  unfolding algebra_def by simp
3.101 +
3.102 +lemma sigma_algebra_measure_update[simp]:
3.103 +  "sigma_algebra (M'\<lparr>measure := m\<rparr>) \<longleftrightarrow> sigma_algebra M'"
3.104 +  unfolding sigma_algebra_def sigma_algebra_axioms_def by simp
3.105 +
3.106 +lemma finite_sigma_algebra_measure_update[simp]:
3.107 +  "finite_sigma_algebra (M'\<lparr>measure := m\<rparr>) \<longleftrightarrow> finite_sigma_algebra M'"
3.108 +  unfolding finite_sigma_algebra_def finite_sigma_algebra_axioms_def by simp
3.109
3.110  lemma (in prob_space) finite_variables_absolutely_continuous:
3.111    assumes X: "finite_random_variable S X" and Y: "finite_random_variable T Y"
3.112 -  shows "measure_space.absolutely_continuous (sigma (pair_algebra S T))
3.113 -   (pair_sigma_finite.pair_measure S (distribution X) T (distribution Y)) (joint_distribution X Y)"
3.114 +  shows "measure_space.absolutely_continuous
3.115 +    (S\<lparr>measure := distribution X\<rparr> \<Otimes>\<^isub>M T\<lparr>measure := distribution Y\<rparr>)
3.116 +    (joint_distribution X Y)"
3.117  proof -
3.118 -  interpret X: finite_prob_space S "distribution X" using X by (rule distribution_finite_prob_space)
3.119 -  interpret Y: finite_prob_space T "distribution Y" using Y by (rule distribution_finite_prob_space)
3.120 -  interpret XY: pair_finite_prob_space S "distribution X" T "distribution Y" by default
3.121 -  interpret P: finite_prob_space XY.P "joint_distribution X Y"
3.122 -    using assms by (intro joint_distribution_finite_prob_space)
3.123 +  interpret X: finite_prob_space "S\<lparr>measure := distribution X\<rparr>"
3.124 +    using X by (rule distribution_finite_prob_space)
3.125 +  interpret Y: finite_prob_space "T\<lparr>measure := distribution Y\<rparr>"
3.126 +    using Y by (rule distribution_finite_prob_space)
3.127 +  interpret XY: pair_finite_prob_space
3.128 +    "S\<lparr>measure := distribution X\<rparr>" "T\<lparr> measure := distribution Y\<rparr>" by default
3.129 +  interpret P: finite_prob_space "XY.P\<lparr> measure := joint_distribution X Y\<rparr>"
3.130 +    using assms by (auto intro!: joint_distribution_finite_prob_space)
3.131 +  note rv = assms[THEN finite_random_variableD]
3.132    show "XY.absolutely_continuous (joint_distribution X Y)"
3.133    proof (rule XY.absolutely_continuousI)
3.134 -    show "finite_measure_space XY.P (joint_distribution X Y)" by default
3.135 -    fix x assume "x \<in> space XY.P" and "XY.pair_measure {x} = 0"
3.136 +    show "finite_measure_space (XY.P\<lparr> measure := joint_distribution X Y\<rparr>)" by default
3.137 +    fix x assume "x \<in> space XY.P" and "XY.\<mu> {x} = 0"
3.138      then obtain a b where "(a, b) = x" and "a \<in> space S" "b \<in> space T"
3.139        and distr: "distribution X {a} * distribution Y {b} = 0"
3.140 -      by (cases x) (auto simp: pair_algebra_def)
3.141 -    with assms[THEN finite_random_variableD]
3.142 -      joint_distribution_Times_le_fst[of S X T Y "{a}" "{b}"]
3.143 -      joint_distribution_Times_le_snd[of S X T Y "{a}" "{b}"]
3.144 +      by (cases x) (auto simp: space_pair_measure)
3.145 +    with X.sets_eq_Pow Y.sets_eq_Pow
3.146 +      joint_distribution_Times_le_fst[OF rv, of "{a}" "{b}"]
3.147 +      joint_distribution_Times_le_snd[OF rv, of "{a}" "{b}"]
3.148      have "joint_distribution X Y {x} \<le> distribution Y {b}"
3.149           "joint_distribution X Y {x} \<le> distribution X {a}"
3.150 -      by auto
3.151 +      by (auto simp del: X.sets_eq_Pow Y.sets_eq_Pow)
3.152      with distr show "joint_distribution X Y {x} = 0" by auto
3.153    qed
3.154  qed
3.155 @@ -274,19 +292,21 @@
3.156    and mutual_information_positive_generic:
3.157       "0 \<le> mutual_information b MX MY X Y" (is ?positive)
3.158  proof -
3.159 -  interpret X: finite_prob_space MX "distribution X" using MX by (rule distribution_finite_prob_space)
3.160 -  interpret Y: finite_prob_space MY "distribution Y" using MY by (rule distribution_finite_prob_space)
3.161 -  interpret XY: pair_finite_prob_space MX "distribution X" MY "distribution Y" by default
3.162 -  interpret P: finite_prob_space XY.P "joint_distribution X Y"
3.163 -    using assms by (intro joint_distribution_finite_prob_space)
3.164 +  interpret X: finite_prob_space "MX\<lparr>measure := distribution X\<rparr>"
3.165 +    using MX by (rule distribution_finite_prob_space)
3.166 +  interpret Y: finite_prob_space "MY\<lparr>measure := distribution Y\<rparr>"
3.167 +    using MY by (rule distribution_finite_prob_space)
3.168 +  interpret XY: pair_finite_prob_space "MX\<lparr>measure := distribution X\<rparr>" "MY\<lparr>measure := distribution Y\<rparr>" by default
3.169 +  interpret P: finite_prob_space "XY.P\<lparr>measure := joint_distribution X Y\<rparr>"
3.170 +    using assms by (auto intro!: joint_distribution_finite_prob_space)
3.171
3.172 -  have P_ms: "finite_measure_space XY.P (joint_distribution X Y)" by default
3.173 -  have P_ps: "finite_prob_space XY.P (joint_distribution X Y)" by default
3.174 +  have P_ms: "finite_measure_space (XY.P\<lparr>measure :=joint_distribution X Y\<rparr>)" by default
3.175 +  have P_ps: "finite_prob_space (XY.P\<lparr>measure := joint_distribution X Y\<rparr>)" by default
3.176
3.177    show ?sum
3.178      unfolding Let_def mutual_information_def
3.179      by (subst XY.KL_divergence_eq_finite[OF P_ms finite_variables_absolutely_continuous[OF MX MY]])
3.180 -       (auto simp add: pair_algebra_def setsum_cartesian_product' real_of_pextreal_mult[symmetric])
3.181 +       (auto simp add: space_pair_measure setsum_cartesian_product' real_of_pextreal_mult[symmetric])
3.182
3.183    show ?positive
3.184      using XY.KL_divergence_positive_finite[OF P_ps finite_variables_absolutely_continuous[OF MX MY] b_gt_1]
3.185 @@ -301,12 +321,12 @@
3.186    by (auto simp add: ac_simps intro!: setsum_reindex_cong[OF swap_inj_on])
3.187
3.188  lemma (in information_space) mutual_information_commute_simple:
3.189 -  assumes X: "simple_function X" and Y: "simple_function Y"
3.190 +  assumes X: "simple_function M X" and Y: "simple_function M Y"
3.191    shows "\<I>(X;Y) = \<I>(Y;X)"
3.192    by (intro X Y simple_function_imp_finite_random_variable mutual_information_commute)
3.193
3.194  lemma (in information_space) mutual_information_eq:
3.195 -  assumes "simple_function X" "simple_function Y"
3.196 +  assumes "simple_function M X" "simple_function M Y"
3.197    shows "\<I>(X;Y) = (\<Sum> (x,y) \<in> X  space M \<times> Y  space M.
3.198      real (distribution (\<lambda>x. (X x, Y x)) {(x,y)}) * log b (real (distribution (\<lambda>x. (X x, Y x)) {(x,y)}) /
3.199                                                     (real (distribution X {x}) * real (distribution Y {y}))))"
3.200 @@ -327,7 +347,7 @@
3.201    by (simp cong: distribution_cong image_cong)
3.202
3.203  lemma (in information_space) mutual_information_positive:
3.204 -  assumes "simple_function X" "simple_function Y"
3.205 +  assumes "simple_function M X" "simple_function M Y"
3.206    shows "0 \<le> \<I>(X;Y)"
3.207    using assms by (simp add: mutual_information_positive_generic)
3.208
3.209 @@ -335,13 +355,14 @@
3.210
3.211  abbreviation (in information_space)
3.212    entropy_Pow ("\<H>'(_')") where
3.213 -  "\<H>(X) \<equiv> entropy b \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr> X"
3.214 +  "\<H>(X) \<equiv> entropy b \<lparr> space = Xspace M, sets = Pow (Xspace M), measure = distribution X \<rparr> X"
3.215
3.216  lemma (in information_space) entropy_generic_eq:
3.217    assumes MX: "finite_random_variable MX X"
3.218    shows "entropy b MX X = -(\<Sum> x \<in> space MX. real (distribution X {x}) * log b (real (distribution X {x})))"
3.219  proof -
3.220 -  interpret MX: finite_prob_space MX "distribution X" using MX by (rule distribution_finite_prob_space)
3.221 +  interpret MX: finite_prob_space "MX\<lparr>measure := distribution X\<rparr>"
3.222 +    using MX by (rule distribution_finite_prob_space)
3.223    let "?X x" = "real (distribution X {x})"
3.224    let "?XX x y" = "real (joint_distribution X X {(x, y)})"
3.225    { fix x y
3.226 @@ -353,25 +374,26 @@
3.227    show ?thesis
3.228      unfolding entropy_def mutual_information_generic_eq[OF MX MX]
3.229      unfolding setsum_cartesian_product[symmetric] setsum_negf[symmetric] remove_XX
3.230 -    by (auto simp: setsum_cases MX.finite_space)
3.231 +    using MX.finite_space by (auto simp: setsum_cases)
3.232  qed
3.233
3.234  lemma (in information_space) entropy_eq:
3.235 -  assumes "simple_function X"
3.236 +  assumes "simple_function M X"
3.237    shows "\<H>(X) = -(\<Sum> x \<in> X  space M. real (distribution X {x}) * log b (real (distribution X {x})))"
3.238    using assms by (simp add: entropy_generic_eq)
3.239
3.240  lemma (in information_space) entropy_positive:
3.241 -  "simple_function X \<Longrightarrow> 0 \<le> \<H>(X)"
3.242 +  "simple_function M X \<Longrightarrow> 0 \<le> \<H>(X)"
3.243    unfolding entropy_def by (simp add: mutual_information_positive)
3.244
3.245  lemma (in information_space) entropy_certainty_eq_0:
3.246 -  assumes "simple_function X" and "x \<in> X  space M" and "distribution X {x} = 1"
3.247 +  assumes "simple_function M X" and "x \<in> X  space M" and "distribution X {x} = 1"
3.248    shows "\<H>(X) = 0"
3.249  proof -
3.250 -  interpret X: finite_prob_space "\<lparr> space = X  space M, sets = Pow (X  space M) \<rparr>" "distribution X"
3.251 -    using simple_function_imp_finite_random_variable[OF simple_function X]
3.252 -    by (rule distribution_finite_prob_space)
3.253 +  let ?X = "\<lparr> space = X  space M, sets = Pow (X  space M), measure = distribution X\<rparr>"
3.254 +  note simple_function_imp_finite_random_variable[OF simple_function M X]
3.255 +  from distribution_finite_prob_space[OF this, of "\<lparr> measure = distribution X \<rparr>"]
3.256 +  interpret X: finite_prob_space ?X by simp
3.257    have "distribution X (X  space M - {x}) = distribution X (X  space M) - distribution X {x}"
3.258      using X.measure_compl[of "{x}"] assms by auto
3.259    also have "\<dots> = 0" using X.prob_space assms by auto
3.260 @@ -383,38 +405,39 @@
3.261    hence fi: "\<And> y. y \<in> X  space M \<Longrightarrow> real (distribution X {y}) = (if x = y then 1 else 0)"
3.262      using assms by auto
3.263    have y: "\<And>y. (if x = y then 1 else 0) * log b (if x = y then 1 else 0) = 0" by simp
3.264 -  show ?thesis unfolding entropy_eq[OF simple_function X] by (auto simp: y fi)
3.265 +  show ?thesis unfolding entropy_eq[OF simple_function M X] by (auto simp: y fi)
3.266  qed
3.267
3.268  lemma (in information_space) entropy_le_card_not_0:
3.269 -  assumes "simple_function X"
3.270 +  assumes "simple_function M X"
3.271    shows "\<H>(X) \<le> log b (real (card (X  space M \<inter> {x . distribution X {x} \<noteq> 0})))"
3.272  proof -
3.273    let "?d x" = "distribution X {x}"
3.274    let "?p x" = "real (?d x)"
3.275    have "\<H>(X) = (\<Sum>x\<in>Xspace M. ?p x * log b (1 / ?p x))"
3.276 -    by (auto intro!: setsum_cong simp: entropy_eq[OF simple_function X] setsum_negf[symmetric] log_simps not_less)
3.277 +    by (auto intro!: setsum_cong simp: entropy_eq[OF simple_function M X] setsum_negf[symmetric] log_simps not_less)
3.278    also have "\<dots> \<le> log b (\<Sum>x\<in>Xspace M. ?p x * (1 / ?p x))"
3.279      apply (rule log_setsum')
3.280 -    using not_empty b_gt_1 simple_function X sum_over_space_real_distribution
3.281 +    using not_empty b_gt_1 simple_function M X sum_over_space_real_distribution
3.282      by (auto simp: simple_function_def)
3.283    also have "\<dots> = log b (\<Sum>x\<in>Xspace M. if ?d x \<noteq> 0 then 1 else 0)"
3.284 -    using distribution_finite[OF simple_function X[THEN simple_function_imp_random_variable], simplified]
3.285 +    using distribution_finite[OF simple_function M X[THEN simple_function_imp_random_variable], simplified]
3.286      by (intro arg_cong[where f="\<lambda>X. log b X"] setsum_cong) (auto simp: real_of_pextreal_eq_0)
3.287    finally show ?thesis
3.288 -    using simple_function X by (auto simp: setsum_cases real_eq_of_nat simple_function_def)
3.289 +    using simple_function M X by (auto simp: setsum_cases real_eq_of_nat simple_function_def)
3.290  qed
3.291
3.292  lemma (in information_space) entropy_uniform_max:
3.293 -  assumes "simple_function X"
3.294 +  assumes "simple_function M X"
3.295    assumes "\<And>x y. \<lbrakk> x \<in> X  space M ; y \<in> X  space M \<rbrakk> \<Longrightarrow> distribution X {x} = distribution X {y}"
3.296    shows "\<H>(X) = log b (real (card (X  space M)))"
3.297  proof -
3.298 -  interpret X: finite_prob_space "\<lparr> space = X  space M, sets = Pow (X  space M) \<rparr>" "distribution X"
3.299 -    using simple_function_imp_finite_random_variable[OF simple_function X]
3.300 -    by (rule distribution_finite_prob_space)
3.301 +  let ?X = "\<lparr> space = X  space M, sets = Pow (X  space M), measure = distribution X\<rparr>"
3.302 +  note simple_function_imp_finite_random_variable[OF simple_function M X]
3.303 +  from distribution_finite_prob_space[OF this, of "\<lparr> measure = distribution X \<rparr>"]
3.304 +  interpret X: finite_prob_space ?X by simp
3.305    have card_gt0: "0 < card (X  space M)" unfolding card_gt_0_iff
3.306 -    using simple_function X not_empty by (auto simp: simple_function_def)
3.307 +    using simple_function M X not_empty by (auto simp: simple_function_def)
3.308    { fix x assume "x \<in> X  space M"
3.309      hence "real (distribution X {x}) = 1 / real (card (X  space M))"
3.310      proof (rule X.uniform_prob[simplified])
3.311 @@ -423,18 +446,18 @@
3.312      qed }
3.313    thus ?thesis
3.314      using not_empty X.finite_space b_gt_1 card_gt0
3.315 -    by (simp add: entropy_eq[OF simple_function X] real_eq_of_nat[symmetric] log_simps)
3.316 +    by (simp add: entropy_eq[OF simple_function M X] real_eq_of_nat[symmetric] log_simps)
3.317  qed
3.318
3.319  lemma (in information_space) entropy_le_card:
3.320 -  assumes "simple_function X"
3.321 +  assumes "simple_function M X"
3.322    shows "\<H>(X) \<le> log b (real (card (X  space M)))"
3.323  proof cases
3.324    assume "X  space M \<inter> {x. distribution X {x} \<noteq> 0} = {}"
3.325    then have "\<And>x. x\<in>Xspace M \<Longrightarrow> distribution X {x} = 0" by auto
3.326    moreover
3.327    have "0 < card (Xspace M)"
3.328 -    using simple_function X not_empty
3.329 +    using simple_function M X not_empty
3.330      by (auto simp: card_gt_0_iff simple_function_def)
3.331    then have "log b 1 \<le> log b (real (card (Xspace M)))"
3.332      using b_gt_1 by (intro log_le) auto
3.333 @@ -451,10 +474,10 @@
3.334  qed
3.335
3.336  lemma (in information_space) entropy_commute:
3.337 -  assumes "simple_function X" "simple_function Y"
3.338 +  assumes "simple_function M X" "simple_function M Y"
3.339    shows "\<H>(\<lambda>x. (X x, Y x)) = \<H>(\<lambda>x. (Y x, X x))"
3.340  proof -
3.341 -  have sf: "simple_function (\<lambda>x. (X x, Y x))" "simple_function (\<lambda>x. (Y x, X x))"
3.342 +  have sf: "simple_function M (\<lambda>x. (X x, Y x))" "simple_function M (\<lambda>x. (Y x, X x))"
3.343      using assms by (auto intro: simple_function_Pair)
3.344    have *: "(\<lambda>x. (Y x, X x))space M = (\<lambda>(a,b). (b,a))(\<lambda>x. (X x, Y x))space M"
3.345      by auto
3.346 @@ -466,12 +489,12 @@
3.347  qed
3.348
3.349  lemma (in information_space) entropy_eq_cartesian_product:
3.350 -  assumes "simple_function X" "simple_function Y"
3.351 +  assumes "simple_function M X" "simple_function M Y"
3.352    shows "\<H>(\<lambda>x. (X x, Y x)) = -(\<Sum>x\<in>Xspace M. \<Sum>y\<in>Yspace M.
3.353      real (joint_distribution X Y {(x,y)}) *
3.354      log b (real (joint_distribution X Y {(x,y)})))"
3.355  proof -
3.356 -  have sf: "simple_function (\<lambda>x. (X x, Y x))"
3.357 +  have sf: "simple_function M (\<lambda>x. (X x, Y x))"
3.358      using assms by (auto intro: simple_function_Pair)
3.359    { fix x assume "x\<notin>(\<lambda>x. (X x, Y x))space M"
3.360      then have "(\<lambda>x. (X x, Y x)) - {x} \<inter> space M = {}" by auto
3.361 @@ -485,19 +508,18 @@
3.362  subsection {* Conditional Mutual Information *}
3.363
3.364  definition (in prob_space)
3.365 -  "conditional_mutual_information b M1 M2 M3 X Y Z \<equiv>
3.366 -    mutual_information b M1 (sigma (pair_algebra M2 M3)) X (\<lambda>x. (Y x, Z x)) -
3.367 -    mutual_information b M1 M3 X Z"
3.368 +  "conditional_mutual_information b MX MY MZ X Y Z \<equiv>
3.369 +    mutual_information b MX (MY \<Otimes>\<^isub>M MZ) X (\<lambda>x. (Y x, Z x)) -
3.370 +    mutual_information b MX MZ X Z"
3.371
3.372  abbreviation (in information_space)
3.373    conditional_mutual_information_Pow ("\<I>'( _ ; _ | _ ')") where
3.374    "\<I>(X ; Y | Z) \<equiv> conditional_mutual_information b
3.375 -    \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr>
3.376 -    \<lparr> space = Yspace M, sets = Pow (Yspace M) \<rparr>
3.377 -    \<lparr> space = Zspace M, sets = Pow (Zspace M) \<rparr>
3.378 +    \<lparr> space = Xspace M, sets = Pow (Xspace M), measure = distribution X \<rparr>
3.379 +    \<lparr> space = Yspace M, sets = Pow (Yspace M), measure = distribution Y \<rparr>
3.380 +    \<lparr> space = Zspace M, sets = Pow (Zspace M), measure = distribution Z \<rparr>
3.381      X Y Z"
3.382
3.383 -
3.384  lemma (in information_space) conditional_mutual_information_generic_eq:
3.385    assumes MX: "finite_random_variable MX X"
3.386      and MY: "finite_random_variable MY Y"
3.387 @@ -519,7 +541,7 @@
3.388    note finite_var = MX MY MZ
3.389    note random_var = finite_var[THEN finite_random_variableD]
3.390
3.391 -  note space_simps = space_pair_algebra space_sigma algebra.simps
3.392 +  note space_simps = space_pair_measure space_sigma algebra.simps
3.393
3.394    note YZ = finite_random_variable_pairI[OF finite_var(2,3)]
3.395    note XZ = finite_random_variable_pairI[OF finite_var(1,3)]
3.396 @@ -574,12 +596,12 @@
3.397      unfolding conditional_mutual_information_def
3.398      unfolding mutual_information_generic_eq[OF finite_var(1,3)]
3.399      unfolding mutual_information_generic_eq[OF finite_var(1) YZ]
3.400 -    by (simp add: space_sigma space_pair_algebra setsum_cartesian_product')
3.401 +    by (simp add: space_sigma space_pair_measure setsum_cartesian_product')
3.402    finally show ?thesis by simp
3.403  qed
3.404
3.405  lemma (in information_space) conditional_mutual_information_eq:
3.406 -  assumes "simple_function X" "simple_function Y" "simple_function Z"
3.407 +  assumes "simple_function M X" "simple_function M Y" "simple_function M Z"
3.408    shows "\<I>(X;Y|Z) = (\<Sum>(x, y, z) \<in> Xspace M \<times> Yspace M \<times> Zspace M.
3.409               real (distribution (\<lambda>x. (X x, Y x, Z x)) {(x, y, z)}) *
3.410               log b (real (distribution (\<lambda>x. (X x, Y x, Z x)) {(x, y, z)}) /
3.411 @@ -588,11 +610,11 @@
3.412    by simp
3.413
3.414  lemma (in information_space) conditional_mutual_information_eq_mutual_information:
3.415 -  assumes X: "simple_function X" and Y: "simple_function Y"
3.416 +  assumes X: "simple_function M X" and Y: "simple_function M Y"
3.417    shows "\<I>(X ; Y) = \<I>(X ; Y | (\<lambda>x. ()))"
3.418  proof -
3.419    have [simp]: "(\<lambda>x. ())  space M = {()}" using not_empty by auto
3.420 -  have C: "simple_function (\<lambda>x. ())" by auto
3.421 +  have C: "simple_function M (\<lambda>x. ())" by auto
3.422    show ?thesis
3.423      unfolding conditional_mutual_information_eq[OF X Y C]
3.424      unfolding mutual_information_eq[OF X Y]
3.425 @@ -608,12 +630,13 @@
3.426  lemma (in prob_space) setsum_distribution:
3.427    assumes X: "finite_random_variable MX X" shows "(\<Sum>a\<in>space MX. distribution X {a}) = 1"
3.428    using setsum_joint_distribution[OF assms, of "\<lparr> space = UNIV, sets = Pow UNIV \<rparr>" "\<lambda>x. ()" "{()}"]
3.429 -  using sigma_algebra_Pow[of "UNIV::unit set"] by simp
3.430 +  using sigma_algebra_Pow[of "UNIV::unit set" "()"] by simp
3.431
3.432  lemma (in prob_space) setsum_real_distribution:
3.433 +  fixes MX :: "('c, 'd) measure_space_scheme"
3.434    assumes X: "finite_random_variable MX X" shows "(\<Sum>a\<in>space MX. real (distribution X {a})) = 1"
3.435 -  using setsum_real_joint_distribution[OF assms, of "\<lparr> space = UNIV, sets = Pow UNIV \<rparr>" "\<lambda>x. ()" "{()}"]
3.436 -  using sigma_algebra_Pow[of "UNIV::unit set"] by simp
3.437 +  using setsum_real_joint_distribution[OF assms, of "\<lparr> space = UNIV, sets = Pow UNIV, measure = undefined \<rparr>" "\<lambda>x. ()" "{()}"]
3.438 +  using sigma_algebra_Pow[of "UNIV::unit set" "\<lparr> measure = undefined \<rparr>"] by simp
3.439
3.440  lemma (in information_space) conditional_mutual_information_generic_positive:
3.441    assumes "finite_random_variable MX X" and "finite_random_variable MY Y" and "finite_random_variable MZ Z"
3.442 @@ -633,7 +656,7 @@
3.443
3.444    have split_beta: "\<And>f. split f = (\<lambda>x. f (fst x) (snd x))" by (simp add: fun_eq_iff)
3.445
3.446 -  note space_simps = space_pair_algebra space_sigma algebra.simps
3.447 +  note space_simps = space_pair_measure space_sigma algebra.simps
3.448
3.449    note finite_var = assms
3.450    note YZ = finite_random_variable_pairI[OF finite_var(2,3)]
3.451 @@ -672,7 +695,7 @@
3.452        unfolding setsum_cartesian_product'
3.453        unfolding setsum_commute[of _ "space MY"]
3.454        unfolding setsum_commute[of _ "space MZ"]
3.455 -      by (simp_all add: space_pair_algebra
3.456 +      by (simp_all add: space_pair_measure
3.457          setsum_real_joint_distribution_singleton[OF finite_random_variable MX X YZ]
3.458          setsum_real_joint_distribution_singleton[OF finite_random_variable MY Y finite_var(3)]
3.459          setsum_real_distribution[OF finite_random_variable MZ Z])
3.460 @@ -704,10 +727,9 @@
3.461  qed
3.462
3.463  lemma (in information_space) conditional_mutual_information_positive:
3.464 -  assumes "simple_function X" and "simple_function Y" and "simple_function Z"
3.465 +  assumes "simple_function M X" and "simple_function M Y" and "simple_function M Z"
3.466    shows "0 \<le> \<I>(X;Y|Z)"
3.467 -  using conditional_mutual_information_generic_positive[OF assms[THEN simple_function_imp_finite_random_variable]]
3.468 -  by simp
3.469 +  by (rule conditional_mutual_information_generic_positive[OF assms[THEN simple_function_imp_finite_random_variable]])
3.470
3.471  subsection {* Conditional Entropy *}
3.472
3.473 @@ -717,16 +739,17 @@
3.474  abbreviation (in information_space)
3.475    conditional_entropy_Pow ("\<H>'(_ | _')") where
3.476    "\<H>(X | Y) \<equiv> conditional_entropy b
3.477 -    \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr>
3.478 -    \<lparr> space = Yspace M, sets = Pow (Yspace M) \<rparr> X Y"
3.479 +    \<lparr> space = Xspace M, sets = Pow (Xspace M), measure = distribution X \<rparr>
3.480 +    \<lparr> space = Yspace M, sets = Pow (Yspace M), measure = distribution Y \<rparr> X Y"
3.481
3.482  lemma (in information_space) conditional_entropy_positive:
3.483 -  "simple_function X \<Longrightarrow> simple_function Y \<Longrightarrow> 0 \<le> \<H>(X | Y)"
3.484 +  "simple_function M X \<Longrightarrow> simple_function M Y \<Longrightarrow> 0 \<le> \<H>(X | Y)"
3.485    unfolding conditional_entropy_def by (auto intro!: conditional_mutual_information_positive)
3.486
3.487  lemma (in measure_space) empty_measureI: "A = {} \<Longrightarrow> \<mu> A = 0" by simp
3.488
3.489  lemma (in information_space) conditional_entropy_generic_eq:
3.490 +  fixes MX :: "('c, 'd) measure_space_scheme" and MY :: "('e, 'f) measure_space_scheme"
3.491    assumes MX: "finite_random_variable MX X"
3.492    assumes MZ: "finite_random_variable MZ Z"
3.493    shows "conditional_entropy b MX MZ X Z =
3.494 @@ -743,7 +766,7 @@
3.495    { fix x z have "?XXZ x x z = ?XZ x z"
3.496        unfolding distribution_def by (auto intro!: arg_cong[where f=\<mu>]) }
3.497    note this[simp]
3.498 -  { fix x x' :: 'b and z assume "x' \<noteq> x"
3.499 +  { fix x x' :: 'c and z assume "x' \<noteq> x"
3.500      then have "?XXZ x x' z = 0"
3.501        by (auto simp: distribution_def intro!: arg_cong[where f=\<mu>] empty_measureI) }
3.502    note this[simp]
3.503 @@ -762,7 +785,6 @@
3.504      finally have "(\<Sum>x'\<in>space MX. real (?XXZ x x' z) * ?f x x' z) =
3.505        - real (?XZ x z) * log b (real (?XZ x z) / real (?Z z))" . }
3.506    note * = this
3.507 -
3.508    show ?thesis
3.509      unfolding conditional_entropy_def
3.510      unfolding conditional_mutual_information_generic_eq[OF MX MX MZ]
3.511 @@ -772,7 +794,7 @@
3.512  qed
3.513
3.514  lemma (in information_space) conditional_entropy_eq:
3.515 -  assumes "simple_function X" "simple_function Z"
3.516 +  assumes "simple_function M X" "simple_function M Z"
3.517    shows "\<H>(X | Z) =
3.518       - (\<Sum>(x, z)\<in>X  space M \<times> Z  space M.
3.519           real (joint_distribution X Z {(x, z)}) *
3.520 @@ -781,7 +803,7 @@
3.521    by simp
3.522
3.523  lemma (in information_space) conditional_entropy_eq_ce_with_hypothesis:
3.524 -  assumes X: "simple_function X" and Y: "simple_function Y"
3.525 +  assumes X: "simple_function M X" and Y: "simple_function M Y"
3.526    shows "\<H>(X | Y) =
3.527      -(\<Sum>y\<in>Yspace M. real (distribution Y {y}) *
3.528        (\<Sum>x\<in>Xspace M. real (joint_distribution X Y {(x,y)}) / real (distribution Y {(y)}) *
3.529 @@ -794,7 +816,7 @@
3.530             intro!: setsum_cong)
3.531
3.532  lemma (in information_space) conditional_entropy_eq_cartesian_product:
3.533 -  assumes "simple_function X" "simple_function Y"
3.534 +  assumes "simple_function M X" "simple_function M Y"
3.535    shows "\<H>(X | Y) = -(\<Sum>x\<in>Xspace M. \<Sum>y\<in>Yspace M.
3.536      real (joint_distribution X Y {(x,y)}) *
3.537      log b (real (joint_distribution X Y {(x,y)}) / real (distribution Y {y})))"
3.538 @@ -804,7 +826,7 @@
3.539  subsection {* Equalities *}
3.540
3.541  lemma (in information_space) mutual_information_eq_entropy_conditional_entropy:
3.542 -  assumes X: "simple_function X" and Z: "simple_function Z"
3.543 +  assumes X: "simple_function M X" and Z: "simple_function M Z"
3.544    shows  "\<I>(X ; Z) = \<H>(X) - \<H>(X | Z)"
3.545  proof -
3.546    let "?XZ x z" = "real (joint_distribution X Z {(x, z)})"
3.547 @@ -828,7 +850,7 @@
3.548  qed
3.549
3.550  lemma (in information_space) conditional_entropy_less_eq_entropy:
3.551 -  assumes X: "simple_function X" and Z: "simple_function Z"
3.552 +  assumes X: "simple_function M X" and Z: "simple_function M Z"
3.553    shows "\<H>(X | Z) \<le> \<H>(X)"
3.554  proof -
3.555    have "\<I>(X ; Z) = \<H>(X) - \<H>(X | Z)" using mutual_information_eq_entropy_conditional_entropy[OF assms] .
3.556 @@ -837,7 +859,7 @@
3.557  qed
3.558
3.559  lemma (in information_space) entropy_chain_rule:
3.560 -  assumes X: "simple_function X" and Y: "simple_function Y"
3.561 +  assumes X: "simple_function M X" and Y: "simple_function M Y"
3.562    shows  "\<H>(\<lambda>x. (X x, Y x)) = \<H>(X) + \<H>(Y|X)"
3.563  proof -
3.564    let "?XY x y" = "real (joint_distribution X Y {(x, y)})"
3.565 @@ -976,7 +998,7 @@
3.566  qed
3.567
3.568  lemma (in information_space) entropy_partition:
3.569 -  assumes sf: "simple_function X" "simple_function P"
3.570 +  assumes sf: "simple_function M X" "simple_function M P"
3.571    assumes svi: "subvimage (space M) X P"
3.572    shows "\<H>(X) = \<H>(P) + \<H>(X|P)"
3.573  proof -
3.574 @@ -1026,10 +1048,10 @@
3.575  qed
3.576
3.577  corollary (in information_space) entropy_data_processing:
3.578 -  assumes X: "simple_function X" shows "\<H>(f \<circ> X) \<le> \<H>(X)"
3.579 +  assumes X: "simple_function M X" shows "\<H>(f \<circ> X) \<le> \<H>(X)"
3.580  proof -
3.581    note X
3.582 -  moreover have fX: "simple_function (f \<circ> X)" using X by auto
3.583 +  moreover have fX: "simple_function M (f \<circ> X)" using X by auto
3.584    moreover have "subvimage (space M) X (f \<circ> X)" by auto
3.585    ultimately have "\<H>(X) = \<H>(f\<circ>X) + \<H>(X|f\<circ>X)" by (rule entropy_partition)
3.586    then show "\<H>(f \<circ> X) \<le> \<H>(X)"
3.587 @@ -1037,12 +1059,12 @@
3.588  qed
3.589
3.590  corollary (in information_space) entropy_of_inj:
3.591 -  assumes X: "simple_function X" and inj: "inj_on f (Xspace M)"
3.592 +  assumes X: "simple_function M X" and inj: "inj_on f (Xspace M)"
3.593    shows "\<H>(f \<circ> X) = \<H>(X)"
3.594  proof (rule antisym)
3.595    show "\<H>(f \<circ> X) \<le> \<H>(X)" using entropy_data_processing[OF X] .
3.596  next
3.597 -  have sf: "simple_function (f \<circ> X)"
3.598 +  have sf: "simple_function M (f \<circ> X)"
3.599      using X by auto
3.600    have "\<H>(X) = \<H>(the_inv_into (Xspace M) f \<circ> (f \<circ> X))"
3.601      by (auto intro!: mutual_information_cong simp: entropy_def the_inv_into_f_f[OF inj])

     4.1 --- a/src/HOL/Probability/Lebesgue_Integration.thy	Wed Feb 02 10:35:41 2011 +0100
4.2 +++ b/src/HOL/Probability/Lebesgue_Integration.thy	Wed Feb 02 12:34:45 2011 +0100
4.3 @@ -7,6 +7,7 @@
4.4  begin
4.5
4.6  lemma sums_If_finite:
4.7 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
4.8    assumes finite: "finite {r. P r}"
4.9    shows "(\<lambda>r. if P r then f r else 0) sums (\<Sum>r\<in>{r. P r}. f r)" (is "?F sums _")
4.10  proof cases
4.11 @@ -24,7 +25,8 @@
4.12  qed
4.13
4.14  lemma sums_single:
4.15 -  "(\<lambda>r. if r = i then f r else 0) sums f i"
4.16 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
4.17 +  shows "(\<lambda>r. if r = i then f r else 0) sums f i"
4.18    using sums_If_finite[of "\<lambda>r. r = i" f] by simp
4.19
4.20  section "Simple function"
4.21 @@ -37,12 +39,12 @@
4.22
4.23  *}
4.24
4.25 -definition (in sigma_algebra) "simple_function g \<longleftrightarrow>
4.26 +definition "simple_function M g \<longleftrightarrow>
4.27      finite (g  space M) \<and>
4.28      (\<forall>x \<in> g  space M. g - {x} \<inter> space M \<in> sets M)"
4.29
4.30  lemma (in sigma_algebra) simple_functionD:
4.31 -  assumes "simple_function g"
4.32 +  assumes "simple_function M g"
4.33    shows "finite (g  space M)" and "g - X \<inter> space M \<in> sets M"
4.34  proof -
4.35    show "finite (g  space M)"
4.36 @@ -55,7 +57,7 @@
4.37
4.38  lemma (in sigma_algebra) simple_function_indicator_representation:
4.39    fixes f ::"'a \<Rightarrow> pextreal"
4.40 -  assumes f: "simple_function f" and x: "x \<in> space M"
4.41 +  assumes f: "simple_function M f" and x: "x \<in> space M"
4.42    shows "f x = (\<Sum>y \<in> f  space M. y * indicator (f - {y} \<inter> space M) x)"
4.43    (is "?l = ?r")
4.44  proof -
4.45 @@ -69,7 +71,7 @@
4.46  qed
4.47
4.48  lemma (in measure_space) simple_function_notspace:
4.49 -  "simple_function (\<lambda>x. h x * indicator (- space M) x::pextreal)" (is "simple_function ?h")
4.50 +  "simple_function M (\<lambda>x. h x * indicator (- space M) x::pextreal)" (is "simple_function M ?h")
4.51  proof -
4.52    have "?h  space M \<subseteq> {0}" unfolding indicator_def by auto
4.53    hence [simp, intro]: "finite (?h  space M)" by (auto intro: finite_subset)
4.54 @@ -79,7 +81,7 @@
4.55
4.56  lemma (in sigma_algebra) simple_function_cong:
4.57    assumes "\<And>t. t \<in> space M \<Longrightarrow> f t = g t"
4.58 -  shows "simple_function f \<longleftrightarrow> simple_function g"
4.59 +  shows "simple_function M f \<longleftrightarrow> simple_function M g"
4.60  proof -
4.61    have "f  space M = g  space M"
4.62      "\<And>x. f - {x} \<inter> space M = g - {x} \<inter> space M"
4.63 @@ -87,15 +89,21 @@
4.64    thus ?thesis unfolding simple_function_def using assms by simp
4.65  qed
4.66
4.67 +lemma (in sigma_algebra) simple_function_cong_algebra:
4.68 +  assumes "sets N = sets M" "space N = space M"
4.69 +  shows "simple_function M f \<longleftrightarrow> simple_function N f"
4.70 +  unfolding simple_function_def assms ..
4.71 +
4.72  lemma (in sigma_algebra) borel_measurable_simple_function:
4.73 -  assumes "simple_function f"
4.74 +  assumes "simple_function M f"
4.75    shows "f \<in> borel_measurable M"
4.76  proof (rule borel_measurableI)
4.77    fix S
4.78    let ?I = "f  (f - S \<inter> space M)"
4.79    have *: "(\<Union>x\<in>?I. f - {x} \<inter> space M) = f - S \<inter> space M" (is "?U = _") by auto
4.80    have "finite ?I"
4.81 -    using assms unfolding simple_function_def by (auto intro: finite_subset)
4.82 +    using assms unfolding simple_function_def
4.83 +    using finite_subset[of "f  (f - S \<inter> space M)" "f  space M"] by auto
4.84    hence "?U \<in> sets M"
4.85      apply (rule finite_UN)
4.86      using assms unfolding simple_function_def by auto
4.87 @@ -105,17 +113,17 @@
4.88  lemma (in sigma_algebra) simple_function_borel_measurable:
4.89    fixes f :: "'a \<Rightarrow> 'x::t2_space"
4.90    assumes "f \<in> borel_measurable M" and "finite (f  space M)"
4.91 -  shows "simple_function f"
4.92 +  shows "simple_function M f"
4.93    using assms unfolding simple_function_def
4.94    by (auto intro: borel_measurable_vimage)
4.95
4.96  lemma (in sigma_algebra) simple_function_const[intro, simp]:
4.97 -  "simple_function (\<lambda>x. c)"
4.98 +  "simple_function M (\<lambda>x. c)"
4.99    by (auto intro: finite_subset simp: simple_function_def)
4.100
4.101  lemma (in sigma_algebra) simple_function_compose[intro, simp]:
4.102 -  assumes "simple_function f"
4.103 -  shows "simple_function (g \<circ> f)"
4.104 +  assumes "simple_function M f"
4.105 +  shows "simple_function M (g \<circ> f)"
4.106    unfolding simple_function_def
4.107  proof safe
4.108    show "finite ((g \<circ> f)  space M)"
4.109 @@ -132,7 +140,7 @@
4.110
4.111  lemma (in sigma_algebra) simple_function_indicator[intro, simp]:
4.112    assumes "A \<in> sets M"
4.113 -  shows "simple_function (indicator A)"
4.114 +  shows "simple_function M (indicator A)"
4.115  proof -
4.116    have "indicator A  space M \<subseteq> {0, 1}" (is "?S \<subseteq> _")
4.117      by (auto simp: indicator_def)
4.118 @@ -143,9 +151,9 @@
4.119  qed
4.120
4.121  lemma (in sigma_algebra) simple_function_Pair[intro, simp]:
4.122 -  assumes "simple_function f"
4.123 -  assumes "simple_function g"
4.124 -  shows "simple_function (\<lambda>x. (f x, g x))" (is "simple_function ?p")
4.125 +  assumes "simple_function M f"
4.126 +  assumes "simple_function M g"
4.127 +  shows "simple_function M (\<lambda>x. (f x, g x))" (is "simple_function M ?p")
4.128    unfolding simple_function_def
4.129  proof safe
4.130    show "finite (?p  space M)"
4.131 @@ -161,16 +169,16 @@
4.132  qed
4.133
4.134  lemma (in sigma_algebra) simple_function_compose1:
4.135 -  assumes "simple_function f"
4.136 -  shows "simple_function (\<lambda>x. g (f x))"
4.137 +  assumes "simple_function M f"
4.138 +  shows "simple_function M (\<lambda>x. g (f x))"
4.139    using simple_function_compose[OF assms, of g]
4.141
4.142  lemma (in sigma_algebra) simple_function_compose2:
4.143 -  assumes "simple_function f" and "simple_function g"
4.144 -  shows "simple_function (\<lambda>x. h (f x) (g x))"
4.145 +  assumes "simple_function M f" and "simple_function M g"
4.146 +  shows "simple_function M (\<lambda>x. h (f x) (g x))"
4.147  proof -
4.148 -  have "simple_function ((\<lambda>(x, y). h x y) \<circ> (\<lambda>x. (f x, g x)))"
4.149 +  have "simple_function M ((\<lambda>(x, y). h x y) \<circ> (\<lambda>x. (f x, g x)))"
4.150      using assms by auto
4.151    thus ?thesis by (simp_all add: comp_def)
4.152  qed
4.153 @@ -183,14 +191,14 @@
4.154    and simple_function_inverse[intro, simp] = simple_function_compose[where g="inverse"]
4.155
4.156  lemma (in sigma_algebra) simple_function_setsum[intro, simp]:
4.157 -  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function (f i)"
4.158 -  shows "simple_function (\<lambda>x. \<Sum>i\<in>P. f i x)"
4.159 +  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function M (f i)"
4.160 +  shows "simple_function M (\<lambda>x. \<Sum>i\<in>P. f i x)"
4.161  proof cases
4.162    assume "finite P" from this assms show ?thesis by induct auto
4.163  qed auto
4.164
4.165  lemma (in sigma_algebra) simple_function_le_measurable:
4.166 -  assumes "simple_function f" "simple_function g"
4.167 +  assumes "simple_function M f" "simple_function M g"
4.168    shows "{x \<in> space M. f x \<le> g x} \<in> sets M"
4.169  proof -
4.170    have *: "{x \<in> space M. f x \<le> g x} =
4.171 @@ -214,7 +222,7 @@
4.172  lemma (in sigma_algebra) borel_measurable_implies_simple_function_sequence:
4.173    fixes u :: "'a \<Rightarrow> pextreal"
4.174    assumes u: "u \<in> borel_measurable M"
4.175 -  shows "\<exists>f. (\<forall>i. simple_function (f i) \<and> (\<forall>x\<in>space M. f i x \<noteq> \<omega>)) \<and> f \<up> u"
4.176 +  shows "\<exists>f. (\<forall>i. simple_function M (f i) \<and> (\<forall>x\<in>space M. f i x \<noteq> \<omega>)) \<and> f \<up> u"
4.177  proof -
4.178    have "\<exists>f. \<forall>x j. (of_nat j \<le> u x \<longrightarrow> f x j = j*2^j) \<and>
4.179      (u x < of_nat j \<longrightarrow> of_nat (f x j) \<le> u x * 2^j \<and> u x * 2^j < of_nat (Suc (f x j)))"
4.180 @@ -406,10 +414,10 @@
4.181  lemma (in sigma_algebra) borel_measurable_implies_simple_function_sequence':
4.182    fixes u :: "'a \<Rightarrow> pextreal"
4.183    assumes "u \<in> borel_measurable M"
4.184 -  obtains (x) f where "f \<up> u" "\<And>i. simple_function (f i)" "\<And>i. \<omega>\<notin>f ispace M"
4.185 +  obtains (x) f where "f \<up> u" "\<And>i. simple_function M (f i)" "\<And>i. \<omega>\<notin>f ispace M"
4.186  proof -
4.187    from borel_measurable_implies_simple_function_sequence[OF assms]
4.188 -  obtain f where x: "\<And>i. simple_function (f i)" "f \<up> u"
4.189 +  obtain f where x: "\<And>i. simple_function M (f i)" "f \<up> u"
4.190      and fin: "\<And>i. \<And>x. x\<in>space M \<Longrightarrow> f i x \<noteq> \<omega>" by auto
4.191    { fix i from fin[of _ i] have "\<omega> \<notin> f ispace M" by fastsimp }
4.192    with x show thesis by (auto intro!: that[of f])
4.193 @@ -417,7 +425,7 @@
4.194
4.195  lemma (in sigma_algebra) simple_function_eq_borel_measurable:
4.196    fixes f :: "'a \<Rightarrow> pextreal"
4.197 -  shows "simple_function f \<longleftrightarrow>
4.198 +  shows "simple_function M f \<longleftrightarrow>
4.199      finite (fspace M) \<and> f \<in> borel_measurable M"
4.200    using simple_function_borel_measurable[of f]
4.201      borel_measurable_simple_function[of f]
4.202 @@ -425,8 +433,8 @@
4.203
4.204  lemma (in measure_space) simple_function_restricted:
4.205    fixes f :: "'a \<Rightarrow> pextreal" assumes "A \<in> sets M"
4.206 -  shows "sigma_algebra.simple_function (restricted_space A) f \<longleftrightarrow> simple_function (\<lambda>x. f x * indicator A x)"
4.207 -    (is "sigma_algebra.simple_function ?R f \<longleftrightarrow> simple_function ?f")
4.208 +  shows "simple_function (restricted_space A) f \<longleftrightarrow> simple_function M (\<lambda>x. f x * indicator A x)"
4.209 +    (is "simple_function ?R f \<longleftrightarrow> simple_function M ?f")
4.210  proof -
4.211    interpret R: sigma_algebra ?R by (rule restricted_sigma_algebra[OF A \<in> sets M])
4.212    have "finite (fA) \<longleftrightarrow> finite (?fspace M)"
4.213 @@ -463,29 +471,26 @@
4.214  qed
4.215
4.216  lemma (in sigma_algebra) simple_function_subalgebra:
4.217 -  assumes "sigma_algebra.simple_function N f"
4.218 -  and N_subalgebra: "sets N \<subseteq> sets M" "space N = space M" "sigma_algebra N"
4.219 -  shows "simple_function f"
4.220 -  using assms
4.221 -  unfolding simple_function_def
4.222 -  unfolding sigma_algebra.simple_function_def[OF N_subalgebra(3)]
4.223 -  by auto
4.224 +  assumes "simple_function N f"
4.225 +  and N_subalgebra: "sets N \<subseteq> sets M" "space N = space M"
4.226 +  shows "simple_function M f"
4.227 +  using assms unfolding simple_function_def by auto
4.228
4.229  lemma (in measure_space) simple_function_vimage:
4.230    assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
4.231 -    and f: "sigma_algebra.simple_function M' f"
4.232 -  shows "simple_function (\<lambda>x. f (T x))"
4.233 +    and f: "simple_function M' f"
4.234 +  shows "simple_function M (\<lambda>x. f (T x))"
4.235  proof (intro simple_function_def[THEN iffD2] conjI ballI)
4.236    interpret T: sigma_algebra M' by fact
4.237    have "(\<lambda>x. f (T x))  space M \<subseteq> f  space M'"
4.238      using T unfolding measurable_def by auto
4.239    then show "finite ((\<lambda>x. f (T x))  space M)"
4.240 -    using f unfolding T.simple_function_def by (auto intro: finite_subset)
4.241 +    using f unfolding simple_function_def by (auto intro: finite_subset)
4.242    fix i assume i: "i \<in> (\<lambda>x. f (T x))  space M"
4.243    then have "i \<in> f  space M'"
4.244      using T unfolding measurable_def by auto
4.245    then have "f - {i} \<inter> space M' \<in> sets M'"
4.246 -    using f unfolding T.simple_function_def by auto
4.247 +    using f unfolding simple_function_def by auto
4.248    then have "T - (f - {i} \<inter> space M') \<inter> space M \<in> sets M"
4.249      using T unfolding measurable_def by auto
4.250    also have "T - (f - {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) - {i} \<inter> space M"
4.251 @@ -495,12 +500,18 @@
4.252
4.253  section "Simple integral"
4.254
4.255 -definition (in measure_space) simple_integral (binder "\<integral>\<^isup>S " 10) where
4.256 -  "simple_integral f = (\<Sum>x \<in> f  space M. x * \<mu> (f - {x} \<inter> space M))"
4.257 +definition simple_integral_def:
4.258 +  "integral\<^isup>S M f = (\<Sum>x \<in> f  space M. x * measure M (f - {x} \<inter> space M))"
4.259 +
4.260 +syntax
4.261 +  "_simple_integral" :: "'a \<Rightarrow> ('a \<Rightarrow> pextreal) \<Rightarrow> ('a, 'b) measure_space_scheme \<Rightarrow> pextreal" ("\<integral>\<^isup>S _. _ \<partial>_" [60,61] 110)
4.262 +
4.263 +translations
4.264 +  "\<integral>\<^isup>S x. f \<partial>M" == "CONST integral\<^isup>S M (%x. f)"
4.265
4.266  lemma (in measure_space) simple_integral_cong:
4.267    assumes "\<And>t. t \<in> space M \<Longrightarrow> f t = g t"
4.268 -  shows "simple_integral f = simple_integral g"
4.269 +  shows "integral\<^isup>S M f = integral\<^isup>S M g"
4.270  proof -
4.271    have "f  space M = g  space M"
4.272      "\<And>x. f - {x} \<inter> space M = g - {x} \<inter> space M"
4.273 @@ -509,18 +520,18 @@
4.274  qed
4.275
4.276  lemma (in measure_space) simple_integral_cong_measure:
4.277 -  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = \<mu> A" and "simple_function f"
4.278 -  shows "measure_space.simple_integral M \<nu> f = simple_integral f"
4.279 +  assumes "\<And>A. A \<in> sets M \<Longrightarrow> measure N A = \<mu> A" "sets N = sets M" "space N = space M"
4.280 +    and "simple_function M f"
4.281 +  shows "integral\<^isup>S N f = integral\<^isup>S M f"
4.282  proof -
4.283 -  interpret v: measure_space M \<nu>
4.284 -    by (rule measure_space_cong) fact
4.285 -  from simple_functionD[OF simple_function f] assms show ?thesis
4.286 -    unfolding simple_integral_def v.simple_integral_def
4.287 -    by (auto intro!: setsum_cong)
4.288 +  interpret v: measure_space N
4.289 +    by (rule measure_space_cong) fact+
4.290 +  from simple_functionD[OF simple_function M f] assms show ?thesis
4.291 +    by (auto intro!: setsum_cong simp: simple_integral_def)
4.292  qed
4.293
4.294  lemma (in measure_space) simple_integral_const[simp]:
4.295 -  "(\<integral>\<^isup>Sx. c) = c * \<mu> (space M)"
4.296 +  "(\<integral>\<^isup>Sx. c \<partial>M) = c * \<mu> (space M)"
4.297  proof (cases "space M = {}")
4.298    case True thus ?thesis unfolding simple_integral_def by simp
4.299  next
4.300 @@ -529,8 +540,8 @@
4.301  qed
4.302
4.303  lemma (in measure_space) simple_function_partition:
4.304 -  assumes "simple_function f" and "simple_function g"
4.305 -  shows "simple_integral f = (\<Sum>A\<in>(\<lambda>x. f - {f x} \<inter> g - {g x} \<inter> space M)  space M. the_elem (fA) * \<mu> A)"
4.306 +  assumes "simple_function M f" and "simple_function M g"
4.307 +  shows "integral\<^isup>S M f = (\<Sum>A\<in>(\<lambda>x. f - {f x} \<inter> g - {g x} \<inter> space M)  space M. the_elem (fA) * \<mu> A)"
4.308      (is "_ = setsum _ (?p  space M)")
4.309  proof-
4.310    let "?sub x" = "?p  (f - {x} \<inter> space M)"
4.311 @@ -561,7 +572,7 @@
4.312      ultimately
4.313      have "\<mu> (f - {f x} \<inter> space M) = setsum (\<mu>) (?sub (f x))"
4.314        by (subst measure_finitely_additive) auto }
4.315 -  hence "simple_integral f = (\<Sum>(x,A)\<in>?SIGMA. x * \<mu> A)"
4.316 +  hence "integral\<^isup>S M f = (\<Sum>(x,A)\<in>?SIGMA. x * \<mu> A)"
4.317      unfolding simple_integral_def
4.318      by (subst setsum_Sigma[symmetric],
4.319         auto intro!: setsum_cong simp: setsum_right_distrib[symmetric])
4.320 @@ -584,8 +595,8 @@
4.321  qed
4.322
4.324 -  assumes "simple_function f" and "simple_function g"
4.325 -  shows "(\<integral>\<^isup>Sx. f x + g x) = simple_integral f + simple_integral g"
4.326 +  assumes "simple_function M f" and "simple_function M g"
4.327 +  shows "(\<integral>\<^isup>Sx. f x + g x \<partial>M) = integral\<^isup>S M f + integral\<^isup>S M g"
4.328  proof -
4.329    { fix x let ?S = "g - {g x} \<inter> f - {f x} \<inter> space M"
4.330      assume "x \<in> space M"
4.331 @@ -595,15 +606,15 @@
4.332    thus ?thesis
4.333      unfolding
4.334        simple_function_partition[OF simple_function_add[OF assms] simple_function_Pair[OF assms]]
4.335 -      simple_function_partition[OF simple_function f simple_function g]
4.336 -      simple_function_partition[OF simple_function g simple_function f]
4.337 +      simple_function_partition[OF simple_function M f simple_function M g]
4.338 +      simple_function_partition[OF simple_function M g simple_function M f]
4.339      apply (subst (3) Int_commute)
4.341  qed
4.342
4.343  lemma (in measure_space) simple_integral_setsum[simp]:
4.344 -  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function (f i)"
4.345 -  shows "(\<integral>\<^isup>Sx. \<Sum>i\<in>P. f i x) = (\<Sum>i\<in>P. simple_integral (f i))"
4.346 +  assumes "\<And>i. i \<in> P \<Longrightarrow> simple_function M (f i)"
4.347 +  shows "(\<integral>\<^isup>Sx. (\<Sum>i\<in>P. f i x) \<partial>M) = (\<Sum>i\<in>P. integral\<^isup>S M (f i))"
4.348  proof cases
4.349    assume "finite P"
4.350    from this assms show ?thesis
4.351 @@ -611,8 +622,8 @@
4.352  qed auto
4.353
4.354  lemma (in measure_space) simple_integral_mult[simp]:
4.355 -  assumes "simple_function f"
4.356 -  shows "(\<integral>\<^isup>Sx. c * f x) = c * simple_integral f"
4.357 +  assumes "simple_function M f"
4.358 +  shows "(\<integral>\<^isup>Sx. c * f x \<partial>M) = c * integral\<^isup>S M f"
4.359  proof -
4.360    note mult = simple_function_mult[OF simple_function_const[of c] assms]
4.361    { fix x let ?S = "f - {f x} \<inter> (\<lambda>x. c * f x) - {c * f x} \<inter> space M"
4.362 @@ -626,8 +637,8 @@
4.363  qed
4.364
4.365  lemma (in sigma_algebra) simple_function_If:
4.366 -  assumes sf: "simple_function f" "simple_function g" and A: "A \<in> sets M"
4.367 -  shows "simple_function (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function ?IF")
4.368 +  assumes sf: "simple_function M f" "simple_function M g" and A: "A \<in> sets M"
4.369 +  shows "simple_function M (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function M ?IF")
4.370  proof -
4.371    def F \<equiv> "\<lambda>x. f - {x} \<inter> space M" and G \<equiv> "\<lambda>x. g - {x} \<inter> space M"
4.372    show ?thesis unfolding simple_function_def
4.373 @@ -648,17 +659,17 @@
4.374  qed
4.375
4.376  lemma (in measure_space) simple_integral_mono_AE:
4.377 -  assumes "simple_function f" and "simple_function g"
4.378 +  assumes "simple_function M f" and "simple_function M g"
4.379    and mono: "AE x. f x \<le> g x"
4.380 -  shows "simple_integral f \<le> simple_integral g"
4.381 +  shows "integral\<^isup>S M f \<le> integral\<^isup>S M g"
4.382  proof -
4.383    let "?S x" = "(g - {g x} \<inter> space M) \<inter> (f - {f x} \<inter> space M)"
4.384    have *: "\<And>x. g - {g x} \<inter> f - {f x} \<inter> space M = ?S x"
4.385      "\<And>x. f - {f x} \<inter> g - {g x} \<inter> space M = ?S x" by auto
4.386    show ?thesis
4.387      unfolding *
4.388 -      simple_function_partition[OF simple_function f simple_function g]
4.389 -      simple_function_partition[OF simple_function g simple_function f]
4.390 +      simple_function_partition[OF simple_function M f simple_function M g]
4.391 +      simple_function_partition[OF simple_function M g simple_function M f]
4.392    proof (safe intro!: setsum_mono)
4.393      fix x assume "x \<in> space M"
4.394      then have *: "f  ?S x = {f x}" "g  ?S x = {g x}" by auto
4.395 @@ -680,23 +691,23 @@
4.396  qed
4.397
4.398  lemma (in measure_space) simple_integral_mono:
4.399 -  assumes "simple_function f" and "simple_function g"
4.400 +  assumes "simple_function M f" and "simple_function M g"
4.401    and mono: "\<And> x. x \<in> space M \<Longrightarrow> f x \<le> g x"
4.402 -  shows "simple_integral f \<le> simple_integral g"
4.403 +  shows "integral\<^isup>S M f \<le> integral\<^isup>S M g"
4.404  proof (rule simple_integral_mono_AE[OF assms(1, 2)])
4.405    show "AE x. f x \<le> g x"
4.406      using mono by (rule AE_cong) auto
4.407  qed
4.408
4.409  lemma (in measure_space) simple_integral_cong_AE:
4.410 -  assumes "simple_function f" "simple_function g" and "AE x. f x = g x"
4.411 -  shows "simple_integral f = simple_integral g"
4.412 +  assumes "simple_function M f" "simple_function M g" and "AE x. f x = g x"
4.413 +  shows "integral\<^isup>S M f = integral\<^isup>S M g"
4.414    using assms by (auto simp: eq_iff intro!: simple_integral_mono_AE)
4.415
4.416  lemma (in measure_space) simple_integral_cong':
4.417 -  assumes sf: "simple_function f" "simple_function g"
4.418 +  assumes sf: "simple_function M f" "simple_function M g"
4.419    and mea: "\<mu> {x\<in>space M. f x \<noteq> g x} = 0"
4.420 -  shows "simple_integral f = simple_integral g"
4.421 +  shows "integral\<^isup>S M f = integral\<^isup>S M g"
4.422  proof (intro simple_integral_cong_AE sf AE_I)
4.423    show "\<mu> {x\<in>space M. f x \<noteq> g x} = 0" by fact
4.424    show "{x \<in> space M. f x \<noteq> g x} \<in> sets M"
4.425 @@ -705,12 +716,12 @@
4.426
4.427  lemma (in measure_space) simple_integral_indicator:
4.428    assumes "A \<in> sets M"
4.429 -  assumes "simple_function f"
4.430 -  shows "(\<integral>\<^isup>Sx. f x * indicator A x) =
4.431 +  assumes "simple_function M f"
4.432 +  shows "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) =
4.433      (\<Sum>x \<in> f  space M. x * \<mu> (f - {x} \<inter> space M \<inter> A))"
4.434  proof cases
4.435    assume "A = space M"
4.436 -  moreover hence "(\<integral>\<^isup>Sx. f x * indicator A x) = simple_integral f"
4.437 +  moreover hence "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) = integral\<^isup>S M f"
4.438      by (auto intro!: simple_integral_cong)
4.439    moreover have "\<And>X. X \<inter> space M \<inter> space M = X \<inter> space M" by auto
4.440    ultimately show ?thesis by (simp add: simple_integral_def)
4.441 @@ -726,7 +737,7 @@
4.442    next
4.443      show "0 \<in> ?I  space M" using x by (auto intro!: image_eqI[of _ _ x])
4.444    qed
4.445 -  have *: "(\<integral>\<^isup>Sx. f x * indicator A x) =
4.446 +  have *: "(\<integral>\<^isup>Sx. f x * indicator A x \<partial>M) =
4.447      (\<Sum>x \<in> f  space M \<union> {0}. x * \<mu> (f - {x} \<inter> space M \<inter> A))"
4.448      unfolding simple_integral_def I
4.449    proof (rule setsum_mono_zero_cong_left)
4.450 @@ -752,7 +763,7 @@
4.451
4.452  lemma (in measure_space) simple_integral_indicator_only[simp]:
4.453    assumes "A \<in> sets M"
4.454 -  shows "simple_integral (indicator A) = \<mu> A"
4.455 +  shows "integral\<^isup>S M (indicator A) = \<mu> A"
4.456  proof cases
4.457    assume "space M = {}" hence "A = {}" using sets_into_space[OF assms] by auto
4.458    thus ?thesis unfolding simple_integral_def using space M = {} by auto
4.459 @@ -765,22 +776,22 @@
4.460  qed
4.461
4.462  lemma (in measure_space) simple_integral_null_set:
4.463 -  assumes "simple_function u" "N \<in> null_sets"
4.464 -  shows "(\<integral>\<^isup>Sx. u x * indicator N x) = 0"
4.465 +  assumes "simple_function M u" "N \<in> null_sets"
4.466 +  shows "(\<integral>\<^isup>Sx. u x * indicator N x \<partial>M) = 0"
4.467  proof -
4.468    have "AE x. indicator N x = (0 :: pextreal)"
4.469      using N \<in> null_sets by (auto simp: indicator_def intro!: AE_I[of _ N])
4.470 -  then have "(\<integral>\<^isup>Sx. u x * indicator N x) = (\<integral>\<^isup>Sx. 0)"
4.471 +  then have "(\<integral>\<^isup>Sx. u x * indicator N x \<partial>M) = (\<integral>\<^isup>Sx. 0 \<partial>M)"
4.472      using assms by (intro simple_integral_cong_AE) (auto intro!: AE_disjI2)
4.473    then show ?thesis by simp
4.474  qed
4.475
4.476  lemma (in measure_space) simple_integral_cong_AE_mult_indicator:
4.477 -  assumes sf: "simple_function f" and eq: "AE x. x \<in> S" and "S \<in> sets M"
4.478 -  shows "simple_integral f = (\<integral>\<^isup>Sx. f x * indicator S x)"
4.479 +  assumes sf: "simple_function M f" and eq: "AE x. x \<in> S" and "S \<in> sets M"
4.480 +  shows "integral\<^isup>S M f = (\<integral>\<^isup>Sx. f x * indicator S x \<partial>M)"
4.481  proof (rule simple_integral_cong_AE)
4.482 -  show "simple_function f" by fact
4.483 -  show "simple_function (\<lambda>x. f x * indicator S x)"
4.484 +  show "simple_function M f" by fact
4.485 +  show "simple_function M (\<lambda>x. f x * indicator S x)"
4.486      using sf S \<in> sets M by auto
4.487    from eq show "AE x. f x = f x * indicator S x"
4.488      by (rule AE_mp) simp
4.489 @@ -788,10 +799,9 @@
4.490
4.491  lemma (in measure_space) simple_integral_restricted:
4.492    assumes "A \<in> sets M"
4.493 -  assumes sf: "simple_function (\<lambda>x. f x * indicator A x)"
4.494 -  shows "measure_space.simple_integral (restricted_space A) \<mu> f = (\<integral>\<^isup>Sx. f x * indicator A x)"
4.495 -    (is "_ = simple_integral ?f")
4.496 -  unfolding measure_space.simple_integral_def[OF restricted_measure_space[OF A \<in> sets M]]
4.497 +  assumes sf: "simple_function M (\<lambda>x. f x * indicator A x)"
4.498 +  shows "integral\<^isup>S (restricted_space A) f = (\<integral>\<^isup>Sx. f x * indicator A x \<partial>M)"
4.499 +    (is "_ = integral\<^isup>S M ?f")
4.500    unfolding simple_integral_def
4.501  proof (simp, safe intro!: setsum_mono_zero_cong_left)
4.502    from sf show "finite (?f  space M)"
4.503 @@ -816,64 +826,71 @@
4.504  qed
4.505
4.506  lemma (in measure_space) simple_integral_subalgebra:
4.507 -  assumes N: "measure_space N \<mu>" and [simp]: "space N = space M"
4.508 -  shows "measure_space.simple_integral N \<mu> = simple_integral"
4.509 -  unfolding simple_integral_def_raw
4.510 -  unfolding measure_space.simple_integral_def_raw[OF N] by simp
4.511 +  assumes N: "measure_space N" and [simp]: "space N = space M" "measure N = measure M"
4.512 +  shows "integral\<^isup>S N = integral\<^isup>S M"
4.513 +  unfolding simple_integral_def_raw by simp
4.514
4.515  lemma (in measure_space) simple_integral_vimage:
4.516    assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
4.517 -    and f: "sigma_algebra.simple_function M' f"
4.518 -  shows "measure_space.simple_integral M' (\<lambda>A. \<mu> (T - A \<inter> space M)) f = (\<integral>\<^isup>S x. f (T x))"
4.519 -    (is "measure_space.simple_integral M' ?nu f = _")
4.520 +    and f: "simple_function M' f"
4.521 +    and \<nu>: "\<And>A. A \<in> sets M' \<Longrightarrow> measure M' A = \<mu> (T - A \<inter> space M)"
4.522 +  shows "integral\<^isup>S M' f = (\<integral>\<^isup>S x. f (T x) \<partial>M)"
4.523  proof -
4.524 -  interpret T: measure_space M' ?nu using T by (rule measure_space_vimage) auto
4.525 -  show "T.simple_integral f = (\<integral>\<^isup>S x. f (T x))"
4.526 -    unfolding simple_integral_def T.simple_integral_def
4.527 +  interpret T: measure_space M' using \<nu> by (rule measure_space_vimage[OF T])
4.528 +  show "integral\<^isup>S M' f = (\<integral>\<^isup>S x. f (T x) \<partial>M)"
4.529 +    unfolding simple_integral_def
4.530    proof (intro setsum_mono_zero_cong_right ballI)
4.531      show "(\<lambda>x. f (T x))  space M \<subseteq> f  space M'"
4.532        using T unfolding measurable_def by auto
4.533      show "finite (f  space M')"
4.534 -      using f unfolding T.simple_function_def by auto
4.535 +      using f unfolding simple_function_def by auto
4.536    next
4.537      fix i assume "i \<in> f  space M' - (\<lambda>x. f (T x))  space M"
4.538      then have "T - (f - {i} \<inter> space M') \<inter> space M = {}" by (auto simp: image_iff)
4.539 -    then show "i * \<mu> (T - (f - {i} \<inter> space M') \<inter> space M) = 0" by simp
4.540 +    with f[THEN T.simple_functionD(2), THEN \<nu>]
4.541 +    show "i * T.\<mu> (f - {i} \<inter> space M') = 0" by simp
4.542    next
4.543      fix i assume "i \<in> (\<lambda>x. f (T x))  space M"
4.544      then have "T - (f - {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) - {i} \<inter> space M"
4.545        using T unfolding measurable_def by auto
4.546 -    then show "i * \<mu> (T - (f - {i} \<inter> space M') \<inter> space M) = i * \<mu> ((\<lambda>x. f (T x)) - {i} \<inter> space M)"
4.547 +    with f[THEN T.simple_functionD(2), THEN \<nu>]
4.548 +    show "i * T.\<mu> (f - {i} \<inter> space M') = i * \<mu> ((\<lambda>x. f (T x)) - {i} \<inter> space M)"
4.549        by auto
4.550    qed
4.551  qed
4.552
4.553 -section "Continuous posititve integration"
4.554 +section "Continuous positive integration"
4.555 +
4.556 +definition positive_integral_def:
4.557 +  "integral\<^isup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> f}. integral\<^isup>S M g)"
4.558
4.559 -definition (in measure_space) positive_integral (binder "\<integral>\<^isup>+ " 10) where
4.560 -  "positive_integral f = SUPR {g. simple_function g \<and> g \<le> f} simple_integral"
4.561 +syntax
4.562 +  "_positive_integral" :: "'a \<Rightarrow> ('a \<Rightarrow> pextreal) \<Rightarrow> ('a, 'b) measure_space_scheme \<Rightarrow> pextreal" ("\<integral>\<^isup>+ _. _ \<partial>_" [60,61] 110)
4.563 +
4.564 +translations
4.565 +  "\<integral>\<^isup>+ x. f \<partial>M" == "CONST integral\<^isup>P M (%x. f)"
4.566
4.567 -lemma (in measure_space) positive_integral_alt:
4.568 -  "positive_integral f =
4.569 -    (SUPR {g. simple_function g \<and> g \<le> f \<and> \<omega> \<notin> gspace M} simple_integral)" (is "_ = ?alt")
4.570 +lemma (in measure_space) positive_integral_alt: "integral\<^isup>P M f =
4.571 +    (SUP g : {g. simple_function M g \<and> g \<le> f \<and> \<omega> \<notin> gspace M}. integral\<^isup>S M g)"
4.572 +  (is "_ = ?alt")
4.573  proof (rule antisym SUP_leI)
4.574 -  show "positive_integral f \<le> ?alt" unfolding positive_integral_def
4.575 +  show "integral\<^isup>P M f \<le> ?alt" unfolding positive_integral_def
4.576    proof (safe intro!: SUP_leI)
4.577 -    fix g assume g: "simple_function g" "g \<le> f"
4.578 +    fix g assume g: "simple_function M g" "g \<le> f"
4.579      let ?G = "g - {\<omega>} \<inter> space M"
4.580 -    show "simple_integral g \<le>
4.581 -      SUPR {g. simple_function g \<and> g \<le> f \<and> \<omega> \<notin> g  space M} simple_integral"
4.582 -      (is "simple_integral g \<le> SUPR ?A simple_integral")
4.583 +    show "integral\<^isup>S M g \<le>
4.584 +      (SUP h : {i. simple_function M i \<and> i \<le> f \<and> \<omega> \<notin> i  space M}. integral\<^isup>S M h)"
4.585 +      (is "integral\<^isup>S M g \<le> SUPR ?A _")
4.586      proof cases
4.587        let ?g = "\<lambda>x. indicator (space M - ?G) x * g x"
4.588 -      have g': "simple_function ?g"
4.589 +      have g': "simple_function M ?g"
4.590          using g by (auto intro: simple_functionD)
4.591        moreover
4.592        assume "\<mu> ?G = 0"
4.593        then have "AE x. g x = ?g x" using g
4.594          by (intro AE_I[where N="?G"])
4.595             (auto intro: simple_functionD simp: indicator_def)
4.596 -      with g(1) g' have "simple_integral g = simple_integral ?g"
4.597 +      with g(1) g' have "integral\<^isup>S M g = integral\<^isup>S M ?g"
4.598          by (rule simple_integral_cong_AE)
4.599        moreover have "?g \<le> g" by (auto simp: le_fun_def indicator_def)
4.600        from this g \<le> f have "?g \<le> f" by (rule order_trans)
4.601 @@ -885,15 +902,15 @@
4.602        then have "?G \<noteq> {}" by auto
4.603        then have "\<omega> \<in> gspace M" by force
4.604        then have "space M \<noteq> {}" by auto
4.605 -      have "SUPR ?A simple_integral = \<omega>"
4.606 +      have "SUPR ?A (integral\<^isup>S M) = \<omega>"
4.607        proof (intro SUP_\<omega>[THEN iffD2] allI impI)
4.608          fix x assume "x < \<omega>"
4.609          then guess n unfolding less_\<omega>_Ex_of_nat .. note n = this
4.610          then have "0 < n" by (intro neq0_conv[THEN iffD1] notI) simp
4.611          let ?g = "\<lambda>x. (of_nat n / (if \<mu> ?G = \<omega> then 1 else \<mu> ?G)) * indicator ?G x"
4.612 -        show "\<exists>i\<in>?A. x < simple_integral i"
4.613 +        show "\<exists>i\<in>?A. x < integral\<^isup>S M i"
4.614          proof (intro bexI impI CollectI conjI)
4.615 -          show "simple_function ?g" using g
4.616 +          show "simple_function M ?g" using g
4.617              by (auto intro!: simple_functionD simple_function_add)
4.618            have "?g \<le> g" by (auto simp: le_fun_def indicator_def)
4.619            from this g(2) show "?g \<le> f" by (rule order_trans)
4.620 @@ -902,10 +919,10 @@
4.621            have "x < (of_nat n / (if \<mu> ?G = \<omega> then 1 else \<mu> ?G)) * \<mu> ?G"
4.622              using n \<mu> ?G \<noteq> 0 0 < n
4.623              by (auto simp: pextreal_noteq_omega_Ex field_simps)
4.624 -          also have "\<dots> = simple_integral ?g" using g space M \<noteq> {}
4.625 +          also have "\<dots> = integral\<^isup>S M ?g" using g space M \<noteq> {}
4.626              by (subst simple_integral_indicator)
4.627                 (auto simp: image_constant ac_simps dest: simple_functionD)
4.628 -          finally show "x < simple_integral ?g" .
4.629 +          finally show "x < integral\<^isup>S M ?g" .
4.630          qed
4.631        qed
4.632        then show ?thesis by simp
4.633 @@ -914,40 +931,41 @@
4.634  qed (auto intro!: SUP_subset simp: positive_integral_def)
4.635
4.636  lemma (in measure_space) positive_integral_cong_measure:
4.637 -  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = \<mu> A"
4.638 -  shows "measure_space.positive_integral M \<nu> f = positive_integral f"
4.639 +  assumes "\<And>A. A \<in> sets M \<Longrightarrow> measure N A = \<mu> A" "sets N = sets M" "space N = space M"
4.640 +  shows "integral\<^isup>P N f = integral\<^isup>P M f"
4.641  proof -
4.642 -  interpret v: measure_space M \<nu>
4.643 -    by (rule measure_space_cong) fact
4.644 +  interpret v: measure_space N
4.645 +    by (rule measure_space_cong) fact+
4.646    with assms show ?thesis
4.647 -    unfolding positive_integral_def v.positive_integral_def SUPR_def
4.648 +    unfolding positive_integral_def SUPR_def
4.649      by (auto intro!: arg_cong[where f=Sup] image_cong
4.650 -             simp: simple_integral_cong_measure[of \<nu>])
4.651 +             simp: simple_integral_cong_measure[OF assms]
4.652 +                   simple_function_cong_algebra[OF assms(2,3)])
4.653  qed
4.654
4.655  lemma (in measure_space) positive_integral_alt1:
4.656 -  "positive_integral f =
4.657 -    (SUP g : {g. simple_function g \<and> (\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>)}. simple_integral g)"
4.658 +  "integral\<^isup>P M f =
4.659 +    (SUP g : {g. simple_function M g \<and> (\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>)}. integral\<^isup>S M g)"
4.660    unfolding positive_integral_alt SUPR_def
4.661  proof (safe intro!: arg_cong[where f=Sup])
4.662    fix g let ?g = "\<lambda>x. if x \<in> space M then g x else f x"
4.663 -  assume "simple_function g" "\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>"
4.664 -  hence "?g \<le> f" "simple_function ?g" "simple_integral g = simple_integral ?g"
4.665 +  assume "simple_function M g" "\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>"
4.666 +  hence "?g \<le> f" "simple_function M ?g" "integral\<^isup>S M g = integral\<^isup>S M ?g"
4.667      "\<omega> \<notin> gspace M"
4.668      unfolding le_fun_def by (auto cong: simple_function_cong simple_integral_cong)
4.669 -  thus "simple_integral g \<in> simple_integral  {g. simple_function g \<and> g \<le> f \<and> \<omega> \<notin> gspace M}"
4.670 +  thus "integral\<^isup>S M g \<in> integral\<^isup>S M  {g. simple_function M g \<and> g \<le> f \<and> \<omega> \<notin> gspace M}"
4.671      by auto
4.672  next
4.673 -  fix g assume "simple_function g" "g \<le> f" "\<omega> \<notin> gspace M"
4.674 -  hence "simple_function g" "\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>"
4.675 +  fix g assume "simple_function M g" "g \<le> f" "\<omega> \<notin> gspace M"
4.676 +  hence "simple_function M g" "\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>"
4.677      by (auto simp add: le_fun_def image_iff)
4.678 -  thus "simple_integral g \<in> simple_integral  {g. simple_function g \<and> (\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>)}"
4.679 +  thus "integral\<^isup>S M g \<in> integral\<^isup>S M  {g. simple_function M g \<and> (\<forall>x\<in>space M. g x \<le> f x \<and> g x \<noteq> \<omega>)}"
4.680      by auto
4.681  qed
4.682
4.683  lemma (in measure_space) positive_integral_cong:
4.684    assumes "\<And>x. x \<in> space M \<Longrightarrow> f x = g x"
4.685 -  shows "positive_integral f = positive_integral g"
4.686 +  shows "integral\<^isup>P M f = integral\<^isup>P M g"
4.687  proof -
4.688    have "\<And>h. (\<forall>x\<in>space M. h x \<le> f x \<and> h x \<noteq> \<omega>) = (\<forall>x\<in>space M. h x \<le> g x \<and> h x \<noteq> \<omega>)"
4.689      using assms by auto
4.690 @@ -955,30 +973,30 @@
4.691  qed
4.692
4.693  lemma (in measure_space) positive_integral_eq_simple_integral:
4.694 -  assumes "simple_function f"
4.695 -  shows "positive_integral f = simple_integral f"
4.696 +  assumes "simple_function M f"
4.697 +  shows "integral\<^isup>P M f = integral\<^isup>S M f"
4.698    unfolding positive_integral_def
4.699  proof (safe intro!: pextreal_SUPI)
4.700 -  fix g assume "simple_function g" "g \<le> f"
4.701 -  with assms show "simple_integral g \<le> simple_integral f"
4.702 +  fix g assume "simple_function M g" "g \<le> f"
4.703 +  with assms show "integral\<^isup>S M g \<le> integral\<^isup>S M f"
4.704      by (auto intro!: simple_integral_mono simp: le_fun_def)
4.705  next
4.706 -  fix y assume "\<forall>x. x\<in>{g. simple_function g \<and> g \<le> f} \<longrightarrow> simple_integral x \<le> y"
4.707 -  with assms show "simple_integral f \<le> y" by auto
4.708 +  fix y assume "\<forall>x. x\<in>{g. simple_function M g \<and> g \<le> f} \<longrightarrow> integral\<^isup>S M x \<le> y"
4.709 +  with assms show "integral\<^isup>S M f \<le> y" by auto
4.710  qed
4.711
4.712  lemma (in measure_space) positive_integral_mono_AE:
4.713    assumes ae: "AE x. u x \<le> v x"
4.714 -  shows "positive_integral u \<le> positive_integral v"
4.715 +  shows "integral\<^isup>P M u \<le> integral\<^isup>P M v"
4.716    unfolding positive_integral_alt1
4.717  proof (safe intro!: SUPR_mono)
4.718 -  fix a assume a: "simple_function a" and mono: "\<forall>x\<in>space M. a x \<le> u x \<and> a x \<noteq> \<omega>"
4.719 +  fix a assume a: "simple_function M a" and mono: "\<forall>x\<in>space M. a x \<le> u x \<and> a x \<noteq> \<omega>"
4.720    from ae obtain N where N: "{x\<in>space M. \<not> u x \<le> v x} \<subseteq> N" "N \<in> sets M" "\<mu> N = 0"
4.721      by (auto elim!: AE_E)
4.722 -  have "simple_function (\<lambda>x. a x * indicator (space M - N) x)"
4.723 +  have "simple_function M (\<lambda>x. a x * indicator (space M - N) x)"
4.724      using N \<in> sets M a by auto
4.725 -  with a show "\<exists>b\<in>{g. simple_function g \<and> (\<forall>x\<in>space M. g x \<le> v x \<and> g x \<noteq> \<omega>)}.
4.726 -    simple_integral a \<le> simple_integral b"
4.727 +  with a show "\<exists>b\<in>{g. simple_function M g \<and> (\<forall>x\<in>space M. g x \<le> v x \<and> g x \<noteq> \<omega>)}.
4.728 +    integral\<^isup>S M a \<le> integral\<^isup>S M b"
4.729    proof (safe intro!: bexI[of _ "\<lambda>x. a x * indicator (space M - N) x"]
4.730                        simple_integral_mono_AE)
4.731      show "AE x. a x \<le> a x * indicator (space M - N) x"
4.732 @@ -987,7 +1005,7 @@
4.733          N \<inter> {x \<in> space M. a x \<noteq> 0}" (is "?N = _")
4.734          using N \<in> sets M[THEN sets_into_space] by (auto simp: indicator_def)
4.735        then show "?N \<in> sets M"
4.736 -        using N \<in> sets M simple_function a[THEN borel_measurable_simple_function]
4.737 +        using N \<in> sets M simple_function M a[THEN borel_measurable_simple_function]
4.738          by (auto intro!: measure_mono Int)
4.739        then have "\<mu> ?N \<le> \<mu> N"
4.740          unfolding * using N \<in> sets M by (auto intro!: measure_mono)
4.741 @@ -1010,12 +1028,12 @@
4.742  qed
4.743
4.744  lemma (in measure_space) positive_integral_cong_AE:
4.745 -  "AE x. u x = v x \<Longrightarrow> positive_integral u = positive_integral v"
4.746 +  "AE x. u x = v x \<Longrightarrow> integral\<^isup>P M u = integral\<^isup>P M v"
4.747    by (auto simp: eq_iff intro!: positive_integral_mono_AE)
4.748
4.749  lemma (in measure_space) positive_integral_mono:
4.750    assumes mono: "\<And>x. x \<in> space M \<Longrightarrow> u x \<le> v x"
4.751 -  shows "positive_integral u \<le> positive_integral v"
4.752 +  shows "integral\<^isup>P M u \<le> integral\<^isup>P M v"
4.753    using mono by (auto intro!: AE_cong positive_integral_mono_AE)
4.754
4.755  lemma image_set_cong:
4.756 @@ -1027,15 +1045,15 @@
4.757  lemma (in measure_space) positive_integral_SUP_approx:
4.758    assumes "f \<up> s"
4.759    and f: "\<And>i. f i \<in> borel_measurable M"
4.760 -  and "simple_function u"
4.761 +  and "simple_function M u"
4.762    and le: "u \<le> s" and real: "\<omega> \<notin> uspace M"
4.763 -  shows "simple_integral u \<le> (SUP i. positive_integral (f i))" (is "_ \<le> ?S")
4.764 +  shows "integral\<^isup>S M u \<le> (SUP i. integral\<^isup>P M (f i))" (is "_ \<le> ?S")
4.765  proof (rule pextreal_le_mult_one_interval)
4.766    fix a :: pextreal assume "0 < a" "a < 1"
4.767    hence "a \<noteq> 0" by auto
4.768    let "?B i" = "{x \<in> space M. a * u x \<le> f i x}"
4.769    have B: "\<And>i. ?B i \<in> sets M"
4.770 -    using f simple_function u by (auto simp: borel_measurable_simple_function)
4.771 +    using f simple_function M u by (auto simp: borel_measurable_simple_function)
4.772
4.773    let "?uB i x" = "u x * indicator (?B i) x"
4.774
4.775 @@ -1049,7 +1067,7 @@
4.776    note B_mono = this
4.777
4.778    have u: "\<And>x. x \<in> space M \<Longrightarrow> u - {u x} \<inter> space M \<in> sets M"
4.779 -    using simple_function u by (auto simp add: simple_function_def)
4.780 +    using simple_function M u by (auto simp add: simple_function_def)
4.781
4.782    have "\<And>i. (\<lambda>n. (u - {i} \<inter> space M) \<inter> ?B n) \<up> (u - {i} \<inter> space M)" using B_mono unfolding isoton_def
4.783    proof safe
4.784 @@ -1071,8 +1089,8 @@
4.785    qed auto
4.786    note measure_conv = measure_up[OF Int[OF u B] this]
4.787
4.788 -  have "simple_integral u = (SUP i. simple_integral (?uB i))"
4.789 -    unfolding simple_integral_indicator[OF B simple_function u]
4.790 +  have "integral\<^isup>S M u = (SUP i. integral\<^isup>S M (?uB i))"
4.791 +    unfolding simple_integral_indicator[OF B simple_function M u]
4.792    proof (subst SUPR_pextreal_setsum, safe)
4.793      fix x n assume "x \<in> space M"
4.794      have "\<mu> (u - {u x} \<inter> space M \<inter> {x \<in> space M. a * u x \<le> f n x})
4.795 @@ -1082,52 +1100,51 @@
4.796              \<le> u x * \<mu> (u - {u x} \<inter> space M \<inter> ?B (Suc n))"
4.797        by (auto intro: mult_left_mono)
4.798    next
4.799 -    show "simple_integral u =
4.800 +    show "integral\<^isup>S M u =
4.801        (\<Sum>i\<in>u  space M. SUP n. i * \<mu> (u - {i} \<inter> space M \<inter> ?B n))"
4.802        using measure_conv unfolding simple_integral_def isoton_def
4.803        by (auto intro!: setsum_cong simp: pextreal_SUP_cmult)
4.804    qed
4.805    moreover
4.806 -  have "a * (SUP i. simple_integral (?uB i)) \<le> ?S"
4.807 +  have "a * (SUP i. integral\<^isup>S M (?uB i)) \<le> ?S"
4.808      unfolding pextreal_SUP_cmult[symmetric]
4.809    proof (safe intro!: SUP_mono bexI)
4.810      fix i
4.811 -    have "a * simple_integral (?uB i) = (\<integral>\<^isup>Sx. a * ?uB i x)"
4.812 -      using B simple_function u
4.813 +    have "a * integral\<^isup>S M (?uB i) = (\<integral>\<^isup>Sx. a * ?uB i x \<partial>M)"
4.814 +      using B simple_function M u
4.815        by (subst simple_integral_mult[symmetric]) (auto simp: field_simps)
4.816 -    also have "\<dots> \<le> positive_integral (f i)"
4.817 +    also have "\<dots> \<le> integral\<^isup>P M (f i)"
4.818      proof -
4.819        have "\<And>x. a * ?uB i x \<le> f i x" unfolding indicator_def by auto
4.820 -      hence *: "simple_function (\<lambda>x. a * ?uB i x)" using B assms(3)
4.821 +      hence *: "simple_function M (\<lambda>x. a * ?uB i x)" using B assms(3)
4.822          by (auto intro!: simple_integral_mono)
4.823        show ?thesis unfolding positive_integral_eq_simple_integral[OF *, symmetric]
4.824          by (auto intro!: positive_integral_mono simp: indicator_def)
4.825      qed
4.826 -    finally show "a * simple_integral (?uB i) \<le> positive_integral (f i)"
4.827 +    finally show "a * integral\<^isup>S M (?uB i) \<le> integral\<^isup>P M (f i)"
4.828        by auto
4.829    qed simp
4.830 -  ultimately show "a * simple_integral u \<le> ?S" by simp
4.831 +  ultimately show "a * integral\<^isup>S M u \<le> ?S" by simp
4.832  qed
4.833
4.834  text {* Beppo-Levi monotone convergence theorem *}
4.835  lemma (in measure_space) positive_integral_isoton:
4.836    assumes "f \<up> u" "\<And>i. f i \<in> borel_measurable M"
4.837 -  shows "(\<lambda>i. positive_integral (f i)) \<up> positive_integral u"
4.838 +  shows "(\<lambda>i. integral\<^isup>P M (f i)) \<up> integral\<^isup>P M u"
4.839    unfolding isoton_def
4.840  proof safe
4.841 -  fix i show "positive_integral (f i) \<le> positive_integral (f (Suc i))"
4.842 +  fix i show "integral\<^isup>P M (f i) \<le> integral\<^isup>P M (f (Suc i))"
4.843      apply (rule positive_integral_mono)
4.844      using f \<up> u unfolding isoton_def le_fun_def by auto
4.845  next
4.846    have u: "u = (SUP i. f i)" using f \<up> u unfolding isoton_def by auto
4.847 -
4.848 -  show "(SUP i. positive_integral (f i)) = positive_integral u"
4.849 +  show "(SUP i. integral\<^isup>P M (f i)) = integral\<^isup>P M u"
4.850    proof (rule antisym)
4.851      from f \<up> u[THEN isoton_Sup, unfolded le_fun_def]
4.852 -    show "(SUP j. positive_integral (f j)) \<le> positive_integral u"
4.853 +    show "(SUP j. integral\<^isup>P M (f j)) \<le> integral\<^isup>P M u"
4.854        by (auto intro!: SUP_leI positive_integral_mono)
4.855    next
4.856 -    show "positive_integral u \<le> (SUP i. positive_integral (f i))"
4.857 +    show "integral\<^isup>P M u \<le> (SUP i. integral\<^isup>P M (f i))"
4.858        unfolding positive_integral_alt[of u]
4.859        by (auto intro!: SUP_leI positive_integral_SUP_approx[OF assms])
4.860    qed
4.861 @@ -1136,12 +1153,12 @@
4.862  lemma (in measure_space) positive_integral_monotone_convergence_SUP:
4.863    assumes "\<And>i x. x \<in> space M \<Longrightarrow> f i x \<le> f (Suc i) x"
4.864    assumes "\<And>i. f i \<in> borel_measurable M"
4.865 -  shows "(SUP i. positive_integral (f i)) = (\<integral>\<^isup>+ x. SUP i. f i x)"
4.866 -    (is "_ = positive_integral ?u")
4.867 +  shows "(SUP i. integral\<^isup>P M (f i)) = (\<integral>\<^isup>+ x. (SUP i. f i x) \<partial>M)"
4.868 +    (is "_ = integral\<^isup>P M ?u")
4.869  proof -
4.870    show ?thesis
4.871    proof (rule antisym)
4.872 -    show "(SUP j. positive_integral (f j)) \<le> positive_integral ?u"
4.873 +    show "(SUP j. integral\<^isup>P M (f j)) \<le> integral\<^isup>P M ?u"
4.874        by (auto intro!: SUP_leI positive_integral_mono le_SUPI)
4.875    next
4.876      def rf \<equiv> "\<lambda>i. \<lambda>x\<in>space M. f i x" and ru \<equiv> "\<lambda>x\<in>space M. ?u x"
4.877 @@ -1151,26 +1168,26 @@
4.878        unfolding isoton_def le_fun_def fun_eq_iff SUPR_apply
4.879        using SUP_const[OF UNIV_not_empty]
4.880        by (auto simp: restrict_def le_fun_def fun_eq_iff)
4.881 -    ultimately have "positive_integral ru \<le> (SUP i. positive_integral (rf i))"
4.882 +    ultimately have "integral\<^isup>P M ru \<le> (SUP i. integral\<^isup>P M (rf i))"
4.883        unfolding positive_integral_alt[of ru]
4.884        by (auto simp: le_fun_def intro!: SUP_leI positive_integral_SUP_approx)
4.885 -    then show "positive_integral ?u \<le> (SUP i. positive_integral (f i))"
4.886 +    then show "integral\<^isup>P M ?u \<le> (SUP i. integral\<^isup>P M (f i))"
4.887        unfolding ru_def rf_def by (simp cong: positive_integral_cong)
4.888    qed
4.889  qed
4.890
4.891  lemma (in measure_space) SUP_simple_integral_sequences:
4.892 -  assumes f: "f \<up> u" "\<And>i. simple_function (f i)"
4.893 -  and g: "g \<up> u" "\<And>i. simple_function (g i)"
4.894 -  shows "(SUP i. simple_integral (f i)) = (SUP i. simple_integral (g i))"
4.895 +  assumes f: "f \<up> u" "\<And>i. simple_function M (f i)"
4.896 +  and g: "g \<up> u" "\<And>i. simple_function M (g i)"
4.897 +  shows "(SUP i. integral\<^isup>S M (f i)) = (SUP i. integral\<^isup>S M (g i))"
4.898      (is "SUPR _ ?F = SUPR _ ?G")
4.899  proof -
4.900 -  have "(SUP i. ?F i) = (SUP i. positive_integral (f i))"
4.901 +  have "(SUP i. ?F i) = (SUP i. integral\<^isup>P M (f i))"
4.902      using assms by (simp add: positive_integral_eq_simple_integral)
4.903 -  also have "\<dots> = positive_integral u"
4.904 +  also have "\<dots> = integral\<^isup>P M u"
4.905      using positive_integral_isoton[OF f(1) borel_measurable_simple_function[OF f(2)]]
4.906      unfolding isoton_def by simp
4.907 -  also have "\<dots> = (SUP i. positive_integral (g i))"
4.908 +  also have "\<dots> = (SUP i. integral\<^isup>P M (g i))"
4.909      using positive_integral_isoton[OF g(1) borel_measurable_simple_function[OF g(2)]]
4.910      unfolding isoton_def by simp
4.911    also have "\<dots> = (SUP i. ?G i)"
4.912 @@ -1179,38 +1196,36 @@
4.913  qed
4.914
4.915  lemma (in measure_space) positive_integral_const[simp]:
4.916 -  "(\<integral>\<^isup>+ x. c) = c * \<mu> (space M)"
4.917 +  "(\<integral>\<^isup>+ x. c \<partial>M) = c * \<mu> (space M)"
4.918    by (subst positive_integral_eq_simple_integral) auto
4.919
4.920  lemma (in measure_space) positive_integral_isoton_simple:
4.921 -  assumes "f \<up> u" and e: "\<And>i. simple_function (f i)"
4.922 -  shows "(\<lambda>i. simple_integral (f i)) \<up> positive_integral u"
4.923 +  assumes "f \<up> u" and e: "\<And>i. simple_function M (f i)"
4.924 +  shows "(\<lambda>i. integral\<^isup>S M (f i)) \<up> integral\<^isup>P M u"
4.925    using positive_integral_isoton[OF f \<up> u e(1)[THEN borel_measurable_simple_function]]
4.926    unfolding positive_integral_eq_simple_integral[OF e] .
4.927
4.928  lemma (in measure_space) positive_integral_vimage:
4.929    assumes T: "sigma_algebra M'" "T \<in> measurable M M'" and f: "f \<in> borel_measurable M'"
4.930 -  shows "measure_space.positive_integral M' (\<lambda>A. \<mu> (T - A \<inter> space M)) f = (\<integral>\<^isup>+ x. f (T x))"
4.931 -    (is "measure_space.positive_integral M' ?nu f = _")
4.932 +    and \<nu>: "\<And>A. A \<in> sets M' \<Longrightarrow> measure M' A = \<mu> (T - A \<inter> space M)"
4.933 +  shows "integral\<^isup>P M' f = (\<integral>\<^isup>+ x. f (T x) \<partial>M)"
4.934  proof -
4.935 -  interpret T: measure_space M' ?nu using T by (rule measure_space_vimage) auto
4.936 -  obtain f' where f': "f' \<up> f" "\<And>i. T.simple_function (f' i)"
4.937 +  interpret T: measure_space M' using \<nu> by (rule measure_space_vimage[OF T])
4.938 +  obtain f' where f': "f' \<up> f" "\<And>i. simple_function M' (f' i)"
4.939      using T.borel_measurable_implies_simple_function_sequence[OF f] by blast
4.940 -  then have f: "(\<lambda>i x. f' i (T x)) \<up> (\<lambda>x. f (T x))" "\<And>i. simple_function (\<lambda>x. f' i (T x))"
4.941 +  then have f: "(\<lambda>i x. f' i (T x)) \<up> (\<lambda>x. f (T x))" "\<And>i. simple_function M (\<lambda>x. f' i (T x))"
4.942      using simple_function_vimage[OF T] unfolding isoton_fun_expand by auto
4.943 -  show "T.positive_integral f = (\<integral>\<^isup>+ x. f (T x))"
4.944 +  show "integral\<^isup>P M' f = (\<integral>\<^isup>+ x. f (T x) \<partial>M)"
4.945      using positive_integral_isoton_simple[OF f]
4.946      using T.positive_integral_isoton_simple[OF f']
4.947 -    unfolding simple_integral_vimage[OF T f'(2)] isoton_def
4.948 -    by simp
4.949 +    by (simp add: simple_integral_vimage[OF T f'(2) \<nu>] isoton_def)
4.950  qed
4.951
4.952  lemma (in measure_space) positive_integral_linear:
4.953    assumes f: "f \<in> borel_measurable M"
4.954    and g: "g \<in> borel_measurable M"
4.955 -  shows "(\<integral>\<^isup>+ x. a * f x + g x) =
4.956 -      a * positive_integral f + positive_integral g"
4.957 -    (is "positive_integral ?L = _")
4.958 +  shows "(\<integral>\<^isup>+ x. a * f x + g x \<partial>M) = a * integral\<^isup>P M f + integral\<^isup>P M g"
4.959 +    (is "integral\<^isup>P M ?L = _")
4.960  proof -
4.961    from borel_measurable_implies_simple_function_sequence'[OF f] guess u .
4.962    note u = this positive_integral_isoton_simple[OF this(1-2)]
4.963 @@ -1222,46 +1237,45 @@
4.964      using assms by simp
4.965    from borel_measurable_implies_simple_function_sequence'[OF this] guess l .
4.966    note positive_integral_isoton_simple[OF this(1-2)] and l = this
4.967 -  moreover have
4.968 -      "(SUP i. simple_integral (l i)) = (SUP i. simple_integral (?L' i))"
4.969 +  moreover have "(SUP i. integral\<^isup>S M (l i)) = (SUP i. integral\<^isup>S M (?L' i))"
4.970    proof (rule SUP_simple_integral_sequences[OF l(1-2)])
4.971 -    show "?L' \<up> ?L" "\<And>i. simple_function (?L' i)"
4.972 +    show "?L' \<up> ?L" "\<And>i. simple_function M (?L' i)"
4.973        using u v by (auto simp: isoton_fun_expand isoton_add isoton_cmult_right)
4.974    qed
4.975    moreover from u v have L'_isoton:
4.976 -      "(\<lambda>i. simple_integral (?L' i)) \<up> a * positive_integral f + positive_integral g"
4.977 +      "(\<lambda>i. integral\<^isup>S M (?L' i)) \<up> a * integral\<^isup>P M f + integral\<^isup>P M g"
4.979    ultimately show ?thesis by (simp add: isoton_def)
4.980  qed
4.981
4.982  lemma (in measure_space) positive_integral_cmult:
4.983    assumes "f \<in> borel_measurable M"
4.984 -  shows "(\<integral>\<^isup>+ x. c * f x) = c * positive_integral f"
4.985 +  shows "(\<integral>\<^isup>+ x. c * f x \<partial>M) = c * integral\<^isup>P M f"
4.986    using positive_integral_linear[OF assms, of "\<lambda>x. 0" c] by auto
4.987
4.988  lemma (in measure_space) positive_integral_multc:
4.989    assumes "f \<in> borel_measurable M"
4.990 -  shows "(\<integral>\<^isup>+ x. f x * c) = positive_integral f * c"
4.991 +  shows "(\<integral>\<^isup>+ x. f x * c \<partial>M) = integral\<^isup>P M f * c"
4.992    unfolding mult_commute[of _ c] positive_integral_cmult[OF assms] by simp
4.993
4.994  lemma (in measure_space) positive_integral_indicator[simp]:
4.995 -  "A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+ x. indicator A x) = \<mu> A"
4.996 +  "A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+ x. indicator A x\<partial>M) = \<mu> A"
4.997    by (subst positive_integral_eq_simple_integral)
4.998       (auto simp: simple_function_indicator simple_integral_indicator)
4.999
4.1000  lemma (in measure_space) positive_integral_cmult_indicator:
4.1001 -  "A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+ x. c * indicator A x) = c * \<mu> A"
4.1002 +  "A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+ x. c * indicator A x \<partial>M) = c * \<mu> A"
4.1003    by (subst positive_integral_eq_simple_integral)
4.1004       (auto simp: simple_function_indicator simple_integral_indicator)
4.1005
4.1007    assumes "f \<in> borel_measurable M" "g \<in> borel_measurable M"
4.1008 -  shows "(\<integral>\<^isup>+ x. f x + g x) = positive_integral f + positive_integral g"
4.1009 +  shows "(\<integral>\<^isup>+ x. f x + g x \<partial>M) = integral\<^isup>P M f + integral\<^isup>P M g"
4.1010    using positive_integral_linear[OF assms, of 1] by simp
4.1011
4.1012  lemma (in measure_space) positive_integral_setsum:
4.1013    assumes "\<And>i. i\<in>P \<Longrightarrow> f i \<in> borel_measurable M"
4.1014 -  shows "(\<integral>\<^isup>+ x. \<Sum>i\<in>P. f i x) = (\<Sum>i\<in>P. positive_integral (f i))"
4.1015 +  shows "(\<integral>\<^isup>+ x. (\<Sum>i\<in>P. f i x) \<partial>M) = (\<Sum>i\<in>P. integral\<^isup>P M (f i))"
4.1016  proof cases
4.1017    assume "finite P"
4.1018    from this assms show ?thesis
4.1019 @@ -1277,14 +1291,13 @@
4.1020
4.1021  lemma (in measure_space) positive_integral_diff:
4.1022    assumes f: "f \<in> borel_measurable M" and g: "g \<in> borel_measurable M"
4.1023 -  and fin: "positive_integral g \<noteq> \<omega>"
4.1024 +  and fin: "integral\<^isup>P M g \<noteq> \<omega>"
4.1025    and mono: "\<And>x. x \<in> space M \<Longrightarrow> g x \<le> f x"
4.1026 -  shows "(\<integral>\<^isup>+ x. f x - g x) = positive_integral f - positive_integral g"
4.1027 +  shows "(\<integral>\<^isup>+ x. f x - g x \<partial>M) = integral\<^isup>P M f - integral\<^isup>P M g"
4.1028  proof -
4.1029    have borel: "(\<lambda>x. f x - g x) \<in> borel_measurable M"
4.1030      using f g by (rule borel_measurable_pextreal_diff)
4.1031 -  have "(\<integral>\<^isup>+x. f x - g x) + positive_integral g =
4.1032 -    positive_integral f"
4.1033 +  have "(\<integral>\<^isup>+x. f x - g x \<partial>M) + integral\<^isup>P M g = integral\<^isup>P M f"
4.1034      unfolding positive_integral_add[OF borel g, symmetric]
4.1035    proof (rule positive_integral_cong)
4.1036      fix x assume "x \<in> space M"
4.1037 @@ -1297,9 +1310,9 @@
4.1038
4.1039  lemma (in measure_space) positive_integral_psuminf:
4.1040    assumes "\<And>i. f i \<in> borel_measurable M"
4.1041 -  shows "(\<integral>\<^isup>+ x. \<Sum>\<^isub>\<infinity> i. f i x) = (\<Sum>\<^isub>\<infinity> i. positive_integral (f i))"
4.1042 +  shows "(\<integral>\<^isup>+ x. (\<Sum>\<^isub>\<infinity> i. f i x) \<partial>M) = (\<Sum>\<^isub>\<infinity> i. integral\<^isup>P M (f i))"
4.1043  proof -
4.1044 -  have "(\<lambda>i. (\<integral>\<^isup>+x. \<Sum>i<i. f i x)) \<up> (\<integral>\<^isup>+x. \<Sum>\<^isub>\<infinity>i. f i x)"
4.1045 +  have "(\<lambda>i. (\<integral>\<^isup>+x. (\<Sum>i<i. f i x) \<partial>M)) \<up> (\<integral>\<^isup>+x. (\<Sum>\<^isub>\<infinity>i. f i x) \<partial>M)"
4.1046      by (rule positive_integral_isoton)
4.1047         (auto intro!: borel_measurable_pextreal_setsum assms positive_integral_mono
4.1048                       arg_cong[where f=Sup]
4.1049 @@ -1312,79 +1325,86 @@
4.1050  lemma (in measure_space) positive_integral_lim_INF:
4.1051    fixes u :: "nat \<Rightarrow> 'a \<Rightarrow> pextreal"
4.1052    assumes "\<And>i. u i \<in> borel_measurable M"
4.1053 -  shows "(\<integral>\<^isup>+ x. SUP n. INF m. u (m + n) x) \<le>
4.1054 -    (SUP n. INF m. positive_integral (u (m + n)))"
4.1055 +  shows "(\<integral>\<^isup>+ x. (SUP n. INF m. u (m + n) x) \<partial>M) \<le>
4.1056 +    (SUP n. INF m. integral\<^isup>P M (u (m + n)))"
4.1057  proof -
4.1058 -  have "(\<integral>\<^isup>+x. SUP n. INF m. u (m + n) x)
4.1059 -      = (SUP n. (\<integral>\<^isup>+x. INF m. u (m + n) x))"
4.1060 +  have "(\<integral>\<^isup>+x. (SUP n. INF m. u (m + n) x) \<partial>M)
4.1061 +      = (SUP n. (\<integral>\<^isup>+x. (INF m. u (m + n) x) \<partial>M))"
4.1062      using assms
4.1063      by (intro positive_integral_monotone_convergence_SUP[symmetric] INF_mono)
4.1065 -  also have "\<dots> \<le> (SUP n. INF m. positive_integral (u (m + n)))"
4.1066 +  also have "\<dots> \<le> (SUP n. INF m. integral\<^isup>P M (u (m + n)))"
4.1067      by (auto intro!: SUP_mono bexI le_INFI positive_integral_mono INF_leI)
4.1068    finally show ?thesis .
4.1069  qed
4.1070
4.1071  lemma (in measure_space) measure_space_density:
4.1072    assumes borel: "u \<in> borel_measurable M"
4.1073 -  shows "measure_space M (\<lambda>A. (\<integral>\<^isup>+ x. u x * indicator A x))" (is "measure_space M ?v")
4.1074 -proof
4.1075 -  show "?v {} = 0" by simp
4.1076 -  show "countably_additive M ?v"
4.1078 -  proof safe
4.1079 -    fix A :: "nat \<Rightarrow> 'a set"
4.1080 -    assume "range A \<subseteq> sets M"
4.1081 -    hence "\<And>i. (\<lambda>x. u x * indicator (A i) x) \<in> borel_measurable M"
4.1082 -      using borel by (auto intro: borel_measurable_indicator)
4.1083 -    moreover assume "disjoint_family A"
4.1084 -    note psuminf_indicator[OF this]
4.1085 -    ultimately show "(\<Sum>\<^isub>\<infinity>n. ?v (A n)) = ?v (\<Union>x. A x)"
4.1086 -      by (simp add: positive_integral_psuminf[symmetric])
4.1087 +    and M'[simp]: "M' = (M\<lparr>measure := \<lambda>A. (\<integral>\<^isup>+ x. u x * indicator A x \<partial>M)\<rparr>)"
4.1088 +  shows "measure_space M'"
4.1089 +proof -
4.1090 +  interpret M': sigma_algebra M' by (intro sigma_algebra_cong) auto
4.1091 +  show ?thesis
4.1092 +  proof
4.1093 +    show "measure M' {} = 0" unfolding M' by simp
4.1094 +    show "countably_additive M' (measure M')"
4.1096 +      fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> sets M'"
4.1097 +      then have "\<And>i. (\<lambda>x. u x * indicator (A i) x) \<in> borel_measurable M"
4.1098 +        using borel by (auto intro: borel_measurable_indicator)
4.1099 +      moreover assume "disjoint_family A"
4.1100 +      note psuminf_indicator[OF this]
4.1101 +      ultimately show "(\<Sum>\<^isub>\<infinity>n. measure M' (A n)) = measure M' (\<Union>x. A x)"
4.1102 +        by (simp add: positive_integral_psuminf[symmetric])
4.1103 +    qed
4.1104    qed
4.1105  qed
4.1106
4.1107  lemma (in measure_space) positive_integral_translated_density:
4.1108    assumes "f \<in> borel_measurable M" "g \<in> borel_measurable M"
4.1109 -  shows "measure_space.positive_integral M (\<lambda>A. (\<integral>\<^isup>+ x. f x * indicator A x)) g =
4.1110 -         (\<integral>\<^isup>+ x. f x * g x)" (is "measure_space.positive_integral M ?T _ = _")
4.1111 +    and M': "M' = (M\<lparr> measure := \<lambda>A. (\<integral>\<^isup>+ x. f x * indicator A x \<partial>M)\<rparr>)"
4.1112 +  shows "integral\<^isup>P M' g = (\<integral>\<^isup>+ x. f x * g x \<partial>M)"
4.1113  proof -
4.1114 -  from measure_space_density[OF assms(1)]
4.1115 -  interpret T: measure_space M ?T .
4.1116 +  from measure_space_density[OF assms(1) M']
4.1117 +  interpret T: measure_space M' .
4.1118 +  have borel[simp]:
4.1119 +    "borel_measurable M' = borel_measurable M"
4.1120 +    "simple_function M' = simple_function M"
4.1121 +    unfolding measurable_def simple_function_def_raw by (auto simp: M')
4.1122    from borel_measurable_implies_simple_function_sequence[OF assms(2)]
4.1123 -  obtain G where G: "\<And>i. simple_function (G i)" "G \<up> g" by blast
4.1124 +  obtain G where G: "\<And>i. simple_function M (G i)" "G \<up> g" by blast
4.1125    note G_borel = borel_measurable_simple_function[OF this(1)]
4.1126 -  from T.positive_integral_isoton[OF G \<up> g G_borel]
4.1127 -  have *: "(\<lambda>i. T.positive_integral (G i)) \<up> T.positive_integral g" .
4.1128 +  from T.positive_integral_isoton[unfolded borel, OF G \<up> g G_borel]
4.1129 +  have *: "(\<lambda>i. integral\<^isup>P M' (G i)) \<up> integral\<^isup>P M' g" .
4.1130    { fix i
4.1131      have [simp]: "finite (G i  space M)"
4.1132        using G(1) unfolding simple_function_def by auto
4.1133 -    have "T.positive_integral (G i) = T.simple_integral (G i)"
4.1134 +    have "integral\<^isup>P M' (G i) = integral\<^isup>S M' (G i)"
4.1135        using G T.positive_integral_eq_simple_integral by simp
4.1136 -    also have "\<dots> = (\<integral>\<^isup>+x. f x * (\<Sum>y\<in>G ispace M. y * indicator (G i - {y} \<inter> space M) x))"
4.1137 -      apply (simp add: T.simple_integral_def)
4.1138 +    also have "\<dots> = (\<integral>\<^isup>+x. f x * (\<Sum>y\<in>G ispace M. y * indicator (G i - {y} \<inter> space M) x) \<partial>M)"
4.1139 +      apply (simp add: simple_integral_def M')
4.1140        apply (subst positive_integral_cmult[symmetric])
4.1141 -      using G_borel assms(1) apply (fastsimp intro: borel_measurable_indicator borel_measurable_vimage)
4.1142 +      using G_borel assms(1) apply (fastsimp intro: borel_measurable_vimage)
4.1143        apply (subst positive_integral_setsum[symmetric])
4.1144 -      using G_borel assms(1) apply (fastsimp intro: borel_measurable_indicator borel_measurable_vimage)
4.1145 +      using G_borel assms(1) apply (fastsimp intro: borel_measurable_vimage)
4.1146        by (simp add: setsum_right_distrib field_simps)
4.1147 -    also have "\<dots> = (\<integral>\<^isup>+x. f x * G i x)"
4.1148 +    also have "\<dots> = (\<integral>\<^isup>+x. f x * G i x \<partial>M)"
4.1149        by (auto intro!: positive_integral_cong
4.1150                 simp: indicator_def if_distrib setsum_cases)
4.1151 -    finally have "T.positive_integral (G i) = (\<integral>\<^isup>+x. f x * G i x)" . }
4.1152 -  with * have eq_Tg: "(\<lambda>i. (\<integral>\<^isup>+x. f x * G i x)) \<up> T.positive_integral g" by simp
4.1153 +    finally have "integral\<^isup>P M' (G i) = (\<integral>\<^isup>+x. f x * G i x \<partial>M)" . }
4.1154 +  with * have eq_Tg: "(\<lambda>i. (\<integral>\<^isup>+x. f x * G i x \<partial>M)) \<up> integral\<^isup>P M' g" by simp
4.1155    from G(2) have "(\<lambda>i x. f x * G i x) \<up> (\<lambda>x. f x * g x)"
4.1156      unfolding isoton_fun_expand by (auto intro!: isoton_cmult_right)
4.1157 -  then have "(\<lambda>i. (\<integral>\<^isup>+x. f x * G i x)) \<up> (\<integral>\<^isup>+x. f x * g x)"
4.1158 +  then have "(\<lambda>i. (\<integral>\<^isup>+x. f x * G i x \<partial>M)) \<up> (\<integral>\<^isup>+x. f x * g x \<partial>M)"
4.1159      using assms(1) G_borel by (auto intro!: positive_integral_isoton borel_measurable_pextreal_times)
4.1160 -  with eq_Tg show "T.positive_integral g = (\<integral>\<^isup>+x. f x * g x)"
4.1161 +  with eq_Tg show "integral\<^isup>P M' g = (\<integral>\<^isup>+x. f x * g x \<partial>M)"
4.1162      unfolding isoton_def by simp
4.1163  qed
4.1164
4.1165  lemma (in measure_space) positive_integral_null_set:
4.1166 -  assumes "N \<in> null_sets" shows "(\<integral>\<^isup>+ x. u x * indicator N x) = 0"
4.1167 +  assumes "N \<in> null_sets" shows "(\<integral>\<^isup>+ x. u x * indicator N x \<partial>M) = 0"
4.1168  proof -
4.1169 -  have "(\<integral>\<^isup>+ x. u x * indicator N x) = (\<integral>\<^isup>+ x. 0)"
4.1170 +  have "(\<integral>\<^isup>+ x. u x * indicator N x \<partial>M) = (\<integral>\<^isup>+ x. 0 \<partial>M)"
4.1171    proof (intro positive_integral_cong_AE AE_I)
4.1172      show "{x \<in> space M. u x * indicator N x \<noteq> 0} \<subseteq> N"
4.1173        by (auto simp: indicator_def)
4.1174 @@ -1396,20 +1416,20 @@
4.1175
4.1176  lemma (in measure_space) positive_integral_Markov_inequality:
4.1177    assumes borel: "u \<in> borel_measurable M" and "A \<in> sets M" and c: "c \<noteq> \<omega>"
4.1178 -  shows "\<mu> ({x\<in>space M. 1 \<le> c * u x} \<inter> A) \<le> c * (\<integral>\<^isup>+ x. u x * indicator A x)"
4.1179 +  shows "\<mu> ({x\<in>space M. 1 \<le> c * u x} \<inter> A) \<le> c * (\<integral>\<^isup>+ x. u x * indicator A x \<partial>M)"
4.1180      (is "\<mu> ?A \<le> _ * ?PI")
4.1181  proof -
4.1182    have "?A \<in> sets M"
4.1183      using A \<in> sets M borel by auto
4.1184 -  hence "\<mu> ?A = (\<integral>\<^isup>+ x. indicator ?A x)"
4.1185 +  hence "\<mu> ?A = (\<integral>\<^isup>+ x. indicator ?A x \<partial>M)"
4.1186      using positive_integral_indicator by simp
4.1187 -  also have "\<dots> \<le> (\<integral>\<^isup>+ x. c * (u x * indicator A x))"
4.1188 +  also have "\<dots> \<le> (\<integral>\<^isup>+ x. c * (u x * indicator A x) \<partial>M)"
4.1189    proof (rule positive_integral_mono)
4.1190      fix x assume "x \<in> space M"
4.1191      show "indicator ?A x \<le> c * (u x * indicator A x)"
4.1192        by (cases "x \<in> ?A") auto
4.1193    qed
4.1194 -  also have "\<dots> = c * (\<integral>\<^isup>+ x. u x * indicator A x)"
4.1195 +  also have "\<dots> = c * (\<integral>\<^isup>+ x. u x * indicator A x \<partial>M)"
4.1196      using assms
4.1197      by (auto intro!: positive_integral_cmult borel_measurable_indicator)
4.1198    finally show ?thesis .
4.1199 @@ -1417,11 +1437,11 @@
4.1200
4.1201  lemma (in measure_space) positive_integral_0_iff:
4.1202    assumes borel: "u \<in> borel_measurable M"
4.1203 -  shows "positive_integral u = 0 \<longleftrightarrow> \<mu> {x\<in>space M. u x \<noteq> 0} = 0"
4.1204 +  shows "integral\<^isup>P M u = 0 \<longleftrightarrow> \<mu> {x\<in>space M. u x \<noteq> 0} = 0"
4.1205      (is "_ \<longleftrightarrow> \<mu> ?A = 0")
4.1206  proof -
4.1207    have A: "?A \<in> sets M" using borel by auto
4.1208 -  have u: "(\<integral>\<^isup>+ x. u x * indicator ?A x) = positive_integral u"
4.1209 +  have u: "(\<integral>\<^isup>+ x. u x * indicator ?A x \<partial>M) = integral\<^isup>P M u"
4.1210      by (auto intro!: positive_integral_cong simp: indicator_def)
4.1211
4.1212    show ?thesis
4.1213 @@ -1429,10 +1449,10 @@
4.1214      assume "\<mu> ?A = 0"
4.1215      hence "?A \<in> null_sets" using ?A \<in> sets M by auto
4.1216      from positive_integral_null_set[OF this]
4.1217 -    have "0 = (\<integral>\<^isup>+ x. u x * indicator ?A x)" by simp
4.1218 -    thus "positive_integral u = 0" unfolding u by simp
4.1219 +    have "0 = (\<integral>\<^isup>+ x. u x * indicator ?A x \<partial>M)" by simp
4.1220 +    thus "integral\<^isup>P M u = 0" unfolding u by simp
4.1221    next
4.1222 -    assume *: "positive_integral u = 0"
4.1223 +    assume *: "integral\<^isup>P M u = 0"
4.1224      let "?M n" = "{x \<in> space M. 1 \<le> of_nat n * u x}"
4.1225      have "0 = (SUP n. \<mu> (?M n \<inter> ?A))"
4.1226      proof -
4.1227 @@ -1469,34 +1489,34 @@
4.1228
4.1229  lemma (in measure_space) positive_integral_restricted:
4.1230    assumes "A \<in> sets M"
4.1231 -  shows "measure_space.positive_integral (restricted_space A) \<mu> f = (\<integral>\<^isup>+ x. f x * indicator A x)"
4.1232 -    (is "measure_space.positive_integral ?R \<mu> f = positive_integral ?f")
4.1233 +  shows "integral\<^isup>P (restricted_space A) f = (\<integral>\<^isup>+ x. f x * indicator A x \<partial>M)"
4.1234 +    (is "integral\<^isup>P ?R f = integral\<^isup>P M ?f")
4.1235  proof -
4.1236 -  have msR: "measure_space ?R \<mu>" by (rule restricted_measure_space[OF A \<in> sets M])
4.1237 -  then interpret R: measure_space ?R \<mu> .
4.1238 +  have msR: "measure_space ?R" by (rule restricted_measure_space[OF A \<in> sets M])
4.1239 +  then interpret R: measure_space ?R .
4.1240    have saR: "sigma_algebra ?R" by fact
4.1241 -  have *: "R.positive_integral f = R.positive_integral ?f"
4.1242 +  have *: "integral\<^isup>P ?R f = integral\<^isup>P ?R ?f"
4.1243      by (intro R.positive_integral_cong) auto
4.1244    show ?thesis
4.1245 -    unfolding * R.positive_integral_def positive_integral_def
4.1246 +    unfolding * positive_integral_def
4.1247      unfolding simple_function_restricted[OF A \<in> sets M]
4.1249      apply (rule arg_cong[where f=Sup])
4.1250    proof (auto simp add: image_iff simple_integral_restricted[OF A \<in> sets M])
4.1251 -    fix g assume "simple_function (\<lambda>x. g x * indicator A x)"
4.1252 +    fix g assume "simple_function M (\<lambda>x. g x * indicator A x)"
4.1253        "g \<le> f"
4.1254 -    then show "\<exists>x. simple_function x \<and> x \<le> (\<lambda>x. f x * indicator A x) \<and>
4.1255 -      (\<integral>\<^isup>Sx. g x * indicator A x) = simple_integral x"
4.1256 +    then show "\<exists>x. simple_function M x \<and> x \<le> (\<lambda>x. f x * indicator A x) \<and>
4.1257 +      (\<integral>\<^isup>Sx. g x * indicator A x \<partial>M) = integral\<^isup>S M x"
4.1258        apply (rule_tac exI[of _ "\<lambda>x. g x * indicator A x"])
4.1259        by (auto simp: indicator_def le_fun_def)
4.1260    next
4.1261 -    fix g assume g: "simple_function g" "g \<le> (\<lambda>x. f x * indicator A x)"
4.1262 +    fix g assume g: "simple_function M g" "g \<le> (\<lambda>x. f x * indicator A x)"
4.1263      then have *: "(\<lambda>x. g x * indicator A x) = g"
4.1264        "\<And>x. g x * indicator A x = g x"
4.1265        "\<And>x. g x \<le> f x"
4.1266        by (auto simp: le_fun_def fun_eq_iff indicator_def split: split_if_asm)
4.1267 -    from g show "\<exists>x. simple_function (\<lambda>xa. x xa * indicator A xa) \<and> x \<le> f \<and>
4.1268 -      simple_integral g = simple_integral (\<lambda>xa. x xa * indicator A xa)"
4.1269 +    from g show "\<exists>x. simple_function M (\<lambda>xa. x xa * indicator A xa) \<and> x \<le> f \<and>
4.1270 +      integral\<^isup>S M g = integral\<^isup>S M (\<lambda>xa. x xa * indicator A xa)"
4.1271        using A \<in> sets M[THEN sets_into_space]
4.1272        apply (rule_tac exI[of _ "\<lambda>x. g x * indicator A x"])
4.1273        by (fastsimp simp: le_fun_def *)
4.1274 @@ -1505,103 +1525,113 @@
4.1275
4.1276  lemma (in measure_space) positive_integral_subalgebra:
4.1277    assumes borel: "f \<in> borel_measurable N"
4.1278 -  and N: "sets N \<subseteq> sets M" "space N = space M" and sa: "sigma_algebra N"
4.1279 -  shows "measure_space.positive_integral N \<mu> f = positive_integral f"
4.1280 +  and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> measure N A = \<mu> A"
4.1281 +  and sa: "sigma_algebra N"
4.1282 +  shows "integral\<^isup>P N f = integral\<^isup>P M f"
4.1283  proof -
4.1284 -  interpret N: measure_space N \<mu> using measure_space_subalgebra[OF sa N] .
4.1285 +  interpret N: measure_space N using measure_space_subalgebra[OF sa N] .
4.1286    from N.borel_measurable_implies_simple_function_sequence[OF borel]
4.1287 -  obtain fs where Nsf: "\<And>i. N.simple_function (fs i)" and "fs \<up> f" by blast
4.1288 -  then have sf: "\<And>i. simple_function (fs i)"
4.1289 -    using simple_function_subalgebra[OF _ N sa] by blast
4.1290 -  from positive_integral_isoton_simple[OF fs \<up> f sf] N.positive_integral_isoton_simple[OF fs \<up> f Nsf]
4.1291 -  show ?thesis unfolding isoton_def simple_integral_def N.simple_integral_def space N = space M by simp
4.1292 +  obtain fs where Nsf: "\<And>i. simple_function N (fs i)" and "fs \<up> f" by blast
4.1293 +  then have sf: "\<And>i. simple_function M (fs i)"
4.1294 +    using simple_function_subalgebra[OF _ N(1,2)] by blast
4.1295 +  from N.positive_integral_isoton_simple[OF fs \<up> f Nsf]
4.1296 +  have "integral\<^isup>P N f = (SUP i. \<Sum>x\<in>fs i  space M. x * N.\<mu> (fs i - {x} \<inter> space M))"
4.1297 +    unfolding isoton_def simple_integral_def space N = space M by simp
4.1298 +  also have "\<dots> = (SUP i. \<Sum>x\<in>fs i  space M. x * \<mu> (fs i - {x} \<inter> space M))"
4.1299 +    using N N.simple_functionD(2)[OF Nsf] unfolding space N = space M by auto
4.1300 +  also have "\<dots> = integral\<^isup>P M f"
4.1301 +    using positive_integral_isoton_simple[OF fs \<up> f sf]
4.1302 +    unfolding isoton_def simple_integral_def space N = space M by simp
4.1303 +  finally show ?thesis .
4.1304  qed
4.1305
4.1306  section "Lebesgue Integral"
4.1307
4.1308 -definition (in measure_space) integrable where
4.1309 -  "integrable f \<longleftrightarrow> f \<in> borel_measurable M \<and>
4.1310 -    (\<integral>\<^isup>+ x. Real (f x)) \<noteq> \<omega> \<and>
4.1311 -    (\<integral>\<^isup>+ x. Real (- f x)) \<noteq> \<omega>"
4.1312 +definition integrable where
4.1313 +  "integrable M f \<longleftrightarrow> f \<in> borel_measurable M \<and>
4.1314 +    (\<integral>\<^isup>+ x. Real (f x) \<partial>M) \<noteq> \<omega> \<and>
4.1315 +    (\<integral>\<^isup>+ x. Real (- f x) \<partial>M) \<noteq> \<omega>"
4.1316
4.1317 -lemma (in measure_space) integrableD[dest]:
4.1318 -  assumes "integrable f"
4.1319 -  shows "f \<in> borel_measurable M"
4.1320 -  "(\<integral>\<^isup>+ x. Real (f x)) \<noteq> \<omega>"
4.1321 -  "(\<integral>\<^isup>+ x. Real (- f x)) \<noteq> \<omega>"
4.1322 +lemma integrableD[dest]:
4.1323 +  assumes "integrable M f"
4.1324 +  shows "f \<in> borel_measurable M" "(\<integral>\<^isup>+ x. Real (f x) \<partial>M) \<noteq> \<omega>" "(\<integral>\<^isup>+ x. Real (- f x) \<partial>M) \<noteq> \<omega>"
4.1325    using assms unfolding integrable_def by auto
4.1326
4.1327 -definition (in measure_space) integral (binder "\<integral> " 10) where
4.1328 -  "integral f = real ((\<integral>\<^isup>+ x. Real (f x))) - real ((\<integral>\<^isup>+ x. Real (- f x)))"
4.1329 +definition lebesgue_integral_def:
4.1330 +  "integral\<^isup>L M f = real ((\<integral>\<^isup>+ x. Real (f x) \<partial>M)) - real ((\<integral>\<^isup>+ x. Real (- f x) \<partial>M))"
4.1331 +
4.1332 +syntax
4.1333 +  "_lebesgue_integral" :: "'a \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> ('a, 'b) measure_space_scheme \<Rightarrow> real" ("\<integral> _. _ \<partial>_" [60,61] 110)
4.1334 +
4.1335 +translations
4.1336 +  "\<integral> x. f \<partial>M" == "CONST integral\<^isup>L M (%x. f)"
4.1337
4.1338  lemma (in measure_space) integral_cong:
4.1339 -  assumes cong: "\<And>x. x \<in> space M \<Longrightarrow> f x = g x"
4.1340 -  shows "integral f = integral g"
4.1341 -  using assms by (simp cong: positive_integral_cong add: integral_def)
4.1342 +  assumes "\<And>x. x \<in> space M \<Longrightarrow> f x = g x"
4.1343 +  shows "integral\<^isup>L M f = integral\<^isup>L M g"
4.1344 +  using assms by (simp cong: positive_integral_cong add: lebesgue_integral_def)
4.1345
4.1346  lemma (in measure_space) integral_cong_measure:
4.1347 -  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = \<mu> A"
4.1348 -  shows "measure_space.integral M \<nu> f = integral f"
4.1349 +  assumes "\<And>A. A \<in> sets M \<Longrightarrow> measure N A = \<mu> A" "sets N = sets M" "space N = space M"
4.1350 +  shows "integral\<^isup>L N f = integral\<^isup>L M f"
4.1351  proof -
4.1352 -  interpret v: measure_space M \<nu>
4.1353 -    by (rule measure_space_cong) fact
4.1354 +  interpret v: measure_space N
4.1355 +    by (rule measure_space_cong) fact+
4.1356    show ?thesis
4.1357 -    unfolding integral_def v.integral_def
4.1358 -    by (simp add: positive_integral_cong_measure[OF assms])
4.1359 +    by (simp add: positive_integral_cong_measure[OF assms] lebesgue_integral_def)
4.1360  qed
4.1361
4.1362  lemma (in measure_space) integral_cong_AE:
4.1363    assumes cong: "AE x. f x = g x"
4.1364 -  shows "integral f = integral g"
4.1365 +  shows "integral\<^isup>L M f = integral\<^isup>L M g"
4.1366  proof -
4.1367    have "AE x. Real (f x) = Real (g x)"
4.1368      using cong by (rule AE_mp) simp
4.1369    moreover have "AE x. Real (- f x) = Real (- g x)"
4.1370      using cong by (rule AE_mp) simp
4.1371    ultimately show ?thesis
4.1372 -    by (simp cong: positive_integral_cong_AE add: integral_def)
4.1373 +    by (simp cong: positive_integral_cong_AE add: lebesgue_integral_def)
4.1374  qed
4.1375
4.1376  lemma (in measure_space) integrable_cong:
4.1377 -  "(\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> integrable f \<longleftrightarrow> integrable g"
4.1378 +  "(\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> integrable M f \<longleftrightarrow> integrable M g"
4.1379    by (simp cong: positive_integral_cong measurable_cong add: integrable_def)
4.1380
4.1381  lemma (in measure_space) integral_eq_positive_integral:
4.1382    assumes "\<And>x. 0 \<le> f x"
4.1383 -  shows "integral f = real ((\<integral>\<^isup>+ x. Real (f x)))"
4.1384 +  shows "integral\<^isup>L M f = real (\<integral>\<^isup>+ x. Real (f x) \<partial>M)"
4.1385  proof -
4.1386    have "\<And>x. Real (- f x) = 0" using assms by simp
4.1387 -  thus ?thesis by (simp del: Real_eq_0 add: integral_def)
4.1388 +  thus ?thesis by (simp del: Real_eq_0 add: lebesgue_integral_def)
4.1389  qed
4.1390
4.1391  lemma (in measure_space) integral_vimage:
4.1392    assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
4.1393 -  assumes f: "measure_space.integrable M' (\<lambda>A. \<mu> (T - A \<inter> space M)) f"
4.1394 -  shows "integrable (\<lambda>x. f (T x))" (is ?P)
4.1395 -    and "measure_space.integral M' (\<lambda>A. \<mu> (T - A \<inter> space M)) f = (\<integral>x. f (T x))" (is ?I)
4.1396 +    and \<nu>: "\<And>A. A \<in> sets M' \<Longrightarrow> measure M' A = \<mu> (T - A \<inter> space M)"
4.1397 +  assumes f: "integrable M' f"
4.1398 +  shows "integrable M (\<lambda>x. f (T x))" (is ?P)
4.1399 +    and "integral\<^isup>L M' f = (\<integral>x. f (T x) \<partial>M)" (is ?I)
4.1400  proof -
4.1401 -  interpret T: measure_space M' "\<lambda>A. \<mu> (T - A \<inter> space M)"
4.1402 -    using T by (rule measure_space_vimage) auto
4.1403 +  interpret T: measure_space M' using \<nu> by (rule measure_space_vimage[OF T])
4.1404    from measurable_comp[OF T(2), of f borel]
4.1405    have borel: "(\<lambda>x. Real (f x)) \<in> borel_measurable M'" "(\<lambda>x. Real (- f x)) \<in> borel_measurable M'"
4.1406      and "(\<lambda>x. f (T x)) \<in> borel_measurable M"
4.1407 -    using f unfolding T.integrable_def by (auto simp: comp_def)
4.1408 +    using f unfolding integrable_def by (auto simp: comp_def)
4.1409    then show ?P ?I
4.1410 -    using f unfolding T.integral_def integral_def T.integrable_def integrable_def
4.1411 -    unfolding borel[THEN positive_integral_vimage[OF T]] by auto
4.1412 +    using f unfolding lebesgue_integral_def integrable_def
4.1413 +    by (auto simp: borel[THEN positive_integral_vimage[OF T], OF \<nu>])
4.1414  qed
4.1415
4.1416  lemma (in measure_space) integral_minus[intro, simp]:
4.1417 -  assumes "integrable f"
4.1418 -  shows "integrable (\<lambda>x. - f x)" "(\<integral>x. - f x) = - integral f"
4.1419 -  using assms by (auto simp: integrable_def integral_def)
4.1420 +  assumes "integrable M f"
4.1421 +  shows "integrable M (\<lambda>x. - f x)" "(\<integral>x. - f x \<partial>M) = - integral\<^isup>L M f"
4.1422 +  using assms by (auto simp: integrable_def lebesgue_integral_def)
4.1423
4.1424  lemma (in measure_space) integral_of_positive_diff:
4.1425 -  assumes integrable: "integrable u" "integrable v"
4.1426 +  assumes integrable: "integrable M u" "integrable M v"
4.1427    and f_def: "\<And>x. f x = u x - v x" and pos: "\<And>x. 0 \<le> u x" "\<And>x. 0 \<le> v x"
4.1428 -  shows "integrable f" and "integral f = integral u - integral v"
4.1429 +  shows "integrable M f" and "integral\<^isup>L M f = integral\<^isup>L M u - integral\<^isup>L M v"
4.1430  proof -
4.1431 -  let ?PI = positive_integral
4.1432    let "?f x" = "Real (f x)"
4.1433    let "?mf x" = "Real (- f x)"
4.1434    let "?u x" = "Real (u x)"
4.1435 @@ -1615,38 +1645,39 @@
4.1436      "f \<in> borel_measurable M"
4.1437      by (auto simp: f_def[symmetric] integrable_def)
4.1438
4.1439 -  have "?PI (\<lambda>x. Real (u x - v x)) \<le> ?PI ?u"
4.1440 +  have "(\<integral>\<^isup>+ x. Real (u x - v x) \<partial>M) \<le> integral\<^isup>P M ?u"
4.1441      using pos by (auto intro!: positive_integral_mono)
4.1442 -  moreover have "?PI (\<lambda>x. Real (v x - u x)) \<le> ?PI ?v"
4.1443 +  moreover have "(\<integral>\<^isup>+ x. Real (v x - u x) \<partial>M) \<le> integral\<^isup>P M ?v"
4.1444      using pos by (auto intro!: positive_integral_mono)
4.1445 -  ultimately show f: "integrable f"
4.1446 -    using integrable u integrable v f \<in> borel_measurable M
4.1447 +  ultimately show f: "integrable M f"
4.1448 +    using integrable M u integrable M v f \<in> borel_measurable M
4.1449      by (auto simp: integrable_def f_def)
4.1450 -  hence mf: "integrable (\<lambda>x. - f x)" ..
4.1451 +  hence mf: "integrable M (\<lambda>x. - f x)" ..
4.1452
4.1453    have *: "\<And>x. Real (- v x) = 0" "\<And>x. Real (- u x) = 0"
4.1454      using pos by auto
4.1455
4.1456    have "\<And>x. ?u x + ?mf x = ?v x + ?f x"
4.1457      unfolding f_def using pos by simp
4.1458 -  hence "?PI (\<lambda>x. ?u x + ?mf x) = ?PI (\<lambda>x. ?v x + ?f x)" by simp
4.1459 -  hence "real (?PI ?u + ?PI ?mf) = real (?PI ?v + ?PI ?f)"
4.1460 +  hence "(\<integral>\<^isup>+ x. ?u x + ?mf x \<partial>M) = (\<integral>\<^isup>+ x. ?v x + ?f x \<partial>M)" by simp
4.1461 +  hence "real (integral\<^isup>P M ?u + integral\<^isup>P M ?mf) =
4.1462 +      real (integral\<^isup>P M ?v + integral\<^isup>P M ?f)"
4.1465      by auto
4.1466 -  then show "integral f = integral u - integral v"
4.1467 -    using f mf integrable u integrable v
4.1468 -    unfolding integral_def integrable_def *
4.1469 -    by (cases "?PI ?f", cases "?PI ?mf", cases "?PI ?v", cases "?PI ?u")
4.1470 +  then show "integral\<^isup>L M f = integral\<^isup>L M u - integral\<^isup>L M v"
4.1471 +    using f mf integrable M u integrable M v
4.1472 +    unfolding lebesgue_integral_def integrable_def *
4.1473 +    by (cases "integral\<^isup>P M ?f", cases "integral\<^isup>P M ?mf", cases "integral\<^isup>P M ?v", cases "integral\<^isup>P M ?u")
4.1475  qed
4.1476
4.1477  lemma (in measure_space) integral_linear:
4.1478 -  assumes "integrable f" "integrable g" and "0 \<le> a"
4.1479 -  shows "integrable (\<lambda>t. a * f t + g t)"
4.1480 -  and "(\<integral> t. a * f t + g t) = a * integral f + integral g"
4.1481 +  assumes "integrable M f" "integrable M g" and "0 \<le> a"
4.1482 +  shows "integrable M (\<lambda>t. a * f t + g t)"
4.1483 +  and "(\<integral> t. a * f t + g t \<partial>M) = a * integral\<^isup>L M f + integral\<^isup>L M g"
4.1484  proof -
4.1485 -  let ?PI = positive_integral
4.1486 +  let ?PI = "integral\<^isup>P M"
4.1487    let "?f x" = "Real (f x)"
4.1488    let "?g x" = "Real (g x)"
4.1489    let "?mf x" = "Real (- f x)"
4.1490 @@ -1670,37 +1701,36 @@
4.1491      positive_integral_linear[OF pos]
4.1492      positive_integral_linear[OF neg]
4.1493
4.1494 -  have "integrable ?p" "integrable ?n"
4.1495 +  have "integrable M ?p" "integrable M ?n"
4.1496        "\<And>t. a * f t + g t = ?p t - ?n t" "\<And>t. 0 \<le> ?p t" "\<And>t. 0 \<le> ?n t"
4.1497      using assms p n unfolding integrable_def * linear by auto
4.1498    note diff = integral_of_positive_diff[OF this]
4.1499
4.1500 -  show "integrable (\<lambda>t. a * f t + g t)" by (rule diff)
4.1501 +  show "integrable M (\<lambda>t. a * f t + g t)" by (rule diff)
4.1502
4.1503 -  from assms show "(\<integral> t. a * f t + g t) = a * integral f + integral g"
4.1504 -    unfolding diff(2) unfolding integral_def * linear integrable_def
4.1505 +  from assms show "(\<integral> t. a * f t + g t \<partial>M) = a * integral\<^isup>L M f + integral\<^isup>L M g"
4.1506 +    unfolding diff(2) unfolding lebesgue_integral_def * linear integrable_def
4.1507      by (cases "?PI ?f", cases "?PI ?mf", cases "?PI ?g", cases "?PI ?mg")
4.1508         (auto simp add: field_simps zero_le_mult_iff)
4.1509  qed
4.1510
4.1511  lemma (in measure_space) integral_add[simp, intro]:
4.1512 -  assumes "integrable f" "integrable g"
4.1513 -  shows "integrable (\<lambda>t. f t + g t)"
4.1514 -  and "(\<integral> t. f t + g t) = integral f + integral g"
4.1515 +  assumes "integrable M f" "integrable M g"
4.1516 +  shows "integrable M (\<lambda>t. f t + g t)"
4.1517 +  and "(\<integral> t. f t + g t \<partial>M) = integral\<^isup>L M f + integral\<^isup>L M g"
4.1518    using assms integral_linear[where a=1] by auto
4.1519
4.1520  lemma (in measure_space) integral_zero[simp, intro]:
4.1521 -  shows "integrable (\<lambda>x. 0)"
4.1522 -  and "(\<integral> x.0) = 0"
4.1523 -  unfolding integrable_def integral_def
4.1524 +  shows "integrable M (\<lambda>x. 0)" "(\<integral> x.0 \<partial>M) = 0"
4.1525 +  unfolding integrable_def lebesgue_integral_def
4.1526    by (auto simp add: borel_measurable_const)
4.1527
4.1528  lemma (in measure_space) integral_cmult[simp, intro]:
4.1529 -  assumes "integrable f"
4.1530 -  shows "integrable (\<lambda>t. a * f t)" (is ?P)
4.1531 -  and "(\<integral> t. a * f t) = a * integral f" (is ?I)
4.1532 +  assumes "integrable M f"
4.1533 +  shows "integrable M (\<lambda>t. a * f t)" (is ?P)
4.1534 +  and "(\<integral> t. a * f t \<partial>M) = a * integral\<^isup>L M f" (is ?I)
4.1535  proof -
4.1536 -  have "integrable (\<lambda>t. a * f t) \<and> (\<integral> t. a * f t) = a * integral f"
4.1537 +  have "integrable M (\<lambda>t. a * f t) \<and> (\<integral> t. a * f t \<partial>M) = a * integral\<^isup>L M f"
4.1538    proof (cases rule: le_cases)
4.1539      assume "0 \<le> a" show ?thesis
4.1540        using integral_linear[OF assms integral_zero(1) 0 \<le> a]
4.1541 @@ -1716,56 +1746,56 @@
4.1542  qed
4.1543
4.1544  lemma (in measure_space) integral_multc:
4.1545 -  assumes "integrable f"
4.1546 -  shows "(\<integral> x. f x * c) = integral f * c"
4.1547 +  assumes "integrable M f"
4.1548 +  shows "(\<integral> x. f x * c \<partial>M) = integral\<^isup>L M f * c"
4.1549    unfolding mult_commute[of _ c] integral_cmult[OF assms] ..
4.1550
4.1551  lemma (in measure_space) integral_mono_AE:
4.1552 -  assumes fg: "integrable f" "integrable g"
4.1553 +  assumes fg: "integrable M f" "integrable M g"
4.1554    and mono: "AE t. f t \<le> g t"
4.1555 -  shows "integral f \<le> integral g"
4.1556 +  shows "integral\<^isup>L M f \<le> integral\<^isup>L M g"
4.1557  proof -
4.1558    have "AE x. Real (f x) \<le> Real (g x)"
4.1559      using mono by (rule AE_mp) (auto intro!: AE_cong)
4.1560 -  moreover have "AE x. Real (- g x) \<le> Real (- f x)"
4.1561 +  moreover have "AE x. Real (- g x) \<le> Real (- f x)"
4.1562      using mono by (rule AE_mp) (auto intro!: AE_cong)
4.1563    ultimately show ?thesis using fg
4.1564 -    by (auto simp: integral_def integrable_def diff_minus
4.1565 +    by (auto simp: lebesgue_integral_def integrable_def diff_minus
4.1567  qed
4.1568
4.1569  lemma (in measure_space) integral_mono:
4.1570 -  assumes fg: "integrable f" "integrable g"
4.1571 +  assumes fg: "integrable M f" "integrable M g"
4.1572    and mono: "\<And>t. t \<in> space M \<Longrightarrow> f t \<le> g t"
4.1573 -  shows "integral f \<le> integral g"
4.1574 +  shows "integral\<^isup>L M f \<le> integral\<^isup>L M g"
4.1575    apply (rule integral_mono_AE[OF fg])
4.1576    using mono by (rule AE_cong) auto
4.1577
4.1578  lemma (in measure_space) integral_diff[simp, intro]:
4.1579 -  assumes f: "integrable f" and g: "integrable g"
4.1580 -  shows "integrable (\<lambda>t. f t - g t)"
4.1581 -  and "(\<integral> t. f t - g t) = integral f - integral g"
4.1582 +  assumes f: "integrable M f" and g: "integrable M g"
4.1583 +  shows "integrable M (\<lambda>t. f t - g t)"
4.1584 +  and "(\<integral> t. f t - g t \<partial>M) = integral\<^isup>L M f - integral\<^isup>L M g"
4.1585    using integral_add[OF f integral_minus(1)[OF g]]
4.1586    unfolding diff_minus integral_minus(2)[OF g]
4.1587    by auto
4.1588
4.1589  lemma (in measure_space) integral_indicator[simp, intro]:
4.1590    assumes "a \<in> sets M" and "\<mu> a \<noteq> \<omega>"
4.1591 -  shows "integral (indicator a) = real (\<mu> a)" (is ?int)
4.1592 -  and "integrable (indicator a)" (is ?able)
4.1593 +  shows "integral\<^isup>L M (indicator a) = real (\<mu> a)" (is ?int)
4.1594 +  and "integrable M (indicator a)" (is ?able)
4.1595  proof -
4.1596    have *:
4.1597      "\<And>A x. Real (indicator A x) = indicator A x"
4.1598      "\<And>A x. Real (- indicator A x) = 0" unfolding indicator_def by auto
4.1599    show ?int ?able
4.1600 -    using assms unfolding integral_def integrable_def
4.1601 +    using assms unfolding lebesgue_integral_def integrable_def
4.1602      by (auto simp: * positive_integral_indicator borel_measurable_indicator)
4.1603  qed
4.1604
4.1605  lemma (in measure_space) integral_cmul_indicator:
4.1606    assumes "A \<in> sets M" and "c \<noteq> 0 \<Longrightarrow> \<mu> A \<noteq> \<omega>"
4.1607 -  shows "integrable (\<lambda>x. c * indicator A x)" (is ?P)
4.1608 -  and "(\<integral>x. c * indicator A x) = c * real (\<mu> A)" (is ?I)
4.1609 +  shows "integrable M (\<lambda>x. c * indicator A x)" (is ?P)
4.1610 +  and "(\<integral>x. c * indicator A x \<partial>M) = c * real (\<mu> A)" (is ?I)
4.1611  proof -
4.1612    show ?P
4.1613    proof (cases "c = 0")
4.1614 @@ -1779,9 +1809,9 @@
4.1615  qed
4.1616
4.1617  lemma (in measure_space) integral_setsum[simp, intro]:
4.1618 -  assumes "\<And>n. n \<in> S \<Longrightarrow> integrable (f n)"
4.1619 -  shows "(\<integral>x. \<Sum> i \<in> S. f i x) = (\<Sum> i \<in> S. integral (f i))" (is "?int S")
4.1620 -    and "integrable (\<lambda>x. \<Sum> i \<in> S. f i x)" (is "?I S")
4.1621 +  assumes "\<And>n. n \<in> S \<Longrightarrow> integrable M (f n)"
4.1622 +  shows "(\<integral>x. (\<Sum> i \<in> S. f i x) \<partial>M) = (\<Sum> i \<in> S. integral\<^isup>L M (f i))" (is "?int S")
4.1623 +    and "integrable M (\<lambda>x. \<Sum> i \<in> S. f i x)" (is "?I S")
4.1624  proof -
4.1625    have "?int S \<and> ?I S"
4.1626    proof (cases "finite S")
4.1627 @@ -1792,8 +1822,8 @@
4.1628  qed
4.1629
4.1630  lemma (in measure_space) integrable_abs:
4.1631 -  assumes "integrable f"
4.1632 -  shows "integrable (\<lambda> x. \<bar>f x\<bar>)"
4.1633 +  assumes "integrable M f"
4.1634 +  shows "integrable M (\<lambda> x. \<bar>f x\<bar>)"
4.1635  proof -
4.1636    have *:
4.1637      "\<And>x. Real \<bar>f x\<bar> = Real (f x) + Real (- f x)"
4.1638 @@ -1808,56 +1838,55 @@
4.1639
4.1640  lemma (in measure_space) integral_subalgebra:
4.1641    assumes borel: "f \<in> borel_measurable N"
4.1642 -  and N: "sets N \<subseteq> sets M" "space N = space M" and sa: "sigma_algebra N"
4.1643 -  shows "measure_space.integrable N \<mu> f \<longleftrightarrow> integrable f" (is ?P)
4.1644 -    and "measure_space.integral N \<mu> f = integral f" (is ?I)
4.1645 +  and N: "sets N \<subseteq> sets M" "space N = space M" "\<And>A. A \<in> sets N \<Longrightarrow> measure N A = \<mu> A" and sa: "sigma_algebra N"
4.1646 +  shows "integrable N f \<longleftrightarrow> integrable M f" (is ?P)
4.1647 +    and "integral\<^isup>L N f = integral\<^isup>L M f" (is ?I)
4.1648  proof -
4.1649 -  interpret N: measure_space N \<mu> using measure_space_subalgebra[OF sa N] .
4.1650 +  interpret N: measure_space N using measure_space_subalgebra[OF sa N] .
4.1651    have "(\<lambda>x. Real (f x)) \<in> borel_measurable N" "(\<lambda>x. Real (- f x)) \<in> borel_measurable N"
4.1652      using borel by auto
4.1653    note * = this[THEN positive_integral_subalgebra[OF _ N sa]]
4.1654    have "f \<in> borel_measurable M \<longleftrightarrow> f \<in> borel_measurable N"
4.1655      using assms unfolding measurable_def by auto
4.1656 -  then show ?P ?I unfolding integrable_def N.integrable_def integral_def N.integral_def
4.1657 -    unfolding * by auto
4.1658 +  then show ?P ?I by (auto simp: * integrable_def lebesgue_integral_def)
4.1659  qed
4.1660
4.1661  lemma (in measure_space) integrable_bound:
4.1662 -  assumes "integrable f"
4.1663 +  assumes "integrable M f"
4.1664    and f: "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> f x"
4.1665      "\<And>x. x \<in> space M \<Longrightarrow> \<bar>g x\<bar> \<le> f x"
4.1666    assumes borel: "g \<in> borel_measurable M"
4.1667 -  shows "integrable g"
4.1668 +  shows "integrable M g"
4.1669  proof -
4.1670 -  have "(\<integral>\<^isup>+ x. Real (g x)) \<le> (\<integral>\<^isup>+ x. Real \<bar>g x\<bar>)"
4.1671 +  have "(\<integral>\<^isup>+ x. Real (g x) \<partial>M) \<le> (\<integral>\<^isup>+ x. Real \<bar>g x\<bar> \<partial>M)"
4.1672      by (auto intro!: positive_integral_mono)
4.1673 -  also have "\<dots> \<le> (\<integral>\<^isup>+ x. Real (f x))"
4.1674 +  also have "\<dots> \<le> (\<integral>\<^isup>+ x. Real (f x) \<partial>M)"
4.1675      using f by (auto intro!: positive_integral_mono)
4.1676    also have "\<dots> < \<omega>"
4.1677 -    using integrable f unfolding integrable_def by (auto simp: pextreal_less_\<omega>)
4.1678 -  finally have pos: "(\<integral>\<^isup>+ x. Real (g x)) < \<omega>" .
4.1679 +    using integrable M f unfolding integrable_def by (auto simp: pextreal_less_\<omega>)
4.1680 +  finally have pos: "(\<integral>\<^isup>+ x. Real (g x) \<partial>M) < \<omega>" .
4.1681
4.1682 -  have "(\<integral>\<^isup>+ x. Real (- g x)) \<le> (\<integral>\<^isup>+ x. Real (\<bar>g x\<bar>))"
4.1683 +  have "(\<integral>\<^isup>+ x. Real (- g x) \<partial>M) \<le> (\<integral>\<^isup>+ x. Real (\<bar>g x\<bar>) \<partial>M)"
4.1684      by (auto intro!: positive_integral_mono)
4.1685 -  also have "\<dots> \<le> (\<integral>\<^isup>+ x. Real (f x))"
4.1686 +  also have "\<dots> \<le> (\<integral>\<^isup>+ x. Real (f x) \<partial>M)"
4.1687      using f by (auto intro!: positive_integral_mono)
4.1688    also have "\<dots> < \<omega>"
4.1689 -    using integrable f unfolding integrable_def by (auto simp: pextreal_less_\<omega>)
4.1690 -  finally have neg: "(\<integral>\<^isup>+ x. Real (- g x)) < \<omega>" .
4.1691 +    using integrable M f unfolding integrable_def by (auto simp: pextreal_less_\<omega>)
4.1692 +  finally have neg: "(\<integral>\<^isup>+ x. Real (- g x) \<partial>M) < \<omega>" .
4.1693
4.1694    from neg pos borel show ?thesis
4.1695      unfolding integrable_def by auto
4.1696  qed
4.1697
4.1698  lemma (in measure_space) integrable_abs_iff:
4.1699 -  "f \<in> borel_measurable M \<Longrightarrow> integrable (\<lambda> x. \<bar>f x\<bar>) \<longleftrightarrow> integrable f"
4.1700 +  "f \<in> borel_measurable M \<Longrightarrow> integrable M (\<lambda> x. \<bar>f x\<bar>) \<longleftrightarrow> integrable M f"
4.1701    by (auto intro!: integrable_bound[where g=f] integrable_abs)
4.1702
4.1703  lemma (in measure_space) integrable_max:
4.1704 -  assumes int: "integrable f" "integrable g"
4.1705 -  shows "integrable (\<lambda> x. max (f x) (g x))"
4.1706 +  assumes int: "integrable M f" "integrable M g"
4.1707 +  shows "integrable M (\<lambda> x. max (f x) (g x))"
4.1708  proof (rule integrable_bound)
4.1709 -  show "integrable (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
4.1710 +  show "integrable M (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
4.1711      using int by (simp add: integrable_abs)
4.1712    show "(\<lambda>x. max (f x) (g x)) \<in> borel_measurable M"
4.1713      using int unfolding integrable_def by auto
4.1714 @@ -1868,10 +1897,10 @@
4.1715  qed
4.1716
4.1717  lemma (in measure_space) integrable_min:
4.1718 -  assumes int: "integrable f" "integrable g"
4.1719 -  shows "integrable (\<lambda> x. min (f x) (g x))"
4.1720 +  assumes int: "integrable M f" "integrable M g"
4.1721 +  shows "integrable M (\<lambda> x. min (f x) (g x))"
4.1722  proof (rule integrable_bound)
4.1723 -  show "integrable (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
4.1724 +  show "integrable M (\<lambda>x. \<bar>f x\<bar> + \<bar>g x\<bar>)"
4.1725      using int by (simp add: integrable_abs)
4.1726    show "(\<lambda>x. min (f x) (g x)) \<in> borel_measurable M"
4.1727      using int unfolding integrable_def by auto
4.1728 @@ -1882,33 +1911,33 @@
4.1729  qed
4.1730
4.1731  lemma (in measure_space) integral_triangle_inequality:
4.1732 -  assumes "integrable f"
4.1733 -  shows "\<bar>integral f\<bar> \<le> (\<integral>x. \<bar>f x\<bar>)"
4.1734 +  assumes "integrable M f"
4.1735 +  shows "\<bar>integral\<^isup>L M f\<bar> \<le> (\<integral>x. \<bar>f x\<bar> \<partial>M)"
4.1736  proof -
4.1737 -  have "\<bar>integral f\<bar> = max (integral f) (- integral f)" by auto
4.1738 -  also have "\<dots> \<le> (\<integral>x. \<bar>f x\<bar>)"
4.1739 +  have "\<bar>integral\<^isup>L M f\<bar> = max (integral\<^isup>L M f) (- integral\<^isup>L M f)" by auto
4.1740 +  also have "\<dots> \<le> (\<integral>x. \<bar>f x\<bar> \<partial>M)"
4.1741        using assms integral_minus(2)[of f, symmetric]
4.1742        by (auto intro!: integral_mono integrable_abs simp del: integral_minus)
4.1743    finally show ?thesis .
4.1744  qed
4.1745
4.1746  lemma (in measure_space) integral_positive:
4.1747 -  assumes "integrable f" "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> f x"
4.1748 -  shows "0 \<le> integral f"
4.1749 +  assumes "integrable M f" "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> f x"
4.1750 +  shows "0 \<le> integral\<^isup>L M f"
4.1751  proof -
4.1752 -  have "0 = (\<integral>x. 0)" by (auto simp: integral_zero)
4.1753 -  also have "\<dots> \<le> integral f"
4.1754 +  have "0 = (\<integral>x. 0 \<partial>M)" by (auto simp: integral_zero)
4.1755 +  also have "\<dots> \<le> integral\<^isup>L M f"
4.1756      using assms by (rule integral_mono[OF integral_zero(1)])
4.1757    finally show ?thesis .
4.1758  qed
4.1759
4.1760  lemma (in measure_space) integral_monotone_convergence_pos:
4.1761 -  assumes i: "\<And>i. integrable (f i)" and mono: "\<And>x. mono (\<lambda>n. f n x)"
4.1762 +  assumes i: "\<And>i. integrable M (f i)" and mono: "\<And>x. mono (\<lambda>n. f n x)"
4.1763    and pos: "\<And>x i. 0 \<le> f i x"
4.1764    and lim: "\<And>x. (\<lambda>i. f i x) ----> u x"
4.1765 -  and ilim: "(\<lambda>i. integral (f i)) ----> x"
4.1766 -  shows "integrable u"
4.1767 -  and "integral u = x"
4.1768 +  and ilim: "(\<lambda>i. integral\<^isup>L M (f i)) ----> x"
4.1769 +  shows "integrable M u"
4.1770 +  and "integral\<^isup>L M u = x"
4.1771  proof -
4.1772    { fix x have "0 \<le> u x"
4.1773        using mono pos[of 0 x] incseq_le[OF _ lim, of x 0]
4.1774 @@ -1928,43 +1957,42 @@
4.1775    hence borel_u: "u \<in> borel_measurable M"
4.1776      using pos_u by (auto simp: borel_measurable_Real_eq SUP_F)
4.1777
4.1778 -  have integral_eq: "\<And>n. (\<integral>\<^isup>+ x. Real (f n x)) = Real (integral (f n))"
4.1779 -    using i unfolding integral_def integrable_def by (auto simp: Real_real)
4.1780 +  have integral_eq: "\<And>n. (\<integral>\<^isup>+ x. Real (f n x) \<partial>M) = Real (integral\<^isup>L M (f n))"
4.1781 +    using i unfolding lebesgue_integral_def integrable_def by (auto simp: Real_real)
4.1782
4.1783 -  have pos_integral: "\<And>n. 0 \<le> integral (f n)"
4.1784 +  have pos_integral: "\<And>n. 0 \<le> integral\<^isup>L M (f n)"
4.1785      using pos i by (auto simp: integral_positive)
4.1786    hence "0 \<le> x"
4.1787      using LIMSEQ_le_const[OF ilim, of 0] by auto
4.1788
4.1789 -  have "(\<lambda>i. (\<integral>\<^isup>+ x. Real (f i x))) \<up> (\<integral>\<^isup>+ x. Real (u x))"
4.1790 +  have "(\<lambda>i. (\<integral>\<^isup>+ x. Real (f i x) \<partial>M)) \<up> (\<integral>\<^isup>+ x. Real (u x) \<partial>M)"
4.1791    proof (rule positive_integral_isoton)
4.1792      from SUP_F mono pos
4.1793      show "(\<lambda>i x. Real (f i x)) \<up> (\<lambda>x. Real (u x))"
4.1794        unfolding isoton_fun_expand by (auto simp: isoton_def mono_def)
4.1795    qed (rule borel_f)
4.1796 -  hence pI: "(\<integral>\<^isup>+ x. Real (u x)) =
4.1797 -      (SUP n. (\<integral>\<^isup>+ x. Real (f n x)))"
4.1798 +  hence pI: "(\<integral>\<^isup>+ x. Real (u x) \<partial>M) = (SUP n. (\<integral>\<^isup>+ x. Real (f n x) \<partial>M))"
4.1799      unfolding isoton_def by simp
4.1800    also have "\<dots> = Real x" unfolding integral_eq
4.1801    proof (rule SUP_eq_LIMSEQ[THEN iffD2])
4.1802 -    show "mono (\<lambda>n. integral (f n))"
4.1803 +    show "mono (\<lambda>n. integral\<^isup>L M (f n))"
4.1804        using mono i by (auto simp: mono_def intro!: integral_mono)
4.1805 -    show "\<And>n. 0 \<le> integral (f n)" using pos_integral .
4.1806 +    show "\<And>n. 0 \<le> integral\<^isup>L M (f n)" using pos_integral .
4.1807      show "0 \<le> x" using 0 \<le> x .
4.1808 -    show "(\<lambda>n. integral (f n)) ----> x" using ilim .
4.1809 +    show "(\<lambda>n. integral\<^isup>L M (f n)) ----> x" using ilim .
4.1810    qed
4.1811 -  finally show  "integrable u" "integral u = x" using borel_u 0 \<le> x
4.1812 -    unfolding integrable_def integral_def by auto
4.1813 +  finally show  "integrable M u" "integral\<^isup>L M u = x" using borel_u 0 \<le> x
4.1814 +    unfolding integrable_def lebesgue_integral_def by auto
4.1815  qed
4.1816
4.1817  lemma (in measure_space) integral_monotone_convergence:
4.1818 -  assumes f: "\<And>i. integrable (f i)" and "mono f"
4.1819 +  assumes f: "\<And>i. integrable M (f i)" and "mono f"
4.1820    and lim: "\<And>x. (\<lambda>i. f i x) ----> u x"
4.1821 -  and ilim: "(\<lambda>i. integral (f i)) ----> x"
4.1822 -  shows "integrable u"
4.1823 -  and "integral u = x"
4.1824 +  and ilim: "(\<lambda>i. integral\<^isup>L M (f i)) ----> x"
4.1825 +  shows "integrable M u"
4.1826 +  and "integral\<^isup>L M u = x"
4.1827  proof -
4.1828 -  have 1: "\<And>i. integrable (\<lambda>x. f i x - f 0 x)"
4.1829 +  have 1: "\<And>i. integrable M (\<lambda>x. f i x - f 0 x)"
4.1830        using f by (auto intro!: integral_diff)
4.1831    have 2: "\<And>x. mono (\<lambda>n. f n x - f 0 x)" using mono f
4.1832        unfolding mono_def le_fun_def by auto
4.1833 @@ -1972,43 +2000,43 @@
4.1834        unfolding mono_def le_fun_def by (auto simp: field_simps)
4.1835    have 4: "\<And>x. (\<lambda>i. f i x - f 0 x) ----> u x - f 0 x"
4.1836      using lim by (auto intro!: LIMSEQ_diff)
4.1837 -  have 5: "(\<lambda>i. (\<integral>x. f i x - f 0 x)) ----> x - integral (f 0)"
4.1838 +  have 5: "(\<lambda>i. (\<integral>x. f i x - f 0 x \<partial>M)) ----> x - integral\<^isup>L M (f 0)"
4.1839      using f ilim by (auto intro!: LIMSEQ_diff simp: integral_diff)
4.1840    note diff = integral_monotone_convergence_pos[OF 1 2 3 4 5]
4.1841 -  have "integrable (\<lambda>x. (u x - f 0 x) + f 0 x)"
4.1842 +  have "integrable M (\<lambda>x. (u x - f 0 x) + f 0 x)"
4.1843      using diff(1) f by (rule integral_add(1))
4.1844 -  with diff(2) f show "integrable u" "integral u = x"
4.1845 +  with diff(2) f show "integrable M u" "integral\<^isup>L M u = x"
4.1846      by (auto simp: integral_diff)
4.1847  qed
4.1848
4.1849  lemma (in measure_space) integral_0_iff:
4.1850 -  assumes "integrable f"
4.1851 -  shows "(\<integral>x. \<bar>f x\<bar>) = 0 \<longleftrightarrow> \<mu> {x\<in>space M. f x \<noteq> 0} = 0"
4.1852 +  assumes "integrable M f"
4.1853 +  shows "(\<integral>x. \<bar>f x\<bar> \<partial>M) = 0 \<longleftrightarrow> \<mu> {x\<in>space M. f x \<noteq> 0} = 0"
4.1854  proof -
4.1855    have *: "\<And>x. Real (- \<bar>f x\<bar>) = 0" by auto
4.1856 -  have "integrable (\<lambda>x. \<bar>f x\<bar>)" using assms by (rule integrable_abs)
4.1857 +  have "integrable M (\<lambda>x. \<bar>f x\<bar>)" using assms by (rule integrable_abs)
4.1858    hence "(\<lambda>x. Real (\<bar>f x\<bar>)) \<in> borel_measurable M"
4.1859 -    "(\<integral>\<^isup>+ x. Real \<bar>f x\<bar>) \<noteq> \<omega>" unfolding integrable_def by auto
4.1860 +    "(\<integral>\<^isup>+ x. Real \<bar>f x\<bar> \<partial>M) \<noteq> \<omega>" unfolding integrable_def by auto
4.1861    from positive_integral_0_iff[OF this(1)] this(2)
4.1862 -  show ?thesis unfolding integral_def *
4.1863 +  show ?thesis unfolding lebesgue_integral_def *
4.1865  qed
4.1866
4.1867  lemma (in measure_space) positive_integral_omega:
4.1868    assumes "f \<in> borel_measurable M"
4.1869 -  and "positive_integral f \<noteq> \<omega>"
4.1870 +  and "integral\<^isup>P M f \<noteq> \<omega>"
4.1871    shows "\<mu> (f - {\<omega>} \<inter> space M) = 0"
4.1872  proof -
4.1873 -  have "\<omega> * \<mu> (f - {\<omega>} \<inter> space M) = (\<integral>\<^isup>+ x. \<omega> * indicator (f - {\<omega>} \<inter> space M) x)"
4.1874 +  have "\<omega> * \<mu> (f - {\<omega>} \<inter> space M) = (\<integral>\<^isup>+ x. \<omega> * indicator (f - {\<omega>} \<inter> space M) x \<partial>M)"
4.1875      using positive_integral_cmult_indicator[OF borel_measurable_vimage, OF assms(1), of \<omega> \<omega>] by simp
4.1876 -  also have "\<dots> \<le> positive_integral f"
4.1877 +  also have "\<dots> \<le> integral\<^isup>P M f"
4.1878      by (auto intro!: positive_integral_mono simp: indicator_def)
4.1879    finally show ?thesis
4.1880      using assms(2) by (cases ?thesis) auto
4.1881  qed
4.1882
4.1883  lemma (in measure_space) positive_integral_omega_AE:
4.1884 -  assumes "f \<in> borel_measurable M" "positive_integral f \<noteq> \<omega>" shows "AE x. f x \<noteq> \<omega>"
4.1885 +  assumes "f \<in> borel_measurable M" "integral\<^isup>P M f \<noteq> \<omega>" shows "AE x. f x \<noteq> \<omega>"
4.1886  proof (rule AE_I)
4.1887    show "\<mu> (f - {\<omega>} \<inter> space M) = 0"
4.1888      by (rule positive_integral_omega[OF assms])
4.1889 @@ -2017,39 +2045,39 @@
4.1890  qed auto
4.1891
4.1892  lemma (in measure_space) simple_integral_omega:
4.1893 -  assumes "simple_function f"
4.1894 -  and "simple_integral f \<noteq> \<omega>"
4.1895 +  assumes "simple_function M f"
4.1896 +  and "integral\<^isup>S M f \<noteq> \<omega>"
4.1897    shows "\<mu> (f - {\<omega>} \<inter> space M) = 0"
4.1898  proof (rule positive_integral_omega)
4.1899    show "f \<in> borel_measurable M" using assms by (auto intro: borel_measurable_simple_function)
4.1900 -  show "positive_integral f \<noteq> \<omega>"
4.1901 +  show "integral\<^isup>P M f \<noteq> \<omega>"
4.1902      using assms by (simp add: positive_integral_eq_simple_integral)
4.1903  qed
4.1904
4.1905  lemma (in measure_space) integral_real:
4.1906    fixes f :: "'a \<Rightarrow> pextreal"
4.1907    assumes "AE x. f x \<noteq> \<omega>"
4.1908 -  shows "(\<integral>x. real (f x)) = real (positive_integral f)" (is ?plus)
4.1909 -    and "(\<integral>x. - real (f x)) = - real (positive_integral f)" (is ?minus)
4.1910 +  shows "(\<integral>x. real (f x) \<partial>M) = real (integral\<^isup>P M f)" (is ?plus)
4.1911 +    and "(\<integral>x. - real (f x) \<partial>M) = - real (integral\<^isup>P M f)" (is ?minus)
4.1912  proof -
4.1913 -  have "(\<integral>\<^isup>+ x. Real (real (f x))) = positive_integral f"
4.1914 +  have "(\<integral>\<^isup>+ x. Real (real (f x)) \<partial>M) = integral\<^isup>P M f"
4.1915      apply (rule positive_integral_cong_AE)
4.1916      apply (rule AE_mp[OF assms(1)])
4.1917      by (auto intro!: AE_cong simp: Real_real)
4.1918    moreover
4.1919 -  have "(\<integral>\<^isup>+ x. Real (- real (f x))) = (\<integral>\<^isup>+ x. 0)"
4.1920 +  have "(\<integral>\<^isup>+ x. Real (- real (f x)) \<partial>M) = (\<integral>\<^isup>+ x. 0 \<partial>M)"
4.1921      by (intro positive_integral_cong) auto
4.1922    ultimately show ?plus ?minus
4.1923 -    by (auto simp: integral_def integrable_def)
4.1924 +    by (auto simp: lebesgue_integral_def integrable_def)
4.1925  qed
4.1926
4.1927  lemma (in measure_space) integral_dominated_convergence:
4.1928 -  assumes u: "\<And>i. integrable (u i)" and bound: "\<And>x j. x\<in>space M \<Longrightarrow> \<bar>u j x\<bar> \<le> w x"
4.1929 -  and w: "integrable w" "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> w x"
4.1930 +  assumes u: "\<And>i. integrable M (u i)" and bound: "\<And>x j. x\<in>space M \<Longrightarrow> \<bar>u j x\<bar> \<le> w x"
4.1931 +  and w: "integrable M w" "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> w x"
4.1932    and u': "\<And>x. x \<in> space M \<Longrightarrow> (\<lambda>i. u i x) ----> u' x"
4.1933 -  shows "integrable u'"
4.1934 -  and "(\<lambda>i. (\<integral>x. \<bar>u i x - u' x\<bar>)) ----> 0" (is "?lim_diff")
4.1935 -  and "(\<lambda>i. integral (u i)) ----> integral u'" (is ?lim)
4.1936 +  shows "integrable M u'"
4.1937 +  and "(\<lambda>i. (\<integral>x. \<bar>u i x - u' x\<bar> \<partial>M)) ----> 0" (is "?lim_diff")
4.1938 +  and "(\<lambda>i. integral\<^isup>L M (u i)) ----> integral\<^isup>L M u'" (is ?lim)
4.1939  proof -
4.1940    { fix x j assume x: "x \<in> space M"
4.1941      from u'[OF x] have "(\<lambda>i. \<bar>u i x\<bar>) ----> \<bar>u' x\<bar>" by (rule LIMSEQ_imp_rabs)
4.1942 @@ -2061,9 +2089,9 @@
4.1943    have u'_borel: "u' \<in> borel_measurable M"
4.1944      using u' by (blast intro: borel_measurable_LIMSEQ[of u])
4.1945
4.1946 -  show "integrable u'"
4.1947 +  show "integrable M u'"
4.1948    proof (rule integrable_bound)
4.1949 -    show "integrable w" by fact
4.1950 +    show "integrable M w" by fact
4.1951      show "u' \<in> borel_measurable M" by fact
4.1952    next
4.1953      fix x assume x: "x \<in> space M"
4.1954 @@ -2072,8 +2100,8 @@
4.1955    qed
4.1956
4.1957    let "?diff n x" = "2 * w x - \<bar>u n x - u' x\<bar>"
4.1958 -  have diff: "\<And>n. integrable (\<lambda>x. \<bar>u n x - u' x\<bar>)"
4.1959 -    using w u integrable u'
4.1960 +  have diff: "\<And>n. integrable M (\<lambda>x. \<bar>u n x - u' x\<bar>)"
4.1961 +    using w u integrable M u'
4.1962      by (auto intro!: integral_add integral_diff integral_cmult integrable_abs)
4.1963
4.1964    { fix j x assume x: "x \<in> space M"
4.1965 @@ -2083,31 +2111,31 @@
4.1966      finally have "\<bar>u j x - u' x\<bar> \<le> 2 * w x" by simp }
4.1967    note diff_less_2w = this
4.1968
4.1969 -  have PI_diff: "\<And>m n. (\<integral>\<^isup>+ x. Real (?diff (m + n) x)) =
4.1970 -    (\<integral>\<^isup>+ x. Real (2 * w x)) - (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar>)"
4.1971 +  have PI_diff: "\<And>m n. (\<integral>\<^isup>+ x. Real (?diff (m + n) x) \<partial>M) =
4.1972 +    (\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) - (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar> \<partial>M)"
4.1973      using diff w diff_less_2w
4.1974      by (subst positive_integral_diff[symmetric])
4.1975         (auto simp: integrable_def intro!: positive_integral_cong)
4.1976
4.1977 -  have "integrable (\<lambda>x. 2 * w x)"
4.1978 +  have "integrable M (\<lambda>x. 2 * w x)"
4.1979      using w by (auto intro: integral_cmult)
4.1980 -  hence I2w_fin: "(\<integral>\<^isup>+ x. Real (2 * w x)) \<noteq> \<omega>" and
4.1981 +  hence I2w_fin: "(\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) \<noteq> \<omega>" and
4.1982      borel_2w: "(\<lambda>x. Real (2 * w x)) \<in> borel_measurable M"
4.1983      unfolding integrable_def by auto
4.1984
4.1985 -  have "(INF n. SUP m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar>)) = 0" (is "?lim_SUP = 0")
4.1986 +  have "(INF n. SUP m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar> \<partial>M)) = 0" (is "?lim_SUP = 0")
4.1987    proof cases
4.1988 -    assume eq_0: "(\<integral>\<^isup>+ x. Real (2 * w x)) = 0"
4.1989 -    have "\<And>i. (\<integral>\<^isup>+ x. Real \<bar>u i x - u' x\<bar>) \<le> (\<integral>\<^isup>+ x. Real (2 * w x))"
4.1990 +    assume eq_0: "(\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) = 0"
4.1991 +    have "\<And>i. (\<integral>\<^isup>+ x. Real \<bar>u i x - u' x\<bar> \<partial>M) \<le> (\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M)"
4.1992      proof (rule positive_integral_mono)
4.1993        fix i x assume "x \<in> space M" from diff_less_2w[OF this, of i]
4.1994        show "Real \<bar>u i x - u' x\<bar> \<le> Real (2 * w x)" by auto
4.1995      qed
4.1996 -    hence "\<And>i. (\<integral>\<^isup>+ x. Real \<bar>u i x - u' x\<bar>) = 0" using eq_0 by auto
4.1997 +    hence "\<And>i. (\<integral>\<^isup>+ x. Real \<bar>u i x - u' x\<bar> \<partial>M) = 0" using eq_0 by auto
4.1998      thus ?thesis by simp
4.1999    next
4.2000 -    assume neq_0: "(\<integral>\<^isup>+ x. Real (2 * w x)) \<noteq> 0"
4.2001 -    have "(\<integral>\<^isup>+ x. Real (2 * w x)) = (\<integral>\<^isup>+ x. SUP n. INF m. Real (?diff (m + n) x))"
4.2002 +    assume neq_0: "(\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) \<noteq> 0"
4.2003 +    have "(\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) = (\<integral>\<^isup>+ x. (SUP n. INF m. Real (?diff (m + n) x)) \<partial>M)"
4.2004      proof (rule positive_integral_cong, subst add_commute)
4.2005        fix x assume x: "x \<in> space M"
4.2006        show "Real (2 * w x) = (SUP n. INF m. Real (?diff (n + m) x))"
4.2007 @@ -2119,22 +2147,22 @@
4.2008          thus "(\<lambda>i. ?diff i x) ----> 2 * w x" by simp
4.2009        qed
4.2010      qed
4.2011 -    also have "\<dots> \<le> (SUP n. INF m. (\<integral>\<^isup>+ x. Real (?diff (m + n) x)))"
4.2012 +    also have "\<dots> \<le> (SUP n. INF m. (\<integral>\<^isup>+ x. Real (?diff (m + n) x) \<partial>M))"
4.2013        using u'_borel w u unfolding integrable_def
4.2014        by (auto intro!: positive_integral_lim_INF)
4.2015 -    also have "\<dots> = (\<integral>\<^isup>+ x. Real (2 * w x)) -
4.2016 -        (INF n. SUP m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar>))"
4.2017 +    also have "\<dots> = (\<integral>\<^isup>+ x. Real (2 * w x) \<partial>M) -
4.2018 +        (INF n. SUP m. \<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar> \<partial>M)"
4.2019        unfolding PI_diff pextreal_INF_minus[OF I2w_fin] pextreal_SUP_minus ..
4.2020      finally show ?thesis using neq_0 I2w_fin by (rule pextreal_le_minus_imp_0)
4.2021    qed
4.2022 -
4.2023 +
4.2024    have [simp]: "\<And>n m x. Real (- \<bar>u (m + n) x - u' x\<bar>) = 0" by auto
4.2025
4.2026 -  have [simp]: "\<And>n m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar>) =
4.2027 -    Real ((\<integral>x. \<bar>u (n + m) x - u' x\<bar>))"
4.2028 -    using diff by (subst add_commute) (simp add: integral_def integrable_def Real_real)
4.2029 +  have [simp]: "\<And>n m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar> \<partial>M) =
4.2030 +    Real ((\<integral>x. \<bar>u (n + m) x - u' x\<bar> \<partial>M))"
4.2031 +    using diff by (subst add_commute) (simp add: lebesgue_integral_def integrable_def Real_real)
4.2032
4.2033 -  have "(SUP n. INF m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar>)) \<le> ?lim_SUP"
4.2034 +  have "(SUP n. INF m. (\<integral>\<^isup>+ x. Real \<bar>u (m + n) x - u' x\<bar> \<partial>M)) \<le> ?lim_SUP"
4.2035      (is "?lim_INF \<le> _") by (subst (1 2) add_commute) (rule lim_INF_le_lim_SUP)
4.2036    hence "?lim_INF = Real 0" "?lim_SUP = Real 0" using ?lim_SUP = 0 by auto
4.2037    thus ?lim_diff using diff by (auto intro!: integral_positive lim_INF_eq_lim_SUP)
4.2038 @@ -2143,28 +2171,28 @@
4.2039    proof (rule LIMSEQ_I)
4.2040      fix r :: real assume "0 < r"
4.2041      from LIMSEQ_D[OF ?lim_diff this]
4.2042 -    obtain N where N: "\<And>n. N \<le> n \<Longrightarrow> (\<integral>x. \<bar>u n x - u' x\<bar>) < r"
4.2043 +    obtain N where N: "\<And>n. N \<le> n \<Longrightarrow> (\<integral>x. \<bar>u n x - u' x\<bar> \<partial>M) < r"
4.2044        using diff by (auto simp: integral_positive)
4.2045
4.2046 -    show "\<exists>N. \<forall>n\<ge>N. norm (integral (u n) - integral u') < r"
4.2047 +    show "\<exists>N. \<forall>n\<ge>N. norm (integral\<^isup>L M (u n) - integral\<^isup>L M u') < r"
4.2048      proof (safe intro!: exI[of _ N])
4.2049        fix n assume "N \<le> n"
4.2050 -      have "\<bar>integral (u n) - integral u'\<bar> = \<bar>(\<integral>x. u n x - u' x)\<bar>"
4.2051 -        using u integrable u' by (auto simp: integral_diff)
4.2052 -      also have "\<dots> \<le> (\<integral>x. \<bar>u n x - u' x\<bar>)" using u integrable u'
4.2053 +      have "\<bar>integral\<^isup>L M (u n) - integral\<^isup>L M u'\<bar> = \<bar>(\<integral>x. u n x - u' x \<partial>M)\<bar>"
4.2054 +        using u integrable M u' by (auto simp: integral_diff)
4.2055 +      also have "\<dots> \<le> (\<integral>x. \<bar>u n x - u' x\<bar> \<partial>M)" using u integrable M u'
4.2056          by (rule_tac integral_triangle_inequality) (auto intro!: integral_diff)
4.2057        also note N[OF N \<le> n]
4.2058 -      finally show "norm (integral (u n) - integral u') < r" by simp
4.2059 +      finally show "norm (integral\<^isup>L M (u n) - integral\<^isup>L M u') < r" by simp
4.2060      qed
4.2061    qed
4.2062  qed
4.2063
4.2064  lemma (in measure_space) integral_sums:
4.2065 -  assumes borel: "\<And>i. integrable (f i)"
4.2066 +  assumes borel: "\<And>i. integrable M (f i)"
4.2067    and summable: "\<And>x. x \<in> space M \<Longrightarrow> summable (\<lambda>i. \<bar>f i x\<bar>)"
4.2068 -  and sums: "summable (\<lambda>i. (\<integral>x. \<bar>f i x\<bar>))"
4.2069 -  shows "integrable (\<lambda>x. (\<Sum>i. f i x))" (is "integrable ?S")
4.2070 -  and "(\<lambda>i. integral (f i)) sums (\<integral>x. (\<Sum>i. f i x))" (is ?integral)
4.2071 +  and sums: "summable (\<lambda>i. (\<integral>x. \<bar>f i x\<bar> \<partial>M))"
4.2072 +  shows "integrable M (\<lambda>x. (\<Sum>i. f i x))" (is "integrable M ?S")
4.2073 +  and "(\<lambda>i. integral\<^isup>L M (f i)) sums (\<integral>x. (\<Sum>i. f i x) \<partial>M)" (is ?integral)
4.2074  proof -
4.2075    have "\<forall>x\<in>space M. \<exists>w. (\<lambda>i. \<bar>f i x\<bar>) sums w"
4.2076      using summable unfolding summable_def by auto
4.2077 @@ -2173,10 +2201,10 @@
4.2078
4.2079    let "?w y" = "if y \<in> space M then w y else 0"
4.2080
4.2081 -  obtain x where abs_sum: "(\<lambda>i. (\<integral>x. \<bar>f i x\<bar>)) sums x"
4.2082 +  obtain x where abs_sum: "(\<lambda>i. (\<integral>x. \<bar>f i x\<bar> \<partial>M)) sums x"
4.2083      using sums unfolding summable_def ..
4.2084
4.2085 -  have 1: "\<And>n. integrable (\<lambda>x. \<Sum>i = 0..<n. f i x)"
4.2086 +  have 1: "\<And>n. integrable M (\<lambda>x. \<Sum>i = 0..<n. f i x)"
4.2087      using borel by (auto intro!: integral_setsum)
4.2088
4.2089    { fix j x assume [simp]: "x \<in> space M"
4.2090 @@ -2185,21 +2213,21 @@
4.2091      finally have "\<bar>\<Sum>i = 0..<j. f i x\<bar> \<le> ?w x" by simp }
4.2092    note 2 = this
4.2093
4.2094 -  have 3: "integrable ?w"
4.2095 +  have 3: "integrable M ?w"
4.2096    proof (rule integral_monotone_convergence(1))
4.2097      let "?F n y" = "(\<Sum>i = 0..<n. \<bar>f i y\<bar>)"
4.2098      let "?w' n y" = "if y \<in> space M then ?F n y else 0"
4.2099 -    have "\<And>n. integrable (?F n)"
4.2100 +    have "\<And>n. integrable M (?F n)"
4.2101        using borel by (auto intro!: integral_setsum integrable_abs)
4.2102 -    thus "\<And>n. integrable (?w' n)" by (simp cong: integrable_cong)
4.2103 +    thus "\<And>n. integrable M (?w' n)" by (simp cong: integrable_cong)
4.2104      show "mono ?w'"
4.2105        by (auto simp: mono_def le_fun_def intro!: setsum_mono2)
4.2106      { fix x show "(\<lambda>n. ?w' n x) ----> ?w x"
4.2107          using w by (cases "x \<in> space M") (simp_all add: LIMSEQ_const sums_def) }
4.2108 -    have *: "\<And>n. integral (?w' n) = (\<Sum>i = 0..< n. (\<integral>x. \<bar>f i x\<bar>))"
4.2109 +    have *: "\<And>n. integral\<^isup>L M (?w' n) = (\<Sum>i = 0..< n. (\<integral>x. \<bar>f i x\<bar> \<partial>M))"
4.2110        using borel by (simp add: integral_setsum integrable_abs cong: integral_cong)
4.2111      from abs_sum
4.2112 -    show "(\<lambda>i. integral (?w' i)) ----> x" unfolding * sums_def .
4.2113 +    show "(\<lambda>i. integral\<^isup>L M (?w' i)) ----> x" unfolding * sums_def .
4.2114    qed
4.2115
4.2116    have 4: "\<And>x. x \<in> space M \<Longrightarrow> 0 \<le> ?w x" using 2[of _ 0] by simp
4.2117 @@ -2210,7 +2238,7 @@
4.2118
4.2119    note int = integral_dominated_convergence(1,3)[OF 1 2 3 4 5]
4.2120
4.2121 -  from int show "integrable ?S" by simp
4.2122 +  from int show "integrable M ?S" by simp
4.2123
4.2124    show ?integral unfolding sums_def integral_setsum(1)[symmetric, OF borel]
4.2125      using int(2) by simp
4.2126 @@ -2224,12 +2252,12 @@
4.2127    and enum_zero: "enum  (-S) \<subseteq> {0}"
4.2128    and fin: "\<And>x. x \<noteq> 0 \<Longrightarrow> \<mu> (f - {x} \<inter> space M) \<noteq> \<omega>"
4.2129    and abs_summable: "summable (\<lambda>r. \<bar>enum r * real (\<mu> (f - {enum r} \<inter> space M))\<bar>)"
4.2130 -  shows "integrable f"
4.2131 -  and "(\<lambda>r. enum r * real (\<mu> (f - {enum r} \<inter> space M))) sums integral f" (is ?sums)
4.2132 +  shows "integrable M f"
4.2133 +  and "(\<lambda>r. enum r * real (\<mu> (f - {enum r} \<inter> space M))) sums integral\<^isup>L M f" (is ?sums)
4.2134  proof -
4.2135    let "?A r" = "f - {enum r} \<inter> space M"
4.2136    let "?F r x" = "enum r * indicator (?A r) x"
4.2137 -  have enum_eq: "\<And>r. enum r * real (\<mu> (?A r)) = integral (?F r)"
4.2138 +  have enum_eq: "\<And>r. enum r * real (\<mu> (?A r)) = integral\<^isup>L M (?F r)"
4.2139      using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
4.2140
4.2141    { fix x assume "x \<in> space M"
4.2142 @@ -2250,19 +2278,19 @@
4.2143        by (auto intro!: sums_single simp: F F_abs) }
4.2144    note F_sums_f = this(1) and F_abs_sums_f = this(2)
4.2145
4.2146 -  have int_f: "integral f = (\<integral>x. \<Sum>r. ?F r x)" "integrable f = integrable (\<lambda>x. \<Sum>r. ?F r x)"
4.2147 +  have int_f: "integral\<^isup>L M f = (\<integral>x. (\<Sum>r. ?F r x) \<partial>M)" "integrable M f = integrable M (\<lambda>x. \<Sum>r. ?F r x)"
4.2148      using F_sums_f by (auto intro!: integral_cong integrable_cong simp: sums_iff)
4.2149
4.2150    { fix r
4.2151 -    have "(\<integral>x. \<bar>?F r x\<bar>) = (\<integral>x. \<bar>enum r\<bar> * indicator (?A r) x)"
4.2152 +    have "(\<integral>x. \<bar>?F r x\<bar> \<partial>M) = (\<integral>x. \<bar>enum r\<bar> * indicator (?A r) x \<partial>M)"
4.2153        by (auto simp: indicator_def intro!: integral_cong)
4.2154      also have "\<dots> = \<bar>enum r\<bar> * real (\<mu> (?A r))"
4.2155        using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
4.2156 -    finally have "(\<integral>x. \<bar>?F r x\<bar>) = \<bar>enum r * real (\<mu> (?A r))\<bar>"
4.2157 +    finally have "(\<integral>x. \<bar>?F r x\<bar> \<partial>M) = \<bar>enum r * real (\<mu> (?A r))\<bar>"
4.2158        by (simp add: abs_mult_pos real_pextreal_pos) }
4.2159    note int_abs_F = this
4.2160
4.2161 -  have 1: "\<And>i. integrable (\<lambda>x. ?F i x)"
4.2162 +  have 1: "\<And>i. integrable M (\<lambda>x. ?F i x)"
4.2163      using f fin by (simp add: borel_measurable_vimage integral_cmul_indicator)
4.2164
4.2165    have 2: "\<And>x. x \<in> space M \<Longrightarrow> summable (\<lambda>i. \<bar>?F i x\<bar>)"
4.2166 @@ -2272,7 +2300,7 @@
4.2167    show ?sums unfolding enum_eq int_f by simp
4.2168
4.2169    from integral_sums(1)[OF 1 2, unfolded int_abs_F, OF _ abs_summable]
4.2170 -  show "integrable f" unfolding int_f by simp
4.2171 +  show "integrable M f" unfolding int_f by simp
4.2172  qed
4.2173
4.2174  section "Lebesgue integration on finite space"
4.2175 @@ -2280,8 +2308,8 @@
4.2176  lemma (in measure_space) integral_on_finite:
4.2177    assumes f: "f \<in> borel_measurable M" and finite: "finite (fspace M)"
4.2178    and fin: "\<And>x. x \<noteq> 0 \<Longrightarrow> \<mu> (f - {x} \<inter> space M) \<noteq> \<omega>"
4.2179 -  shows "integrable f"
4.2180 -  and "(\<integral>x. f x) =
4.2181 +  shows "integrable M f"
4.2182 +  and "(\<integral>x. f x \<partial>M) =
4.2183      (\<Sum> r \<in> fspace M. r * real (\<mu> (f - {r} \<inter> space M)))" (is "?integral")
4.2184  proof -
4.2185    let "?A r" = "f - {r} \<inter> space M"
4.2186 @@ -2295,40 +2323,40 @@
4.2187      finally have "f x = ?S x" . }
4.2188    note f_eq = this
4.2189
4.2190 -  have f_eq_S: "integrable f \<longleftrightarrow> integrable ?S" "integral f = integral ?S"
4.2191 +  have f_eq_S: "integrable M f \<longleftrightarrow> integrable M ?S" "integral\<^isup>L M f = integral\<^isup>L M ?S"
4.2192      by (auto intro!: integrable_cong integral_cong simp only: f_eq)
4.2193
4.2194 -  show "integrable f" ?integral using fin f f_eq_S
4.2195 +  show "integrable M f" ?integral using fin f f_eq_S
4.2196      by (simp_all add: integral_cmul_indicator borel_measurable_vimage)
4.2197  qed
4.2198
4.2199 -lemma (in finite_measure_space) simple_function_finite[simp, intro]: "simple_function f"
4.2200 +lemma (in finite_measure_space) simple_function_finite[simp, intro]: "simple_function M f"
4.2201    unfolding simple_function_def using finite_space by auto
4.2202
4.2203  lemma (in finite_measure_space) borel_measurable_finite[intro, simp]: "f \<in> borel_measurable M"
4.2204    by (auto intro: borel_measurable_simple_function)
4.2205
4.2206  lemma (in finite_measure_space) positive_integral_finite_eq_setsum:
4.2207 -  "positive_integral f = (\<Sum>x \<in> space M. f x * \<mu> {x})"
4.2208 +  "integral\<^isup>P M f = (\<Sum>x \<in> space M. f x * \<mu> {x})"
4.2209  proof -
4.2210 -  have *: "positive_integral f = (\<integral>\<^isup>+ x. \<Sum>y\<in>space M. f y * indicator {y} x)"
4.2211 +  have *: "integral\<^isup>P M f = (\<integral>\<^isup>+ x. (\<Sum>y\<in>space M. f y * indicator {y} x) \<partial>M)"
4.2212      by (auto intro!: positive_integral_cong simp add: indicator_def if_distrib setsum_cases[OF finite_space])
4.2213    show ?thesis unfolding * using borel_measurable_finite[of f]
4.2214      by (simp add: positive_integral_setsum positive_integral_cmult_indicator)
4.2215  qed
4.2216
4.2217  lemma (in finite_measure_space) integral_finite_singleton:
4.2218 -  shows "integrable f"
4.2219 -  and "integral f = (\<Sum>x \<in> space M. f x * real (\<mu> {x}))" (is ?I)
4.2220 +  shows "integrable M f"
4.2221 +  and "integral\<^isup>L M f = (\<Sum>x \<in> space M. f x * real (\<mu> {x}))" (is ?I)
4.2222  proof -
4.2223    have [simp]:
4.2224 -    "(\<integral>\<^isup>+ x. Real (f x)) = (\<Sum>x \<in> space M. Real (f x) * \<mu> {x})"
4.2225 -    "(\<integral>\<^isup>+ x. Real (- f x)) = (\<Sum>x \<in> space M. Real (- f x) * \<mu> {x})"
4.2226 +    "(\<integral>\<^isup>+ x. Real (f x) \<partial>M) = (\<Sum>x \<in> space M. Real (f x) * \<mu> {x})"
4.2227 +    "(\<integral>\<^isup>+ x. Real (- f x) \<partial>M) = (\<Sum>x \<in> space M. Real (- f x) * \<mu> {x})"
4.2228      unfolding positive_integral_finite_eq_setsum by auto
4.2229 -  show "integrable f" using finite_space finite_measure
4.2230 +  show "integrable M f" using finite_space finite_measure
4.2231      by (simp add: setsum_\<omega> integrable_def)
4.2232    show ?I using finite_measure
4.2233 -    apply (simp add: integral_def real_of_pextreal_setsum[symmetric]
4.2234 +    apply (simp add: lebesgue_integral_def real_of_pextreal_setsum[symmetric]
4.2235        real_of_pextreal_mult[symmetric] setsum_subtractf[symmetric])
4.2236      by (rule setsum_cong) (simp_all split: split_if)
4.2237  qed

     5.1 --- a/src/HOL/Probability/Lebesgue_Measure.thy	Wed Feb 02 10:35:41 2011 +0100
5.2 +++ b/src/HOL/Probability/Lebesgue_Measure.thy	Wed Feb 02 12:34:45 2011 +0100
5.3 @@ -1,7 +1,7 @@
5.4  (*  Author: Robert Himmelmann, TU Muenchen *)
5.5  header {* Lebsegue measure *}
5.6  theory Lebesgue_Measure
5.7 -  imports Product_Measure Complete_Measure
5.8 +  imports Product_Measure
5.9  begin
5.10
5.11  subsection {* Standard Cubes *}
5.12 @@ -42,10 +42,16 @@
5.14  qed
5.15
5.16 -definition lebesgue :: "'a::ordered_euclidean_space algebra" where
5.17 -  "lebesgue = \<lparr> space = UNIV, sets = {A. \<forall>n. (indicator A :: 'a \<Rightarrow> real) integrable_on cube n} \<rparr>"
5.18 +lemma cube_subset_Suc[intro]: "cube n \<subseteq> cube (Suc n)"
5.19 +  unfolding cube_def_raw subset_eq apply safe unfolding mem_interval by auto
5.20
5.21 -definition "lmeasure A = (SUP n. Real (integral (cube n) (indicator A)))"
5.22 +lemma Pi_iff: "f \<in> Pi I X \<longleftrightarrow> (\<forall>i\<in>I. f i \<in> X i)"
5.23 +  unfolding Pi_def by auto
5.24 +
5.25 +definition lebesgue :: "'a::ordered_euclidean_space measure_space" where
5.26 +  "lebesgue = \<lparr> space = UNIV,
5.27 +    sets = {A. \<forall>n. (indicator A :: 'a \<Rightarrow> real) integrable_on cube n},
5.28 +    measure = \<lambda>A. SUP n. Real (integral (cube n) (indicator A)) \<rparr>"
5.29
5.30  lemma space_lebesgue[simp]: "space lebesgue = UNIV"
5.31    unfolding lebesgue_def by simp
5.32 @@ -106,12 +112,12 @@
5.33    qed (auto intro: LIMSEQ_indicator_UN simp: cube_def)
5.34  qed simp
5.35
5.36 -interpretation lebesgue: measure_space lebesgue lmeasure
5.37 +interpretation lebesgue: measure_space lebesgue
5.38  proof
5.39    have *: "indicator {} = (\<lambda>x. 0 :: real)" by (simp add: fun_eq_iff)
5.40 -  show "lmeasure {} = 0" by (simp add: integral_0 * lmeasure_def)
5.41 +  show "measure lebesgue {} = 0" by (simp add: integral_0 * lebesgue_def)
5.42  next
5.43 -  show "countably_additive lebesgue lmeasure"
5.44 +  show "countably_additive lebesgue (measure lebesgue)"
5.45    proof (intro countably_additive_def[THEN iffD2] allI impI)
5.46      fix A :: "nat \<Rightarrow> 'b set" assume rA: "range A \<subseteq> sets lebesgue" "disjoint_family A"
5.47      then have A[simp, intro]: "\<And>i n. (indicator (A i) :: _ \<Rightarrow> real) integrable_on cube n"
5.48 @@ -122,8 +128,8 @@
5.49      assume "(\<Union>i. A i) \<in> sets lebesgue"
5.50      then have UN_A[simp, intro]: "\<And>i n. (indicator (\<Union>i. A i) :: _ \<Rightarrow> real) integrable_on cube n"
5.51        by (auto dest: lebesgueD)
5.52 -    show "(\<Sum>\<^isub>\<infinity>n. lmeasure (A n)) = lmeasure (\<Union>i. A i)" unfolding lmeasure_def
5.53 -    proof (subst psuminf_SUP_eq)
5.54 +    show "(\<Sum>\<^isub>\<infinity>n. measure lebesgue (A n)) = measure lebesgue (\<Union>i. A i)"
5.55 +    proof (simp add: lebesgue_def, subst psuminf_SUP_eq)
5.56        fix n i show "Real (?m n i) \<le> Real (?m (Suc n) i)"
5.57          using cube_subset[of n "Suc n"] by (auto intro!: integral_subset_le)
5.58      next
5.59 @@ -213,20 +219,19 @@
5.60    using assms by (force simp: cube_def integrable_on_def negligible_def intro!: lebesgueI)
5.61
5.62  lemma lmeasure_eq_0:
5.63 -  fixes S :: "'a::ordered_euclidean_space set" assumes "negligible S" shows "lmeasure S = 0"
5.64 +  fixes S :: "'a::ordered_euclidean_space set" assumes "negligible S" shows "lebesgue.\<mu> S = 0"
5.65  proof -
5.66    have "\<And>n. integral (cube n) (indicator S :: 'a\<Rightarrow>real) = 0"
5.67 -    unfolding integral_def using assms
5.68 -    by (intro some1_equality ex_ex1I has_integral_unique)
5.69 -       (auto simp: cube_def negligible_def intro: )
5.70 -  then show ?thesis unfolding lmeasure_def by auto
5.71 +    unfolding lebesgue_integral_def using assms
5.72 +    by (intro integral_unique some1_equality ex_ex1I)
5.73 +       (auto simp: cube_def negligible_def)
5.74 +  then show ?thesis by (auto simp: lebesgue_def)
5.75  qed
5.76
5.77  lemma lmeasure_iff_LIMSEQ:
5.78    assumes "A \<in> sets lebesgue" "0 \<le> m"
5.79 -  shows "lmeasure A = Real m \<longleftrightarrow> (\<lambda>n. integral (cube n) (indicator A :: _ \<Rightarrow> real)) ----> m"
5.80 -  unfolding lmeasure_def
5.81 -proof (intro SUP_eq_LIMSEQ)
5.82 +  shows "lebesgue.\<mu> A = Real m \<longleftrightarrow> (\<lambda>n. integral (cube n) (indicator A :: _ \<Rightarrow> real)) ----> m"
5.83 +proof (simp add: lebesgue_def, intro SUP_eq_LIMSEQ)
5.84    show "mono (\<lambda>n. integral (cube n) (indicator A::_=>real))"
5.85      using cube_subset assms by (intro monoI integral_subset_le) (auto dest!: lebesgueD)
5.86    fix n show "0 \<le> integral (cube n) (indicator A::_=>real)"
5.87 @@ -253,7 +258,7 @@
5.88
5.89  lemma lmeasure_finite_has_integral:
5.90    fixes s :: "'a::ordered_euclidean_space set"
5.91 -  assumes "s \<in> sets lebesgue" "lmeasure s = Real m" "0 \<le> m"
5.92 +  assumes "s \<in> sets lebesgue" "lebesgue.\<mu> s = Real m" "0 \<le> m"
5.93    shows "(indicator s has_integral m) UNIV"
5.94  proof -
5.95    let ?I = "indicator :: 'a set \<Rightarrow> 'a \<Rightarrow> real"
5.96 @@ -295,9 +300,9 @@
5.97      unfolding m by (intro integrable_integral **)
5.98  qed
5.99
5.100 -lemma lmeasure_finite_integrable: assumes "s \<in> sets lebesgue" "lmeasure s \<noteq> \<omega>"
5.101 +lemma lmeasure_finite_integrable: assumes "s \<in> sets lebesgue" "lebesgue.\<mu> s \<noteq> \<omega>"
5.102    shows "(indicator s :: _ \<Rightarrow> real) integrable_on UNIV"
5.103 -proof (cases "lmeasure s")
5.104 +proof (cases "lebesgue.\<mu> s")
5.105    case (preal m) from lmeasure_finite_has_integral[OF s \<in> sets lebesgue this]
5.106    show ?thesis unfolding integrable_on_def by auto
5.107  qed (insert assms, auto)
5.108 @@ -314,7 +319,7 @@
5.109  qed
5.110
5.111  lemma has_integral_lmeasure: assumes "((indicator s :: _\<Rightarrow>real) has_integral m) UNIV"
5.112 -  shows "lmeasure s = Real m"
5.113 +  shows "lebesgue.\<mu> s = Real m"
5.114  proof (intro lmeasure_iff_LIMSEQ[THEN iffD2])
5.115    let ?I = "indicator :: 'a set \<Rightarrow> 'a \<Rightarrow> real"
5.116    show "s \<in> sets lebesgue" using has_integral_lebesgue[OF assms] .
5.117 @@ -339,37 +344,37 @@
5.118  qed
5.119
5.120  lemma has_integral_iff_lmeasure:
5.121 -  "(indicator A has_integral m) UNIV \<longleftrightarrow> (A \<in> sets lebesgue \<and> 0 \<le> m \<and> lmeasure A = Real m)"
5.122 +  "(indicator A has_integral m) UNIV \<longleftrightarrow> (A \<in> sets lebesgue \<and> 0 \<le> m \<and> lebesgue.\<mu> A = Real m)"
5.123  proof
5.124    assume "(indicator A has_integral m) UNIV"
5.125    with has_integral_lmeasure[OF this] has_integral_lebesgue[OF this]
5.126 -  show "A \<in> sets lebesgue \<and> 0 \<le> m \<and> lmeasure A = Real m"
5.127 +  show "A \<in> sets lebesgue \<and> 0 \<le> m \<and> lebesgue.\<mu> A = Real m"
5.128      by (auto intro: has_integral_nonneg)
5.129  next
5.130 -  assume "A \<in> sets lebesgue \<and> 0 \<le> m \<and> lmeasure A = Real m"
5.131 +  assume "A \<in> sets lebesgue \<and> 0 \<le> m \<and> lebesgue.\<mu> A = Real m"
5.132    then show "(indicator A has_integral m) UNIV" by (intro lmeasure_finite_has_integral) auto
5.133  qed
5.134
5.135  lemma lmeasure_eq_integral: assumes "(indicator s::_\<Rightarrow>real) integrable_on UNIV"
5.136 -  shows "lmeasure s = Real (integral UNIV (indicator s))"
5.137 +  shows "lebesgue.\<mu> s = Real (integral UNIV (indicator s))"
5.138    using assms unfolding integrable_on_def
5.139  proof safe
5.140    fix y :: real assume "(indicator s has_integral y) UNIV"
5.141    from this[unfolded has_integral_iff_lmeasure] integral_unique[OF this]
5.142 -  show "lmeasure s = Real (integral UNIV (indicator s))" by simp
5.143 +  show "lebesgue.\<mu> s = Real (integral UNIV (indicator s))" by simp
5.144  qed
5.145
5.146  lemma lebesgue_simple_function_indicator:
5.147    fixes f::"'a::ordered_euclidean_space \<Rightarrow> pextreal"
5.148 -  assumes f:"lebesgue.simple_function f"
5.149 +  assumes f:"simple_function lebesgue f"
5.150    shows "f = (\<lambda>x. (\<Sum>y \<in> f  UNIV. y * indicator (f - {y}) x))"
5.151 -  apply(rule,subst lebesgue.simple_function_indicator_representation[OF f]) by auto
5.152 +  by (rule, subst lebesgue.simple_function_indicator_representation[OF f]) auto
5.153
5.154  lemma integral_eq_lmeasure:
5.155 -  "(indicator s::_\<Rightarrow>real) integrable_on UNIV \<Longrightarrow> integral UNIV (indicator s) = real (lmeasure s)"
5.156 +  "(indicator s::_\<Rightarrow>real) integrable_on UNIV \<Longrightarrow> integral UNIV (indicator s) = real (lebesgue.\<mu> s)"
5.157    by (subst lmeasure_eq_integral) (auto intro!: integral_nonneg)
5.158
5.159 -lemma lmeasure_finite: assumes "(indicator s::_\<Rightarrow>real) integrable_on UNIV" shows "lmeasure s \<noteq> \<omega>"
5.160 +lemma lmeasure_finite: assumes "(indicator s::_\<Rightarrow>real) integrable_on UNIV" shows "lebesgue.\<mu> s \<noteq> \<omega>"
5.161    using lmeasure_eq_integral[OF assms] by auto
5.162
5.163  lemma negligible_iff_lebesgue_null_sets:
5.164 @@ -402,14 +407,13 @@
5.165    shows "integral {a .. b} (\<lambda>x. c) = content {a .. b} *\<^sub>R c"
5.166    by (rule integral_unique) (rule has_integral_const)
5.167
5.168 -lemma lmeasure_UNIV[intro]: "lmeasure (UNIV::'a::ordered_euclidean_space set) = \<omega>"
5.169 -  unfolding lmeasure_def SUP_\<omega>
5.170 -proof (intro allI impI)
5.171 +lemma lmeasure_UNIV[intro]: "lebesgue.\<mu> (UNIV::'a::ordered_euclidean_space set) = \<omega>"
5.172 +proof (simp add: lebesgue_def SUP_\<omega>, intro allI impI)
5.173    fix x assume "x < \<omega>"
5.174    then obtain r where r: "x = Real r" "0 \<le> r" by (cases x) auto
5.175    then obtain n where n: "r < of_nat n" using ex_less_of_nat by auto
5.176 -  show "\<exists>i\<in>UNIV. x < Real (integral (cube i) (indicator UNIV::'a\<Rightarrow>real))"
5.177 -  proof (intro bexI[of _ n])
5.178 +  show "\<exists>i. x < Real (integral (cube i) (indicator UNIV::'a\<Rightarrow>real))"
5.179 +  proof (intro exI[of _ n])
5.180      have [simp]: "indicator UNIV = (\<lambda>x. 1)" by (auto simp: fun_eq_iff)
5.181      { fix m :: nat assume "0 < m" then have "real n \<le> (\<Prod>x<m. 2 * real n)"
5.182        proof (induct m)
5.183 @@ -428,12 +432,12 @@
5.184      also have "Real (of_nat n) \<le> Real (integral (cube n) (indicator UNIV::'a\<Rightarrow>real))"
5.185        by (auto simp: real_eq_of_nat[symmetric] cube_def content_closed_interval_cases)
5.186      finally show "x < Real (integral (cube n) (indicator UNIV::'a\<Rightarrow>real))" .
5.187 -  qed auto
5.188 +  qed
5.189  qed
5.190
5.191  lemma
5.192    fixes a b ::"'a::ordered_euclidean_space"
5.193 -  shows lmeasure_atLeastAtMost[simp]: "lmeasure {a..b} = Real (content {a..b})"
5.194 +  shows lmeasure_atLeastAtMost[simp]: "lebesgue.\<mu> {a..b} = Real (content {a..b})"
5.195  proof -
5.196    have "(indicator (UNIV \<inter> {a..b})::_\<Rightarrow>real) integrable_on UNIV"
5.197      unfolding integrable_indicator_UNIV by (simp add: integrable_const indicator_def_raw)
5.198 @@ -453,7 +457,7 @@
5.199  qed
5.200
5.201  lemma lmeasure_singleton[simp]:
5.202 -  fixes a :: "'a::ordered_euclidean_space" shows "lmeasure {a} = 0"
5.203 +  fixes a :: "'a::ordered_euclidean_space" shows "lebesgue.\<mu> {a} = 0"
5.204    using lmeasure_atLeastAtMost[of a a] by simp
5.205
5.206  declare content_real[simp]
5.207 @@ -461,74 +465,97 @@
5.208  lemma
5.209    fixes a b :: real
5.210    shows lmeasure_real_greaterThanAtMost[simp]:
5.211 -    "lmeasure {a <.. b} = Real (if a \<le> b then b - a else 0)"
5.212 +    "lebesgue.\<mu> {a <.. b} = Real (if a \<le> b then b - a else 0)"
5.213  proof cases
5.214    assume "a < b"
5.215 -  then have "lmeasure {a <.. b} = lmeasure {a .. b} - lmeasure {a}"
5.216 +  then have "lebesgue.\<mu> {a <.. b} = lebesgue.\<mu> {a .. b} - lebesgue.\<mu> {a}"
5.217      by (subst lebesgue.measure_Diff[symmetric])
5.218 -       (auto intro!: arg_cong[where f=lmeasure])
5.219 +       (auto intro!: arg_cong[where f=lebesgue.\<mu>])
5.220    then show ?thesis by auto
5.221  qed auto
5.222
5.223  lemma
5.224    fixes a b :: real
5.225    shows lmeasure_real_atLeastLessThan[simp]:
5.226 -    "lmeasure {a ..< b} = Real (if a \<le> b then b - a else 0)"
5.227 +    "lebesgue.\<mu> {a ..< b} = Real (if a \<le> b then b - a else 0)"
5.228  proof cases
5.229    assume "a < b"
5.230 -  then have "lmeasure {a ..< b} = lmeasure {a .. b} - lmeasure {b}"
5.231 +  then have "lebesgue.\<mu> {a ..< b} = lebesgue.\<mu> {a .. b} - lebesgue.\<mu> {b}"
5.232      by (subst lebesgue.measure_Diff[symmetric])
5.233 -       (auto intro!: arg_cong[where f=lmeasure])
5.234 +       (auto intro!: arg_cong[where f=lebesgue.\<mu>])
5.235    then show ?thesis by auto
5.236  qed auto
5.237
5.238  lemma
5.239    fixes a b :: real
5.240    shows lmeasure_real_greaterThanLessThan[simp]:
5.241 -    "lmeasure {a <..< b} = Real (if a \<le> b then b - a else 0)"
5.242 +    "lebesgue.\<mu> {a <..< b} = Real (if a \<le> b then b - a else 0)"
5.243  proof cases
5.244    assume "a < b"
5.245 -  then have "lmeasure {a <..< b} = lmeasure {a <.. b} - lmeasure {b}"
5.246 +  then have "lebesgue.\<mu> {a <..< b} = lebesgue.\<mu> {a <.. b} - lebesgue.\<mu> {b}"
5.247      by (subst lebesgue.measure_Diff[symmetric])
5.248 -       (auto intro!: arg_cong[where f=lmeasure])
5.249 +       (auto intro!: arg_cong[where f=lebesgue.\<mu>])
5.250    then show ?thesis by auto
5.251  qed auto
5.252
5.253 -interpretation borel: measure_space borel lmeasure
5.254 -proof
5.255 -  show "countably_additive borel lmeasure"
5.256 -    using lebesgue.ca unfolding countably_additive_def
5.257 -    apply safe apply (erule_tac x=A in allE) by auto
5.258 -qed auto
5.259 +definition "lborel = lebesgue \<lparr> sets := sets borel \<rparr>"
5.260 +
5.261 +lemma
5.262 +  shows space_lborel[simp]: "space lborel = UNIV"
5.263 +  and sets_lborel[simp]: "sets lborel = sets borel"
5.264 +  and measure_lborel[simp]: "measure lborel = lebesgue.\<mu>"
5.265 +  and measurable_lborel[simp]: "measurable lborel = measurable borel"
5.266 +  by (simp_all add: measurable_def_raw lborel_def)
5.267
5.268 -interpretation borel: sigma_finite_measure borel lmeasure
5.269 -proof (default, intro conjI exI[of _ "\<lambda>n. cube n"])
5.270 -  show "range cube \<subseteq> sets borel" by (auto intro: borel_closed)
5.271 -  { fix x have "\<exists>n. x\<in>cube n" using mem_big_cube by auto }
5.272 -  thus "(\<Union>i. cube i) = space borel" by auto
5.273 -  show "\<forall>i. lmeasure (cube i) \<noteq> \<omega>" unfolding cube_def by auto
5.274 -qed
5.275 +interpretation lborel: measure_space lborel
5.276 +  where "space lborel = UNIV"
5.277 +  and "sets lborel = sets borel"
5.278 +  and "measure lborel = lebesgue.\<mu>"
5.279 +  and "measurable lborel = measurable borel"
5.280 +proof -
5.281 +  show "measure_space lborel"
5.282 +  proof
5.283 +    show "countably_additive lborel (measure lborel)"
5.284 +      using lebesgue.ca unfolding countably_additive_def lborel_def
5.285 +      apply safe apply (erule_tac x=A in allE) by auto
5.286 +  qed (auto simp: lborel_def)
5.287 +qed simp_all
5.288
5.289 -interpretation lebesgue: sigma_finite_measure lebesgue lmeasure
5.290 +interpretation lborel: sigma_finite_measure lborel
5.291 +  where "space lborel = UNIV"
5.292 +  and "sets lborel = sets borel"
5.293 +  and "measure lborel = lebesgue.\<mu>"
5.294 +  and "measurable lborel = measurable borel"
5.295 +proof -
5.296 +  show "sigma_finite_measure lborel"
5.297 +  proof (default, intro conjI exI[of _ "\<lambda>n. cube n"])
5.298 +    show "range cube \<subseteq> sets lborel" by (auto intro: borel_closed)
5.299 +    { fix x have "\<exists>n. x\<in>cube n" using mem_big_cube by auto }
5.300 +    thus "(\<Union>i. cube i) = space lborel" by auto
5.301 +    show "\<forall>i. measure lborel (cube i) \<noteq> \<omega>" by (simp add: cube_def)
5.302 +  qed
5.303 +qed simp_all
5.304 +
5.305 +interpretation lebesgue: sigma_finite_measure lebesgue
5.306  proof
5.307 -  from borel.sigma_finite guess A ..
5.308 +  from lborel.sigma_finite guess A ..
5.309    moreover then have "range A \<subseteq> sets lebesgue" using lebesgueI_borel by blast
5.310 -  ultimately show "\<exists>A::nat \<Rightarrow> 'b set. range A \<subseteq> sets lebesgue \<and> (\<Union>i. A i) = space lebesgue \<and> (\<forall>i. lmeasure (A i) \<noteq> \<omega>)"
5.311 +  ultimately show "\<exists>A::nat \<Rightarrow> 'b set. range A \<subseteq> sets lebesgue \<and> (\<Union>i. A i) = space lebesgue \<and> (\<forall>i. lebesgue.\<mu> (A i) \<noteq> \<omega>)"
5.312      by auto
5.313  qed
5.314
5.315  lemma simple_function_has_integral:
5.316    fixes f::"'a::ordered_euclidean_space \<Rightarrow> pextreal"
5.317 -  assumes f:"lebesgue.simple_function f"
5.318 +  assumes f:"simple_function lebesgue f"
5.319    and f':"\<forall>x. f x \<noteq> \<omega>"
5.320 -  and om:"\<forall>x\<in>range f. lmeasure (f - {x} \<inter> UNIV) = \<omega> \<longrightarrow> x = 0"
5.321 -  shows "((\<lambda>x. real (f x)) has_integral (real (lebesgue.simple_integral f))) UNIV"
5.322 -  unfolding lebesgue.simple_integral_def
5.323 +  and om:"\<forall>x\<in>range f. lebesgue.\<mu> (f - {x} \<inter> UNIV) = \<omega> \<longrightarrow> x = 0"
5.324 +  shows "((\<lambda>x. real (f x)) has_integral (real (integral\<^isup>S lebesgue f))) UNIV"
5.325 +  unfolding simple_integral_def
5.326    apply(subst lebesgue_simple_function_indicator[OF f])
5.327  proof -
5.328    case goal1
5.329    have *:"\<And>x. \<forall>y\<in>range f. y * indicator (f - {y}) x \<noteq> \<omega>"
5.330 -    "\<forall>x\<in>range f. x * lmeasure (f - {x} \<inter> UNIV) \<noteq> \<omega>"
5.331 +    "\<forall>x\<in>range f. x * lebesgue.\<mu> (f - {x} \<inter> UNIV) \<noteq> \<omega>"
5.332      using f' om unfolding indicator_def by auto
5.333    show ?case unfolding space_lebesgue real_of_pextreal_setsum'[OF *(1),THEN sym]
5.334      unfolding real_of_pextreal_setsum'[OF *(2),THEN sym]
5.335 @@ -536,11 +563,11 @@
5.336      apply(rule has_integral_setsum)
5.337    proof safe show "finite (range f)" using f by (auto dest: lebesgue.simple_functionD)
5.338      fix y::'a show "((\<lambda>x. real (f y * indicator (f - {f y}) x)) has_integral
5.339 -      real (f y * lmeasure (f - {f y} \<inter> UNIV))) UNIV"
5.340 +      real (f y * lebesgue.\<mu> (f - {f y} \<inter> UNIV))) UNIV"
5.341      proof(cases "f y = 0") case False
5.342        have mea:"(indicator (f - {f y}) ::_\<Rightarrow>real) integrable_on UNIV"
5.343          apply(rule lmeasure_finite_integrable)
5.344 -        using assms unfolding lebesgue.simple_function_def using False by auto
5.345 +        using assms unfolding simple_function_def using False by auto
5.346        have *:"\<And>x. real (indicator (f - {f y}) x::pextreal) = (indicator (f - {f y}) x)"
5.347          by (auto simp: indicator_def)
5.348        show ?thesis unfolding real_of_pextreal_mult[THEN sym]
5.349 @@ -558,31 +585,31 @@
5.350
5.351  lemma simple_function_has_integral':
5.352    fixes f::"'a::ordered_euclidean_space \<Rightarrow> pextreal"
5.353 -  assumes f:"lebesgue.simple_function f"
5.354 -  and i: "lebesgue.simple_integral f \<noteq> \<omega>"
5.355 -  shows "((\<lambda>x. real (f x)) has_integral (real (lebesgue.simple_integral f))) UNIV"
5.356 +  assumes f:"simple_function lebesgue f"
5.357 +  and i: "integral\<^isup>S lebesgue f \<noteq> \<omega>"
5.358 +  shows "((\<lambda>x. real (f x)) has_integral (real (integral\<^isup>S lebesgue f))) UNIV"
5.359  proof- let ?f = "\<lambda>x. if f x = \<omega> then 0 else f x"
5.360    { fix x have "real (f x) = real (?f x)" by (cases "f x") auto } note * = this
5.361    have **:"{x. f x \<noteq> ?f x} = f - {\<omega>}" by auto
5.362 -  have **:"lmeasure {x\<in>space lebesgue. f x \<noteq> ?f x} = 0"
5.363 +  have **:"lebesgue.\<mu> {x\<in>space lebesgue. f x \<noteq> ?f x} = 0"
5.364      using lebesgue.simple_integral_omega[OF assms] by(auto simp add:**)
5.365    show ?thesis apply(subst lebesgue.simple_integral_cong'[OF f _ **])
5.366      apply(rule lebesgue.simple_function_compose1[OF f])
5.367      unfolding * defer apply(rule simple_function_has_integral)
5.368    proof-
5.369 -    show "lebesgue.simple_function ?f"
5.370 +    show "simple_function lebesgue ?f"
5.371        using lebesgue.simple_function_compose1[OF f] .
5.372      show "\<forall>x. ?f x \<noteq> \<omega>" by auto
5.373 -    show "\<forall>x\<in>range ?f. lmeasure (?f - {x} \<inter> UNIV) = \<omega> \<longrightarrow> x = 0"
5.374 +    show "\<forall>x\<in>range ?f. lebesgue.\<mu> (?f - {x} \<inter> UNIV) = \<omega> \<longrightarrow> x = 0"
5.375      proof (safe, simp, safe, rule ccontr)
5.376        fix y assume "f y \<noteq> \<omega>" "f y \<noteq> 0"
5.377        hence "(\<lambda>x. if f x = \<omega> then 0 else f x) - {if f y = \<omega> then 0 else f y} = f - {f y}"
5.378          by (auto split: split_if_asm)
5.379 -      moreover assume "lmeasure ((\<lambda>x. if f x = \<omega> then 0 else f x) - {if f y = \<omega> then 0 else f y}) = \<omega>"
5.380 -      ultimately have "lmeasure (f - {f y}) = \<omega>" by simp
5.381 +      moreover assume "lebesgue.\<mu> ((\<lambda>x. if f x = \<omega> then 0 else f x) - {if f y = \<omega> then 0 else f y}) = \<omega>"
5.382 +      ultimately have "lebesgue.\<mu> (f - {f y}) = \<omega>" by simp
5.383        moreover
5.384 -      have "f y * lmeasure (f - {f y}) \<noteq> \<omega>" using i f
5.385 -        unfolding lebesgue.simple_integral_def setsum_\<omega> lebesgue.simple_function_def
5.386 +      have "f y * lebesgue.\<mu> (f - {f y}) \<noteq> \<omega>" using i f
5.387 +        unfolding simple_integral_def setsum_\<omega> simple_function_def
5.388          by auto
5.389        ultimately have "f y = 0" by (auto split: split_if_asm)
5.390        then show False using f y \<noteq> 0 by simp
5.391 @@ -595,7 +622,7 @@
5.392    assumes i: "\<And>i. f i \<in> borel_measurable M" and mono: "\<And>x. mono (\<lambda>n. f n x)"
5.393    and lim: "\<And>x. (\<lambda>i. f i x) ----> u x"
5.394    shows "u \<in> borel_measurable M"
5.395 -  and "(\<lambda>i. positive_integral (f i)) ----> positive_integral u" (is ?ilim)
5.396 +  and "(\<lambda>i. integral\<^isup>P M (f i)) ----> integral\<^isup>P M u" (is ?ilim)
5.397  proof -
5.398    from positive_integral_isoton[unfolded isoton_fun_expand isoton_iff_Lim_mono, of f u]
5.399    show ?ilim using mono lim i by auto
5.400 @@ -609,19 +636,19 @@
5.401  lemma positive_integral_has_integral:
5.402    fixes f::"'a::ordered_euclidean_space => pextreal"
5.403    assumes f:"f \<in> borel_measurable lebesgue"
5.404 -  and int_om:"lebesgue.positive_integral f \<noteq> \<omega>"
5.405 +  and int_om:"integral\<^isup>P lebesgue f \<noteq> \<omega>"
5.406    and f_om:"\<forall>x. f x \<noteq> \<omega>" (* TODO: remove this *)
5.407 -  shows "((\<lambda>x. real (f x)) has_integral (real (lebesgue.positive_integral f))) UNIV"
5.408 -proof- let ?i = "lebesgue.positive_integral f"
5.409 +  shows "((\<lambda>x. real (f x)) has_integral (real (integral\<^isup>P lebesgue f))) UNIV"
5.410 +proof- let ?i = "integral\<^isup>P lebesgue f"
5.411    from lebesgue.borel_measurable_implies_simple_function_sequence[OF f]
5.412    guess u .. note conjunctD2[OF this,rule_format] note u = conjunctD2[OF this(1)] this(2)
5.413    let ?u = "\<lambda>i x. real (u i x)" and ?f = "\<lambda>x. real (f x)"
5.414 -  have u_simple:"\<And>k. lebesgue.simple_integral (u k) = lebesgue.positive_integral (u k)"
5.415 +  have u_simple:"\<And>k. integral\<^isup>S lebesgue (u k) = integral\<^isup>P lebesgue (u k)"
5.416      apply(subst lebesgue.positive_integral_eq_simple_integral[THEN sym,OF u(1)]) ..
5.417 -  have int_u_le:"\<And>k. lebesgue.simple_integral (u k) \<le> lebesgue.positive_integral f"
5.418 +  have int_u_le:"\<And>k. integral\<^isup>S lebesgue (u k) \<le> integral\<^isup>P lebesgue f"
5.419      unfolding u_simple apply(rule lebesgue.positive_integral_mono)
5.420      using isoton_Sup[OF u(3)] unfolding le_fun_def by auto
5.421 -  have u_int_om:"\<And>i. lebesgue.simple_integral (u i) \<noteq> \<omega>"
5.422 +  have u_int_om:"\<And>i. integral\<^isup>S lebesgue (u i) \<noteq> \<omega>"
5.423    proof- case goal1 thus ?case using int_u_le[of i] int_om by auto qed
5.424
5.425    note u_int = simple_function_has_integral'[OF u(1) this]
5.426 @@ -633,17 +660,17 @@
5.427        prefer 3 apply(subst Real_real') defer apply(subst Real_real')
5.428        using isotone_Lim[OF u(3)[unfolded isoton_fun_expand, THEN spec]] using f_om u by auto
5.429    next case goal3
5.430 -    show ?case apply(rule bounded_realI[where B="real (lebesgue.positive_integral f)"])
5.431 +    show ?case apply(rule bounded_realI[where B="real (integral\<^isup>P lebesgue f)"])
5.432        apply safe apply(subst abs_of_nonneg) apply(rule integral_nonneg,rule) apply(rule u_int)
5.433        unfolding integral_unique[OF u_int] defer apply(rule real_of_pextreal_mono[OF _ int_u_le])
5.434        using u int_om by auto
5.435    qed note int = conjunctD2[OF this]
5.436
5.437 -  have "(\<lambda>i. lebesgue.simple_integral (u i)) ----> ?i" unfolding u_simple
5.438 +  have "(\<lambda>i. integral\<^isup>S lebesgue (u i)) ----> ?i" unfolding u_simple
5.439      apply(rule lebesgue.positive_integral_monotone_convergence(2))
5.440      apply(rule lebesgue.borel_measurable_simple_function[OF u(1)])
5.441      using isotone_Lim[OF u(3)[unfolded isoton_fun_expand, THEN spec]] by auto
5.442 -  hence "(\<lambda>i. real (lebesgue.simple_integral (u i))) ----> real ?i" apply-
5.443 +  hence "(\<lambda>i. real (integral\<^isup>S lebesgue (u i))) ----> real ?i" apply-
5.444      apply(subst lim_Real[THEN sym]) prefer 3
5.445      apply(subst Real_real') defer apply(subst Real_real')
5.446      using u f_om int_om u_int_om by auto
5.447 @@ -653,12 +680,12 @@
5.448
5.449  lemma lebesgue_integral_has_integral:
5.450    fixes f::"'a::ordered_euclidean_space => real"
5.451 -  assumes f:"lebesgue.integrable f"
5.452 -  shows "(f has_integral (lebesgue.integral f)) UNIV"
5.453 +  assumes f:"integrable lebesgue f"
5.454 +  shows "(f has_integral (integral\<^isup>L lebesgue f)) UNIV"
5.455  proof- let ?n = "\<lambda>x. - min (f x) 0" and ?p = "\<lambda>x. max (f x) 0"
5.456    have *:"f = (\<lambda>x. ?p x - ?n x)" apply rule by auto
5.457 -  note f = lebesgue.integrableD[OF f]
5.458 -  show ?thesis unfolding lebesgue.integral_def apply(subst *)
5.459 +  note f = integrableD[OF f]
5.460 +  show ?thesis unfolding lebesgue_integral_def apply(subst *)
5.461    proof(rule has_integral_sub) case goal1
5.462      have *:"\<forall>x. Real (f x) \<noteq> \<omega>" by auto
5.463      note lebesgue.borel_measurable_Real[OF f(1)]
5.464 @@ -674,27 +701,27 @@
5.465  qed
5.466
5.467  lemma lebesgue_positive_integral_eq_borel:
5.468 -  "f \<in> borel_measurable borel \<Longrightarrow> lebesgue.positive_integral f = borel.positive_integral f "
5.469 +  "f \<in> borel_measurable borel \<Longrightarrow> integral\<^isup>P lebesgue f = integral\<^isup>P lborel f"
5.470    by (auto intro!: lebesgue.positive_integral_subalgebra[symmetric]) default
5.471
5.472  lemma lebesgue_integral_eq_borel:
5.473    assumes "f \<in> borel_measurable borel"
5.474 -  shows "lebesgue.integrable f = borel.integrable f" (is ?P)
5.475 -    and "lebesgue.integral f = borel.integral f" (is ?I)
5.476 +  shows "integrable lebesgue f \<longleftrightarrow> integrable lborel f" (is ?P)
5.477 +    and "integral\<^isup>L lebesgue f = integral\<^isup>L lborel f" (is ?I)
5.478  proof -
5.479 -  have *: "sigma_algebra borel" by default
5.480 -  have "sets borel \<subseteq> sets lebesgue" by auto
5.481 -  from lebesgue.integral_subalgebra[OF assms this _ *]
5.482 +  have *: "sigma_algebra lborel" by default
5.483 +  have "sets lborel \<subseteq> sets lebesgue" by auto
5.484 +  from lebesgue.integral_subalgebra[of f lborel, OF _ this _ _ *] assms
5.485    show ?P ?I by auto
5.486  qed
5.487
5.488  lemma borel_integral_has_integral:
5.489    fixes f::"'a::ordered_euclidean_space => real"
5.490 -  assumes f:"borel.integrable f"
5.491 -  shows "(f has_integral (borel.integral f)) UNIV"
5.492 +  assumes f:"integrable lborel f"
5.493 +  shows "(f has_integral (integral\<^isup>L lborel f)) UNIV"
5.494  proof -
5.495    have borel: "f \<in> borel_measurable borel"
5.496 -    using f unfolding borel.integrable_def by auto
5.497 +    using f unfolding integrable_def by auto
5.498    from f show ?thesis
5.499      using lebesgue_integral_has_integral[of f]
5.500      unfolding lebesgue_integral_eq_borel[OF borel] by simp
5.501 @@ -708,11 +735,11 @@
5.502    using continuous_open_preimage[OF assms] unfolding vimage_def by auto
5.503
5.504  lemma (in measure_space) integral_monotone_convergence_pos':
5.505 -  assumes i: "\<And>i. integrable (f i)" and mono: "\<And>x. mono (\<lambda>n. f n x)"
5.506 +  assumes i: "\<And>i. integrable M (f i)" and mono: "\<And>x. mono (\<lambda>n. f n x)"
5.507    and pos: "\<And>x i. 0 \<le> f i x"
5.508    and lim: "\<And>x. (\<lambda>i. f i x) ----> u x"
5.509 -  and ilim: "(\<lambda>i. integral (f i)) ----> x"
5.510 -  shows "integrable u \<and> integral u = x"
5.511 +  and ilim: "(\<lambda>i. integral\<^isup>L M (f i)) ----> x"
5.512 +  shows "integrable M u \<and> integral\<^isup>L M u = x"
5.513    using integral_monotone_convergence_pos[OF assms] by auto
5.514
5.515  definition e2p :: "'a::ordered_euclidean_space \<Rightarrow> (nat \<Rightarrow> real)" where
5.516 @@ -751,53 +778,68 @@
5.517    thus "x \<in> e2p  A" unfolding image_iff apply(rule_tac x="p2e x" in bexI) apply(subst e2p_p2e) by auto
5.518  qed
5.519
5.520 -interpretation borel_product: product_sigma_finite "\<lambda>x. borel::real algebra" "\<lambda>x. lmeasure"
5.521 +interpretation lborel_product: product_sigma_finite "\<lambda>x. lborel::real measure_space"
5.522    by default
5.523
5.524 -lemma cube_subset_Suc[intro]: "cube n \<subseteq> cube (Suc n)"
5.525 -  unfolding cube_def_raw subset_eq apply safe unfolding mem_interval by auto
5.526 -
5.527 -lemma Pi_iff: "f \<in> Pi I X \<longleftrightarrow> (\<forall>i\<in>I. f i \<in> X i)"
5.528 -  unfolding Pi_def by auto
5.529 +interpretation lborel_space: finite_product_sigma_finite "\<lambda>x. lborel::real measure_space" "{..<DIM('a::ordered_euclidean_space)}"
5.530 +  where "space lborel = UNIV"
5.531 +  and "sets lborel = sets borel"
5.532 +  and "measure lborel = lebesgue.\<mu>"
5.533 +  and "measurable lborel = measurable borel"
5.534 +proof -
5.535 +  show "finite_product_sigma_finite (\<lambda>x. lborel::real measure_space) {..<DIM('a::ordered_euclidean_space)}"
5.536 +    by default simp
5.537 +qed simp_all
5.538
5.539 -lemma measurable_e2p_on_generator:
5.540 -  "e2p \<in> measurable \<lparr> space = UNIV::'a set, sets = range lessThan \<rparr>
5.541 -  (product_algebra
5.542 -    (\<lambda>x. \<lparr> space = UNIV::real set, sets = range lessThan \<rparr>)
5.543 -    {..<DIM('a::ordered_euclidean_space)})"
5.544 -  (is "e2p \<in> measurable ?E ?P")
5.545 -proof (unfold measurable_def, intro CollectI conjI ballI)
5.546 -  show "e2p \<in> space ?E \<rightarrow> space ?P" by (auto simp: e2p_def)
5.547 -  fix A assume "A \<in> sets ?P"
5.548 -  then obtain E where A: "A = (\<Pi>\<^isub>E i\<in>{..<DIM('a)}. E i)"
5.549 -    and "E \<in> {..<DIM('a)} \<rightarrow> (range lessThan)"
5.550 -    by (auto elim!: product_algebraE)
5.551 -  then have "\<forall>i\<in>{..<DIM('a)}. \<exists>xs. E i = {..< xs}" by auto
5.552 -  from this[THEN bchoice] guess xs ..
5.553 -  then have A_eq: "A = (\<Pi>\<^isub>E i\<in>{..<DIM('a)}. {..< xs i})"
5.554 -    using A by auto
5.555 -  have "e2p - A = {..< (\<chi>\<chi> i. xs i) :: 'a}"
5.556 -    using DIM_positive by (auto simp add: Pi_iff set_eq_iff e2p_def A_eq
5.557 -      euclidean_eq[where 'a='a] eucl_less[where 'a='a])
5.558 -  then show "e2p - A \<inter> space ?E \<in> sets ?E" by simp
5.559 +lemma sets_product_borel:
5.560 +  assumes [intro]: "finite I"
5.561 +  shows "sets (\<Pi>\<^isub>M i\<in>I.
5.562 +     \<lparr> space = UNIV::real set, sets = range lessThan, measure = lebesgue.\<mu> \<rparr>) =
5.563 +   sets (\<Pi>\<^isub>M i\<in>I. lborel)" (is "sets ?G = _")
5.564 +proof -
5.565 +  have "sets ?G = sets (\<Pi>\<^isub>M i\<in>I.
5.566 +       sigma \<lparr> space = UNIV::real set, sets = range lessThan, measure = lebesgue.\<mu> \<rparr>)"
5.567 +    by (subst sigma_product_algebra_sigma_eq[of I "\<lambda>_ i. {..<real i}" ])
5.568 +       (auto intro!: measurable_sigma_sigma isotoneI real_arch_lt
5.569 +             simp: product_algebra_def)
5.570 +  then show ?thesis
5.571 +    unfolding lborel_def borel_eq_lessThan lebesgue_def sigma_def by simp
5.572  qed
5.573
5.574  lemma measurable_e2p:
5.575 -  "e2p \<in> measurable (borel::'a algebra)
5.576 -                    (sigma (product_algebra (\<lambda>x. borel :: real algebra) {..<DIM('a::ordered_euclidean_space)}))"
5.577 -  using measurable_e2p_on_generator[where 'a='a] unfolding borel_eq_lessThan
5.578 -  by (subst sigma_product_algebra_sigma_eq[where S="\<lambda>_ i. {..<real i}"])
5.579 -     (auto intro!: measurable_sigma_sigma isotoneI real_arch_lt
5.580 -           simp: product_algebra_def)
5.581 +  "e2p \<in> measurable (borel::'a::ordered_euclidean_space algebra)
5.582 +                    (\<Pi>\<^isub>M i\<in>{..<DIM('a)}. (lborel :: real measure_space))"
5.583 +    (is "_ \<in> measurable ?E ?P")
5.584 +proof -
5.585 +  let ?B = "\<lparr> space = UNIV::real set, sets = range lessThan, measure = lebesgue.\<mu> \<rparr>"
5.586 +  let ?G = "product_algebra_generator {..<DIM('a)} (\<lambda>_. ?B)"
5.587 +  have "e2p \<in> measurable ?E (sigma ?G)"
5.588 +  proof (rule borel.measurable_sigma)
5.589 +    show "e2p \<in> space ?E \<rightarrow> space ?G" by (auto simp: e2p_def)
5.590 +    fix A assume "A \<in> sets ?G"
5.591 +    then obtain E where A: "A = (\<Pi>\<^isub>E i\<in>{..<DIM('a)}. E i)"
5.592 +      and "E \<in> {..<DIM('a)} \<rightarrow> (range lessThan)"
5.593 +      by (auto elim!: product_algebraE simp: )
5.594 +    then have "\<forall>i\<in>{..<DIM('a)}. \<exists>xs. E i = {..< xs}" by auto
5.595 +    from this[THEN bchoice] guess xs ..
5.596 +    then have A_eq: "A = (\<Pi>\<^isub>E i\<in>{..<DIM('a)}. {..< xs i})"
5.597 +      using A by auto
5.598 +    have "e2p - A = {..< (\<chi>\<chi> i. xs i) :: 'a}"
5.599 +      using DIM_positive by (auto simp add: Pi_iff set_eq_iff e2p_def A_eq
5.600 +        euclidean_eq[where 'a='a] eucl_less[where 'a='a])
5.601 +    then show "e2p - A \<inter> space ?E \<in> sets ?E" by simp
5.602 +  qed (auto simp: product_algebra_generator_def)
5.603 +  with sets_product_borel[of "{..<DIM('a)}"] show ?thesis
5.604 +    unfolding measurable_def product_algebra_def by simp
5.605 +qed
5.606
5.607 -lemma measurable_p2e_on_generator:
5.608 -  "p2e \<in> measurable
5.609 -    (product_algebra
5.610 -      (\<lambda>x. \<lparr> space = UNIV::real set, sets = range lessThan \<rparr>)
5.611 -      {..<DIM('a::ordered_euclidean_space)})
5.612 -    \<lparr> space = UNIV::'a set, sets = range lessThan \<rparr>"
5.613 -  (is "p2e \<in> measurable ?P ?E")
5.614 -proof (unfold measurable_def, intro CollectI conjI ballI)
5.615 +lemma measurable_p2e:
5.616 +  "p2e \<in> measurable (\<Pi>\<^isub>M i\<in>{..<DIM('a)}. (lborel :: real measure_space))
5.617 +    (borel :: 'a::ordered_euclidean_space algebra)"
5.618 +  (is "p2e \<in> measurable ?P _")
5.619 +  unfolding borel_eq_lessThan
5.620 +proof (intro lborel_space.measurable_sigma)
5.621 +  let ?E = "\<lparr> space = UNIV :: 'a set, sets = range lessThan \<rparr>"
5.622    show "p2e \<in> space ?P \<rightarrow> space ?E" by simp
5.623    fix A assume "A \<in> sets ?E"
5.624    then obtain x where "A = {..<x}" by auto
5.625 @@ -806,15 +848,7 @@
5.626      by (auto simp: Pi_iff set_eq_iff p2e_def
5.627                     euclidean_eq[where 'a='a] eucl_less[where 'a='a])
5.628    then show "p2e - A \<inter> space ?P \<in> sets ?P" by auto
5.629 -qed
5.630 -
5.631 -lemma measurable_p2e:
5.632 -  "p2e \<in> measurable (sigma (product_algebra (\<lambda>x. borel :: real algebra) {..<DIM('a::ordered_euclidean_space)}))
5.633 -                    (borel::'a algebra)"
5.634 -  using measurable_p2e_on_generator[where 'a='a] unfolding borel_eq_lessThan
5.635 -  by (subst sigma_product_algebra_sigma_eq[where S="\<lambda>_ i. {..<real i}"])
5.636 -     (auto intro!: measurable_sigma_sigma isotoneI real_arch_lt
5.637 -           simp: product_algebra_def)
5.638 +qed simp
5.639
5.640  lemma e2p_Int:"e2p  A \<inter> e2p  B = e2p  (A \<inter> B)" (is "?L = ?R")
5.641    apply(rule image_Int[THEN sym])
5.642 @@ -840,15 +874,13 @@
5.643  lemma lmeasure_measure_eq_borel_prod:
5.644    fixes A :: "('a::ordered_euclidean_space) set"
5.645    assumes "A \<in> sets borel"
5.646 -  shows "lmeasure A = borel_product.product_measure {..<DIM('a)} (e2p  A :: (nat \<Rightarrow> real) set)"
5.647 +  shows "lebesgue.\<mu> A = lborel_space.\<mu> TYPE('a) (e2p  A)" (is "_ = ?m A")
5.648  proof (rule measure_unique_Int_stable[where X=A and A=cube])
5.649 -  interpret fprod: finite_product_sigma_finite "\<lambda>x. borel :: real algebra" "\<lambda>x. lmeasure" "{..<DIM('a)}" by default auto
5.650    show "Int_stable \<lparr> space = UNIV :: 'a set, sets = range (\<lambda>(a,b). {a..b}) \<rparr>"
5.651      (is "Int_stable ?E" ) using Int_stable_cuboids' .
5.652 -  show "borel = sigma ?E" using borel_eq_atLeastAtMost .
5.653 -  show "\<And>i. lmeasure (cube i) \<noteq> \<omega>" unfolding cube_def by auto
5.654 -  show "\<And>X. X \<in> sets ?E \<Longrightarrow>
5.655 -    lmeasure X = borel_product.product_measure {..<DIM('a)} (e2p  X :: (nat \<Rightarrow> real) set)"
5.656 +  have [simp]: "sigma ?E = borel" using borel_eq_atLeastAtMost ..
5.657 +  show "\<And>i. lebesgue.\<mu> (cube i) \<noteq> \<omega>" unfolding cube_def by auto
5.658 +  show "\<And>X. X \<in> sets ?E \<Longrightarrow> lebesgue.\<mu> X = ?m X"
5.659    proof- case goal1 then obtain a b where X:"X = {a..b}" by auto
5.660      { presume *:"X \<noteq> {} \<Longrightarrow> ?case"
5.661        show ?case apply(cases,rule *,assumption) by auto }
5.662 @@ -861,12 +893,12 @@
5.663        show "x \<in> Pi\<^isub>E {..<DIM('a)} XX" unfolding y using y(1)
5.664          unfolding Pi_def extensional_def e2p_def restrict_def X mem_interval XX_def by auto
5.665      qed
5.666 -    have "lmeasure X = (\<Prod>x<DIM('a). Real (b $$x - a$$ x))"  using X' apply- unfolding X
5.667 +    have "lebesgue.\<mu> X = (\<Prod>x<DIM('a). Real (b $$x - a$$ x))"  using X' apply- unfolding X
5.668        unfolding lmeasure_atLeastAtMost content_closed_interval apply(subst Real_setprod) by auto
5.669 -    also have "... = (\<Prod>i<DIM('a). lmeasure (XX i))" apply(rule setprod_cong2)
5.670 +    also have "... = (\<Prod>i<DIM('a). lebesgue.\<mu> (XX i))" apply(rule setprod_cong2)
5.671        unfolding XX_def lmeasure_atLeastAtMost apply(subst content_real) using X' by auto
5.672 -    also have "... = borel_product.product_measure {..<DIM('a)} (e2p  X)" unfolding *[THEN sym]
5.673 -      apply(rule fprod.measure_times[THEN sym]) unfolding XX_def by auto
5.674 +    also have "... = ?m X" unfolding *[THEN sym]
5.675 +      apply(rule lborel_space.measure_times[symmetric]) unfolding XX_def by auto
5.676      finally show ?case .
5.677    qed
5.678
5.679 @@ -875,18 +907,21 @@
5.680    have "\<And>x. \<exists>xa. x \<in> cube xa" apply(rule_tac x=x in mem_big_cube) by fastsimp
5.681    thus "cube \<up> space \<lparr>space = UNIV, sets = range (\<lambda>(a, b). {a..b})\<rparr>"
5.682      apply-apply(rule isotoneI) apply(rule cube_subset_Suc) by auto
5.683 -  show "A \<in> sets borel " by fact
5.684 -  show "measure_space borel lmeasure" by default
5.685 -  show "measure_space borel
5.686 -     (\<lambda>a::'a set. finite_product_sigma_finite.measure (\<lambda>x. borel) (\<lambda>x. lmeasure) {..<DIM('a)} (e2p  a))"
5.687 -  proof (rule fprod.measure_space_vimage)
5.688 -    show "sigma_algebra borel" by default
5.689 -    show "(p2e :: (nat \<Rightarrow> real) \<Rightarrow> 'a) \<in> measurable fprod.P borel" by (rule measurable_p2e)
5.690 -    fix A :: "'a set" assume "A \<in> sets borel"
5.691 -    show "fprod.measure (e2p  A) = fprod.measure (p2e - A \<inter> space fprod.P)"
5.692 +  show "A \<in> sets (sigma ?E)" using assms by simp
5.693 +  have "measure_space lborel" by default
5.694 +  then show "measure_space \<lparr> space = space ?E, sets = sets (sigma ?E), measure = measure lebesgue\<rparr>"
5.695 +    unfolding lebesgue_def lborel_def by simp
5.696 +  let ?M = "\<lparr> space = space ?E, sets = sets (sigma ?E), measure = ?m \<rparr>"
5.697 +  show "measure_space ?M"
5.698 +  proof (rule lborel_space.measure_space_vimage)
5.699 +    show "sigma_algebra ?M" by (rule lborel.sigma_algebra_cong) auto
5.700 +    show "p2e \<in> measurable (\<Pi>\<^isub>M i\<in>{..<DIM('a)}. lborel) ?M"
5.701 +      using measurable_p2e unfolding measurable_def by auto
5.702 +    fix A :: "'a set" assume "A \<in> sets ?M"
5.703 +    show "measure ?M A = lborel_space.\<mu> TYPE('a) (p2e - A \<inter> space (\<Pi>\<^isub>M i\<in>{..<DIM('a)}. lborel))"
5.705    qed
5.706 -qed
5.707 +qed simp
5.708
5.709  lemma range_e2p:"range (e2p::'a::ordered_euclidean_space \<Rightarrow> _) = extensional {..<DIM('a)}"
5.710    unfolding e2p_def_raw
5.711 @@ -896,41 +931,30 @@
5.712  lemma borel_fubini_positiv_integral:
5.713    fixes f :: "'a::ordered_euclidean_space \<Rightarrow> pextreal"
5.714    assumes f: "f \<in> borel_measurable borel"
5.715 -  shows "borel.positive_integral f =
5.716 -          borel_product.product_positive_integral {..<DIM('a)} (f \<circ> p2e)"
5.717 -proof- def U \<equiv> "extensional {..<DIM('a)} :: (nat \<Rightarrow> real) set"
5.718 -  interpret fprod: finite_product_sigma_finite "\<lambda>x. borel" "\<lambda>x. lmeasure" "{..<DIM('a)}" by default auto
5.719 -  show ?thesis
5.720 -  proof (subst borel.positive_integral_vimage[symmetric, of _ "e2p :: 'a \<Rightarrow> _" "(\<lambda>x. f (p2e x))", unfolded p2e_e2p])
5.721 -    show "(e2p :: 'a \<Rightarrow> _) \<in> measurable borel fprod.P" by (rule measurable_e2p)
5.722 -    show "sigma_algebra fprod.P" by default
5.723 -    from measurable_comp[OF measurable_p2e f]
5.724 -    show "(\<lambda>x. f (p2e x)) \<in> borel_measurable fprod.P" by (simp add: comp_def)
5.725 -    let "?L A" = "lmeasure ((e2p::'a \<Rightarrow> (nat \<Rightarrow> real)) - A \<inter> space borel)"
5.726 -    show "measure_space.positive_integral fprod.P ?L (\<lambda>x. f (p2e x)) =
5.727 -      fprod.positive_integral (f \<circ> p2e)"
5.728 -      unfolding comp_def
5.729 -    proof (rule fprod.positive_integral_cong_measure)
5.730 -      fix A :: "(nat \<Rightarrow> real) set" assume "A \<in> sets fprod.P"
5.731 -      then have A: "(e2p::'a \<Rightarrow> (nat \<Rightarrow> real)) - A \<inter> space borel \<in> sets borel"
5.732 -        by (rule measurable_sets[OF measurable_e2p])
5.733 -      have [simp]: "A \<inter> extensional {..<DIM('a)} = A"
5.734 -        using A \<in> sets fprod.P[THEN fprod.sets_into_space] by auto
5.735 -      show "?L A = fprod.measure A"
5.736 -        unfolding lmeasure_measure_eq_borel_prod[OF A]
5.737 -        by (simp add: range_e2p)
5.738 -    qed
5.739 -  qed
5.740 +  shows "integral\<^isup>P lborel f = \<integral>\<^isup>+x. f (p2e x) \<partial>(lborel_space.P TYPE('a))"
5.741 +proof (rule lborel.positive_integral_vimage[symmetric, of _ "e2p :: 'a \<Rightarrow> _" "(\<lambda>x. f (p2e x))", unfolded p2e_e2p])
5.742 +  show "(e2p :: 'a \<Rightarrow> _) \<in> measurable borel (lborel_space.P TYPE('a))" by (rule measurable_e2p)
5.743 +  show "sigma_algebra (lborel_space.P TYPE('a))" by default
5.744 +  from measurable_comp[OF measurable_p2e f]
5.745 +  show "(\<lambda>x. f (p2e x)) \<in> borel_measurable (lborel_space.P TYPE('a))" by (simp add: comp_def)
5.746 +  let "?L A" = "lebesgue.\<mu> ((e2p::'a \<Rightarrow> (nat \<Rightarrow> real)) - A \<inter> UNIV)"
5.747 +  fix A :: "(nat \<Rightarrow> real) set" assume "A \<in> sets (lborel_space.P TYPE('a))"
5.748 +  then have A: "(e2p::'a \<Rightarrow> (nat \<Rightarrow> real)) - A \<inter> space borel \<in> sets borel"
5.749 +    by (rule measurable_sets[OF measurable_e2p])
5.750 +  have [simp]: "A \<inter> extensional {..<DIM('a)} = A"
5.751 +    using A \<in> sets (lborel_space.P TYPE('a))[THEN lborel_space.sets_into_space] by auto
5.752 +  show "lborel_space.\<mu> TYPE('a) A = ?L A"
5.753 +    using lmeasure_measure_eq_borel_prod[OF A] by (simp add: range_e2p)
5.754  qed
5.755
5.756  lemma borel_fubini:
5.757    fixes f :: "'a::ordered_euclidean_space \<Rightarrow> real"
5.758    assumes f: "f \<in> borel_measurable borel"
5.759 -  shows "borel.integral f = borel_product.product_integral {..<DIM('a)} (f \<circ> p2e)"
5.760 -proof- interpret fprod: finite_product_sigma_finite "\<lambda>x. borel" "\<lambda>x. lmeasure" "{..<DIM('a)}" by default auto
5.761 +  shows "integral\<^isup>L lborel f = \<integral>x. f (p2e x) \<partial>(lborel_space.P TYPE('a))"
5.762 +proof -
5.763    have 1:"(\<lambda>x. Real (f x)) \<in> borel_measurable borel" using f by auto
5.764    have 2:"(\<lambda>x. Real (- f x)) \<in> borel_measurable borel" using f by auto
5.765 -  show ?thesis unfolding fprod.integral_def borel.integral_def
5.766 +  show ?thesis unfolding lebesgue_integral_def
5.767      unfolding borel_fubini_positiv_integral[OF 1] borel_fubini_positiv_integral[OF 2]
5.768      unfolding o_def ..
5.769  qed

     6.1 --- a/src/HOL/Probability/Measure.thy	Wed Feb 02 10:35:41 2011 +0100
6.2 +++ b/src/HOL/Probability/Measure.thy	Wed Feb 02 12:34:45 2011 +0100
6.3 @@ -4,6 +4,18 @@
6.4    imports Caratheodory
6.5  begin
6.6
6.7 +lemma measure_algebra_more[simp]:
6.8 +  "\<lparr> space = A, sets = B, \<dots> = algebra.more M \<rparr> \<lparr> measure := m \<rparr> =
6.9 +   \<lparr> space = A, sets = B, \<dots> = algebra.more (M \<lparr> measure := m \<rparr>) \<rparr>"
6.10 +  by (cases M) simp
6.11 +
6.12 +lemma measure_algebra_more_eq[simp]:
6.13 +  "\<And>X. measure \<lparr> space = T, sets = A, \<dots> = algebra.more X \<rparr> = measure X"
6.14 +  unfolding measure_space.splits by simp
6.15 +
6.16 +lemma measure_sigma[simp]: "measure (sigma A) = measure A"
6.17 +  unfolding sigma_def by simp
6.18 +
6.19  lemma inj_on_image_eq_iff:
6.20    assumes "inj_on f S"
6.21    assumes "A \<subseteq> S" "B \<subseteq> S"
6.22 @@ -53,24 +65,34 @@
6.24  qed
6.25
6.26 +lemma (in sigma_algebra) sigma_algebra_cong:
6.27 +  assumes "space N = space M" "sets N = sets M"
6.28 +  shows "sigma_algebra N"
6.29 +  by default (insert sets_into_space, auto simp: assms)
6.30 +
6.31  lemma (in measure_space) measure_space_cong:
6.32 -  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = \<mu> A"
6.33 -  shows "measure_space M \<nu>"
6.34 -proof
6.35 -  show "\<nu> {} = 0" using assms by auto
6.37 -  proof safe
6.38 -    fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets M" "disjoint_family A"
6.39 -    then have "\<And>i. A i \<in> sets M" "(UNION UNIV A) \<in> sets M" by auto
6.40 -    from this[THEN assms] measure_countably_additive[OF A]
6.41 -    show "(\<Sum>\<^isub>\<infinity>n. \<nu> (A n)) = \<nu> (UNION UNIV A)" by simp
6.42 +  assumes "\<And>A. A \<in> sets M \<Longrightarrow> measure N A = \<mu> A" "space N = space M" "sets N = sets M"
6.43 +  shows "measure_space N"
6.44 +proof -
6.45 +  interpret N: sigma_algebra N by (intro sigma_algebra_cong assms)
6.46 +  show ?thesis
6.47 +  proof
6.48 +    show "measure N {} = 0" using assms by auto
6.50 +    proof safe
6.51 +      fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets N" "disjoint_family A"
6.52 +      then have "\<And>i. A i \<in> sets M" "(UNION UNIV A) \<in> sets M" unfolding assms by auto
6.53 +      from measure_countably_additive[of A] A this[THEN assms(1)]
6.54 +      show "(\<Sum>\<^isub>\<infinity>n. measure N (A n)) = measure N (UNION UNIV A)"
6.55 +        unfolding assms by simp
6.56 +    qed
6.57    qed
6.58  qed
6.59
6.62    show "algebra M" by default
6.63 -  show "positive \<mu>" by (simp add: positive_def)
6.64 +  show "positive M \<mu>" by (simp add: positive_def)
6.65  qed
6.66
6.68 @@ -358,12 +380,16 @@
6.69    finally show ?thesis by simp
6.70  qed
6.71
6.73 -  assumes fin: "finite (space M)" and pos: "positive \<mu>" and add: "additive M \<mu>"
6.74 -  shows "measure_space M \<mu>"
6.75 -proof
6.76 -  show [simp]: "\<mu> {} = 0" using pos by (simp add: positive_def)
6.77 -  show "countably_additive M \<mu>"
6.79 +  assumes "sigma_algebra M"
6.80 +  assumes fin: "finite (space M)" and pos: "positive M (measure M)" and add: "additive M (measure M)"
6.81 +  shows "measure_space M"
6.82 +proof -
6.83 +  interpret sigma_algebra M by fact
6.84 +  show ?thesis
6.85 +  proof
6.86 +    show [simp]: "measure M {} = 0" using pos by (simp add: positive_def)
6.87 +    show "countably_additive M (measure M)"
6.89        fix A :: "nat \<Rightarrow> 'a set"
6.90        assume A: "range A \<subseteq> sets M"
6.91 @@ -391,15 +417,15 @@
6.92              by blast
6.93          qed
6.94        then obtain N where N: "\<forall>m\<ge>N. A m = {}" by blast
6.95 -      then have "\<forall>m\<ge>N. \<mu> (A m) = 0" by simp
6.96 -      then have "(\<Sum>\<^isub>\<infinity> n. \<mu> (A n)) = setsum (\<lambda>m. \<mu> (A m)) {..<N}"
6.97 +      then have "\<forall>m\<ge>N. measure M (A m) = 0" by simp
6.98 +      then have "(\<Sum>\<^isub>\<infinity> n. measure M (A n)) = setsum (\<lambda>m. measure M (A m)) {..<N}"
6.100 -      also have "... = \<mu> (\<Union>i<N. A i)"
6.101 +      also have "... = measure M (\<Union>i<N. A i)"
6.102          proof (induct N)
6.103            case 0 thus ?case by simp
6.104          next
6.105            case (Suc n)
6.106 -          have "\<mu> (A n \<union> (\<Union> x<n. A x)) = \<mu> (A n) + \<mu> (\<Union> i<n. A i)"
6.107 +          have "measure M (A n \<union> (\<Union> x<n. A x)) = measure M (A n) + measure M (\<Union> i<n. A i)"
6.109                show "A n \<inter> (\<Union> x<n. A x) = {}" using disj
6.110                  by (auto simp add: disjoint_family_on_def nat_less_le) blast
6.111 @@ -416,14 +442,15 @@
6.112            thus ?case using Suc
6.114          qed
6.115 -      also have "... = \<mu> (\<Union>i. A i)"
6.116 +      also have "... = measure M (\<Union>i. A i)"
6.117          proof -
6.118            have "(\<Union> i<N. A i) = (\<Union>i. A i)" using N
6.119              by auto (metis Int_absorb N disjoint_iff_not_equal lessThan_iff not_leE)
6.120            thus ?thesis by simp
6.121          qed
6.122 -      finally show "(\<Sum>\<^isub>\<infinity> n. \<mu> (A n)) = \<mu> (\<Union>i. A i)" .
6.123 +      finally show "(\<Sum>\<^isub>\<infinity> n. measure M (A n)) = measure M (\<Union>i. A i)" .
6.124      qed
6.125 +  qed
6.126  qed
6.127
6.128  lemma (in measure_space) measure_setsum_split:
6.129 @@ -525,95 +552,75 @@
6.130    qed
6.131  qed
6.132
6.133 -lemma True
6.134 -proof
6.135 -  fix x a b :: nat
6.136 -  have "\<And>x a b :: int. x dvd a \<Longrightarrow> x dvd (a + b) \<Longrightarrow> x dvd b"
6.137 -    by (metis dvd_mult_div_cancel zadd_commute zdvd_reduce)
6.138 -  then have "x dvd a \<Longrightarrow> x dvd (a + b) \<Longrightarrow> x dvd b"
6.139 -    unfolding zdvd_int[of x] zadd_int[symmetric] .
6.140 -qed
6.141 -
6.142  lemma measure_unique_Int_stable:
6.143 -  fixes M E :: "'a algebra" and A :: "nat \<Rightarrow> 'a set"
6.144 -  assumes "Int_stable E" "M = sigma E"
6.145 -  and A: "range  A \<subseteq> sets E" "A \<up> space E"
6.146 -  and ms: "measure_space M \<mu>" "measure_space M \<nu>"
6.147 +  fixes E :: "('a, 'b) algebra_scheme" and A :: "nat \<Rightarrow> 'a set"
6.148 +  assumes "Int_stable E"
6.149 +  and A: "range A \<subseteq> sets E" "A \<up> space E"
6.150 +  and M: "measure_space \<lparr>space = space E, sets = sets (sigma E), measure = \<mu>\<rparr>" (is "measure_space ?M")
6.151 +  and N: "measure_space \<lparr>space = space E, sets = sets (sigma E), measure = \<nu>\<rparr>" (is "measure_space ?N")
6.152    and eq: "\<And>X. X \<in> sets E \<Longrightarrow> \<mu> X = \<nu> X"
6.153    and finite: "\<And>i. \<mu> (A i) \<noteq> \<omega>"
6.154 -  assumes "X \<in> sets M"
6.155 +  assumes "X \<in> sets (sigma E)"
6.156    shows "\<mu> X = \<nu> X"
6.157  proof -
6.158 -  let "?D F" = "{D. D \<in> sets M \<and> \<mu> (F \<inter> D) = \<nu> (F \<inter> D)}"
6.159 -  interpret M: measure_space M \<mu> by fact
6.160 -  interpret M': measure_space M \<nu> by fact
6.161 -  have "space E = space M"
6.162 -    using M = sigma E by simp
6.163 -  have sets_E: "sets E \<subseteq> Pow (space E)"
6.164 -  proof
6.165 -    fix X assume "X \<in> sets E"
6.166 -    then have "X \<in> sets M" unfolding M = sigma E
6.167 -      unfolding sigma_def by (auto intro!: sigma_sets.Basic)
6.168 -    with M.sets_into_space show "X \<in> Pow (space E)"
6.169 -      unfolding space E = space M by auto
6.170 -  qed
6.171 -  have A': "range A \<subseteq> sets M" using M = sigma E A
6.172 -    by (auto simp: sets_sigma intro!: sigma_sets.Basic)
6.173 +  let "?D F" = "{D. D \<in> sets (sigma E) \<and> \<mu> (F \<inter> D) = \<nu> (F \<inter> D)}"
6.174 +  interpret M: measure_space ?M
6.175 +    where "space ?M = space E" and "sets ?M = sets (sigma E)" and "measure ?M = \<mu>" by (simp_all add: M)
6.176 +  interpret N: measure_space ?N
6.177 +    where "space ?N = space E" and "sets ?N = sets (sigma E)" and "measure ?N = \<nu>" by (simp_all add: N)
6.178    { fix F assume "F \<in> sets E" and "\<mu> F \<noteq> \<omega>"
6.179 -    then have [intro]: "F \<in> sets M" unfolding M = sigma E sets_sigma
6.180 -      by (intro sigma_sets.Basic)
6.181 +    then have [intro]: "F \<in> sets (sigma E)" by auto
6.182      have "\<nu> F \<noteq> \<omega>" using \<mu> F \<noteq> \<omega> F \<in> sets E eq by simp
6.183      interpret D: dynkin_system "\<lparr>space=space E, sets=?D F\<rparr>"
6.184      proof (rule dynkin_systemI, simp_all)
6.185 -      fix A assume "A \<in> sets M \<and> \<mu> (F \<inter> A) = \<nu> (F \<inter> A)"
6.186 -      then show "A \<subseteq> space E"
6.187 -        unfolding space E = space M using M.sets_into_space by auto
6.188 +      fix A assume "A \<in> sets (sigma E) \<and> \<mu> (F \<inter> A) = \<nu> (F \<inter> A)"
6.189 +      then show "A \<subseteq> space E" using M.sets_into_space by auto
6.190      next
6.191 -      have "F \<inter> space E = F" using F \<in> sets E sets_E by auto
6.192 -      then show "space E \<in> sets M \<and> \<mu> (F \<inter> space E) = \<nu> (F \<inter> space E)"
6.193 -        unfolding space E = space M using F \<in> sets E eq by auto
6.194 +      have "F \<inter> space E = F" using F \<in> sets E by auto
6.195 +      then show "\<mu> (F \<inter> space E) = \<nu> (F \<inter> space E)"
6.196 +        using F \<in> sets E eq by auto
6.197      next
6.198 -      fix A assume *: "A \<in> sets M \<and> \<mu> (F \<inter> A) = \<nu> (F \<inter> A)"
6.199 -      then have **: "F \<inter> (space M - A) = F - (F \<inter> A)"
6.200 -        and [intro]: "F \<inter> A \<in> sets M"
6.201 -        using F \<in> sets E sets_E space E = space M by auto
6.202 -      have "\<nu> (F \<inter> A) \<le> \<nu> F" by (auto intro!: M'.measure_mono)
6.203 +      fix A assume *: "A \<in> sets (sigma E) \<and> \<mu> (F \<inter> A) = \<nu> (F \<inter> A)"
6.204 +      then have **: "F \<inter> (space (sigma E) - A) = F - (F \<inter> A)"
6.205 +        and [intro]: "F \<inter> A \<in> sets (sigma E)"
6.206 +        using F \<in> sets E M.sets_into_space by auto
6.207 +      have "\<nu> (F \<inter> A) \<le> \<nu> F" by (auto intro!: N.measure_mono)
6.208        then have "\<nu> (F \<inter> A) \<noteq> \<omega>" using \<nu> F \<noteq> \<omega> by auto
6.209        have "\<mu> (F \<inter> A) \<le> \<mu> F" by (auto intro!: M.measure_mono)
6.210        then have "\<mu> (F \<inter> A) \<noteq> \<omega>" using \<mu> F \<noteq> \<omega> by auto
6.211 -      then have "\<mu> (F \<inter> (space M - A)) = \<mu> F - \<mu> (F \<inter> A)" unfolding **
6.212 -        using F \<inter> A \<in> sets M by (auto intro!: M.measure_Diff)
6.213 +      then have "\<mu> (F \<inter> (space (sigma E) - A)) = \<mu> F - \<mu> (F \<inter> A)" unfolding **
6.214 +        using F \<inter> A \<in> sets (sigma E) by (auto intro!: M.measure_Diff)
6.215        also have "\<dots> = \<nu> F - \<nu> (F \<inter> A)" using eq F \<in> sets E * by simp
6.216 -      also have "\<dots> = \<nu> (F \<inter> (space M - A))" unfolding **
6.217 -        using F \<inter> A \<in> sets M \<nu> (F \<inter> A) \<noteq> \<omega> by (auto intro!: M'.measure_Diff[symmetric])
6.218 -      finally show "space E - A \<in> sets M \<and> \<mu> (F \<inter> (space E - A)) = \<nu> (F \<inter> (space E - A))"
6.219 -        using space E = space M * by auto
6.220 +      also have "\<dots> = \<nu> (F \<inter> (space (sigma E) - A))" unfolding **
6.221 +        using F \<inter> A \<in> sets (sigma E) \<nu> (F \<inter> A) \<noteq> \<omega> by (auto intro!: N.measure_Diff[symmetric])
6.222 +      finally show "space E - A \<in> sets (sigma E) \<and> \<mu> (F \<inter> (space E - A)) = \<nu> (F \<inter> (space E - A))"
6.223 +        using * by auto
6.224      next
6.225        fix A :: "nat \<Rightarrow> 'a set"
6.226 -      assume "disjoint_family A" "range A \<subseteq> {X \<in> sets M. \<mu> (F \<inter> X) = \<nu> (F \<inter> X)}"
6.227 -      then have A: "range (\<lambda>i. F \<inter> A i) \<subseteq> sets M" "F \<inter> (\<Union>x. A x) = (\<Union>x. F \<inter> A x)"
6.228 -        "disjoint_family (\<lambda>i. F \<inter> A i)" "\<And>i. \<mu> (F \<inter> A i) = \<nu> (F \<inter> A i)" "range A \<subseteq> sets M"
6.229 -        by ((fastsimp simp: disjoint_family_on_def)+)
6.230 -      then show "(\<Union>x. A x) \<in> sets M \<and> \<mu> (F \<inter> (\<Union>x. A x)) = \<nu> (F \<inter> (\<Union>x. A x))"
6.231 +      assume "disjoint_family A" "range A \<subseteq> {X \<in> sets (sigma E). \<mu> (F \<inter> X) = \<nu> (F \<inter> X)}"
6.232 +      then have A: "range (\<lambda>i. F \<inter> A i) \<subseteq> sets (sigma E)" "F \<inter> (\<Union>x. A x) = (\<Union>x. F \<inter> A x)"
6.233 +        "disjoint_family (\<lambda>i. F \<inter> A i)" "\<And>i. \<mu> (F \<inter> A i) = \<nu> (F \<inter> A i)" "range A \<subseteq> sets (sigma E)"
6.234 +        by (auto simp: disjoint_family_on_def subset_eq)
6.235 +      then show "(\<Union>x. A x) \<in> sets (sigma E) \<and> \<mu> (F \<inter> (\<Union>x. A x)) = \<nu> (F \<inter> (\<Union>x. A x))"
6.239              simp del: UN_simps)
6.240      qed
6.241 -    have *: "sigma E = \<lparr>space = space E, sets = ?D F\<rparr>"
6.242 -      using M = sigma E F \<in> sets E Int_stable E
6.243 +    have *: "sets (sigma E) = sets \<lparr>space = space E, sets = ?D F\<rparr>"
6.244 +      using F \<in> sets E Int_stable E
6.245        by (intro D.dynkin_lemma)
6.246           (auto simp add: sets_sigma Int_stable_def eq intro: sigma_sets.Basic)
6.247 -    have "\<And>D. D \<in> sets M \<Longrightarrow> \<mu> (F \<inter> D) = \<nu> (F \<inter> D)"
6.248 -      unfolding M = sigma E by (auto simp: *) }
6.249 +    have "\<And>D. D \<in> sets (sigma E) \<Longrightarrow> \<mu> (F \<inter> D) = \<nu> (F \<inter> D)"
6.250 +      by (subst (asm) *) auto }
6.251    note * = this
6.252    { fix i have "\<mu> (A i \<inter> X) = \<nu> (A i \<inter> X)"
6.253 -      using *[of "A i" X] X \<in> sets M A finite by auto }
6.254 +      using *[of "A i" X] X \<in> sets (sigma E) A finite by auto }
6.255    moreover
6.256    have "(\<lambda>i. A i \<inter> X) \<up> X"
6.257 -    using X \<in> sets M M.sets_into_space A space E = space M
6.258 +    using X \<in> sets (sigma E) M.sets_into_space A
6.259      by (auto simp: isoton_def)
6.260    then have "(\<lambda>i. \<mu> (A i \<inter> X)) \<up> \<mu> X" "(\<lambda>i. \<nu> (A i \<inter> X)) \<up> \<nu> X"
6.261 -    using X \<in> sets M A' by (auto intro!: M.measure_up M'.measure_up M.Int)
6.262 +    using X \<in> sets (sigma E) A by (auto intro!: M.measure_up N.measure_up M.Int simp: subset_eq)
6.263    ultimately show ?thesis by (simp add: isoton_def)
6.264  qed
6.265
6.266 @@ -830,37 +837,38 @@
6.267
6.268  lemma (in measure_space) restricted_measure_space:
6.269    assumes "S \<in> sets M"
6.270 -  shows "measure_space (restricted_space S) \<mu>"
6.271 -    (is "measure_space ?r \<mu>")
6.272 +  shows "measure_space (restricted_space S)"
6.273 +    (is "measure_space ?r")
6.274    unfolding measure_space_def measure_space_axioms_def
6.275  proof safe
6.276    show "sigma_algebra ?r" using restricted_sigma_algebra[OF assms] .
6.277 -  show "\<mu> {} = 0" by simp
6.278 -  show "countably_additive ?r \<mu>"
6.279 +  show "measure ?r {} = 0" by simp
6.280 +
6.281 +  show "countably_additive ?r (measure ?r)"
6.283    proof safe
6.284      fix A :: "nat \<Rightarrow> 'a set"
6.285      assume *: "range A \<subseteq> sets ?r" and **: "disjoint_family A"
6.286      from restriction_in_sets[OF assms *[simplified]] **
6.287 -    show "(\<Sum>\<^isub>\<infinity> n. \<mu> (A n)) = \<mu> (\<Union>i. A i)"
6.288 +    show "(\<Sum>\<^isub>\<infinity> n. measure ?r (A n)) = measure ?r (\<Union>i. A i)"
6.290    qed
6.291  qed
6.292
6.293  lemma (in measure_space) measure_space_vimage:
6.294 -  fixes M' :: "'b algebra"
6.295 +  fixes M' :: "('c, 'd) measure_space_scheme"
6.296    assumes T: "sigma_algebra M'" "T \<in> measurable M M'"
6.297 -    and \<nu>: "\<And>A. A \<in> sets M' \<Longrightarrow> \<nu> A = \<mu> (T - A \<inter> space M)"
6.298 -  shows "measure_space M' \<nu>"
6.299 +    and \<nu>: "\<And>A. A \<in> sets M' \<Longrightarrow> measure M' A = \<mu> (T - A \<inter> space M)"
6.300 +  shows "measure_space M'"
6.301  proof -
6.302    interpret M': sigma_algebra M' by fact
6.303    show ?thesis
6.304    proof
6.305 -    show "\<nu> {} = 0" using \<nu>[of "{}"] by simp
6.306 +    show "measure M' {} = 0" using \<nu>[of "{}"] by simp
6.307
6.308 -    show "countably_additive M' \<nu>"
6.309 -    proof (intro countably_additive_def[THEN iffD2] allI impI)
6.310 -      fix A :: "nat \<Rightarrow> 'b set" assume "range A \<subseteq> sets M'" "disjoint_family A"
6.311 +    show "countably_additive M' (measure M')"
6.313 +      fix A :: "nat \<Rightarrow> 'c set" assume "range A \<subseteq> sets M'" "disjoint_family A"
6.314        then have A: "\<And>i. A i \<in> sets M'" "(\<Union>i. A i) \<in> sets M'" by auto
6.315        then have *: "range (\<lambda>i. T - (A i) \<inter> space M) \<subseteq> sets M"
6.316          using T \<in> measurable M M' by (auto simp: measurable_def)
6.317 @@ -868,7 +876,7 @@
6.318          using * by blast
6.319        moreover have **: "disjoint_family (\<lambda>i. T - A i \<inter> space M)"
6.320          using disjoint_family A by (auto simp: disjoint_family_on_def)
6.321 -      ultimately show "(\<Sum>\<^isub>\<infinity> i. \<nu> (A i)) = \<nu> (\<Union>i. A i)"
6.322 +      ultimately show "(\<Sum>\<^isub>\<infinity> i. measure M' (A i)) = measure M' (\<Union>i. A i)"
6.323          using measure_countably_additive[OF _ **] A
6.324          by (auto simp: comp_def vimage_UN \<nu>)
6.325      qed
6.326 @@ -877,14 +885,15 @@
6.327
6.328  lemma (in measure_space) measure_space_subalgebra:
6.329    assumes "sigma_algebra N" and [simp]: "sets N \<subseteq> sets M" "space N = space M"
6.330 -  shows "measure_space N \<mu>"
6.331 +  and measure[simp]: "\<And>X. X \<in> sets N \<Longrightarrow> measure N X = measure M X"
6.332 +  shows "measure_space N"
6.333  proof -
6.334    interpret N: sigma_algebra N by fact
6.335    show ?thesis
6.336    proof
6.337      from sets N \<subseteq> sets M have "\<And>A. range A \<subseteq> sets N \<Longrightarrow> range A \<subseteq> sets M" by blast
6.338 -    then show "countably_additive N \<mu>"
6.340 +    then show "countably_additive N (measure N)"
6.342    qed simp
6.343  qed
6.344
6.345 @@ -895,16 +904,16 @@
6.346
6.347  lemma (in sigma_finite_measure) restricted_sigma_finite_measure:
6.348    assumes "S \<in> sets M"
6.349 -  shows "sigma_finite_measure (restricted_space S) \<mu>"
6.350 -    (is "sigma_finite_measure ?r _")
6.351 +  shows "sigma_finite_measure (restricted_space S)"
6.352 +    (is "sigma_finite_measure ?r")
6.353    unfolding sigma_finite_measure_def sigma_finite_measure_axioms_def
6.354  proof safe
6.355 -  show "measure_space ?r \<mu>" using restricted_measure_space[OF assms] .
6.356 +  show "measure_space ?r" using restricted_measure_space[OF assms] .
6.357  next
6.358    obtain A :: "nat \<Rightarrow> 'a set" where
6.359        "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. \<mu> (A i) \<noteq> \<omega>"
6.360      using sigma_finite by auto
6.361 -  show "\<exists>A::nat \<Rightarrow> 'a set. range A \<subseteq> sets ?r \<and> (\<Union>i. A i) = space ?r \<and> (\<forall>i. \<mu> (A i) \<noteq> \<omega>)"
6.362 +  show "\<exists>A::nat \<Rightarrow> 'a set. range A \<subseteq> sets ?r \<and> (\<Union>i. A i) = space ?r \<and> (\<forall>i. measure ?r (A i) \<noteq> \<omega>)"
6.363    proof (safe intro!: exI[of _ "\<lambda>i. A i \<inter> S"] del: notI)
6.364      fix i
6.365      show "A i \<inter> S \<in> sets ?r"
6.366 @@ -919,22 +928,21 @@
6.367      have "\<mu> (A i \<inter> S) \<le> \<mu> (A i)"
6.368        using range A \<subseteq> sets M S \<in> sets M by (auto intro!: measure_mono)
6.369      also have "\<dots> < \<omega>" using \<mu> (A i) \<noteq> \<omega> by (auto simp: pextreal_less_\<omega>)
6.370 -    finally show "\<mu> (A i \<inter> S) \<noteq> \<omega>" by (auto simp: pextreal_less_\<omega>)
6.371 +    finally show "measure ?r (A i \<inter> S) \<noteq> \<omega>" by (auto simp: pextreal_less_\<omega>)
6.372    qed
6.373  qed
6.374
6.375  lemma (in sigma_finite_measure) sigma_finite_measure_cong:
6.376 -  assumes cong: "\<And>A. A \<in> sets M \<Longrightarrow> \<mu>' A = \<mu> A"
6.377 -  shows "sigma_finite_measure M \<mu>'"
6.378 +  assumes cong: "\<And>A. A \<in> sets M \<Longrightarrow> measure M' A = \<mu> A" "sets M' = sets M" "space M' = space M"
6.379 +  shows "sigma_finite_measure M'"
6.380  proof -
6.381 -  interpret \<mu>': measure_space M \<mu>'
6.382 -    using cong by (rule measure_space_cong)
6.383 +  interpret M': measure_space M' by (intro measure_space_cong cong)
6.384    from sigma_finite guess A .. note A = this
6.385    then have "\<And>i. A i \<in> sets M" by auto
6.386 -  with A have fin: "(\<forall>i. \<mu>' (A i) \<noteq> \<omega>)" using cong by auto
6.387 +  with A have fin: "(\<forall>i. measure M' (A i) \<noteq> \<omega>)" using cong by auto
6.388    show ?thesis
6.389      apply default
6.390 -    using A fin by auto
6.391 +    using A fin cong by auto
6.392  qed
6.393
6.394  lemma (in sigma_finite_measure) disjoint_sigma_finite:
6.395 @@ -1110,20 +1118,20 @@
6.396
6.397  lemma (in finite_measure) restricted_finite_measure:
6.398    assumes "S \<in> sets M"
6.399 -  shows "finite_measure (restricted_space S) \<mu>"
6.400 -    (is "finite_measure ?r _")
6.401 +  shows "finite_measure (restricted_space S)"
6.402 +    (is "finite_measure ?r")
6.403    unfolding finite_measure_def finite_measure_axioms_def
6.404  proof (safe del: notI)
6.405 -  show "measure_space ?r \<mu>" using restricted_measure_space[OF assms] .
6.406 +  show "measure_space ?r" using restricted_measure_space[OF assms] .
6.407  next
6.408 -  show "\<mu> (space ?r) \<noteq> \<omega>" using finite_measure[OF S \<in> sets M] by auto
6.409 +  show "measure ?r (space ?r) \<noteq> \<omega>" using finite_measure[OF S \<in> sets M] by auto
6.410  qed
6.411
6.412  lemma (in measure_space) restricted_to_finite_measure:
6.413    assumes "S \<in> sets M" "\<mu> S \<noteq> \<omega>"
6.414 -  shows "finite_measure (restricted_space S) \<mu>"
6.415 +  shows "finite_measure (restricted_space S)"
6.416  proof -
6.417 -  have "measure_space (restricted_space S) \<mu>"
6.418 +  have "measure_space (restricted_space S)"
6.419      using S \<in> sets M by (rule restricted_measure_space)
6.420    then show ?thesis
6.421      unfolding finite_measure_def finite_measure_axioms_def
6.422 @@ -1218,105 +1226,104 @@
6.423
6.424  section {* Measure preserving *}
6.425
6.426 -definition "measure_preserving A \<mu> B \<nu> =
6.427 -    {f \<in> measurable A B. (\<forall>y \<in> sets B. \<mu> (f - y \<inter> space A) = \<nu> y)}"
6.428 +definition "measure_preserving A B =
6.429 +    {f \<in> measurable A B. (\<forall>y \<in> sets B. measure A (f - y \<inter> space A) = measure B y)}"
6.430
6.431  lemma (in finite_measure) measure_preserving_lift:
6.432 -  fixes f :: "'a \<Rightarrow> 'a2" and A :: "'a2 algebra"
6.433 -  assumes "algebra A"
6.434 -  assumes "finite_measure (sigma A) \<nu>" (is "finite_measure ?sA _")
6.435 -  assumes fmp: "f \<in> measure_preserving M \<mu> A \<nu>"
6.436 -  shows "f \<in> measure_preserving M \<mu> (sigma A) \<nu>"
6.437 +  fixes f :: "'a \<Rightarrow> 'c" and A :: "('c, 'd) measure_space_scheme"
6.438 +  assumes "algebra A" "finite_measure (sigma A)" (is "finite_measure ?sA")
6.439 +  assumes fmp: "f \<in> measure_preserving M A"
6.440 +  shows "f \<in> measure_preserving M (sigma A)"
6.441  proof -
6.442 -  interpret sA: finite_measure ?sA \<nu> by fact
6.443 +  interpret sA: finite_measure ?sA by fact
6.444    interpret A: algebra A by fact
6.445    show ?thesis using fmp
6.446 -    proof (clarsimp simp add: measure_preserving_def)
6.447 -      assume fm: "f \<in> measurable M A"
6.448 -         and meq: "\<forall>y\<in>sets A. \<mu> (f - y \<inter> space M) = \<nu> y"
6.449 -      have f12: "f \<in> measurable M ?sA"
6.450 -        using measurable_subset[OF A.sets_into_space] fm by auto
6.451 -      hence ffn: "f \<in> space M \<rightarrow> space A"
6.452 -        by (simp add: measurable_def)
6.453 -      have "space M \<subseteq> f - (space A)"
6.454 -        by auto (metis PiE ffn)
6.455 -      hence fveq [simp]: "(f - (space A)) \<inter> space M = space M"
6.456 -        by blast
6.457 -      {
6.458 -        fix y
6.459 -        assume y: "y \<in> sets ?sA"
6.460 -        have "sets ?sA = sigma_sets (space A) (sets A)" (is "_ = ?A") by (auto simp: sigma_def)
6.461 -        also have "\<dots> \<subseteq> {s . \<mu> ((f - s) \<inter> space M) = \<nu> s}"
6.462 -          proof (rule A.sigma_property_disjoint, auto)
6.463 -            fix x assume "x \<in> sets A" then show "\<mu> (f - x \<inter> space M) = \<nu> x" by (simp add: meq)
6.464 -          next
6.465 -            fix s
6.466 -            assume eq: "\<mu> (f - s \<inter> space M) = \<nu> s" and s: "s \<in> ?A"
6.467 -            then have s': "s \<in> sets ?sA" by (simp add: sigma_def)
6.468 -            show "\<mu> (f - (space A - s) \<inter> space M) = \<nu> (space A - s)"
6.469 -              using sA.finite_measure_compl[OF s']
6.470 -              using measurable_sets[OF f12 s'] meq[THEN bspec, OF A.top]
6.471 -              by (simp add: vimage_Diff Diff_Int_distrib2 finite_measure_compl eq)
6.472 -          next
6.473 -            fix S
6.474 -            assume S0: "S 0 = {}"
6.475 -               and SSuc: "\<And>n.  S n \<subseteq> S (Suc n)"
6.476 -               and rS1: "range S \<subseteq> {s. \<mu> (f - s \<inter> space M) = \<nu> s}"
6.477 -               and "range S \<subseteq> ?A"
6.478 -            hence rS2: "range S \<subseteq> sets ?sA" by (simp add: sigma_def)
6.479 -            have eq1: "\<And>i. \<mu> (f - S i \<inter> space M) = \<nu> (S i)"
6.480 -              using rS1 by blast
6.481 -            have *: "(\<lambda>n. \<nu> (S n)) = (\<lambda>n. \<mu> (f - S n \<inter> space M))"
6.482 -              by (simp add: eq1)
6.483 -            have "(SUP n. ... n) = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.484 -              proof (rule measure_countable_increasing)
6.485 -                show "range (\<lambda>i. f - S i \<inter> space M) \<subseteq> sets M"
6.486 -                  using f12 rS2 by (auto simp add: measurable_def)
6.487 -                show "f - S 0 \<inter> space M = {}" using S0
6.488 -                  by blast
6.489 -                show "\<And>n. f - S n \<inter> space M \<subseteq> f - S (Suc n) \<inter> space M"
6.490 -                  using SSuc by auto
6.491 -              qed
6.492 -            also have "\<mu> (\<Union>i. f - S i \<inter> space M) = \<mu> (f - (\<Union>i. S i) \<inter> space M)"
6.493 -              by (simp add: vimage_UN)
6.494 -            finally have "(SUP n. \<nu> (S n)) = \<mu> (f - (\<Union>i. S i) \<inter> space M)" unfolding * .
6.495 -            moreover
6.496 -            have "(SUP n. \<nu> (S n)) = \<nu> (\<Union>i. S i)"
6.497 -              by (rule sA.measure_countable_increasing[OF rS2, OF S0 SSuc])
6.498 -            ultimately
6.499 -            show "\<mu> (f - (\<Union>i. S i) \<inter> space M) = \<nu> (\<Union>i. S i)" by simp
6.500 -          next
6.501 -            fix S :: "nat => 'a2 set"
6.502 -              assume dS: "disjoint_family S"
6.503 -                 and rS1: "range S \<subseteq> {s. \<mu> (f - s \<inter> space M) = \<nu> s}"
6.504 -                 and "range S \<subseteq> ?A"
6.505 -              hence rS2: "range S \<subseteq> sets ?sA" by (simp add: sigma_def)
6.506 -              have "\<And>i. \<mu> (f - S i \<inter> space M) = \<nu> (S i)"
6.507 -                using rS1 by blast
6.508 -              hence *: "(\<lambda>i. \<nu> (S i)) = (\<lambda>n. \<mu> (f - S n \<inter> space M))"
6.509 -                by simp
6.510 -              have "psuminf ... = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.512 -                  show "range (\<lambda>i. f - S i \<inter> space M) \<subseteq> sets M"
6.513 -                    using f12 rS2 by (auto simp add: measurable_def)
6.514 -                  show "disjoint_family (\<lambda>i. f - S i \<inter> space M)" using dS
6.515 -                    by (auto simp add: disjoint_family_on_def)
6.516 -                qed
6.517 -              hence "(\<Sum>\<^isub>\<infinity> i. \<nu> (S i)) = \<mu> (\<Union>i. f - S i \<inter> space M)" unfolding * .
6.518 -              with sA.measure_countably_additive [OF rS2 dS]
6.519 -              have "\<mu> (\<Union>i. f - S i \<inter> space M) = \<nu> (\<Union>i. S i)"
6.520 -                by simp
6.521 -              moreover have "\<mu> (f - (\<Union>i. S i) \<inter> space M) = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.522 -                by (simp add: vimage_UN)
6.523 -              ultimately show "\<mu> (f - (\<Union>i. S i) \<inter> space M) = \<nu> (\<Union>i. S i)"
6.524 -                by metis
6.525 +  proof (clarsimp simp add: measure_preserving_def)
6.526 +    assume fm: "f \<in> measurable M A"
6.527 +       and "\<forall>y\<in>sets A. \<mu> (f - y \<inter> space M) = measure A y"
6.528 +    then have meq: "\<forall>y\<in>sets A. \<mu> (f - y \<inter> space M) = sA.\<mu> y"
6.529 +      by simp
6.530 +    have f12: "f \<in> measurable M ?sA"
6.531 +      using measurable_subset[OF A.sets_into_space] fm by auto
6.532 +    hence ffn: "f \<in> space M \<rightarrow> space A"
6.533 +      by (simp add: measurable_def)
6.534 +    have "space M \<subseteq> f - (space A)"
6.535 +      by auto (metis PiE ffn)
6.536 +    hence fveq [simp]: "(f - (space A)) \<inter> space M = space M"
6.537 +      by blast
6.538 +    {
6.539 +      fix y
6.540 +      assume y: "y \<in> sets ?sA"
6.541 +      have "sets ?sA = sigma_sets (space A) (sets A)" (is "_ = ?A") by (auto simp: sigma_def)
6.542 +      also have "\<dots> \<subseteq> {s . \<mu> ((f - s) \<inter> space M) = sA.\<mu> s}"
6.543 +      proof (rule A.sigma_property_disjoint, safe)
6.544 +        fix x assume "x \<in> sets A" then show "\<mu> (f - x \<inter> space M) = sA.\<mu> x" by (simp add: meq)
6.545 +      next
6.546 +        fix s
6.547 +        assume eq: "\<mu> (f - s \<inter> space M) = sA.\<mu> s" and s: "s \<in> ?A"
6.548 +        then have s': "s \<in> sets ?sA" by (simp add: sigma_def)
6.549 +        show "\<mu> (f - (space A - s) \<inter> space M) = measure ?sA (space A - s)"
6.550 +          using sA.finite_measure_compl[OF s']
6.551 +          using measurable_sets[OF f12 s'] meq[THEN bspec, OF A.top]
6.552 +          by (simp add: vimage_Diff Diff_Int_distrib2 finite_measure_compl eq)
6.553 +      next
6.554 +        fix S
6.555 +        assume S0: "S 0 = {}"
6.556 +           and SSuc: "\<And>n.  S n \<subseteq> S (Suc n)"
6.557 +           and rS1: "range S \<subseteq> {s. \<mu> (f - s \<inter> space M) = sA.\<mu> s} \<inter> ?A"
6.558 +        hence rS2: "range S \<subseteq> sets ?sA" by (simp add: sigma_def)
6.559 +        have eq1: "\<And>i. \<mu> (f - S i \<inter> space M) = sA.\<mu> (S i)"
6.560 +          using rS1 by blast
6.561 +        have *: "(\<lambda>n. sA.\<mu> (S n)) = (\<lambda>n. \<mu> (f - S n \<inter> space M))"
6.562 +          by (simp add: eq1)
6.563 +        have "(SUP n. ... n) = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.564 +        proof (rule measure_countable_increasing)
6.565 +          show "range (\<lambda>i. f - S i \<inter> space M) \<subseteq> sets M"
6.566 +            using f12 rS2 by (auto simp add: measurable_def)
6.567 +          show "f - S 0 \<inter> space M = {}" using S0
6.568 +            by blast
6.569 +          show "\<And>n. f - S n \<inter> space M \<subseteq> f - S (Suc n) \<inter> space M"
6.570 +            using SSuc by auto
6.571 +        qed
6.572 +        also have "\<mu> (\<Union>i. f - S i \<inter> space M) = \<mu> (f - (\<Union>i. S i) \<inter> space M)"
6.573 +          by (simp add: vimage_UN)
6.574 +        finally have "(SUP n. sA.\<mu> (S n)) = \<mu> (f - (\<Union>i. S i) \<inter> space M)" unfolding * .
6.575 +        moreover
6.576 +        have "(SUP n. sA.\<mu> (S n)) = sA.\<mu> (\<Union>i. S i)"
6.577 +          by (rule sA.measure_countable_increasing[OF rS2, OF S0 SSuc])
6.578 +        ultimately
6.579 +        show "\<mu> (f - (\<Union>i. S i) \<inter> space M) = sA.\<mu> (\<Union>i. S i)" by simp
6.580 +      next
6.581 +        fix S :: "nat \<Rightarrow> 'c set"
6.582 +        assume dS: "disjoint_family S"
6.583 +           and rS1: "range S \<subseteq> {s. \<mu> (f - s \<inter> space M) = sA.\<mu> s} \<inter> ?A"
6.584 +        hence rS2: "range S \<subseteq> sets ?sA" by (simp add: sigma_def)
6.585 +        have "\<And>i. \<mu> (f - S i \<inter> space M) = sA.\<mu> (S i)"
6.586 +          using rS1 by blast
6.587 +        hence *: "(\<lambda>i. sA.\<mu> (S i)) = (\<lambda>n. \<mu> (f - S n \<inter> space M))"
6.588 +          by simp
6.589 +        have "psuminf ... = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.591 +            show "range (\<lambda>i. f - S i \<inter> space M) \<subseteq> sets M"
6.592 +              using f12 rS2 by (auto simp add: measurable_def)
6.593 +            show "disjoint_family (\<lambda>i. f - S i \<inter> space M)" using dS
6.594 +              by (auto simp add: disjoint_family_on_def)
6.595            qed
6.596 -        finally have "sets ?sA \<subseteq> {s . \<mu> ((f - s) \<inter> space M) = \<nu> s}" .
6.597 -        hence "\<mu> (f - y \<inter> space M) = \<nu> y" using y by force
6.598 -      }
6.599 -      thus "f \<in> measurable M ?sA \<and> (\<forall>y\<in>sets ?sA. \<mu> (f - y \<inter> space M) = \<nu> y)"
6.600 -        by (blast intro: f12)
6.601 -    qed
6.602 +        hence "(\<Sum>\<^isub>\<infinity> i. sA.\<mu> (S i)) = \<mu> (\<Union>i. f - S i \<inter> space M)" unfolding * .
6.603 +        with sA.measure_countably_additive [OF rS2 dS]
6.604 +        have "\<mu> (\<Union>i. f - S i \<inter> space M) = sA.\<mu> (\<Union>i. S i)"
6.605 +          by simp
6.606 +        moreover have "\<mu> (f - (\<Union>i. S i) \<inter> space M) = \<mu> (\<Union>i. f - S i \<inter> space M)"
6.607 +          by (simp add: vimage_UN)
6.608 +        ultimately show "\<mu> (f - (\<Union>i. S i) \<inter> space M) = sA.\<mu> (\<Union>i. S i)"
6.609 +          by metis
6.610 +      qed
6.611 +      finally have "sets ?sA \<subseteq> {s . \<mu> ((f - s) \<inter> space M) = sA.\<mu> s}" .
6.612 +      hence "\<mu> (f - y \<inter> space M) = sA.\<mu> y" using y by force
6.613 +    }
6.614 +    thus "f \<in> measurable M ?sA \<and> (\<forall>y\<in>sets ?sA. \<mu> (f - y \<inter> space M) = measure A y)"
6.615 +      by simp_all (blast intro: f12)
6.616 +  qed
6.617  qed
6.618
6.619  section "Finite spaces"
6.620 @@ -1329,22 +1336,24 @@
6.621    by (simp add: sets_eq_Pow disjoint_family_on_def finite_space)
6.622
6.623  lemma finite_measure_spaceI:
6.624 -  assumes "finite (space M)" "sets M = Pow(space M)" and space: "\<mu> (space M) \<noteq> \<omega>"
6.625 -    and add: "\<And>A B. A\<subseteq>space M \<Longrightarrow> B\<subseteq>space M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> \<mu> (A \<union> B) = \<mu> A + \<mu> B"
6.626 -    and "\<mu> {} = 0"
6.627 -  shows "finite_measure_space M \<mu>"
6.628 +  assumes "finite (space M)" "sets M = Pow(space M)" and space: "measure M (space M) \<noteq> \<omega>"
6.629 +    and add: "\<And>A B. A\<subseteq>space M \<Longrightarrow> B\<subseteq>space M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> measure M (A \<union> B) = measure M A + measure M B"
6.630 +    and "measure M {} = 0"
6.631 +  shows "finite_measure_space M"
6.632      unfolding finite_measure_space_def finite_measure_space_axioms_def
6.633  proof (intro allI impI conjI)
6.634 -  show "measure_space M \<mu>"
6.636 -    have *: "\<lparr>space = space M, sets = sets M\<rparr> = M" by auto
6.637 +  show "measure_space M"
6.639 +    have *: "\<lparr>space = space M, sets = Pow (space M), \<dots> = algebra.more M\<rparr> = M"
6.640 +      unfolding assms(2)[symmetric] by (auto intro!: algebra.equality)
6.641      show "sigma_algebra M"
6.642 -      using sigma_algebra_Pow[of "space M" "more M"] assms(2)[symmetric] by (simp add: *)
6.643 +      using sigma_algebra_Pow[of "space M" "algebra.more M"]
6.644 +      unfolding * .
6.645      show "finite (space M)" by fact
6.646 -    show "positive \<mu>" unfolding positive_def by fact
6.647 -    show "additive M \<mu>" unfolding additive_def using assms by simp
6.648 +    show "positive M (measure M)" unfolding positive_def by fact
6.649 +    show "additive M (measure M)" unfolding additive_def using assms by simp
6.650    qed
6.651 -  then interpret measure_space M \<mu> .
6.652 +  then interpret measure_space M .
6.653    show "finite_sigma_algebra M"
6.654    proof
6.655      show "finite (space M)" by fact
6.656 @@ -1363,18 +1372,18 @@
6.657  qed
6.658
6.659  lemma finite_measure_space_iff:
6.660 -  "finite_measure_space M \<mu> \<longleftrightarrow>
6.661 -    finite (space M) \<and> sets M = Pow(space M) \<and> \<mu> (space M) \<noteq> \<omega> \<and> \<mu> {} = 0 \<and>
6.662 -    (\<forall>A\<subseteq>space M. \<forall>B\<subseteq>space M. A \<inter> B = {} \<longrightarrow> \<mu> (A \<union> B) = \<mu> A + \<mu> B)"
6.663 +  "finite_measure_space M \<longleftrightarrow>
6.664 +    finite (space M) \<and> sets M = Pow(space M) \<and> measure M (space M) \<noteq> \<omega> \<and> measure M {} = 0 \<and>
6.665 +    (\<forall>A\<subseteq>space M. \<forall>B\<subseteq>space M. A \<inter> B = {} \<longrightarrow> measure M (A \<union> B) = measure M A + measure M B)"
6.666      (is "_ = ?rhs")
6.667  proof (intro iffI)
6.668 -  assume "finite_measure_space M \<mu>"
6.669 -  then interpret finite_measure_space M \<mu> .
6.670 +  assume "finite_measure_space M"
6.671 +  then interpret finite_measure_space M .
6.672    show ?rhs
6.673      using finite_space sets_eq_Pow measure_additive empty_measure finite_measure
6.674      by auto
6.675  next
6.676 -  assume ?rhs then show "finite_measure_space M \<mu>"
6.677 +  assume ?rhs then show "finite_measure_space M"
6.678      by (auto intro!: finite_measure_spaceI)
6.679  qed
6.680

     7.1 --- a/src/HOL/Probability/Probability.thy	Wed Feb 02 10:35:41 2011 +0100
7.2 +++ b/src/HOL/Probability/Probability.thy	Wed Feb 02 12:34:45 2011 +0100
7.3 @@ -1,6 +1,8 @@
7.4  theory Probability
7.5  imports
7.6 +  Complete_Measure
7.7    Information
7.8    "ex/Dining_Cryptographers"
7.9 +  "ex/Koepf_Duermuth_Countermeasure"
7.10  begin
7.11  end

     8.1 --- a/src/HOL/Probability/Probability_Space.thy	Wed Feb 02 10:35:41 2011 +0100
8.2 +++ b/src/HOL/Probability/Probability_Space.thy	Wed Feb 02 12:34:45 2011 +0100
8.3 @@ -14,7 +14,7 @@
8.4    by (cases X) auto
8.5
8.6  locale prob_space = measure_space +
8.7 -  assumes measure_space_1: "\<mu> (space M) = 1"
8.8 +  assumes measure_space_1: "measure M (space M) = 1"
8.9
8.10  lemma abs_real_of_pextreal[simp]: "\<bar>real (X :: pextreal)\<bar> = real X"
8.11    by simp
8.12 @@ -31,7 +31,7 @@
8.13  abbreviation (in prob_space) "prob \<equiv> \<lambda>A. real (\<mu> A)"
8.14  abbreviation (in prob_space) "prob_preserving \<equiv> measure_preserving"
8.15  abbreviation (in prob_space) "random_variable M' X \<equiv> sigma_algebra M' \<and> X \<in> measurable M M'"
8.16 -abbreviation (in prob_space) "expectation \<equiv> integral"
8.17 +abbreviation (in prob_space) "expectation \<equiv> integral\<^isup>L M"
8.18
8.19  definition (in prob_space)
8.20    "indep A B \<longleftrightarrow> A \<in> events \<and> B \<in> events \<and> prob (A \<inter> B) = prob A * prob B"
8.21 @@ -193,12 +193,14 @@
8.22
8.23  lemma (in prob_space) distribution_prob_space:
8.24    assumes "random_variable S X"
8.25 -  shows "prob_space S (distribution X)"
8.26 +  shows "prob_space (S\<lparr>measure := distribution X\<rparr>)"
8.27  proof -
8.28 -  interpret S: measure_space S "distribution X" unfolding distribution_def
8.29 -    using assms by (intro measure_space_vimage) auto
8.30 +  interpret S: measure_space "S\<lparr>measure := distribution X\<rparr>"
8.31 +    unfolding distribution_def using assms
8.32 +    by (intro measure_space_vimage)
8.33 +       (auto intro!: sigma_algebra.sigma_algebra_cong[of S])
8.34    show ?thesis
8.35 -  proof
8.36 +  proof (default, simp)
8.37      have "X - space S \<inter> space M = space M"
8.38        using random_variable S X by (auto simp: measurable_def)
8.39      then show "distribution X (space S) = 1"
8.40 @@ -207,10 +209,10 @@
8.41  qed
8.42
8.43  lemma (in prob_space) AE_distribution:
8.44 -  assumes X: "random_variable MX X" and "measure_space.almost_everywhere MX (distribution X) (\<lambda>x. Q x)"
8.45 +  assumes X: "random_variable MX X" and "measure_space.almost_everywhere (MX\<lparr>measure := distribution X\<rparr>) (\<lambda>x. Q x)"
8.46    shows "AE x. Q (X x)"
8.47  proof -
8.48 -  interpret X: prob_space MX "distribution X" using X by (rule distribution_prob_space)
8.49 +  interpret X: prob_space "MX\<lparr>measure := distribution X\<rparr>" using X by (rule distribution_prob_space)
8.50    obtain N where N: "N \<in> sets MX" "distribution X N = 0" "{x\<in>space MX. \<not> Q x} \<subseteq> N"
8.51      using assms unfolding X.almost_everywhere_def by auto
8.52    show "AE x. Q (X x)"
8.53 @@ -228,12 +230,10 @@
8.54
8.55  lemma (in prob_space) distribution_lebesgue_thm2:
8.56    assumes "random_variable S X" and "A \<in> sets S"
8.57 -  shows "distribution X A =
8.58 -    measure_space.positive_integral S (distribution X) (indicator A)"
8.59 -  (is "_ = measure_space.positive_integral _ ?D _")
8.60 +  shows "distribution X A = integral\<^isup>P (S\<lparr>measure := distribution X\<rparr>) (indicator A)"
8.61  proof -
8.62 -  interpret S: prob_space S "distribution X" using assms(1) by (rule distribution_prob_space)
8.63 -
8.64 +  interpret S: prob_space "S\<lparr>measure := distribution X\<rparr>"
8.65 +    using assms(1) by (rule distribution_prob_space)
8.66    show ?thesis
8.67      using S.positive_integral_indicator(1)
8.68      using assms unfolding distribution_def by auto
8.69 @@ -249,7 +249,7 @@
8.70  qed
8.71
8.72  lemma (in prob_space) finite_expectation:
8.73 -  assumes "finite (space M)" "random_variable borel X"
8.74 +  assumes "finite (Xspace M)" "random_variable borel X"
8.75    shows "expectation X = (\<Sum> r \<in> X  (space M). r * real (distribution X {r}))"
8.76    using assms unfolding distribution_def using finite_expectation1 by auto
8.77
8.78 @@ -290,27 +290,24 @@
8.79    assumes "distribution X {x} = 1"
8.80    assumes "y \<noteq> x"
8.81    shows "distribution X {y} = 0"
8.82 -proof -
8.83 -  from distribution_prob_space[OF X]
8.84 -  interpret S: prob_space ?S "distribution X" by simp
8.85 -  have x: "{x} \<in> sets ?S"
8.86 -  proof (rule ccontr)
8.87 -    assume "{x} \<notin> sets ?S"
8.88 -    hence "X - {x} \<inter> space M = {}" by auto
8.89 -    thus "False" using assms unfolding distribution_def by auto
8.90 -  qed
8.91 -  have [simp]: "{y} \<inter> {x} = {}" "{x} - {y} = {x}" using y \<noteq> x by auto
8.92 -  show ?thesis
8.93 -  proof cases
8.94 -    assume "{y} \<in> sets ?S"
8.95 -    with {x} \<in> sets ?S assms show "distribution X {y} = 0"
8.96 -      using S.measure_inter_full_set[of "{y}" "{x}"]
8.97 -      by simp
8.98 -  next
8.99 -    assume "{y} \<notin> sets ?S"
8.100 -    hence "X - {y} \<inter> space M = {}" by auto
8.101 -    thus "distribution X {y} = 0" unfolding distribution_def by auto
8.102 -  qed
8.103 +proof cases
8.104 +  { fix x have "X - {x} \<inter> space M \<in> sets M"
8.105 +    proof cases
8.106 +      assume "x \<in> Xspace M" with X show ?thesis
8.107 +        by (auto simp: measurable_def image_iff)
8.108 +    next
8.109 +      assume "x \<notin> Xspace M" then have "X - {x} \<inter> space M = {}" by auto
8.110 +      then show ?thesis by auto
8.111 +    qed } note single = this
8.112 +  have "X - {x} \<inter> space M - X - {y} \<inter> space M = X - {x} \<inter> space M"
8.113 +    "X - {y} \<inter> space M \<inter> (X - {x} \<inter> space M) = {}"
8.114 +    using y \<noteq> x by auto
8.115 +  with measure_inter_full_set[OF single single, of x y] assms(2)
8.116 +  show ?thesis unfolding distribution_def measure_space_1 by auto
8.117 +next
8.118 +  assume "{y} \<notin> sets ?S"
8.119 +  then have "X - {y} \<inter> space M = {}" by auto
8.120 +  thus "distribution X {y} = 0" unfolding distribution_def by auto
8.121  qed
8.122
8.123  lemma (in prob_space) joint_distribution_Times_le_fst:
8.124 @@ -344,14 +341,14 @@
8.125  lemma (in prob_space) random_variable_pairI:
8.126    assumes "random_variable MX X"
8.127    assumes "random_variable MY Y"
8.128 -  shows "random_variable (sigma (pair_algebra MX MY)) (\<lambda>x. (X x, Y x))"
8.129 +  shows "random_variable (MX \<Otimes>\<^isub>M MY) (\<lambda>x. (X x, Y x))"
8.130  proof
8.131    interpret MX: sigma_algebra MX using assms by simp
8.132    interpret MY: sigma_algebra MY using assms by simp
8.133    interpret P: pair_sigma_algebra MX MY by default
8.134 -  show "sigma_algebra (sigma (pair_algebra MX MY))" by default
8.135 +  show "sigma_algebra (MX \<Otimes>\<^isub>M MY)" by default
8.136    have sa: "sigma_algebra M" by default
8.137 -  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (sigma (pair_algebra MX MY))"
8.138 +  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (MX \<Otimes>\<^isub>M MY)"
8.139      unfolding P.measurable_pair_iff[OF sa] using assms by (simp add: comp_def)
8.140  qed
8.141
8.142 @@ -377,15 +374,12 @@
8.143     joint_distribution (\<lambda>x. (X x, Y x)) Z {((x, y), z)}"
8.144    unfolding distribution_def by (auto intro!: arg_cong[where f=\<mu>])
8.145
8.146 -locale pair_prob_space = M1: prob_space M1 p1 + M2: prob_space M2 p2 for M1 p1 M2 p2
8.147 -
8.148 -sublocale pair_prob_space \<subseteq> pair_sigma_finite M1 p1 M2 p2 by default
8.149 +locale pair_prob_space = M1: prob_space M1 + M2: prob_space M2 for M1 M2
8.150
8.151 -sublocale pair_prob_space \<subseteq> P: prob_space P pair_measure
8.152 -proof
8.153 -  show "pair_measure (space P) = 1"
8.154 -    by (simp add: pair_algebra_def pair_measure_times M1.measure_space_1 M2.measure_space_1)
8.155 -qed
8.156 +sublocale pair_prob_space \<subseteq> pair_sigma_finite M1 M2 by default
8.157 +
8.158 +sublocale pair_prob_space \<subseteq> P: prob_space P
8.159 +by default (simp add: pair_measure_times M1.measure_space_1 M2.measure_space_1 space_pair_measure)
8.160
8.162    assumes "\<And>A. \<lbrakk> range A \<subseteq> sets M ; disjoint_family A ; (\<Union>i. A i) \<in> sets M\<rbrakk> \<Longrightarrow>
8.163 @@ -395,38 +389,8 @@
8.164
8.165  lemma (in prob_space) joint_distribution_prob_space:
8.166    assumes "random_variable MX X" "random_variable MY Y"
8.167 -  shows "prob_space (sigma (pair_algebra MX MY)) (joint_distribution X Y)"
8.168 -proof -
8.169 -  interpret X: prob_space MX "distribution X" by (intro distribution_prob_space assms)
8.170 -  interpret Y: prob_space MY "distribution Y" by (intro distribution_prob_space assms)
8.171 -  interpret XY: pair_sigma_finite MX "distribution X" MY "distribution Y" by default
8.172 -  show ?thesis
8.173 -  proof
8.174 -    let "?X A" = "(\<lambda>x. (X x, Y x)) - A \<inter> space M"
8.175 -    show "joint_distribution X Y {} = 0" by (simp add: distribution_def)
8.176 -    show "countably_additive XY.P (joint_distribution X Y)"
8.178 -      fix A :: "nat \<Rightarrow> ('b \<times> 'c) set"
8.179 -      assume A: "range A \<subseteq> sets XY.P" and df: "disjoint_family A"
8.180 -      have "(\<Sum>\<^isub>\<infinity>n. \<mu> (?X (A n))) = \<mu> (\<Union>x. ?X (A x))"
8.182 -        have "sigma_algebra M" by default
8.183 -        then have *: "(\<lambda>x. (X x, Y x)) \<in> measurable M XY.P"
8.184 -          using assms by (simp add: XY.measurable_pair comp_def)
8.185 -        show "range (\<lambda>n. ?X (A n)) \<subseteq> events"
8.186 -          using measurable_sets[OF *] A by auto
8.187 -        show "disjoint_family (\<lambda>n. ?X (A n))"
8.188 -          by (intro disjoint_family_on_bisimulation[OF df]) auto
8.189 -      qed
8.190 -      then show "(\<Sum>\<^isub>\<infinity>n. joint_distribution X Y (A n)) = joint_distribution X Y (\<Union>i. A i)"
8.191 -        by (simp add: distribution_def vimage_UN)
8.192 -    qed
8.193 -    have "?X (space MX \<times> space MY) = space M"
8.194 -      using assms by (auto simp: measurable_def)
8.195 -    then show "joint_distribution X Y (space XY.P) = 1"
8.196 -      by (simp add: space_pair_algebra distribution_def measure_space_1)
8.197 -  qed
8.198 -qed
8.199 +  shows "prob_space ((MX \<Otimes>\<^isub>M MY) \<lparr> measure := joint_distribution X Y\<rparr>)"
8.200 +  using random_variable_pairI[OF assms] by (rule distribution_prob_space)
8.201
8.202  section "Probability spaces on finite sets"
8.203
8.204 @@ -443,32 +407,32 @@
8.205
8.206  lemma (in prob_space) distribution_finite_prob_space:
8.207    assumes "finite_random_variable MX X"
8.208 -  shows "finite_prob_space MX (distribution X)"
8.209 +  shows "finite_prob_space (MX\<lparr>measure := distribution X\<rparr>)"
8.210  proof -
8.211 -  interpret X: prob_space MX "distribution X"
8.212 +  interpret X: prob_space "MX\<lparr>measure := distribution X\<rparr>"
8.213      using assms[THEN finite_random_variableD] by (rule distribution_prob_space)
8.214    interpret MX: finite_sigma_algebra MX
8.215 -    using assms by simp
8.216 +    using assms by auto
8.217    show ?thesis
8.218 -  proof
8.219 +  proof (default, simp_all)
8.220      fix x assume "x \<in> space MX"
8.221      then have "X - {x} \<inter> space M \<in> sets M"
8.222        using assms unfolding measurable_def by simp
8.223      then show "distribution X {x} \<noteq> \<omega>"
8.224        unfolding distribution_def by simp
8.225 -  qed
8.226 +  qed (rule MX.finite_space)
8.227  qed
8.228
8.229  lemma (in prob_space) simple_function_imp_finite_random_variable[simp, intro]:
8.230 -  assumes "simple_function X"
8.231 -  shows "finite_random_variable \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr> X"
8.232 +  assumes "simple_function M X"
8.233 +  shows "finite_random_variable \<lparr> space = Xspace M, sets = Pow (Xspace M), \<dots> = x \<rparr> X"
8.234 +    (is "finite_random_variable ?X _")
8.235  proof (intro conjI)
8.236    have [simp]: "finite (X  space M)" using assms unfolding simple_function_def by simp
8.237 -  interpret X: sigma_algebra "\<lparr>space = X  space M, sets = Pow (X  space M)\<rparr>"
8.238 -    by (rule sigma_algebra_Pow)
8.239 -  show "finite_sigma_algebra \<lparr>space = X  space M, sets = Pow (X  space M)\<rparr>"
8.240 +  interpret X: sigma_algebra ?X by (rule sigma_algebra_Pow)
8.241 +  show "finite_sigma_algebra ?X"
8.242      by default auto
8.243 -  show "X \<in> measurable M \<lparr>space = X  space M, sets = Pow (X  space M)\<rparr>"
8.244 +  show "X \<in> measurable M ?X"
8.245    proof (unfold measurable_def, clarsimp)
8.246      fix A assume A: "A \<subseteq> Xspace M"
8.247      then have "finite A" by (rule finite_subset) simp
8.248 @@ -481,13 +445,13 @@
8.249  qed
8.250
8.251  lemma (in prob_space) simple_function_imp_random_variable[simp, intro]:
8.252 -  assumes "simple_function X"
8.253 -  shows "random_variable \<lparr> space = Xspace M, sets = Pow (Xspace M) \<rparr> X"
8.254 -  using simple_function_imp_finite_random_variable[OF assms]
8.255 +  assumes "simple_function M X"
8.256 +  shows "random_variable \<lparr> space = Xspace M, sets = Pow (Xspace M), \<dots> = ext \<rparr> X"
8.257 +  using simple_function_imp_finite_random_variable[OF assms, of ext]
8.258    by (auto dest!: finite_random_variableD)
8.259
8.260  lemma (in prob_space) sum_over_space_real_distribution:
8.261 -  "simple_function X \<Longrightarrow> (\<Sum>x\<in>Xspace M. real (distribution X {x})) = 1"
8.262 +  "simple_function M X \<Longrightarrow> (\<Sum>x\<in>Xspace M. real (distribution X {x})) = 1"
8.263    unfolding distribution_def prob_space[symmetric]
8.264    by (subst real_finite_measure_finite_Union[symmetric])
8.265       (auto simp add: disjoint_family_on_def simple_function_def
8.266 @@ -496,14 +460,14 @@
8.267  lemma (in prob_space) finite_random_variable_pairI:
8.268    assumes "finite_random_variable MX X"
8.269    assumes "finite_random_variable MY Y"
8.270 -  shows "finite_random_variable (sigma (pair_algebra MX MY)) (\<lambda>x. (X x, Y x))"
8.271 +  shows "finite_random_variable (MX \<Otimes>\<^isub>M MY) (\<lambda>x. (X x, Y x))"
8.272  proof
8.273    interpret MX: finite_sigma_algebra MX using assms by simp
8.274    interpret MY: finite_sigma_algebra MY using assms by simp
8.275    interpret P: pair_finite_sigma_algebra MX MY by default
8.276 -  show "finite_sigma_algebra (sigma (pair_algebra MX MY))" by default
8.277 +  show "finite_sigma_algebra (MX \<Otimes>\<^isub>M MY)" by default
8.278    have sa: "sigma_algebra M" by default
8.279 -  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (sigma (pair_algebra MX MY))"
8.280 +  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (MX \<Otimes>\<^isub>M MY)"
8.281      unfolding P.measurable_pair_iff[OF sa] using assms by (simp add: comp_def)
8.282  qed
8.283
8.284 @@ -599,6 +563,7 @@
8.285      finite_random_variable_imp_sets[OF Y]] by simp
8.286
8.287  lemma (in prob_space) setsum_real_joint_distribution:
8.288 +  fixes MX :: "('c, 'x) measure_space_scheme" and MY :: "('d, 'y) measure_space_scheme"
8.289    assumes X: "finite_random_variable MX X"
8.290    assumes Y: "random_variable MY Y" "B \<in> sets MY"
8.291    shows "(\<Sum>a\<in>space MX. real (joint_distribution X Y ({a} \<times> B))) = real (distribution Y B)"
8.292 @@ -607,10 +572,11 @@
8.293    show ?thesis
8.294      unfolding setsum_joint_distribution[OF assms, symmetric]
8.295      using distribution_finite[OF random_variable_pairI[OF finite_random_variableD[OF X] Y(1)]] Y(2)
8.296 -    by (simp add: space_pair_algebra in_sigma pair_algebraI MX.sets_eq_Pow real_of_pextreal_setsum)
8.297 +    by (simp add: space_pair_measure real_of_pextreal_setsum)
8.298  qed
8.299
8.300  lemma (in prob_space) setsum_real_joint_distribution_singleton:
8.301 +  fixes MX :: "('c, 'x) measure_space_scheme" and MY :: "('d, 'y) measure_space_scheme"
8.302    assumes X: "finite_random_variable MX X"
8.303    assumes Y: "finite_random_variable MY Y" "b \<in> space MY"
8.304    shows "(\<Sum>a\<in>space MX. real (joint_distribution X Y {(a,b)})) = real (distribution Y {b})"
8.305 @@ -618,39 +584,20 @@
8.306      finite_random_variableD[OF Y(1)]
8.307      finite_random_variable_imp_sets[OF Y]] by simp
8.308
8.309 -locale pair_finite_prob_space = M1: finite_prob_space M1 p1 + M2: finite_prob_space M2 p2 for M1 p1 M2 p2
8.310 +locale pair_finite_prob_space = M1: finite_prob_space M1 + M2: finite_prob_space M2 for M1 M2
8.311
8.312 -sublocale pair_finite_prob_space \<subseteq> pair_prob_space M1 p1 M2 p2 by default
8.313 -sublocale pair_finite_prob_space \<subseteq> pair_finite_space M1 p1 M2 p2  by default
8.314 -sublocale pair_finite_prob_space \<subseteq> finite_prob_space P pair_measure by default
8.315 +sublocale pair_finite_prob_space \<subseteq> pair_prob_space M1 M2 by default
8.316 +sublocale pair_finite_prob_space \<subseteq> pair_finite_space M1 M2  by default
8.317 +sublocale pair_finite_prob_space \<subseteq> finite_prob_space P by default
8.318
8.319  lemma (in prob_space) joint_distribution_finite_prob_space:
8.320    assumes X: "finite_random_variable MX X"
8.321    assumes Y: "finite_random_variable MY Y"
8.322 -  shows "finite_prob_space (sigma (pair_algebra MX MY)) (joint_distribution X Y)"
8.323 -proof -
8.324 -  interpret X: finite_prob_space MX "distribution X"
8.325 -    using X by (rule distribution_finite_prob_space)
8.326 -  interpret Y: finite_prob_space MY "distribution Y"
8.327 -    using Y by (rule distribution_finite_prob_space)
8.328 -  interpret P: prob_space "sigma (pair_algebra MX MY)" "joint_distribution X Y"
8.329 -    using assms[THEN finite_random_variableD] by (rule joint_distribution_prob_space)
8.330 -  interpret XY: pair_finite_prob_space MX "distribution X" MY "distribution Y"
8.331 -    by default
8.332 -  show ?thesis
8.333 -  proof
8.334 -    fix x assume "x \<in> space XY.P"
8.335 -    moreover have "(\<lambda>x. (X x, Y x)) \<in> measurable M XY.P"
8.336 -      using X Y by (intro XY.measurable_pair) (simp_all add: o_def, default)
8.337 -    ultimately have "(\<lambda>x. (X x, Y x)) - {x} \<inter> space M \<in> sets M"
8.338 -      unfolding measurable_def by simp
8.339 -    then show "joint_distribution X Y {x} \<noteq> \<omega>"
8.340 -      unfolding distribution_def by simp
8.341 -  qed
8.342 -qed
8.343 +  shows "finite_prob_space ((MX \<Otimes>\<^isub>M MY)\<lparr> measure := joint_distribution X Y\<rparr>)"
8.344 +  by (intro distribution_finite_prob_space finite_random_variable_pairI X Y)
8.345
8.346  lemma finite_prob_space_eq:
8.347 -  "finite_prob_space M \<mu> \<longleftrightarrow> finite_measure_space M \<mu> \<and> \<mu> (space M) = 1"
8.348 +  "finite_prob_space M \<longleftrightarrow> finite_measure_space M \<and> measure M (space M) = 1"
8.349    unfolding finite_prob_space_def finite_measure_space_def prob_space_def prob_space_axioms_def
8.350    by auto
8.351
8.352 @@ -852,48 +799,51 @@
8.353
8.354  lemma (in prob_space) prob_space_subalgebra:
8.355    assumes "sigma_algebra N" "sets N \<subseteq> sets M" "space N = space M"
8.356 -  shows "prob_space N \<mu>"
8.357 +    and "\<And>A. A \<in> sets N \<Longrightarrow> measure N A = \<mu> A"
8.358 +  shows "prob_space N"
8.359  proof -
8.360 -  interpret N: measure_space N \<mu>
8.361 -    using measure_space_subalgebra[OF assms] .
8.362 +  interpret N: measure_space N
8.363 +    by (rule measure_space_subalgebra[OF assms])
8.364    show ?thesis
8.365 -    proof qed (simp add: space N = space M measure_space_1)
8.366 +  proof qed (insert assms(4)[OF N.top], simp add: assms measure_space_1)
8.367  qed
8.368
8.369  lemma (in prob_space) prob_space_of_restricted_space:
8.370    assumes "\<mu> A \<noteq> 0" "\<mu> A \<noteq> \<omega>" "A \<in> sets M"
8.371 -  shows "prob_space (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
8.372 -  unfolding prob_space_def prob_space_axioms_def
8.373 -proof
8.374 -  show "\<mu> (space (restricted_space A)) / \<mu> A = 1"
8.375 -    using \<mu> A \<noteq> 0 \<mu> A \<noteq> \<omega> by (auto simp: pextreal_noteq_omega_Ex)
8.376 -  have *: "\<And>S. \<mu> S / \<mu> A = inverse (\<mu> A) * \<mu> S" by (simp add: mult_commute)
8.377 -  interpret A: measure_space "restricted_space A" \<mu>
8.378 +  shows "prob_space (restricted_space A \<lparr>measure := \<lambda>S. \<mu> S / \<mu> A\<rparr>)"
8.379 +    (is "prob_space ?P")
8.380 +proof -
8.381 +  interpret A: measure_space "restricted_space A"
8.382      using A \<in> sets M by (rule restricted_measure_space)
8.383 -  show "measure_space (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
8.384 +  interpret A': sigma_algebra ?P
8.385 +    by (rule A.sigma_algebra_cong) auto
8.386 +  show "prob_space ?P"
8.387    proof
8.388 -    show "\<mu> {} / \<mu> A = 0" by auto
8.389 -    show "countably_additive (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
8.390 -        unfolding countably_additive_def psuminf_cmult_right *
8.391 +    show "measure ?P (space ?P) = 1"
8.392 +      using \<mu> A \<noteq> 0 \<mu> A \<noteq> \<omega> by (auto simp: pextreal_noteq_omega_Ex)
8.393 +    show "measure ?P {} = 0" by auto
8.394 +    have "\<And>S. \<mu> S / \<mu> A = inverse (\<mu> A) * \<mu> S" by (simp add: mult_commute)
8.395 +    then show "countably_additive ?P (measure ?P)"
8.398    qed
8.399  qed
8.400
8.401  lemma finite_prob_spaceI:
8.402 -  assumes "finite (space M)" "sets M = Pow(space M)" "\<mu> (space M) = 1" "\<mu> {} = 0"
8.403 -    and "\<And>A B. A\<subseteq>space M \<Longrightarrow> B\<subseteq>space M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> \<mu> (A \<union> B) = \<mu> A + \<mu> B"
8.404 -  shows "finite_prob_space M \<mu>"
8.405 +  assumes "finite (space M)" "sets M = Pow(space M)" "measure M (space M) = 1" "measure M {} = 0"
8.406 +    and "\<And>A B. A\<subseteq>space M \<Longrightarrow> B\<subseteq>space M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> measure M (A \<union> B) = measure M A + measure M B"
8.407 +  shows "finite_prob_space M"
8.408    unfolding finite_prob_space_eq
8.409  proof
8.410 -  show "finite_measure_space M \<mu>" using assms
8.411 +  show "finite_measure_space M" using assms
8.412       by (auto intro!: finite_measure_spaceI)
8.413 -  show "\<mu> (space M) = 1" by fact
8.414 +  show "measure M (space M) = 1" by fact
8.415  qed
8.416
8.417  lemma (in finite_prob_space) finite_measure_space:
8.418    fixes X :: "'a \<Rightarrow> 'x"
8.419 -  shows "finite_measure_space \<lparr>space = X  space M, sets = Pow (X  space M)\<rparr> (distribution X)"
8.420 -    (is "finite_measure_space ?S _")
8.421 +  shows "finite_measure_space \<lparr>space = X  space M, sets = Pow (X  space M), measure = distribution X\<rparr>"
8.422 +    (is "finite_measure_space ?S")
8.423  proof (rule finite_measure_spaceI, simp_all)
8.424    show "finite (X  space M)" using finite_space by simp
8.425  next
8.426 @@ -905,7 +855,7 @@
8.427  qed
8.428
8.429  lemma (in finite_prob_space) finite_prob_space_of_images:
8.430 -  "finite_prob_space \<lparr> space = X  space M, sets = Pow (X  space M)\<rparr> (distribution X)"
8.431 +  "finite_prob_space \<lparr> space = X  space M, sets = Pow (X  space M), measure = distribution X \<rparr>"
8.432    by (simp add: finite_prob_space_eq finite_measure_space)
8.433
8.434  lemma (in finite_prob_space) real_distribution_order':
8.435 @@ -919,8 +869,8 @@
8.436  lemma (in finite_prob_space) finite_product_measure_space:
8.437    fixes X :: "'a \<Rightarrow> 'x" and Y :: "'a \<Rightarrow> 'y"
8.438    assumes "finite s1" "finite s2"
8.439 -  shows "finite_measure_space \<lparr> space = s1 \<times> s2, sets = Pow (s1 \<times> s2)\<rparr> (joint_distribution X Y)"
8.440 -    (is "finite_measure_space ?M ?D")
8.441 +  shows "finite_measure_space \<lparr> space = s1 \<times> s2, sets = Pow (s1 \<times> s2), measure = joint_distribution X Y\<rparr>"
8.442 +    (is "finite_measure_space ?M")
8.443  proof (rule finite_measure_spaceI, simp_all)
8.444    show "finite (s1 \<times> s2)"
8.445      using assms by auto
8.446 @@ -936,14 +886,14 @@
8.447
8.448  lemma (in finite_prob_space) finite_product_measure_space_of_images:
8.449    shows "finite_measure_space \<lparr> space = X  space M \<times> Y  space M,
8.450 -                                sets = Pow (X  space M \<times> Y  space M) \<rparr>
8.451 -                              (joint_distribution X Y)"
8.452 +                                sets = Pow (X  space M \<times> Y  space M),
8.453 +                                measure = joint_distribution X Y \<rparr>"
8.454    using finite_space by (auto intro!: finite_product_measure_space)
8.455
8.456  lemma (in finite_prob_space) finite_product_prob_space_of_images:
8.457 -  "finite_prob_space \<lparr> space = X  space M \<times> Y  space M, sets = Pow (X  space M \<times> Y  space M)\<rparr>
8.458 -                     (joint_distribution X Y)"
8.459 -  (is "finite_prob_space ?S _")
8.460 +  "finite_prob_space \<lparr> space = X  space M \<times> Y  space M, sets = Pow (X  space M \<times> Y  space M),
8.461 +                       measure = joint_distribution X Y \<rparr>"
8.462 +  (is "finite_prob_space ?S")
8.463  proof (simp add: finite_prob_space_eq finite_product_measure_space_of_images)
8.464    have "X - X  space M \<inter> Y - Y  space M \<inter> space M = space M" by auto
8.465    thus "joint_distribution X Y (X  space M \<times> Y  space M) = 1"
8.466 @@ -953,27 +903,29 @@
8.467  section "Conditional Expectation and Probability"
8.468
8.469  lemma (in prob_space) conditional_expectation_exists:
8.470 -  fixes X :: "'a \<Rightarrow> pextreal"
8.471 +  fixes X :: "'a \<Rightarrow> pextreal" and N :: "('a, 'b) measure_space_scheme"
8.472    assumes borel: "X \<in> borel_measurable M"
8.473 -  and N: "sigma_algebra N" "sets N \<subseteq> sets M" "space N = space M"
8.474 +  and N: "sigma_algebra N" "sets N \<subseteq> sets M" "space N = space M" "\<And>A. measure N A = \<mu> A"
8.475    shows "\<exists>Y\<in>borel_measurable N. \<forall>C\<in>sets N.
8.476 -      (\<integral>\<^isup>+x. Y x * indicator C x) = (\<integral>\<^isup>+x. X x * indicator C x)"
8.477 +      (\<integral>\<^isup>+x. Y x * indicator C x \<partial>M) = (\<integral>\<^isup>+x. X x * indicator C x \<partial>M)"
8.478  proof -
8.479 -  interpret P: prob_space N \<mu>
8.480 +  note N(4)[simp]
8.481 +  interpret P: prob_space N
8.482      using prob_space_subalgebra[OF N] .
8.483
8.484    let "?f A" = "\<lambda>x. X x * indicator A x"
8.485 -  let "?Q A" = "positive_integral (?f A)"
8.486 +  let "?Q A" = "integral\<^isup>P M (?f A)"
8.487
8.488    from measure_space_density[OF borel]
8.489 -  have Q: "measure_space N ?Q"
8.490 -    by (rule measure_space.measure_space_subalgebra[OF _ N])
8.491 -  then interpret Q: measure_space N ?Q .
8.492 +  have Q: "measure_space (N\<lparr> measure := ?Q \<rparr>)"
8.493 +    apply (rule measure_space.measure_space_subalgebra[of "M\<lparr> measure := ?Q \<rparr>"])
8.494 +    using N by (auto intro!: P.sigma_algebra_cong)
8.495 +  then interpret Q: measure_space "N\<lparr> measure := ?Q \<rparr>" .
8.496
8.497    have "P.absolutely_continuous ?Q"
8.498      unfolding P.absolutely_continuous_def
8.499    proof safe
8.500 -    fix A assume "A \<in> sets N" "\<mu> A = 0"
8.501 +    fix A assume "A \<in> sets N" "P.\<mu> A = 0"
8.502      moreover then have f_borel: "?f A \<in> borel_measurable M"
8.503        using borel N by (auto intro: borel_measurable_indicator)
8.504      moreover have "{x\<in>space M. ?f A x \<noteq> 0} = (?f A - {0<..} \<inter> space M) \<inter> A"
8.505 @@ -986,28 +938,28 @@
8.506    qed
8.508    obtain Y where Y: "Y \<in> borel_measurable N"
8.509 -    "\<And>A. A \<in> sets N \<Longrightarrow> ?Q A = P.positive_integral (\<lambda>x. Y x * indicator A x)"
8.510 +    "\<And>A. A \<in> sets N \<Longrightarrow> ?Q A =(\<integral>\<^isup>+x. Y x * indicator A x \<partial>N)"
8.511      by blast
8.512    with N(2) show ?thesis
8.513 -    by (auto intro!: bexI[OF _ Y(1)] simp: positive_integral_subalgebra[OF _ N(2,3,1)])
8.514 +    by (auto intro!: bexI[OF _ Y(1)] simp: positive_integral_subalgebra[OF _ N(2,3,4,1)])
8.515  qed
8.516
8.517  definition (in prob_space)
8.518    "conditional_expectation N X = (SOME Y. Y\<in>borel_measurable N
8.519 -    \<and> (\<forall>C\<in>sets N. (\<integral>\<^isup>+x. Y x * indicator C x) = (\<integral>\<^isup>+x. X x * indicator C x)))"
8.520 +    \<and> (\<forall>C\<in>sets N. (\<integral>\<^isup>+x. Y x * indicator C x\<partial>M) = (\<integral>\<^isup>+x. X x * indicator C x\<partial>M)))"
8.521
8.522  abbreviation (in prob_space)
8.523    "conditional_prob N A \<equiv> conditional_expectation N (indicator A)"
8.524
8.525  lemma (in prob_space)
8.526 -  fixes X :: "'a \<Rightarrow> pextreal"
8.527 +  fixes X :: "'a \<Rightarrow> pextreal" and N :: "('a, 'b) measure_space_scheme"
8.528    assumes borel: "X \<in> borel_measurable M"
8.529 -  and N: "sigma_algebra N" "sets N \<subseteq> sets M" "space N = space M"
8.530 +  and N: "sigma_algebra N" "sets N \<subseteq> sets M" "space N = space M" "\<And>A. measure N A = \<mu> A"
8.531    shows borel_measurable_conditional_expectation:
8.532      "conditional_expectation N X \<in> borel_measurable N"
8.533    and conditional_expectation: "\<And>C. C \<in> sets N \<Longrightarrow>
8.534 -      (\<integral>\<^isup>+x. conditional_expectation N X x * indicator C x) =
8.535 -      (\<integral>\<^isup>+x. X x * indicator C x)"
8.536 +      (\<integral>\<^isup>+x. conditional_expectation N X x * indicator C x \<partial>M) =
8.537 +      (\<integral>\<^isup>+x. X x * indicator C x \<partial>M)"
8.538     (is "\<And>C. C \<in> sets N \<Longrightarrow> ?eq C")
8.539  proof -
8.540    note CE = conditional_expectation_exists[OF assms, unfolded Bex_def]
8.541 @@ -1042,21 +994,21 @@
8.542
8.543    assume "Z \<in> borel_measurable (M'.vimage_algebra (space M) Y)"
8.544    from va.borel_measurable_implies_simple_function_sequence[OF this]
8.545 -  obtain f where f: "\<And>i. va.simple_function (f i)" and "f \<up> Z" by blast
8.546 +  obtain f where f: "\<And>i. simple_function (M'.vimage_algebra (space M) Y) (f i)" and "f \<up> Z" by blast
8.547
8.548 -  have "\<forall>i. \<exists>g. M'.simple_function g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
8.549 +  have "\<forall>i. \<exists>g. simple_function M' g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
8.550    proof
8.551      fix i
8.552      from f[of i] have "finite (f ispace M)" and B_ex:
8.553        "\<forall>z\<in>(f i)space M. \<exists>B. B \<in> sets M' \<and> (f i) - {z} \<inter> space M = Y - B \<inter> space M"
8.554 -      unfolding va.simple_function_def by auto
8.555 +      unfolding simple_function_def by auto
8.556      from B_ex[THEN bchoice] guess B .. note B = this
8.557
8.558      let ?g = "\<lambda>x. \<Sum>z\<in>f ispace M. z * indicator (B z) x"
8.559
8.560 -    show "\<exists>g. M'.simple_function g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
8.561 +    show "\<exists>g. simple_function M' g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
8.562      proof (intro exI[of _ ?g] conjI ballI)
8.563 -      show "M'.simple_function ?g" using B by auto
8.564 +      show "simple_function M' ?g" using B by auto
8.565
8.566        fix x assume "x \<in> space M"
8.567        then have "\<And>z. z \<in> f ispace M \<Longrightarrow> indicator (B z) (Y x) = (indicator (f i - {z} \<inter> space M) x::pextreal)"

     9.1 --- a/src/HOL/Probability/Product_Measure.thy	Wed Feb 02 10:35:41 2011 +0100
9.2 +++ b/src/HOL/Probability/Product_Measure.thy	Wed Feb 02 12:34:45 2011 +0100
9.3 @@ -2,6 +2,20 @@
9.4  imports Lebesgue_Integration
9.5  begin
9.6
9.7 +lemma measurable_cancel_measure2[simp]:
9.8 +  "measurable M1 (M2\<lparr>measure := m\<rparr>) = measurable M1 M2"
9.9 +  unfolding measurable_def by auto
9.10 +
9.11 +lemma measurable_cancel_measure1[simp]:
9.12 +  "measurable (M1\<lparr>measure := m\<rparr>) M2 = measurable M1 M2"
9.13 +  unfolding measurable_def by auto
9.14 +
9.15 +lemma sigma_sets_subseteq: assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
9.16 +proof
9.17 +  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
9.18 +    by induct (insert A \<subseteq> B, auto intro: sigma_sets.intros)
9.19 +qed
9.20 +
9.21  lemma times_Int_times: "A \<times> B \<inter> C \<times> D = (A \<inter> C) \<times> (B \<inter> D)"
9.22    by auto
9.23
9.24 @@ -20,6 +34,18 @@
9.25  abbreviation
9.26    "Pi\<^isub>E A B \<equiv> Pi A B \<inter> extensional A"
9.27
9.28 +syntax
9.29 +  "_PiE"  :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3PIE _:_./ _)" 10)
9.30 +
9.31 +syntax (xsymbols)
9.32 +  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
9.33 +
9.34 +syntax (HTML output)
9.35 +  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
9.36 +
9.37 +translations
9.38 +  "PIE x:A. B" == "CONST Pi\<^isub>E A (%x. B)"
9.39 +
9.40  abbreviation
9.41    funcset_extensional :: "['a set, 'b set] => ('a => 'b) set"
9.42      (infixr "->\<^isub>E" 60) where
9.43 @@ -171,61 +197,121 @@
9.44    "i \<notin> I \<Longrightarrow> (restrict f I)(i := y) = restrict (f(i := y)) (insert i I)"
9.45    by (auto simp: fun_eq_iff)
9.46
9.47 +lemma Pi_eq_subset:
9.48 +  assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}"
9.49 +  assumes eq: "Pi\<^isub>E I F = Pi\<^isub>E I F'" and "i \<in> I"
9.50 +  shows "F i \<subseteq> F' i"
9.51 +proof
9.52 +  fix x assume "x \<in> F i"
9.53 +  with ne have "\<forall>j. \<exists>y. ((j \<in> I \<longrightarrow> y \<in> F j \<and> (i = j \<longrightarrow> x = y)) \<and> (j \<notin> I \<longrightarrow> y = undefined))" by auto
9.54 +  from choice[OF this] guess f .. note f = this
9.55 +  then have "f \<in> Pi\<^isub>E I F" by (auto simp: extensional_def)
9.56 +  then have "f \<in> Pi\<^isub>E I F'" using assms by simp
9.57 +  then show "x \<in> F' i" using f i \<in> I by auto
9.58 +qed
9.59 +
9.60 +lemma Pi_eq_iff_not_empty:
9.61 +  assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}"
9.62 +  shows "Pi\<^isub>E I F = Pi\<^isub>E I F' \<longleftrightarrow> (\<forall>i\<in>I. F i = F' i)"
9.63 +proof (intro iffI ballI)
9.64 +  fix i assume eq: "Pi\<^isub>E I F = Pi\<^isub>E I F'" and i: "i \<in> I"
9.65 +  show "F i = F' i"
9.66 +    using Pi_eq_subset[of I F F', OF ne eq i]
9.67 +    using Pi_eq_subset[of I F' F, OF ne(2,1) eq[symmetric] i]
9.68 +    by auto
9.69 +qed auto
9.70 +
9.71 +lemma Pi_eq_empty_iff:
9.72 +  "Pi\<^isub>E I F = {} \<longleftrightarrow> (\<exists>i\<in>I. F i = {})"
9.73 +proof
9.74 +  assume "Pi\<^isub>E I F = {}"
9.75 +  show "\<exists>i\<in>I. F i = {}"
9.76 +  proof (rule ccontr)
9.77 +    assume "\<not> ?thesis"
9.78 +    then have "\<forall>i. \<exists>y. (i \<in> I \<longrightarrow> y \<in> F i) \<and> (i \<notin> I \<longrightarrow> y = undefined)" by auto
9.79 +    from choice[OF this] guess f ..
9.80 +    then have "f \<in> Pi\<^isub>E I F" by (auto simp: extensional_def)
9.81 +    with Pi\<^isub>E I F = {} show False by auto
9.82 +  qed
9.83 +qed auto
9.84 +
9.85 +lemma Pi_eq_iff:
9.86 +  "Pi\<^isub>E I F = Pi\<^isub>E I F' \<longleftrightarrow> (\<forall>i\<in>I. F i = F' i) \<or> ((\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {}))"
9.87 +proof (intro iffI disjCI)
9.88 +  assume eq[simp]: "Pi\<^isub>E I F = Pi\<^isub>E I F'"
9.89 +  assume "\<not> ((\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {}))"
9.90 +  then have "(\<forall>i\<in>I. F i \<noteq> {}) \<and> (\<forall>i\<in>I. F' i \<noteq> {})"
9.91 +    using Pi_eq_empty_iff[of I F] Pi_eq_empty_iff[of I F'] by auto
9.92 +  with Pi_eq_iff_not_empty[of I F F'] show "\<forall>i\<in>I. F i = F' i" by auto
9.93 +next
9.94 +  assume "(\<forall>i\<in>I. F i = F' i) \<or> (\<exists>i\<in>I. F i = {}) \<and> (\<exists>i\<in>I. F' i = {})"
9.95 +  then show "Pi\<^isub>E I F = Pi\<^isub>E I F'"
9.96 +    using Pi_eq_empty_iff[of I F] Pi_eq_empty_iff[of I F'] by auto
9.97 +qed
9.98 +
9.99  section "Binary products"
9.100
9.101  definition
9.102 -  "pair_algebra A B = \<lparr> space = space A \<times> space B,
9.103 -                           sets = {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B} \<rparr>"
9.104 +  "pair_measure_generator A B =
9.105 +    \<lparr> space = space A \<times> space B,
9.106 +      sets = {a \<times> b | a b. a \<in> sets A \<and> b \<in> sets B},
9.107 +      measure = \<lambda>X. \<integral>\<^isup>+x. (\<integral>\<^isup>+y. indicator X (x,y) \<partial>B) \<partial>A \<rparr>"
9.108 +
9.109 +definition pair_measure (infixr "\<Otimes>\<^isub>M" 80) where
9.110 +  "A \<Otimes>\<^isub>M B = sigma (pair_measure_generator A B)"
9.111
9.112  locale pair_sigma_algebra = M1: sigma_algebra M1 + M2: sigma_algebra M2
9.113 -  for M1 M2
9.114 +  for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
9.115 +
9.116 +abbreviation (in pair_sigma_algebra)
9.117 +  "E \<equiv> pair_measure_generator M1 M2"
9.118
9.119  abbreviation (in pair_sigma_algebra)
9.120 -  "E \<equiv> pair_algebra M1 M2"
9.121 +  "P \<equiv> M1 \<Otimes>\<^isub>M M2"
9.122
9.123 -abbreviation (in pair_sigma_algebra)
9.124 -  "P \<equiv> sigma E"
9.125 +lemma sigma_algebra_pair_measure:
9.126 +  "sets M1 \<subseteq> Pow (space M1) \<Longrightarrow> sets M2 \<subseteq> Pow (space M2) \<Longrightarrow> sigma_algebra (pair_measure M1 M2)"
9.127 +  by (force simp: pair_measure_def pair_measure_generator_def intro!: sigma_algebra_sigma)
9.128
9.129  sublocale pair_sigma_algebra \<subseteq> sigma_algebra P
9.130 -  using M1.sets_into_space M2.sets_into_space
9.131 -  by (force simp: pair_algebra_def intro!: sigma_algebra_sigma)
9.132 +  using M1.space_closed M2.space_closed
9.133 +  by (rule sigma_algebra_pair_measure)
9.134
9.135 -lemma pair_algebraI[intro, simp]:
9.136 -  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (pair_algebra A B)"
9.137 -  by (auto simp add: pair_algebra_def)
9.138 +lemma pair_measure_generatorI[intro, simp]:
9.139 +  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (pair_measure_generator A B)"
9.140 +  by (auto simp add: pair_measure_generator_def)
9.141
9.142 -lemma space_pair_algebra:
9.143 -  "space (pair_algebra A B) = space A \<times> space B"
9.144 -  by (simp add: pair_algebra_def)
9.145 +lemma pair_measureI[intro, simp]:
9.146 +  "x \<in> sets A \<Longrightarrow> y \<in> sets B \<Longrightarrow> x \<times> y \<in> sets (A \<Otimes>\<^isub>M B)"
9.147 +  by (auto simp add: pair_measure_def)
9.148
9.149 -lemma sets_pair_algebra: "sets (pair_algebra N M) = (\<lambda>(x, y). x \<times> y)  (sets N \<times> sets M)"
9.150 -  unfolding pair_algebra_def by auto
9.151 +lemma space_pair_measure:
9.152 +  "space (A \<Otimes>\<^isub>M B) = space A \<times> space B"
9.153 +  by (simp add: pair_measure_def pair_measure_generator_def)
9.154
9.155 -lemma pair_algebra_sets_into_space:
9.156 -  assumes "sets M \<subseteq> Pow (space M)" "sets N \<subseteq> Pow (space N)"
9.157 -  shows "sets (pair_algebra M N) \<subseteq> Pow (space (pair_algebra M N))"
9.158 -  using assms by (auto simp: pair_algebra_def)
9.159 +lemma sets_pair_measure_generator:
9.160 +  "sets (pair_measure_generator N M) = (\<lambda>(x, y). x \<times> y)  (sets N \<times> sets M)"
9.161 +  unfolding pair_measure_generator_def by auto
9.162
9.163 -lemma pair_algebra_Int_snd:
9.164 +lemma pair_measure_generator_sets_into_space:
9.165 +  assumes "sets M \<subseteq> Pow (space M)" "sets N \<subseteq> Pow (space N)"
9.166 +  shows "sets (pair_measure_generator M N) \<subseteq> Pow (space (pair_measure_generator M N))"
9.167 +  using assms by (auto simp: pair_measure_generator_def)
9.168 +
9.169 +lemma pair_measure_generator_Int_snd:
9.170    assumes "sets S1 \<subseteq> Pow (space S1)"
9.171 -  shows "pair_algebra S1 (algebra.restricted_space S2 A) =
9.172 -         algebra.restricted_space (pair_algebra S1 S2) (space S1 \<times> A)"
9.173 +  shows "sets (pair_measure_generator S1 (algebra.restricted_space S2 A)) =
9.174 +         sets (algebra.restricted_space (pair_measure_generator S1 S2) (space S1 \<times> A))"
9.175    (is "?L = ?R")
9.176 -proof (intro algebra.equality set_eqI iffI)
9.177 -  fix X assume "X \<in> sets ?L"
9.178 -  then obtain A1 A2 where X: "X = A1 \<times> (A \<inter> A2)" and "A1 \<in> sets S1" "A2 \<in> sets S2"
9.179 -    by (auto simp: pair_algebra_def)
9.180 -  then show "X \<in> sets ?R" unfolding pair_algebra_def
9.181 -    using assms apply simp by (intro image_eqI[of _ _ "A1 \<times> A2"]) auto
9.182 -next
9.183 -  fix X assume "X \<in> sets ?R"
9.184 -  then obtain A1 A2 where "X = space S1 \<times> A \<inter> A1 \<times> A2" "A1 \<in> sets S1" "A2 \<in> sets S2"
9.185 -    by (auto simp: pair_algebra_def)
9.186 -  moreover then have "X = A1 \<times> (A \<inter> A2)"
9.187 -    using assms by auto
9.188 -  ultimately show "X \<in> sets ?L"
9.189 -    unfolding pair_algebra_def by auto
9.190 -qed (auto simp add: pair_algebra_def)
9.191 +  apply (auto simp: pair_measure_generator_def image_iff)
9.192 +  using assms
9.193 +  apply (rule_tac x="a \<times> xa" in exI)
9.194 +  apply force
9.195 +  using assms
9.196 +  apply (rule_tac x="a" in exI)
9.197 +  apply (rule_tac x="b \<inter> A" in exI)
9.198 +  apply auto
9.199 +  done
9.200
9.201  lemma (in pair_sigma_algebra)
9.202    shows measurable_fst[intro!, simp]:
9.203 @@ -243,7 +329,7 @@
9.204        apply - apply (rule bexI[of _ "space M1"]) apply (rule bexI[of _ X])
9.205        using M2.sets_into_space by force+ }
9.206    ultimately have "?fst \<and> ?snd"
9.207 -    by (fastsimp simp: measurable_def sets_sigma space_pair_algebra
9.208 +    by (fastsimp simp: measurable_def sets_sigma space_pair_measure
9.209                   intro!: sigma_sets.Basic)
9.210    then show ?fst ?snd by auto
9.211  qed
9.212 @@ -257,15 +343,15 @@
9.213    from assms show ?thesis
9.214    proof (safe intro!: measurable_comp[where b=P])
9.215      assume f: "(fst \<circ> f) \<in> measurable M M1" and s: "(snd \<circ> f) \<in> measurable M M2"
9.216 -    show "f \<in> measurable M P"
9.217 +    show "f \<in> measurable M P" unfolding pair_measure_def
9.218      proof (rule M.measurable_sigma)
9.219 -      show "sets (pair_algebra M1 M2) \<subseteq> Pow (space E)"
9.220 -        unfolding pair_algebra_def using M1.sets_into_space M2.sets_into_space by auto
9.221 +      show "sets (pair_measure_generator M1 M2) \<subseteq> Pow (space E)"
9.222 +        unfolding pair_measure_generator_def using M1.sets_into_space M2.sets_into_space by auto
9.223        show "f \<in> space M \<rightarrow> space E"
9.224 -        using f s by (auto simp: mem_Times_iff measurable_def comp_def space_sigma space_pair_algebra)
9.225 +        using f s by (auto simp: mem_Times_iff measurable_def comp_def space_sigma pair_measure_generator_def)
9.226        fix A assume "A \<in> sets E"
9.227        then obtain B C where "B \<in> sets M1" "C \<in> sets M2" "A = B \<times> C"
9.228 -        unfolding pair_algebra_def by auto
9.229 +        unfolding pair_measure_generator_def by auto
9.230        moreover have "(fst \<circ> f) - B \<inter> space M \<in> sets M"
9.231          using f B \<in> sets M1 unfolding measurable_def by auto
9.232        moreover have "(snd \<circ> f) - C \<inter> space M \<in> sets M"
9.233 @@ -283,52 +369,58 @@
9.234    shows "f \<in> measurable M P"
9.235    unfolding measurable_pair_iff[OF assms(1)] using assms(2,3) by simp
9.236
9.237 -lemma pair_algebraE:
9.238 -  assumes "X \<in> sets (pair_algebra M1 M2)"
9.239 +lemma pair_measure_generatorE:
9.240 +  assumes "X \<in> sets (pair_measure_generator M1 M2)"
9.241    obtains A B where "X = A \<times> B" "A \<in> sets M1" "B \<in> sets M2"
9.242 -  using assms unfolding pair_algebra_def by auto
9.243 +  using assms unfolding pair_measure_generator_def by auto
9.244
9.245 -lemma (in pair_sigma_algebra) pair_algebra_swap:
9.246 -  "(\<lambda>X. (\<lambda>(x,y). (y,x)) - X \<inter> space M2 \<times> space M1)  sets E = sets (pair_algebra M2 M1)"
9.247 -proof (safe elim!: pair_algebraE)
9.248 +lemma (in pair_sigma_algebra) pair_measure_generator_swap:
9.249 +  "(\<lambda>X. (\<lambda>(x,y). (y,x)) - X \<inter> space M2 \<times> space M1)  sets E = sets (pair_measure_generator M2 M1)"
9.250 +proof (safe elim!: pair_measure_generatorE)
9.251    fix A B assume "A \<in> sets M1" "B \<in> sets M2"
9.252    moreover then have "(\<lambda>(x, y). (y, x)) - (A \<times> B) \<inter> space M2 \<times> space M1 = B \<times> A"
9.253      using M1.sets_into_space M2.sets_into_space by auto
9.254 -  ultimately show "(\<lambda>(x, y). (y, x)) - (A \<times> B) \<inter> space M2 \<times> space M1 \<in> sets (pair_algebra M2 M1)"
9.255 -    by (auto intro: pair_algebraI)
9.256 +  ultimately show "(\<lambda>(x, y). (y, x)) - (A \<times> B) \<inter> space M2 \<times> space M1 \<in> sets (pair_measure_generator M2 M1)"
9.257 +    by (auto intro: pair_measure_generatorI)
9.258  next
9.259    fix A B assume "A \<in> sets M1" "B \<in> sets M2"
9.260    then show "B \<times> A \<in> (\<lambda>X. (\<lambda>(x, y). (y, x)) - X \<inter> space M2 \<times> space M1)  sets E"
9.261      using M1.sets_into_space M2.sets_into_space
9.262 -    by (auto intro!: image_eqI[where x="A \<times> B"] pair_algebraI)
9.263 +    by (auto intro!: image_eqI[where x="A \<times> B"] pair_measure_generatorI)
9.264  qed
9.265
9.266  lemma (in pair_sigma_algebra) sets_pair_sigma_algebra_swap:
9.267    assumes Q: "Q \<in> sets P"
9.268 -  shows "(\<lambda>(x,y). (y, x))  Q \<in> sets (sigma (pair_algebra M2 M1))" (is "_ \<in> sets ?Q")
9.269 +  shows "(\<lambda>(x,y). (y, x)) - Q \<in> sets (M2 \<Otimes>\<^isub>M M1)" (is "_ \<in> sets ?Q")
9.270  proof -
9.271 -  have *: "(\<lambda>(x,y). (y, x)) \<in> space M2 \<times> space M1 \<rightarrow> (space M1 \<times> space M2)"
9.272 -       "sets (pair_algebra M1 M2) \<subseteq> Pow (space M1 \<times> space M2)"
9.273 -    using M1.sets_into_space M2.sets_into_space by (auto elim!: pair_algebraE)
9.274 -  from Q sets_into_space show ?thesis
9.275 -    by (auto intro!: image_eqI[where x=Q]
9.276 -             simp: pair_algebra_swap[symmetric] sets_sigma
9.277 -                   sigma_sets_vimage[OF *] space_pair_algebra)
9.278 +  let "?f Q" = "(\<lambda>(x,y). (y, x)) - Q \<inter> space M2 \<times> space M1"
9.279 +  have *: "(\<lambda>(x,y). (y, x)) - Q = ?f Q"
9.280 +    using sets_into_space[OF Q] by (auto simp: space_pair_measure)
9.281 +  have "sets (M2 \<Otimes>\<^isub>M M1) = sets (sigma (pair_measure_generator M2 M1))"
9.282 +    unfolding pair_measure_def ..
9.283 +  also have "\<dots> = sigma_sets (space M2 \<times> space M1) (?f  sets E)"
9.284 +    unfolding sigma_def pair_measure_generator_swap[symmetric]
9.285 +    by (simp add: pair_measure_generator_def)
9.286 +  also have "\<dots> = ?f  sigma_sets (space M1 \<times> space M2) (sets E)"
9.287 +    using M1.sets_into_space M2.sets_into_space
9.288 +    by (intro sigma_sets_vimage) (auto simp: pair_measure_generator_def)
9.289 +  also have "\<dots> = ?f  sets P"
9.290 +    unfolding pair_measure_def pair_measure_generator_def sigma_def by simp
9.291 +  finally show ?thesis
9.292 +    using Q by (subst *) auto
9.293  qed
9.294
9.295  lemma (in pair_sigma_algebra) pair_sigma_algebra_swap_measurable:
9.296 -  shows "(\<lambda>(x,y). (y, x)) \<in> measurable P (sigma (pair_algebra M2 M1))"
9.297 +  shows "(\<lambda>(x,y). (y, x)) \<in> measurable P (M2 \<Otimes>\<^isub>M M1)"
9.298      (is "?f \<in> measurable ?P ?Q")
9.299    unfolding measurable_def
9.300  proof (intro CollectI conjI Pi_I ballI)
9.301    fix x assume "x \<in> space ?P" then show "(case x of (x, y) \<Rightarrow> (y, x)) \<in> space ?Q"
9.302 -    unfolding pair_algebra_def by auto
9.303 +    unfolding pair_measure_generator_def pair_measure_def by auto
9.304  next
9.305 -  fix A assume "A \<in> sets ?Q"
9.306 +  fix A assume "A \<in> sets (M2 \<Otimes>\<^isub>M M1)"
9.307    interpret Q: pair_sigma_algebra M2 M1 by default
9.308 -  have "?f - A \<inter> space ?P = (\<lambda>(x,y). (y, x))  A"
9.309 -    using Q.sets_into_space A \<in> sets ?Q by (auto simp: pair_algebra_def)
9.310 -  with Q.sets_pair_sigma_algebra_swap[OF A \<in> sets ?Q]
9.311 +  with Q.sets_pair_sigma_algebra_swap[OF A \<in> sets (M2 \<Otimes>\<^isub>M M1)]
9.312    show "?f - A \<inter> space ?P \<in> sets ?P" by simp
9.313  qed
9.314
9.315 @@ -338,13 +430,13 @@
9.316    let ?Q' = "{Q. Q \<subseteq> space P \<and> Pair x - Q \<in> sets M2}"
9.317    let ?Q = "\<lparr> space = space P, sets = ?Q' \<rparr>"
9.318    interpret Q: sigma_algebra ?Q
9.319 -    proof qed (auto simp: vimage_UN vimage_Diff space_pair_algebra)
9.320 +    proof qed (auto simp: vimage_UN vimage_Diff space_pair_measure)
9.321    have "sets E \<subseteq> sets ?Q"
9.322      using M1.sets_into_space M2.sets_into_space
9.323 -    by (auto simp: pair_algebra_def space_pair_algebra)
9.324 +    by (auto simp: pair_measure_generator_def space_pair_measure)
9.325    then have "sets P \<subseteq> sets ?Q"
9.326 -    by (subst pair_algebra_def, intro Q.sets_sigma_subset)
9.328 +    apply (subst pair_measure_def, intro Q.sets_sigma_subset)
9.329 +    by (simp add: pair_measure_def)
9.330    with assms show ?thesis by auto
9.331  qed
9.332
9.333 @@ -352,9 +444,8 @@
9.334    assumes Q: "Q \<in> sets P" shows "(\<lambda>x. (x, y)) - Q \<in> sets M1" (is "?cut Q \<in> sets M1")
9.335  proof -
9.336    interpret Q: pair_sigma_algebra M2 M1 by default
9.337 -  have "Pair y - (\<lambda>(x, y). (y, x))  Q = (\<lambda>x. (x, y)) - Q" by auto
9.338    with Q.measurable_cut_fst[OF sets_pair_sigma_algebra_swap[OF Q], of y]
9.339 -  show ?thesis by simp
9.340 +  show ?thesis by (simp add: vimage_compose[symmetric] comp_def)
9.341  qed
9.342
9.343  lemma (in pair_sigma_algebra) measurable_pair_image_snd:
9.344 @@ -363,14 +454,15 @@
9.345    unfolding measurable_def
9.346  proof (intro CollectI conjI Pi_I ballI)
9.347    fix y assume "y \<in> space M2" with f \<in> measurable P M x \<in> space M1
9.348 -  show "f (x, y) \<in> space M" unfolding measurable_def pair_algebra_def by auto
9.349 +  show "f (x, y) \<in> space M"
9.350 +    unfolding measurable_def pair_measure_generator_def pair_measure_def by auto
9.351  next
9.352    fix A assume "A \<in> sets M"
9.353    then have "Pair x - (f - A \<inter> space P) \<in> sets M2" (is "?C \<in> _")
9.354      using f \<in> measurable P M
9.355      by (intro measurable_cut_fst) (auto simp: measurable_def)
9.356    also have "?C = (\<lambda>y. f (x, y)) - A \<inter> space M2"
9.357 -    using x \<in> space M1 by (auto simp: pair_algebra_def)
9.358 +    using x \<in> space M1 by (auto simp: pair_measure_generator_def pair_measure_def)
9.359    finally show "(\<lambda>y. f (x, y)) - A \<inter> space M2 \<in> sets M2" .
9.360  qed
9.361
9.362 @@ -384,31 +476,31 @@
9.363    show ?thesis by simp
9.364  qed
9.365
9.366 -lemma (in pair_sigma_algebra) Int_stable_pair_algebra: "Int_stable E"
9.367 +lemma (in pair_sigma_algebra) Int_stable_pair_measure_generator: "Int_stable E"
9.368    unfolding Int_stable_def
9.369  proof (intro ballI)
9.370    fix A B assume "A \<in> sets E" "B \<in> sets E"
9.371    then obtain A1 A2 B1 B2 where "A = A1 \<times> A2" "B = B1 \<times> B2"
9.372      "A1 \<in> sets M1" "A2 \<in> sets M2" "B1 \<in> sets M1" "B2 \<in> sets M2"
9.373 -    unfolding pair_algebra_def by auto
9.374 +    unfolding pair_measure_generator_def by auto
9.375    then show "A \<inter> B \<in> sets E"
9.376 -    by (auto simp add: times_Int_times pair_algebra_def)
9.377 +    by (auto simp add: times_Int_times pair_measure_generator_def)
9.378  qed
9.379
9.380  lemma finite_measure_cut_measurable:
9.381 -  fixes M1 :: "'a algebra" and M2 :: "'b algebra"
9.382 -  assumes "sigma_finite_measure M1 \<mu>1" "finite_measure M2 \<mu>2"
9.383 -  assumes "Q \<in> sets (sigma (pair_algebra M1 M2))"
9.384 -  shows "(\<lambda>x. \<mu>2 (Pair x - Q)) \<in> borel_measurable M1"
9.385 +  fixes M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
9.386 +  assumes "sigma_finite_measure M1" "finite_measure M2"
9.387 +  assumes "Q \<in> sets (M1 \<Otimes>\<^isub>M M2)"
9.388 +  shows "(\<lambda>x. measure M2 (Pair x - Q)) \<in> borel_measurable M1"
9.389      (is "?s Q \<in> _")
9.390  proof -
9.391 -  interpret M1: sigma_finite_measure M1 \<mu>1 by fact
9.392 -  interpret M2: finite_measure M2 \<mu>2 by fact
9.393 +  interpret M1: sigma_finite_measure M1 by fact
9.394 +  interpret M2: finite_measure M2 by fact
9.395    interpret pair_sigma_algebra M1 M2 by default
9.396    have [intro]: "sigma_algebra M1" by fact
9.397    have [intro]: "sigma_algebra M2" by fact
9.398    let ?D = "\<lparr> space = space P, sets = {A\<in>sets P. ?s A \<in> borel_measurable M1}  \<rparr>"
9.399 -  note space_pair_algebra[simp]
9.400 +  note space_pair_measure[simp]
9.401    interpret dynkin_system ?D
9.402    proof (intro dynkin_systemI)
9.403      fix A assume "A \<in> sets ?D" then show "A \<subseteq> space ?D"
9.404 @@ -418,73 +510,83 @@
9.405        by (auto simp add: if_distrib intro!: M1.measurable_If)
9.406    next
9.407      fix A assume "A \<in> sets ?D"
9.408 -    with sets_into_space have "\<And>x. \<mu>2 (Pair x - (space M1 \<times> space M2 - A)) =
9.409 -        (if x \<in> space M1 then \<mu>2 (space M2) - ?s A x else 0)"
9.410 +    with sets_into_space have "\<And>x. measure M2 (Pair x - (space M1 \<times> space M2 - A)) =
9.411 +        (if x \<in> space M1 then measure M2 (space M2) - ?s A x else 0)"
9.412        by (auto intro!: M2.finite_measure_compl measurable_cut_fst
9.413                 simp: vimage_Diff)
9.414      with A \<in> sets ?D top show "space ?D - A \<in> sets ?D"
9.415        by (auto intro!: Diff M1.measurable_If M1.borel_measurable_pextreal_diff)
9.416    next
9.417      fix F :: "nat \<Rightarrow> ('a\<times>'b) set" assume "disjoint_family F" "range F \<subseteq> sets ?D"
9.418 -    moreover then have "\<And>x. \<mu>2 (\<Union>i. Pair x - F i) = (\<Sum>\<^isub>\<infinity> i. ?s (F i) x)"
9.419 +    moreover then have "\<And>x. measure M2 (\<Union>i. Pair x - F i) = (\<Sum>\<^isub>\<infinity> i. ?s (F i) x)"
9.421           (auto intro!: measurable_cut_fst simp: disjoint_family_on_def)
9.422      ultimately show "(\<Union>i. F i) \<in> sets ?D"
9.423        by (auto simp: vimage_UN intro!: M1.borel_measurable_psuminf)
9.424    qed
9.425 -  have "P = ?D"
9.426 +  have "sets P = sets ?D" apply (subst pair_measure_def)
9.427    proof (intro dynkin_lemma)
9.428 -    show "Int_stable E" by (rule Int_stable_pair_algebra)
9.429 +    show "Int_stable E" by (rule Int_stable_pair_measure_generator)
9.430      from M1.sets_into_space have "\<And>A. A \<in> sets M1 \<Longrightarrow> {x \<in> space M1. x \<in> A} = A"
9.431        by auto
9.432      then show "sets E \<subseteq> sets ?D"
9.433 -      by (auto simp: pair_algebra_def sets_sigma if_distrib
9.434 +      by (auto simp: pair_measure_generator_def sets_sigma if_distrib
9.435                 intro: sigma_sets.Basic intro!: M1.measurable_If)
9.436 -  qed auto
9.437 +  qed (auto simp: pair_measure_def)
9.438    with Q \<in> sets P have "Q \<in> sets ?D" by simp
9.439    then show "?s Q \<in> borel_measurable M1" by simp
9.440  qed
9.441
9.442  subsection {* Binary products of $\sigma$-finite measure spaces *}
9.443
9.444 -locale pair_sigma_finite = M1: sigma_finite_measure M1 \<mu>1 + M2: sigma_finite_measure M2 \<mu>2
9.445 -  for M1 \<mu>1 M2 \<mu>2
9.446 +locale pair_sigma_finite = M1: sigma_finite_measure M1 + M2: sigma_finite_measure M2
9.447 +  for M1 :: "('a, 'c) measure_space_scheme" and M2 :: "('b, 'd) measure_space_scheme"
9.448
9.449  sublocale pair_sigma_finite \<subseteq> pair_sigma_algebra M1 M2
9.450    by default
9.451
9.452 +lemma times_eq_iff: "A \<times> B = C \<times> D \<longleftrightarrow> A = C \<and> B = D \<or> ((A = {} \<or> B = {}) \<and> (C = {} \<or> D = {}))"
9.453 +  by auto
9.454 +
9.455  lemma (in pair_sigma_finite) measure_cut_measurable_fst:
9.456 -  assumes "Q \<in> sets P" shows "(\<lambda>x. \<mu>2 (Pair x - Q)) \<in> borel_measurable M1" (is "?s Q \<in> _")
9.457 +  assumes "Q \<in> sets P" shows "(\<lambda>x. measure M2 (Pair x - Q)) \<in> borel_measurable M1" (is "?s Q \<in> _")
9.458  proof -
9.459    have [intro]: "sigma_algebra M1" and [intro]: "sigma_algebra M2" by default+
9.460 -  have M1: "sigma_finite_measure M1 \<mu>1" by default
9.461 -
9.462 +  have M1: "sigma_finite_measure M1" by default
9.463    from M2.disjoint_sigma_finite guess F .. note F = this
9.464 +  then have "\<And>i. F i \<in> sets M2" by auto
9.465    let "?C x i" = "F i \<inter> Pair x - Q"
9.466    { fix i
9.467      let ?R = "M2.restricted_space (F i)"
9.468      have [simp]: "space M1 \<times> F i \<inter> space M1 \<times> space M2 = space M1 \<times> F i"
9.469        using F M2.sets_into_space by auto
9.470 -    have "(\<lambda>x. \<mu>2 (Pair x - (space M1 \<times> F i \<inter> Q))) \<in> borel_measurable M1"
9.471 +    let ?R2 = "M2.restricted_space (F i)"
9.472 +    have "(\<lambda>x. measure ?R2 (Pair x - (space M1 \<times> space ?R2 \<inter> Q))) \<in> borel_measurable M1"
9.473      proof (intro finite_measure_cut_measurable[OF M1])
9.474 -      show "finite_measure (M2.restricted_space (F i)) \<mu>2"
9.475 +      show "finite_measure ?R2"
9.476          using F by (intro M2.restricted_to_finite_measure) auto
9.477 -      have "space M1 \<times> F i \<in> sets P"
9.478 -        using M1.top F by blast
9.479 -      from sigma_sets_Int[symmetric,
9.480 -        OF this[unfolded pair_sigma_algebra_def sets_sigma]]
9.481 -      show "(space M1 \<times> F i) \<inter> Q \<in> sets (sigma (pair_algebra M1 ?R))"
9.482 -        using Q \<in> sets P
9.483 -        using pair_algebra_Int_snd[OF M1.space_closed, of "F i" M2]
9.484 -        by (auto simp: pair_algebra_def sets_sigma)
9.485 +      have "(space M1 \<times> space ?R2) \<inter> Q \<in> (op \<inter> (space M1 \<times> F i))  sets P"
9.486 +        using Q \<in> sets P by (auto simp: image_iff)
9.487 +      also have "\<dots> = sigma_sets (space M1 \<times> F i) ((op \<inter> (space M1 \<times> F i))  sets E)"
9.488 +        unfolding pair_measure_def pair_measure_generator_def sigma_def
9.489 +        using F i \<in> sets M2 M2.sets_into_space
9.490 +        by (auto intro!: sigma_sets_Int sigma_sets.Basic)
9.491 +      also have "\<dots> \<subseteq> sets (M1 \<Otimes>\<^isub>M ?R2)"
9.492 +        using M1.sets_into_space
9.493 +        apply (auto simp: times_Int_times pair_measure_def pair_measure_generator_def sigma_def
9.494 +                    intro!: sigma_sets_subseteq)
9.495 +        apply (rule_tac x="a" in exI)
9.496 +        apply (rule_tac x="b \<inter> F i" in exI)
9.497 +        by auto
9.498 +      finally show "(space M1 \<times> space ?R2) \<inter> Q \<in> sets (M1 \<Otimes>\<^isub>M ?R2)" .
9.499      qed
9.500      moreover have "\<And>x. Pair x - (space M1 \<times> F i \<inter> Q) = ?C x i"
9.501 -      using Q \<in> sets P sets_into_space by (auto simp: space_pair_algebra)
9.502 -    ultimately have "(\<lambda>x. \<mu>2 (?C x i)) \<in> borel_measurable M1"
9.503 +      using Q \<in> sets P sets_into_space by (auto simp: space_pair_measure)
9.504 +    ultimately have "(\<lambda>x. measure M2 (?C x i)) \<in> borel_measurable M1"
9.505        by simp }
9.506    moreover
9.507    { fix x
9.508 -    have "(\<Sum>\<^isub>\<infinity>i. \<mu>2 (?C x i)) = \<mu>2 (\<Union>i. ?C x i)"
9.509 +    have "(\<Sum>\<^isub>\<infinity>i. measure M2 (?C x i)) = measure M2 (\<Union>i. ?C x i)"
9.511        show "range (?C x) \<subseteq> sets M2"
9.512          using F Q \<in> sets P by (auto intro!: M2.Int measurable_cut_fst)
9.513 @@ -494,27 +596,24 @@
9.514      qed
9.515      also have "(\<Union>i. ?C x i) = Pair x - Q"
9.516        using F sets_into_space Q \<in> sets P
9.517 -      by (auto simp: space_pair_algebra)
9.518 -    finally have "\<mu>2 (Pair x - Q) = (\<Sum>\<^isub>\<infinity>i. \<mu>2 (?C x i))"
9.519 +      by (auto simp: space_pair_measure)
9.520 +    finally have "measure M2 (Pair x - Q) = (\<Sum>\<^isub>\<infinity>i. measure M2 (?C x i))"
9.521        by simp }
9.522    ultimately show ?thesis
9.523      by (auto intro!: M1.borel_measurable_psuminf)
9.524  qed
9.525
9.526  lemma (in pair_sigma_finite) measure_cut_measurable_snd:
9.527 -  assumes "Q \<in> sets P" shows "(\<lambda>y. \<mu>1 ((\<lambda>x. (x, y)) - Q)) \<in> borel_measurable M2"
9.528 +  assumes "Q \<in> sets P" shows "(\<lambda>y. M1.\<mu> ((\<lambda>x. (x, y)) - Q)) \<in> borel_measurable M2"
9.529  proof -
9.530 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.531 -  have [simp]: "\<And>y. (Pair y - (\<lambda>(x, y). (y, x))  Q) = (\<lambda>x. (x, y)) - Q"
9.532 -    by auto
9.533 +  interpret Q: pair_sigma_finite M2 M1 by default
9.534    note sets_pair_sigma_algebra_swap[OF assms]
9.535    from Q.measure_cut_measurable_fst[OF this]
9.536 -  show ?thesis by simp
9.537 +  show ?thesis by (simp add: vimage_compose[symmetric] comp_def)
9.538  qed
9.539
9.540  lemma (in pair_sigma_algebra) pair_sigma_algebra_measurable:
9.541 -  assumes "f \<in> measurable P M"
9.542 -  shows "(\<lambda>(x,y). f (y, x)) \<in> measurable (sigma (pair_algebra M2 M1)) M"
9.543 +  assumes "f \<in> measurable P M" shows "(\<lambda>(x,y). f (y, x)) \<in> measurable (M2 \<Otimes>\<^isub>M M1) M"
9.544  proof -
9.545    interpret Q: pair_sigma_algebra M2 M1 by default
9.546    have *: "(\<lambda>(x,y). f (y, x)) = f \<circ> (\<lambda>(x,y). (y, x))" by (simp add: fun_eq_iff)
9.547 @@ -523,19 +622,15 @@
9.548      unfolding * by (rule measurable_comp)
9.549  qed
9.550
9.551 -definition (in pair_sigma_finite)
9.552 -  "pair_measure A = M1.positive_integral (\<lambda>x.
9.553 -    M2.positive_integral (\<lambda>y. indicator A (x, y)))"
9.554 -
9.555  lemma (in pair_sigma_finite) pair_measure_alt:
9.556    assumes "A \<in> sets P"
9.557 -  shows "pair_measure A = M1.positive_integral (\<lambda>x. \<mu>2 (Pair x - A))"
9.558 -  unfolding pair_measure_def
9.559 +  shows "measure (M1 \<Otimes>\<^isub>M M2) A = (\<integral>\<^isup>+ x. measure M2 (Pair x - A) \<partial>M1)"
9.560 +  apply (simp add: pair_measure_def pair_measure_generator_def)
9.561  proof (rule M1.positive_integral_cong)
9.562    fix x assume "x \<in> space M1"
9.563    have *: "\<And>y. indicator A (x, y) = (indicator (Pair x - A) y :: pextreal)"
9.564      unfolding indicator_def by auto
9.565 -  show "M2.positive_integral (\<lambda>y. indicator A (x, y)) = \<mu>2 (Pair x - A)"
9.566 +  show "(\<integral>\<^isup>+ y. indicator A (x, y) \<partial>M2) = measure M2 (Pair x - A)"
9.567      unfolding *
9.568      apply (subst M2.positive_integral_indicator)
9.569      apply (rule measurable_cut_fst[OF assms])
9.570 @@ -544,30 +639,29 @@
9.571
9.572  lemma (in pair_sigma_finite) pair_measure_times:
9.573    assumes A: "A \<in> sets M1" and "B \<in> sets M2"
9.574 -  shows "pair_measure (A \<times> B) = \<mu>1 A * \<mu>2 B"
9.575 +  shows "measure (M1 \<Otimes>\<^isub>M M2) (A \<times> B) = M1.\<mu> A * measure M2 B"
9.576  proof -
9.577 -  from assms have "pair_measure (A \<times> B) =
9.578 -      M1.positive_integral (\<lambda>x. \<mu>2 B * indicator A x)"
9.579 -    by (auto intro!: M1.positive_integral_cong simp: pair_measure_alt)
9.580 +  have "measure (M1 \<Otimes>\<^isub>M M2) (A \<times> B) = (\<integral>\<^isup>+ x. measure M2 B * indicator A x \<partial>M1)"
9.581 +    using assms by (auto intro!: M1.positive_integral_cong simp: pair_measure_alt)
9.582    with assms show ?thesis
9.583      by (simp add: M1.positive_integral_cmult_indicator ac_simps)
9.584  qed
9.585
9.586 -lemma (in pair_sigma_finite) sigma_finite_up_in_pair_algebra:
9.587 +lemma (in pair_sigma_finite) sigma_finite_up_in_pair_measure_generator:
9.588    "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets E \<and> F \<up> space E \<and>
9.589 -    (\<forall>i. pair_measure (F i) \<noteq> \<omega>)"
9.590 +    (\<forall>i. measure (M1 \<Otimes>\<^isub>M M2) (F i) \<noteq> \<omega>)"
9.591  proof -
9.592    obtain F1 :: "nat \<Rightarrow> 'a set" and F2 :: "nat \<Rightarrow> 'b set" where
9.593 -    F1: "range F1 \<subseteq> sets M1" "F1 \<up> space M1" "\<And>i. \<mu>1 (F1 i) \<noteq> \<omega>" and
9.594 -    F2: "range F2 \<subseteq> sets M2" "F2 \<up> space M2" "\<And>i. \<mu>2 (F2 i) \<noteq> \<omega>"
9.595 +    F1: "range F1 \<subseteq> sets M1" "F1 \<up> space M1" "\<And>i. M1.\<mu> (F1 i) \<noteq> \<omega>" and
9.596 +    F2: "range F2 \<subseteq> sets M2" "F2 \<up> space M2" "\<And>i. M2.\<mu> (F2 i) \<noteq> \<omega>"
9.597      using M1.sigma_finite_up M2.sigma_finite_up by auto
9.598    then have space: "space M1 = (\<Union>i. F1 i)" "space M2 = (\<Union>i. F2 i)"
9.599      unfolding isoton_def by auto
9.600    let ?F = "\<lambda>i. F1 i \<times> F2 i"
9.601 -  show ?thesis unfolding isoton_def space_pair_algebra
9.602 +  show ?thesis unfolding isoton_def space_pair_measure
9.603    proof (intro exI[of _ ?F] conjI allI)
9.604      show "range ?F \<subseteq> sets E" using F1 F2
9.605 -      by (fastsimp intro!: pair_algebraI)
9.606 +      by (fastsimp intro!: pair_measure_generatorI)
9.607    next
9.608      have "space M1 \<times> space M2 \<subseteq> (\<Union>i. ?F i)"
9.609      proof (intro subsetI)
9.610 @@ -581,8 +675,8 @@
9.611          by (intro SigmaI) (auto simp add: min_max.sup_commute)
9.612        then show "x \<in> (\<Union>i. ?F i)" by auto
9.613      qed
9.614 -    then show "(\<Union>i. ?F i) = space M1 \<times> space M2"
9.615 -      using space by (auto simp: space)
9.616 +    then show "(\<Union>i. ?F i) = space E"
9.617 +      using space by (auto simp: space pair_measure_generator_def)
9.618    next
9.619      fix i show "F1 i \<times> F2 i \<subseteq> F1 (Suc i) \<times> F2 (Suc i)"
9.620        using F1 \<up> space M1 F2 \<up> space M2 unfolding isoton_def
9.621 @@ -590,103 +684,163 @@
9.622    next
9.623      fix i
9.624      from F1 F2 have "F1 i \<in> sets M1" "F2 i \<in> sets M2" by auto
9.625 -    with F1 F2 show "pair_measure (F1 i \<times> F2 i) \<noteq> \<omega>"
9.626 +    with F1 F2 show "measure P (F1 i \<times> F2 i) \<noteq> \<omega>"
9.628    qed
9.629  qed
9.630
9.631 -sublocale pair_sigma_finite \<subseteq> sigma_finite_measure P pair_measure
9.632 +sublocale pair_sigma_finite \<subseteq> sigma_finite_measure P
9.633  proof
9.634 -  show "pair_measure {} = 0"
9.635 -    unfolding pair_measure_def by auto
9.636 +  show "measure P {} = 0"
9.637 +    unfolding pair_measure_def pair_measure_generator_def sigma_def by auto
9.638
9.639 -  show "countably_additive P pair_measure"
9.640 +  show "countably_additive P (measure P)"
9.642    proof (intro allI impI)
9.643      fix F :: "nat \<Rightarrow> ('a \<times> 'b) set"
9.644      assume F: "range F \<subseteq> sets P" "disjoint_family F"
9.645      from F have *: "\<And>i. F i \<in> sets P" "(\<Union>i. F i) \<in> sets P" by auto
9.646 -    moreover from F have "\<And>i. (\<lambda>x. \<mu>2 (Pair x - F i)) \<in> borel_measurable M1"
9.647 +    moreover from F have "\<And>i. (\<lambda>x. measure M2 (Pair x - F i)) \<in> borel_measurable M1"
9.648        by (intro measure_cut_measurable_fst) auto
9.649      moreover have "\<And>x. disjoint_family (\<lambda>i. Pair x - F i)"
9.650        by (intro disjoint_family_on_bisimulation[OF F(2)]) auto
9.651      moreover have "\<And>x. x \<in> space M1 \<Longrightarrow> range (\<lambda>i. Pair x - F i) \<subseteq> sets M2"
9.652        using F by (auto intro!: measurable_cut_fst)
9.653 -    ultimately show "(\<Sum>\<^isub>\<infinity>n. pair_measure (F n)) = pair_measure (\<Union>i. F i)"
9.654 +    ultimately show "(\<Sum>\<^isub>\<infinity>n. measure P (F n)) = measure P (\<Union>i. F i)"
9.655        by (simp add: pair_measure_alt vimage_UN M1.positive_integral_psuminf[symmetric]
9.657                 cong: M1.positive_integral_cong)
9.658    qed
9.659
9.660 -  from sigma_finite_up_in_pair_algebra guess F :: "nat \<Rightarrow> ('a \<times> 'c) set" .. note F = this
9.661 -  show "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets P \<and> (\<Union>i. F i) = space P \<and> (\<forall>i. pair_measure (F i) \<noteq> \<omega>)"
9.662 +  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
9.663 +  show "\<exists>F::nat \<Rightarrow> ('a \<times> 'b) set. range F \<subseteq> sets P \<and> (\<Union>i. F i) = space P \<and> (\<forall>i. measure P (F i) \<noteq> \<omega>)"
9.664    proof (rule exI[of _ F], intro conjI)
9.665 -    show "range F \<subseteq> sets P" using F by auto
9.666 +    show "range F \<subseteq> sets P" using F by (auto simp: pair_measure_def)
9.667      show "(\<Union>i. F i) = space P"
9.668 -      using F by (auto simp: space_pair_algebra isoton_def)
9.669 -    show "\<forall>i. pair_measure (F i) \<noteq> \<omega>" using F by auto
9.670 +      using F by (auto simp: pair_measure_def pair_measure_generator_def isoton_def)
9.671 +    show "\<forall>i. measure P (F i) \<noteq> \<omega>" using F by auto
9.672    qed
9.673  qed
9.674
9.675  lemma (in pair_sigma_algebra) sets_swap:
9.676    assumes "A \<in> sets P"
9.677 -  shows "(\<lambda>(x, y). (y, x)) - A \<inter> space (sigma (pair_algebra M2 M1)) \<in> sets (sigma (pair_algebra M2 M1))"
9.678 +  shows "(\<lambda>(x, y). (y, x)) - A \<inter> space (M2 \<Otimes>\<^isub>M M1) \<in> sets (M2 \<Otimes>\<^isub>M M1)"
9.679      (is "_ - A \<inter> space ?Q \<in> sets ?Q")
9.680  proof -
9.681 -  have *: "(\<lambda>(x, y). (y, x)) - A \<inter> space ?Q = (\<lambda>(x, y). (y, x))  A"
9.682 -    using A \<in> sets P sets_into_space by (auto simp: space_pair_algebra)
9.683 +  have *: "(\<lambda>(x, y). (y, x)) - A \<inter> space ?Q = (\<lambda>(x, y). (y, x)) - A"
9.684 +    using A \<in> sets P sets_into_space by (auto simp: space_pair_measure)
9.685    show ?thesis
9.686      unfolding * using assms by (rule sets_pair_sigma_algebra_swap)
9.687  qed
9.688
9.689  lemma (in pair_sigma_finite) pair_measure_alt2:
9.690    assumes "A \<in> sets P"
9.691 -  shows "pair_measure A = M2.positive_integral (\<lambda>y. \<mu>1 ((\<lambda>x. (x, y)) - A))"
9.692 +  shows "\<mu> A = (\<integral>\<^isup>+y. M1.\<mu> ((\<lambda>x. (x, y)) - A) \<partial>M2)"
9.693      (is "_ = ?\<nu> A")
9.694  proof -
9.695 -  from sigma_finite_up_in_pair_algebra guess F :: "nat \<Rightarrow> ('a \<times> 'c) set" .. note F = this
9.696 +  from sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('a \<times> 'b) set" .. note F = this
9.697 +  have [simp]: "\<And>m. \<lparr> space = space E, sets = sets (sigma E), measure = m \<rparr> = P\<lparr> measure := m \<rparr>"
9.698 +    unfolding pair_measure_def by simp
9.699    show ?thesis
9.700 -  proof (rule measure_unique_Int_stable[where \<nu>="?\<nu>", OF Int_stable_pair_algebra],
9.702 -    show "range F \<subseteq> sets E" "F \<up> space E" "\<And>i. pair_measure (F i) \<noteq> \<omega>"
9.703 -      using F by auto
9.704 -    show "measure_space P pair_measure" by default
9.705 -    interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.706 -    have P: "sigma_algebra P" by default
9.707 -    show "measure_space P ?\<nu>"
9.708 +  proof (rule measure_unique_Int_stable[where \<nu>="?\<nu>", OF Int_stable_pair_measure_generator], simp_all)
9.709 +    show "range F \<subseteq> sets E" "F \<up> space E" "\<And>i. \<mu> (F i) \<noteq> \<omega>" "A \<in> sets (sigma E)"
9.710 +      using F A \<in> sets P by (auto simp: pair_measure_def)
9.711 +    show "measure_space P" by default
9.712 +    interpret Q: pair_sigma_finite M2 M1 by default
9.713 +    have P: "sigma_algebra (P\<lparr> measure := ?\<nu>\<rparr>)"
9.714 +      by (intro sigma_algebra_cong) auto
9.715 +    show "measure_space (P\<lparr> measure := ?\<nu>\<rparr>)"
9.716        apply (rule Q.measure_space_vimage[OF P])
9.717 +      apply (simp_all)
9.718        apply (rule Q.pair_sigma_algebra_swap_measurable)
9.719      proof -
9.720        fix A assume "A \<in> sets P"
9.721        from sets_swap[OF this]
9.722 -      show "M2.positive_integral (\<lambda>y. \<mu>1 ((\<lambda>x. (x, y)) - A)) =
9.723 -            Q.pair_measure ((\<lambda>(x, y). (y, x)) - A \<inter> space Q.P)"
9.724 +      show "(\<integral>\<^isup>+ y. M1.\<mu> ((\<lambda>x. (x, y)) - A) \<partial>M2) = Q.\<mu> ((\<lambda>(x, y). (y, x)) - A \<inter> space (M2 \<Otimes>\<^isub>M M1))"
9.725          using sets_into_space[OF A \<in> sets P]
9.726 -        by (auto simp add: Q.pair_measure_alt space_pair_algebra
9.727 -                 intro!: M2.positive_integral_cong arg_cong[where f=\<mu>1])
9.728 +        by (auto simp add: Q.pair_measure_alt space_pair_measure
9.729 +                 intro!: M2.positive_integral_cong arg_cong[where f="M1.\<mu>"])
9.730      qed
9.731      fix X assume "X \<in> sets E"
9.732      then obtain A B where X: "X = A \<times> B" and AB: "A \<in> sets M1" "B \<in> sets M2"
9.733 -      unfolding pair_algebra_def by auto
9.734 -    show "pair_measure X = ?\<nu> X"
9.735 +      unfolding pair_measure_def pair_measure_generator_def by auto
9.736 +    show "\<mu> X = ?\<nu> X"
9.737      proof -
9.738 -      from AB have "?\<nu> (A \<times> B) =
9.739 -          M2.positive_integral (\<lambda>y. \<mu>1 A * indicator B y)"
9.740 +      from AB have "?\<nu> (A \<times> B) = (\<integral>\<^isup>+y. M1.\<mu> A * indicator B y \<partial>M2)"
9.741          by (auto intro!: M2.positive_integral_cong)
9.742        with AB show ?thesis
9.743          unfolding pair_measure_times[OF AB] X
9.744          by (simp add: M2.positive_integral_cmult_indicator ac_simps)
9.745      qed
9.746 -  qed fact
9.747 +  qed
9.748 +qed
9.749 +
9.750 +
9.751 +lemma pair_sigma_algebra_sigma:
9.752 +  assumes 1: "S1 \<up> (space E1)" "range S1 \<subseteq> sets E1" and E1: "sets E1 \<subseteq> Pow (space E1)"
9.753 +  assumes 2: "S2 \<up> (space E2)" "range S2 \<subseteq> sets E2" and E2: "sets E2 \<subseteq> Pow (space E2)"
9.754 +  shows "sets (sigma (pair_measure_generator (sigma E1) (sigma E2))) = sets (sigma (pair_measure_generator E1 E2))"
9.755 +    (is "sets ?S = sets ?E")
9.756 +proof -
9.757 +  interpret M1: sigma_algebra "sigma E1" using E1 by (rule sigma_algebra_sigma)
9.758 +  interpret M2: sigma_algebra "sigma E2" using E2 by (rule sigma_algebra_sigma)
9.759 +  have P: "sets (pair_measure_generator E1 E2) \<subseteq> Pow (space E1 \<times> space E2)"
9.760 +    using E1 E2 by (auto simp add: pair_measure_generator_def)
9.761 +  interpret E: sigma_algebra ?E unfolding pair_measure_generator_def
9.762 +    using E1 E2 by (intro sigma_algebra_sigma) auto
9.763 +  { fix A assume "A \<in> sets E1"
9.764 +    then have "fst - A \<inter> space ?E = A \<times> (\<Union>i. S2 i)"
9.765 +      using E1 2 unfolding isoton_def pair_measure_generator_def by auto
9.766 +    also have "\<dots> = (\<Union>i. A \<times> S2 i)" by auto
9.767 +    also have "\<dots> \<in> sets ?E" unfolding pair_measure_generator_def sets_sigma
9.768 +      using 2 A \<in> sets E1
9.769 +      by (intro sigma_sets.Union)
9.770 +         (auto simp: image_subset_iff intro!: sigma_sets.Basic)
9.771 +    finally have "fst - A \<inter> space ?E \<in> sets ?E" . }
9.772 +  moreover
9.773 +  { fix B assume "B \<in> sets E2"
9.774 +    then have "snd - B \<inter> space ?E = (\<Union>i. S1 i) \<times> B"
9.775 +      using E2 1 unfolding isoton_def pair_measure_generator_def by auto
9.776 +    also have "\<dots> = (\<Union>i. S1 i \<times> B)" by auto
9.777 +    also have "\<dots> \<in> sets ?E"
9.778 +      using 1 B \<in> sets E2 unfolding pair_measure_generator_def sets_sigma
9.779 +      by (intro sigma_sets.Union)
9.780 +         (auto simp: image_subset_iff intro!: sigma_sets.Basic)
9.781 +    finally have "snd - B \<inter> space ?E \<in> sets ?E" . }
9.782 +  ultimately have proj:
9.783 +    "fst \<in> measurable ?E (sigma E1) \<and> snd \<in> measurable ?E (sigma E2)"
9.784 +    using E1 E2 by (subst (1 2) E.measurable_iff_sigma)
9.785 +                   (auto simp: pair_measure_generator_def sets_sigma)
9.786 +  { fix A B assume A: "A \<in> sets (sigma E1)" and B: "B \<in> sets (sigma E2)"
9.787 +    with proj have "fst - A \<inter> space ?E \<in> sets ?E" "snd - B \<inter> space ?E \<in> sets ?E"
9.788 +      unfolding measurable_def by simp_all
9.789 +    moreover have "A \<times> B = (fst - A \<inter> space ?E) \<inter> (snd - B \<inter> space ?E)"
9.790 +      using A B M1.sets_into_space M2.sets_into_space
9.791 +      by (auto simp: pair_measure_generator_def)
9.792 +    ultimately have "A \<times> B \<in> sets ?E" by auto }
9.793 +  then have "sigma_sets (space ?E) (sets (pair_measure_generator (sigma E1) (sigma E2))) \<subseteq> sets ?E"
9.794 +    by (intro E.sigma_sets_subset) (auto simp add: pair_measure_generator_def sets_sigma)
9.795 +  then have subset: "sets ?S \<subseteq> sets ?E"
9.796 +    by (simp add: sets_sigma pair_measure_generator_def)
9.797 +  show "sets ?S = sets ?E"
9.798 +  proof (intro set_eqI iffI)
9.799 +    fix A assume "A \<in> sets ?E" then show "A \<in> sets ?S"
9.800 +      unfolding sets_sigma
9.801 +    proof induct
9.802 +      case (Basic A) then show ?case
9.803 +        by (auto simp: pair_measure_generator_def sets_sigma intro: sigma_sets.Basic)
9.804 +    qed (auto intro: sigma_sets.intros simp: pair_measure_generator_def)
9.805 +  next
9.806 +    fix A assume "A \<in> sets ?S" then show "A \<in> sets ?E" using subset by auto
9.807 +  qed
9.808  qed
9.809
9.810  section "Fubinis theorem"
9.811
9.812  lemma (in pair_sigma_finite) simple_function_cut:
9.813 -  assumes f: "simple_function f"
9.814 -  shows "(\<lambda>x. M2.positive_integral (\<lambda> y. f (x, y))) \<in> borel_measurable M1"
9.815 -    and "M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. f (x, y)))
9.816 -      = positive_integral f"
9.817 +  assumes f: "simple_function P f"
9.818 +  shows "(\<lambda>x. \<integral>\<^isup>+y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
9.819 +    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
9.820  proof -
9.821    have f_borel: "f \<in> borel_measurable P"
9.822      using f by (rule borel_measurable_simple_function)
9.823 @@ -696,42 +850,40 @@
9.824      have [simp]: "\<And>z y. indicator (?F z) (x, y) = indicator (?F' x z) y"
9.825        by (auto simp: indicator_def)
9.826      have "\<And>y. y \<in> space M2 \<Longrightarrow> (x, y) \<in> space P" using x \<in> space M1
9.827 -      by (simp add: space_pair_algebra)
9.828 +      by (simp add: space_pair_measure)
9.829      moreover have "\<And>x z. ?F' x z \<in> sets M2" using f_borel
9.830        by (intro borel_measurable_vimage measurable_cut_fst)
9.831 -    ultimately have "M2.simple_function (\<lambda> y. f (x, y))"
9.832 +    ultimately have "simple_function M2 (\<lambda> y. f (x, y))"
9.833        apply (rule_tac M2.simple_function_cong[THEN iffD2, OF _])
9.834        apply (rule simple_function_indicator_representation[OF f])
9.835        using x \<in> space M1 by (auto simp del: space_sigma) }
9.836    note M2_sf = this
9.837    { fix x assume x: "x \<in> space M1"
9.838 -    then have "M2.positive_integral (\<lambda> y. f (x, y)) =
9.839 -        (\<Sum>z\<in>f  space P. z * \<mu>2 (?F' x z))"
9.840 +    then have "(\<integral>\<^isup>+y. f (x, y) \<partial>M2) = (\<Sum>z\<in>f  space P. z * M2.\<mu> (?F' x z))"
9.841        unfolding M2.positive_integral_eq_simple_integral[OF M2_sf[OF x]]
9.842 -      unfolding M2.simple_integral_def
9.843 +      unfolding simple_integral_def
9.844      proof (safe intro!: setsum_mono_zero_cong_left)
9.845        from f show "finite (f  space P)" by (rule simple_functionD)
9.846      next
9.847        fix y assume "y \<in> space M2" then show "f (x, y) \<in> f  space P"
9.848 -        using x \<in> space M1 by (auto simp: space_pair_algebra)
9.849 +        using x \<in> space M1 by (auto simp: space_pair_measure)
9.850      next
9.851        fix x' y assume "(x', y) \<in> space P"
9.852          "f (x', y) \<notin> (\<lambda>y. f (x, y))  space M2"
9.853        then have *: "?F' x (f (x', y)) = {}"
9.854 -        by (force simp: space_pair_algebra)
9.855 -      show  "f (x', y) * \<mu>2 (?F' x (f (x', y))) = 0"
9.856 +        by (force simp: space_pair_measure)
9.857 +      show  "f (x', y) * M2.\<mu> (?F' x (f (x', y))) = 0"
9.858          unfolding * by simp
9.859      qed (simp add: vimage_compose[symmetric] comp_def
9.860 -                   space_pair_algebra) }
9.861 +                   space_pair_measure) }
9.862    note eq = this
9.863    moreover have "\<And>z. ?F z \<in> sets P"
9.864      by (auto intro!: f_borel borel_measurable_vimage simp del: space_sigma)
9.865 -  moreover then have "\<And>z. (\<lambda>x. \<mu>2 (?F' x z)) \<in> borel_measurable M1"
9.866 +  moreover then have "\<And>z. (\<lambda>x. M2.\<mu> (?F' x z)) \<in> borel_measurable M1"
9.867      by (auto intro!: measure_cut_measurable_fst simp del: vimage_Int)
9.868    ultimately
9.869 -  show "(\<lambda> x. M2.positive_integral (\<lambda> y. f (x, y))) \<in> borel_measurable M1"
9.870 -    and "M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. f (x, y)))
9.871 -    = positive_integral f"
9.872 +  show "(\<lambda>x. \<integral>\<^isup>+y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
9.873 +    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
9.874      by (auto simp del: vimage_Int cong: measurable_cong
9.875               intro!: M1.borel_measurable_pextreal_setsum
9.877 @@ -743,13 +895,12 @@
9.878
9.879  lemma (in pair_sigma_finite) positive_integral_fst_measurable:
9.880    assumes f: "f \<in> borel_measurable P"
9.881 -  shows "(\<lambda> x. M2.positive_integral (\<lambda> y. f (x, y))) \<in> borel_measurable M1"
9.882 +  shows "(\<lambda>x. \<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<in> borel_measurable M1"
9.883        (is "?C f \<in> borel_measurable M1")
9.884 -    and "M1.positive_integral (\<lambda> x. M2.positive_integral (\<lambda> y. f (x, y))) =
9.885 -      positive_integral f"
9.886 +    and "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
9.887  proof -
9.888    from borel_measurable_implies_simple_function_sequence[OF f]
9.889 -  obtain F where F: "\<And>i. simple_function (F i)" "F \<up> f" by auto
9.890 +  obtain F where F: "\<And>i. simple_function P (F i)" "F \<up> f" by auto
9.891    then have F_borel: "\<And>i. F i \<in> borel_measurable P"
9.892      and F_mono: "\<And>i x. F i x \<le> F (Suc i) x"
9.893      and F_SUPR: "\<And>x. (SUP i. F i x) = f x"
9.894 @@ -770,56 +921,48 @@
9.895    note SUPR_C = this
9.896    ultimately show "?C f \<in> borel_measurable M1"
9.897      by (simp cong: measurable_cong)
9.898 -  have "positive_integral (\<lambda>x. (SUP i. F i x)) = (SUP i. positive_integral (F i))"
9.899 +  have "(\<integral>\<^isup>+x. (SUP i. F i x) \<partial>P) = (SUP i. integral\<^isup>P P (F i))"
9.900      using F_borel F_mono
9.901      by (auto intro!: positive_integral_monotone_convergence_SUP[symmetric])
9.902 -  also have "(SUP i. positive_integral (F i)) =
9.903 -    (SUP i. M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. F i (x, y))))"
9.904 +  also have "(SUP i. integral\<^isup>P P (F i)) = (SUP i. \<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. F i (x, y) \<partial>M2) \<partial>M1)"
9.905      unfolding sf(2) by simp
9.906 -  also have "\<dots> = M1.positive_integral (\<lambda>x. SUP i. M2.positive_integral (\<lambda>y. F i (x, y)))"
9.907 +  also have "\<dots> = \<integral>\<^isup>+ x. (SUP i. \<integral>\<^isup>+ y. F i (x, y) \<partial>M2) \<partial>M1"
9.908      by (auto intro!: M1.positive_integral_monotone_convergence_SUP[OF _ sf(1)]
9.909                       M2.positive_integral_mono F_mono)
9.910 -  also have "\<dots> = M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. SUP i. F i (x, y)))"
9.911 +  also have "\<dots> = \<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. (SUP i. F i (x, y)) \<partial>M2) \<partial>M1"
9.912      using F_borel F_mono
9.913      by (auto intro!: M2.positive_integral_monotone_convergence_SUP
9.914                       M1.positive_integral_cong measurable_pair_image_snd)
9.915 -  finally show "M1.positive_integral (\<lambda> x. M2.positive_integral (\<lambda> y. f (x, y))) =
9.916 -      positive_integral f"
9.917 +  finally show "(\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>P P f"
9.918      unfolding F_SUPR by simp
9.919  qed
9.920
9.921  lemma (in pair_sigma_finite) positive_integral_product_swap:
9.922    assumes f: "f \<in> borel_measurable P"
9.923 -  shows "measure_space.positive_integral
9.924 -    (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \<mu>2 M1 \<mu>1) (\<lambda>x. f (case x of (x,y)\<Rightarrow>(y,x))) =
9.925 -  positive_integral f"
9.926 +  shows "(\<integral>\<^isup>+x. f (case x of (x,y)\<Rightarrow>(y,x)) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>P P f"
9.927  proof -
9.928 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.929 -  have P: "sigma_algebra P" by default
9.930 +  interpret Q: pair_sigma_finite M2 M1 by default
9.931 +  have "sigma_algebra P" by default
9.932    show ?thesis
9.933 -    unfolding Q.positive_integral_vimage[OF P Q.pair_sigma_algebra_swap_measurable f, symmetric]
9.934 -  proof (rule positive_integral_cong_measure)
9.935 -    fix A
9.936 -    assume A: "A \<in> sets P"
9.937 +  proof (intro Q.positive_integral_vimage[symmetric] Q.pair_sigma_algebra_swap_measurable)
9.938 +    fix A assume "A \<in> sets P"
9.939      from Q.pair_sigma_algebra_swap_measurable[THEN measurable_sets, OF this] this sets_into_space[OF this]
9.940 -    show "Q.pair_measure ((\<lambda>(x, y). (y, x)) - A \<inter> space Q.P) = pair_measure A"
9.941 -      by (auto intro!: M1.positive_integral_cong arg_cong[where f=\<mu>2]
9.942 -               simp: pair_measure_alt Q.pair_measure_alt2 space_pair_algebra)
9.943 -  qed
9.944 +    show "\<mu> A = Q.\<mu> ((\<lambda>(x, y). (y, x)) - A \<inter> space (M2 \<Otimes>\<^isub>M M1))"
9.945 +      by (auto intro!: M1.positive_integral_cong arg_cong[where f="M2.\<mu>"]
9.946 +               simp: pair_measure_alt Q.pair_measure_alt2 space_pair_measure)
9.947 +  qed fact+
9.948  qed
9.949
9.950  lemma (in pair_sigma_finite) positive_integral_snd_measurable:
9.951    assumes f: "f \<in> borel_measurable P"
9.952 -  shows "M2.positive_integral (\<lambda>y. M1.positive_integral (\<lambda>x. f (x, y))) =
9.953 -      positive_integral f"
9.954 +  shows "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>P P f"
9.955  proof -
9.956 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.957 +  interpret Q: pair_sigma_finite M2 M1 by default
9.958    note pair_sigma_algebra_measurable[OF f]
9.959    from Q.positive_integral_fst_measurable[OF this]
9.960 -  have "M2.positive_integral (\<lambda>y. M1.positive_integral (\<lambda>x. f (x, y))) =
9.961 -    Q.positive_integral (\<lambda>(x, y). f (y, x))"
9.962 +  have "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>\<^isup>+ (x, y). f (y, x) \<partial>Q.P)"
9.963      by simp
9.964 -  also have "Q.positive_integral (\<lambda>(x, y). f (y, x)) = positive_integral f"
9.965 +  also have "(\<integral>\<^isup>+ (x, y). f (y, x) \<partial>Q.P) = integral\<^isup>P P f"
9.966      unfolding positive_integral_product_swap[OF f, symmetric]
9.967      by (auto intro!: Q.positive_integral_cong)
9.968    finally show ?thesis .
9.969 @@ -827,8 +970,7 @@
9.970
9.971  lemma (in pair_sigma_finite) Fubini:
9.972    assumes f: "f \<in> borel_measurable P"
9.973 -  shows "M2.positive_integral (\<lambda>y. M1.positive_integral (\<lambda>x. f (x, y))) =
9.974 -      M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. f (x, y)))"
9.975 +  shows "(\<integral>\<^isup>+ y. (\<integral>\<^isup>+ x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>\<^isup>+ x. (\<integral>\<^isup>+ y. f (x, y) \<partial>M2) \<partial>M1)"
9.976    unfolding positive_integral_snd_measurable[OF assms]
9.977    unfolding positive_integral_fst_measurable[OF assms] ..
9.978
9.979 @@ -836,30 +978,30 @@
9.980    assumes "almost_everywhere (\<lambda>x. Q x)"
9.981    shows "M1.almost_everywhere (\<lambda>x. M2.almost_everywhere (\<lambda>y. Q (x, y)))"
9.982  proof -
9.983 -  obtain N where N: "N \<in> sets P" "pair_measure N = 0" "{x\<in>space P. \<not> Q x} \<subseteq> N"
9.984 +  obtain N where N: "N \<in> sets P" "\<mu> N = 0" "{x\<in>space P. \<not> Q x} \<subseteq> N"
9.985      using assms unfolding almost_everywhere_def by auto
9.986    show ?thesis
9.987    proof (rule M1.AE_I)
9.988      from N measure_cut_measurable_fst[OF N \<in> sets P]
9.989 -    show "\<mu>1 {x\<in>space M1. \<mu>2 (Pair x - N) \<noteq> 0} = 0"
9.990 +    show "M1.\<mu> {x\<in>space M1. M2.\<mu> (Pair x - N) \<noteq> 0} = 0"
9.991        by (simp add: M1.positive_integral_0_iff pair_measure_alt vimage_def)
9.992 -    show "{x \<in> space M1. \<mu>2 (Pair x - N) \<noteq> 0} \<in> sets M1"
9.993 +    show "{x \<in> space M1. M2.\<mu> (Pair x - N) \<noteq> 0} \<in> sets M1"
9.994        by (intro M1.borel_measurable_pextreal_neq_const measure_cut_measurable_fst N)
9.995 -    { fix x assume "x \<in> space M1" "\<mu>2 (Pair x - N) = 0"
9.996 +    { fix x assume "x \<in> space M1" "M2.\<mu> (Pair x - N) = 0"
9.997        have "M2.almost_everywhere (\<lambda>y. Q (x, y))"
9.998        proof (rule M2.AE_I)
9.999 -        show "\<mu>2 (Pair x - N) = 0" by fact
9.1000 +        show "M2.\<mu> (Pair x - N) = 0" by fact
9.1001          show "Pair x - N \<in> sets M2" by (intro measurable_cut_fst N)
9.1002          show "{y \<in> space M2. \<not> Q (x, y)} \<subseteq> Pair x - N"
9.1003 -          using N x \<in> space M1 unfolding space_sigma space_pair_algebra by auto
9.1004 +          using N x \<in> space M1 unfolding space_sigma space_pair_measure by auto
9.1005        qed }
9.1006 -    then show "{x \<in> space M1. \<not> M2.almost_everywhere (\<lambda>y. Q (x, y))} \<subseteq> {x \<in> space M1. \<mu>2 (Pair x - N) \<noteq> 0}"
9.1007 +    then show "{x \<in> space M1. \<not> M2.almost_everywhere (\<lambda>y. Q (x, y))} \<subseteq> {x \<in> space M1. M2.\<mu> (Pair x - N) \<noteq> 0}"
9.1008        by auto
9.1009    qed
9.1010  qed
9.1011
9.1012  lemma (in pair_sigma_algebra) measurable_product_swap:
9.1013 -  "f \<in> measurable (sigma (pair_algebra M2 M1)) M \<longleftrightarrow> (\<lambda>(x,y). f (y,x)) \<in> measurable P M"
9.1014 +  "f \<in> measurable (M2 \<Otimes>\<^isub>M M1) M \<longleftrightarrow> (\<lambda>(x,y). f (y,x)) \<in> measurable P M"
9.1015  proof -
9.1016    interpret Q: pair_sigma_algebra M2 M1 by default
9.1017    show ?thesis
9.1018 @@ -868,114 +1010,106 @@
9.1019  qed
9.1020
9.1021  lemma (in pair_sigma_finite) integrable_product_swap:
9.1022 -  assumes "integrable f"
9.1023 -  shows "measure_space.integrable
9.1024 -    (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \<mu>2 M1 \<mu>1) (\<lambda>(x,y). f (y,x))"
9.1025 +  assumes "integrable P f"
9.1026 +  shows "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x))"
9.1027  proof -
9.1028 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.1029 +  interpret Q: pair_sigma_finite M2 M1 by default
9.1030    have *: "(\<lambda>(x,y). f (y,x)) = (\<lambda>x. f (case x of (x,y)\<Rightarrow>(y,x)))" by (auto simp: fun_eq_iff)
9.1031    show ?thesis unfolding *
9.1032 -    using assms unfolding Q.integrable_def integrable_def
9.1033 +    using assms unfolding integrable_def
9.1034      apply (subst (1 2) positive_integral_product_swap)
9.1035 -    using integrable f unfolding integrable_def
9.1036 +    using integrable P f unfolding integrable_def
9.1037      by (auto simp: *[symmetric] Q.measurable_product_swap[symmetric])
9.1038  qed
9.1039
9.1040  lemma (in pair_sigma_finite) integrable_product_swap_iff:
9.1041 -  "measure_space.integrable
9.1042 -    (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \<mu>2 M1 \<mu>1) (\<lambda>(x,y). f (y,x)) \<longleftrightarrow>
9.1043 -  integrable f"
9.1044 +  "integrable (M2 \<Otimes>\<^isub>M M1) (\<lambda>(x,y). f (y,x)) \<longleftrightarrow> integrable P f"
9.1045  proof -
9.1046 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.1047 +  interpret Q: pair_sigma_finite M2 M1 by default
9.1048    from Q.integrable_product_swap[of "\<lambda>(x,y). f (y,x)"] integrable_product_swap[of f]
9.1049    show ?thesis by auto
9.1050  qed
9.1051
9.1052  lemma (in pair_sigma_finite) integral_product_swap:
9.1053 -  assumes "integrable f"
9.1054 -  shows "measure_space.integral
9.1055 -    (sigma (pair_algebra M2 M1)) (pair_sigma_finite.pair_measure M2 \<mu>2 M1 \<mu>1) (\<lambda>(x,y). f (y,x)) =
9.1056 -  integral f"
9.1057 +  assumes "integrable P f"
9.1058 +  shows "(\<integral>(x,y). f (y,x) \<partial>(M2 \<Otimes>\<^isub>M M1)) = integral\<^isup>L P f"
9.1059  proof -
9.1060 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.1061 +  interpret Q: pair_sigma_finite M2 M1 by default
9.1062    have *: "(\<lambda>(x,y). f (y,x)) = (\<lambda>x. f (case x of (x,y)\<Rightarrow>(y,x)))" by (auto simp: fun_eq_iff)
9.1063    show ?thesis
9.1064 -    unfolding integral_def Q.integral_def *
9.1065 +    unfolding lebesgue_integral_def *
9.1066      apply (subst (1 2) positive_integral_product_swap)
9.1067 -    using integrable f unfolding integrable_def
9.1068 +    using integrable P f unfolding integrable_def
9.1069      by (auto simp: *[symmetric] Q.measurable_product_swap[symmetric])
9.1070  qed
9.1071
9.1072  lemma (in pair_sigma_finite) integrable_fst_measurable:
9.1073 -  assumes f: "integrable f"
9.1074 -  shows "M1.almost_everywhere (\<lambda>x. M2.integrable (\<lambda> y. f (x, y)))" (is "?AE")
9.1075 -    and "M1.integral (\<lambda> x. M2.integral (\<lambda> y. f (x, y))) = integral f" (is "?INT")
9.1076 +  assumes f: "integrable P f"
9.1077 +  shows "M1.almost_everywhere (\<lambda>x. integrable M2 (\<lambda> y. f (x, y)))" (is "?AE")
9.1078 +    and "(\<integral>x. (\<integral>y. f (x, y) \<partial>M2) \<partial>M1) = integral\<^isup>L P f" (is "?INT")
9.1079  proof -
9.1080    let "?pf x" = "Real (f x)" and "?nf x" = "Real (- f x)"
9.1081    have
9.1082      borel: "?nf \<in> borel_measurable P""?pf \<in> borel_measurable P" and
9.1083 -    int: "positive_integral ?nf \<noteq> \<omega>" "positive_integral ?pf \<noteq> \<omega>"
9.1084 +    int: "integral\<^isup>P P ?nf \<noteq> \<omega>" "integral\<^isup>P P ?pf \<noteq> \<omega>"
9.1085      using assms by auto
9.1086 -  have "M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. Real (f (x, y)))) \<noteq> \<omega>"
9.1087 -     "M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>y. Real (- f (x, y)))) \<noteq> \<omega>"
9.1088 +  have "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. Real (f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<omega>"
9.1089 +     "(\<integral>\<^isup>+x. (\<integral>\<^isup>+y. Real (- f (x, y)) \<partial>M2) \<partial>M1) \<noteq> \<omega>"
9.1090      using borel[THEN positive_integral_fst_measurable(1)] int
9.1091      unfolding borel[THEN positive_integral_fst_measurable(2)] by simp_all
9.1092    with borel[THEN positive_integral_fst_measurable(1)]
9.1093 -  have AE: "M1.almost_everywhere (\<lambda>x. M2.positive_integral (\<lambda>y. Real (f (x, y))) \<noteq> \<omega>)"
9.1094 -    "M1.almost_everywhere (\<lambda>x. M2.positive_integral (\<lambda>y. Real (- f (x, y))) \<noteq> \<omega>)"
9.1095 +  have AE: "M1.almost_everywhere (\<lambda>x. (\<integral>\<^isup>+y. Real (f (x, y)) \<partial>M2) \<noteq> \<omega>)"
9.1096 +    "M1.almost_everywhere (\<lambda>x. (\<integral>\<^isup>+y. Real (- f (x, y)) \<partial>M2) \<noteq> \<omega>)"
9.1097      by (auto intro!: M1.positive_integral_omega_AE)
9.1098    then show ?AE
9.1099      apply (rule M1.AE_mp[OF _ M1.AE_mp])
9.1100      apply (rule M1.AE_cong)
9.1101 -    using assms unfolding M2.integrable_def
9.1102 +    using assms unfolding integrable_def
9.1103      by (auto intro!: measurable_pair_image_snd)
9.1104 -  have "M1.integrable
9.1105 -     (\<lambda>x. real (M2.positive_integral (\<lambda>xa. Real (f (x, xa)))))" (is "M1.integrable ?f")
9.1106 -  proof (unfold M1.integrable_def, intro conjI)
9.1107 +  have "integrable M1 (\<lambda>x. real (\<integral>\<^isup>+y. Real (f (x, y)) \<partial>M2))" (is "integrable M1 ?f")
9.1108 +  proof (intro integrable_def[THEN iffD2] conjI)
9.1109      show "?f \<in> borel_measurable M1"
9.1110        using borel by (auto intro!: M1.borel_measurable_real positive_integral_fst_measurable)
9.1111 -    have "M1.positive_integral (\<lambda>x. Real (?f x)) =
9.1112 -        M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>xa. Real (f (x, xa))))"
9.1113 +    have "(\<integral>\<^isup>+x. Real (?f x) \<partial>M1) = (\<integral>\<^isup>+x. (\<integral>\<^isup>+y. Real (f (x, y))  \<partial>M2) \<partial>M1)"
9.1114        apply (rule M1.positive_integral_cong_AE)
9.1115        apply (rule M1.AE_mp[OF AE(1)])
9.1116        apply (rule M1.AE_cong)
9.1117        by (auto simp: Real_real)
9.1118 -    then show "M1.positive_integral (\<lambda>x. Real (?f x)) \<noteq> \<omega>"
9.1119 +    then show "(\<integral>\<^isup>+x. Real (?f x) \<partial>M1) \<noteq> \<omega>"
9.1120        using positive_integral_fst_measurable[OF borel(2)] int by simp
9.1121 -    have "M1.positive_integral (\<lambda>x. Real (- ?f x)) = M1.positive_integral (\<lambda>x. 0)"
9.1122 +    have "(\<integral>\<^isup>+x. Real (- ?f x) \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
9.1123        by (intro M1.positive_integral_cong) simp
9.1124 -    then show "M1.positive_integral (\<lambda>x. Real (- ?f x)) \<noteq> \<omega>" by simp
9.1125 +    then show "(\<integral>\<^isup>+x. Real (- ?f x) \<partial>M1) \<noteq> \<omega>" by simp
9.1126    qed
9.1127 -  moreover have "M1.integrable
9.1128 -     (\<lambda>x. real (M2.positive_integral (\<lambda>xa. Real (- f (x, xa)))))" (is "M1.integrable ?f")
9.1129 -  proof (unfold M1.integrable_def, intro conjI)
9.1130 +  moreover have "integrable M1 (\<lambda>x. real (\<integral>\<^isup>+ y. Real (- f (x, y)) \<partial>M2))"
9.1131 +    (is "integrable M1 ?f")
9.1132 +  proof (intro integrable_def[THEN iffD2] conjI)
9.1133      show "?f \<in> borel_measurable M1"
9.1134        using borel by (auto intro!: M1.borel_measurable_real positive_integral_fst_measurable)
9.1135 -    have "M1.positive_integral (\<lambda>x. Real (?f x)) =
9.1136 -        M1.positive_integral (\<lambda>x. M2.positive_integral (\<lambda>xa. Real (- f (x, xa))))"
9.1137 +    have "(\<integral>\<^isup>+x. Real (?f x) \<partial>M1) = (\<integral>\<^isup>+x. (\<integral>\<^isup>+y. Real (- f (x, y))  \<partial>M2) \<partial>M1)"
9.1138        apply (rule M1.positive_integral_cong_AE)
9.1139        apply (rule M1.AE_mp[OF AE(2)])
9.1140        apply (rule M1.AE_cong)
9.1141        by (auto simp: Real_real)
9.1142 -    then show "M1.positive_integral (\<lambda>x. Real (?f x)) \<noteq> \<omega>"
9.1143 +    then show "(\<integral>\<^isup>+x. Real (?f x) \<partial>M1) \<noteq> \<omega>"
9.1144        using positive_integral_fst_measurable[OF borel(1)] int by simp
9.1145 -    have "M1.positive_integral (\<lambda>x. Real (- ?f x)) = M1.positive_integral (\<lambda>x. 0)"
9.1146 +    have "(\<integral>\<^isup>+x. Real (- ?f x) \<partial>M1) = (\<integral>\<^isup>+x. 0 \<partial>M1)"
9.1147        by (intro M1.positive_integral_cong) simp
9.1148 -    then show "M1.positive_integral (\<lambda>x. Real (- ?f x)) \<noteq> \<omega>" by simp
9.1149 +    then show "(\<integral>\<^isup>+x. Real (- ?f x) \<partial>M1) \<noteq> \<omega>" by simp
9.1150    qed
9.1151    ultimately show ?INT
9.1152 -    unfolding M2.integral_def integral_def
9.1153 +    unfolding lebesgue_integral_def[of P] lebesgue_integral_def[of M2]
9.1154        borel[THEN positive_integral_fst_measurable(2), symmetric]
9.1155      by (simp add: M1.integral_real[OF AE(1)] M1.integral_real[OF AE(2)])
9.1156  qed
9.1157
9.1158  lemma (in pair_sigma_finite) integrable_snd_measurable:
9.1159 -  assumes f: "integrable f"
9.1160 -  shows "M2.almost_everywhere (\<lambda>y. M1.integrable (\<lambda>x. f (x, y)))" (is "?AE")
9.1161 -    and "M2.integral (\<lambda>y. M1.integral (\<lambda>x. f (x, y))) = integral f" (is "?INT")
9.1162 +  assumes f: "integrable P f"
9.1163 +  shows "M2.almost_everywhere (\<lambda>y. integrable M1 (\<lambda>x. f (x, y)))" (is "?AE")
9.1164 +    and "(\<integral>y. (\<integral>x. f (x, y) \<partial>M1) \<partial>M2) = integral\<^isup>L P f" (is "?INT")
9.1165  proof -
9.1166 -  interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
9.1167 -  have Q_int: "Q.integrable (\<lambda>(x, y). f (y, x))"
9.1168 +  interpret Q: pair_sigma_finite M2 M1 by default
9.1169 +  have Q_int: "integrable Q.P (\<lambda>(x, y). f (y, x))"
9.1170      using f unfolding integrable_product_swap_iff .
9.1171    show ?INT
9.1172      using Q.integrable_fst_measurable(2)[OF Q_int]
9.1173 @@ -986,9 +1120,8 @@
9.1174  qed
9.1175
9.1176  lemma (in pair_sigma_finite) Fubini_integral:
9.1177 -  assumes f: "integrable f"
9.1178 -  shows "M2.integral (\<lambda>y. M1.integral (\<lambda>x. f (x, y))) =
9.1179 -      M1.integral (\<lambda>x. M2.integral (\<lambda>y. f (x, y)))"
9.1180 +  assumes f: "integrable P f"
9.1181 +  shows "(\<integral>y. (\<integral>x. f (x, y) \<partial>M1) \<partial>M2) = (\<integral>x. (\<integral>y. f (x, y) \<partial>M2) \<partial>M1)"
9.1182    unfolding integrable_snd_measurable[OF assms]
9.1183    unfolding integrable_fst_measurable[OF assms] ..
9.1184
9.1185 @@ -997,291 +1130,140 @@
9.1186  section "Products"
9.1187
9.1188  locale product_sigma_algebra =
9.1189 -  fixes M :: "'i \<Rightarrow> 'a algebra"
9.1190 +  fixes M :: "'i \<Rightarrow> ('a, 'b) measure_space_scheme"
9.1191    assumes sigma_algebras: "\<And>i. sigma_algebra (M i)"
9.1192
9.1193 -locale finite_product_sigma_algebra = product_sigma_algebra M for M :: "'i \<Rightarrow> 'a algebra" +
9.1194 +locale finite_product_sigma_algebra = product_sigma_algebra M
9.1195 +  for M :: "'i \<Rightarrow> ('a, 'b) measure_space_scheme" +
9.1196    fixes I :: "'i set"
9.1197    assumes finite_index: "finite I"
9.1198
9.1199 +definition
9.1200 +  "product_algebra_generator I M = \<lparr> space = (\<Pi>\<^isub>E i \<in> I. space (M i)),
9.1201 +    sets = Pi\<^isub>E I  (\<Pi> i \<in> I. sets (M i)),
9.1202 +    measure = \<lambda>A. (\<Prod>i\<in>I. measure (M i) ((SOME F. A = Pi\<^isub>E I F) i)) \<rparr>"
9.1203 +
9.1204 +definition product_algebra_def:
9.1205 +  "Pi\<^isub>M I M = sigma (product_algebra_generator I M)
9.1206 +    \<lparr> measure := (SOME \<mu>. sigma_finite_measure (sigma (product_algebra_generator I M) \<lparr> measure := \<mu> \<rparr>) \<and>
9.1207 +      (\<forall>A\<in>\<Pi> i\<in>I. sets (M i). \<mu> (Pi\<^isub>E I A) = (\<Prod>i\<in>I. measure (M i) (A i))))\<rparr>"
9.1208 +
9.1209  syntax
9.1210 -  "_PiE"  :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3PIE _:_./ _)" 10)
9.1211 +  "_PiM"  :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
9.1212 +              ('i => 'a, 'b) measure_space_scheme"  ("(3PIM _:_./ _)" 10)
9.1213
9.1214  syntax (xsymbols)
9.1215 -  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
9.1216 +  "_PiM" :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
9.1217 +             ('i => 'a, 'b) measure_space_scheme"  ("(3\<Pi>\<^isub>M _\<in>_./ _)"   10)
9.1218
9.1219  syntax (HTML output)
9.1220 -  "_PiE" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>\<^isub>E _\<in>_./ _)"   10)
9.1221 +  "_PiM" :: "[pttrn, 'i set, ('a, 'b) measure_space_scheme] =>
9.1222 +             ('i => 'a, 'b) measure_space_scheme"  ("(3\<Pi>\<^isub>M _\<in>_./ _)"   10)
9.1223
9.1224  translations
9.1225 -  "PIE x:A. B" == "CONST Pi\<^isub>E A (%x. B)"
9.1226 +  "PIM x:I. M" == "CONST Pi\<^isub>M I (%x. M)"
9.1227
9.1228 -definition
9.1229 -  "product_algebra M I = \<lparr> space = (\<Pi>\<^isub>E i\<in>I. space (M i)), sets = Pi\<^isub>E I  (\<Pi> i \<in> I. sets (M i)) \<rparr>"
9.1230 -
9.1231 -abbreviation (in finite_product_sigma_algebra) "G \<equiv> product_algebra M I"
9.1232 -abbreviation (in finite_product_sigma_algebra) "P \<equiv> sigma G"
9.1233 +abbreviation (in finite_product_sigma_algebra) "G \<equiv> product_algebra_generator I M"
9.1234 +abbreviation (in finite_product_sigma_algebra) "P \<equiv> Pi\<^isub>M I M"
9.1235
9.1236  sublocale product_sigma_algebra \<subseteq> M: sigma_algebra "M i" for i by (rule sigma_algebras)
9.1237
9.1238 -lemma (in finite_product_sigma_algebra) product_algebra_into_space:
9.1239 -  "sets G \<subseteq> Pow (space G)"
9.1240 -  using M.sets_into_space unfolding product_algebra_def
9.1241 +lemma sigma_into_space:
9.1242 +  assumes "sets M \<subseteq> Pow (space M)"
9.1243 +  shows "sets (sigma M) \<subseteq> Pow (space M)"
9.1244 +  using sigma_sets_into_sp[OF assms] unfolding sigma_def by auto
9.1245 +
9.1246 +lemma (in product_sigma_algebra) product_algebra_generator_into_space:
9.1247 +  "sets (product_algebra_generator I M) \<subseteq> Pow (space (product_algebra_generator I M))"
9.1248 +  using M.sets_into_space unfolding product_algebra_generator_def
9.1249    by auto blast
9.1250
9.1251 +lemma (in product_sigma_algebra) product_algebra_into_space:
9.1252 +  "sets (Pi\<^isub>M I M) \<subseteq> Pow (space (Pi\<^isub>M I M))"
9.1253 +  using product_algebra_generator_into_space
9.1254 +  by (auto intro!: sigma_into_space simp add: product_algebra_def)
9.1255 +
9.1256 +lemma (in product_sigma_algebra) sigma_algebra_product_algebra: "sigma_algebra (Pi\<^isub>M I M)"
9.1257 +  using product_algebra_generator_into_space unfolding product_algebra_def
9.1258 +  by (rule sigma_algebra.sigma_algebra_cong[OF sigma_algebra_sigma]) simp_all
9.1259 +
9.1260  sublocale finite_product_sigma_algebra \<subseteq> sigma_algebra P
9.1261 -  using product_algebra_into_space by (rule sigma_algebra_sigma)
9.1262 +  using sigma_algebra_product_algebra .
9.1263
9.1264  lemma product_algebraE:
9.1265 -  assumes "A \<in> sets (product_algebra M I)"
9.1266 +  assumes "A \<in> sets (product_algebra_generator I M)"
9.1267    obtains E where "A = Pi\<^isub>E I E" "E \<in> (\<Pi> i\<in>I. sets (M i))"
9.1268 -  using assms unfolding product_algebra_def by auto
9.1269 +  using assms unfolding product_algebra_generator_def by auto
9.1270
9.1271 -lemma product_algebraI[intro]:
9.1272 +lemma product_algebra_generatorI[intro]:
9.1273    assumes "E \<in> (\<Pi> i\<in>I. sets (M i))"
9.1274 -  shows "Pi\<^isub>E I E \<in> sets (product_algebra M I)"
9.1275 -  using assms unfolding product_algebra_def by auto
9.1276 +  shows "Pi\<^isub>E I E \<in> sets (product_algebra_generator I M)"
9.1277 +  using assms unfolding product_algebra_generator_def by auto
9.1278 +
9.1279 +lemma space_product_algebra_generator[simp]:
9.1280 +  "space (product_algebra_generator I M) = Pi\<^isub>E I (\<lambda>i. space (M i))"
9.1281 +  unfolding product_algebra_generator_def by simp
9.1282
9.1283  lemma space_product_algebra[simp]:
9.1284 -  "space (product_algebra M I) = Pi\<^isub>E I (\<lambda>i. space (M i))"
9.1285 -  unfolding product_algebra_def by simp
9.1286 +  "space (Pi\<^isub>M I M) = (\<Pi>\<^isub>E i\<in>I. space (M i))"
9.1287 +  unfolding product_algebra_def product_algebra_generator_def by simp
9.1288
9.1289 -lemma product_algebra_sets_into_space:
9.1290 +lemma sets_product_algebra:
9.1291 +  "sets (Pi\<^isub>M I M) = sets (sigma (product_algebra_generator I M))"
9.1292 +  unfolding product_algebra_def sigma_def by simp
9.1293 +
9.1294 +lemma product_algebra_generator_sets_into_space:
9.1295    assumes "\<And>i. i\<in>I \<Longrightarrow> sets (M i) \<subseteq> Pow (space (M i))"
9.1296 -  shows "sets (product_algebra M I) \<subseteq> Pow (space (product_algebra M I))"
9.1297 -  using assms by (auto simp: product_algebra_def) blast
9.1298 -
9.1299 -lemma (in finite_product_sigma_algebra) P_empty:
9.1300 -  "I = {} \<Longrightarrow> P = \<lparr> space = {\<lambda>k. undefined}, sets = { {}, {\<lambda>k. undefined} }\<rparr>"
9.1301 -  unfolding product_algebra_def by (simp add: sigma_def image_constant)
9.1302 +  shows "sets (product_algebra_generator I M) \<subseteq> Pow (space (product_algebra_generator I M))"
9.1303 +  using assms by (auto simp: product_algebra_generator_def) blast
9.1304
9.1305  lemma (in finite_product_sigma_algebra) in_P[simp, intro]:
9.1306    "\<lbrakk> \<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (M i) \<rbrakk> \<Longrightarrow> Pi\<^isub>E I A \<in> sets P"
9.1307 -  by (auto simp: product_algebra_def sets_sigma intro!: sigma_sets.Basic)
9.1308 -
9.1309 -lemma (in product_sigma_algebra) bij_inv_restrict_merge:
9.1310 -  assumes [simp]: "I \<inter> J = {}"
9.1311 -  shows "bij_inv
9.1312 -    (space (sigma (product_algebra M (I \<union> J))))
9.1313 -    (space (sigma (pair_algebra (product_algebra M I) (product_algebra M J))))
9.1314 -    (\<lambda>x. (restrict x I, restrict x J)) (\<lambda>(x, y). merge I x J y)"
9.1315 -  by (rule bij_invI) (auto simp: space_pair_algebra extensional_restrict)
9.1316 -
9.1317 -lemma (in product_sigma_algebra) bij_inv_singleton:
9.1318 -  "bij_inv (space (sigma (product_algebra M {i}))) (space (M i))
9.1319 -    (\<lambda>x. x i) (\<lambda>x. (\<lambda>j\<in>{i}. x))"
9.1320 -  by (rule bij_invI) (auto simp: restrict_def extensional_def fun_eq_iff)
9.1321 -
9.1322 -lemma (in product_sigma_algebra) bij_inv_restrict_insert:
9.1323 -  assumes [simp]: "i \<notin> I"
9.1324 -  shows "bij_inv
9.1325 -    (space (sigma (product_algebra M (insert i I))))
9.1326 -    (space (sigma (pair_algebra (product_algebra M I) (M i))))
9.1327 -    (\<lambda>x. (restrict x I, x i)) (\<lambda>(x, y). x(i := y))"
9.1328 -  by (rule bij_invI) (auto simp: space_pair_algebra extensional_restrict)
9.1329 -
9.1330 -lemma (in product_sigma_algebra) measurable_restrict_on_generating:
9.1331 -  assumes [simp]: "I \<inter> J = {}"
9.1332 -  shows "(\<lambda>x. (restrict x I, restrict x J)) \<in> measurable
9.1333 -    (product_algebra M (I \<union> J))
9.1334 -    (pair_algebra (product_algebra M I) (product_algebra M J))"
9.1335 -    (is "?R \<in> measurable ?IJ ?P")
9.1336 -proof (unfold measurable_def, intro CollectI conjI ballI)
9.1337 -  show "?R \<in> space ?IJ \<rightarrow> space ?P" by (auto simp: space_pair_algebra)
9.1338 -  { fix F E assume "E \<in> (\<Pi> i\<in>I. sets (M i))" "F \<in> (\<Pi> i\<in>J. sets (M i))"
9.1339 -    then have "Pi (I \<union> J) (merge I E J F) \<inter> (\<Pi>\<^isub>E i\<in>I \<union> J. space (M i)) =
9.1340 -        Pi\<^isub>E (I \<union> J) (merge I E J F)"
9.1341 -      using M.sets_into_space by auto blast+ }
9.1342 -  note this[simp]
9.1343 -  show "\<And>A. A \<in> sets ?P \<Longrightarrow> ?R - A \<inter> space ?IJ \<in> sets ?IJ"
9.1344 -    by (force elim!: pair_algebraE product_algebraE
9.1345 -              simp del: vimage_Int simp: restrict_vimage merge_vimage space_pair_algebra)
9.1346 -  qed
9.1347 -
9.1348 -lemma (in product_sigma_algebra) measurable_merge_on_generating:
9.1349 -  assumes [simp]: "I \<inter> J = {}"
9.1350 -  shows "(\<lambda>(x, y). merge I x J y) \<in> measurable
9.1351 -    (pair_algebra (product_algebra M I) (product_algebra M J))
9.1352 -    (product_algebra M (I \<union> J))"
9.1353 -    (is "?M \<in> measurable ?P ?IJ")
9.1354 -proof (unfold measurable_def, intro CollectI conjI ballI)
9.1355 -  show "?M \<in> space ?P \<rightarrow> space ?IJ" by (auto sim`