author hoelzl Wed, 01 Dec 2010 21:03:02 +0100 changeset 40871 688f6ff859e1 parent 40870 94427db32392 child 40872 7c556a9240de
Generalized simple_functionD and less_SUP_iff. Moved theorems to appropriate places.
```--- a/src/HOL/Probability/Complete_Measure.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Complete_Measure.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -189,56 +189,13 @@
qed
qed

-lemma (in sigma_algebra) simple_functionD':
-  assumes "simple_function f"
-  shows "f -` {x} \<inter> space M \<in> sets M"
-proof cases
-  assume "x \<in> f`space M" from simple_functionD(2)[OF assms this] show ?thesis .
-next
-  assume "x \<notin> f`space M" then have "f -` {x} \<inter> space M = {}" by auto
-  then show ?thesis by auto
-qed
-
-lemma (in sigma_algebra) simple_function_If:
-  assumes sf: "simple_function f" "simple_function g" and A: "A \<in> sets M"
-  shows "simple_function (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function ?IF")
-proof -
-  def F \<equiv> "\<lambda>x. f -` {x} \<inter> space M" and G \<equiv> "\<lambda>x. g -` {x} \<inter> space M"
-  show ?thesis unfolding simple_function_def
-  proof safe
-    have "?IF ` space M \<subseteq> f ` space M \<union> g ` space M" by auto
-    from finite_subset[OF this] assms
-    show "finite (?IF ` space M)" unfolding simple_function_def by auto
-  next
-    fix x assume "x \<in> space M"
-    then have *: "?IF -` {?IF x} \<inter> space M = (if x \<in> A
-      then ((F (f x) \<inter> A) \<union> (G (f x) - (G (f x) \<inter> A)))
-      else ((F (g x) \<inter> A) \<union> (G (g x) - (G (g x) \<inter> A))))"
-      using sets_into_space[OF A] by (auto split: split_if_asm simp: G_def F_def)
-    have [intro]: "\<And>x. F x \<in> sets M" "\<And>x. G x \<in> sets M"
-      unfolding F_def G_def using sf[THEN simple_functionD'] by auto
-    show "?IF -` {?IF x} \<inter> space M \<in> sets M" unfolding * using A by auto
-  qed
-qed
-
-lemma (in measure_space) null_sets_finite_UN:
-  assumes "finite S" "\<And>i. i \<in> S \<Longrightarrow> A i \<in> null_sets"
-  shows "(\<Union>i\<in>S. A i) \<in> null_sets"
-proof (intro CollectI conjI)
-  show "(\<Union>i\<in>S. A i) \<in> sets M" using assms by (intro finite_UN) auto
-  have "\<mu> (\<Union>i\<in>S. A i) \<le> (\<Sum>i\<in>S. \<mu> (A i))"
-    using assms by (intro measure_finitely_subadditive) auto
-  then show "\<mu> (\<Union>i\<in>S. A i) = 0"
-    using assms by auto
-qed
-
lemma (in completeable_measure_space) completion_ex_simple_function:
assumes f: "completion.simple_function f"
shows "\<exists>f'. simple_function f' \<and> (AE x. f x = f' x)"
proof -
let "?F x" = "f -` {x} \<inter> space M"
have F: "\<And>x. ?F x \<in> sets completion" and fin: "finite (f`space M)"
-    using completion.simple_functionD'[OF f]
+    using completion.simple_functionD[OF f]
completion.simple_functionD[OF f] by simp_all
have "\<forall>x. \<exists>N. N \<in> null_sets \<and> null_part (?F x) \<subseteq> N"
using F null_part by auto```
```--- a/src/HOL/Probability/Lebesgue_Integration.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Lebesgue_Integration.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -6,20 +6,6 @@
imports Measure Borel_Space
begin

-lemma image_set_cong:
-  assumes A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y\<in>B. f x = g y"
-  assumes B: "\<And>y. y \<in> B \<Longrightarrow> \<exists>x\<in>A. g y = f x"
-  shows "f ` A = g ` B"
-proof safe
-  fix x assume "x \<in> A"
-  with A obtain y where "f x = g y" "y \<in> B" by auto
-  then show "f x \<in> g ` B" by auto
-next
-  fix y assume "y \<in> B"
-  with B obtain x where "g y = f x" "x \<in> A" by auto
-  then show "g y \<in> f ` A" by auto
-qed
-
lemma sums_If_finite:
assumes finite: "finite {r. P r}"
shows "(\<lambda>r. if P r then f r else 0) sums (\<Sum>r\<in>{r. P r}. f r)" (is "?F sums _")
@@ -57,9 +43,20 @@

lemma (in sigma_algebra) simple_functionD:
assumes "simple_function g"
-  shows "finite (g ` space M)"
-  "x \<in> g ` space M \<Longrightarrow> g -` {x} \<inter> space M \<in> sets M"
-  using assms unfolding simple_function_def by auto
+  shows "finite (g ` space M)" and "g -` {x} \<inter> space M \<in> sets M"
+proof -
+  show "finite (g ` space M)"
+    using assms unfolding simple_function_def by auto
+  show "g -` {x} \<inter> space M \<in> sets M"
+  proof cases
+    assume "x \<in> g`space M" then show ?thesis
+      using assms unfolding simple_function_def by auto
+  next
+    assume "x \<notin> g`space M"
+    then have "g -` {x} \<inter> space M = {}" by auto
+    then show ?thesis by auto
+  qed
+qed

lemma (in sigma_algebra) simple_function_indicator_representation:
fixes f ::"'a \<Rightarrow> pinfreal"
@@ -516,9 +513,7 @@
proof -
interpret v: measure_space M \<nu>
by (rule measure_space_cong) fact
-  have "\<And>x. x \<in> space M \<Longrightarrow> f -` {f x} \<inter> space M \<in> sets M"
-    using `simple_function f`[THEN simple_functionD(2)] by auto
-  with assms show ?thesis
+  from simple_functionD[OF `simple_function f`] assms show ?thesis
unfolding simple_integral_def v.simple_integral_def
by (auto intro!: setsum_cong)
qed
@@ -629,6 +624,28 @@
by (auto simp: setsum_right_distrib field_simps intro!: setsum_cong)
qed

+lemma (in sigma_algebra) simple_function_If:
+  assumes sf: "simple_function f" "simple_function g" and A: "A \<in> sets M"
+  shows "simple_function (\<lambda>x. if x \<in> A then f x else g x)" (is "simple_function ?IF")
+proof -
+  def F \<equiv> "\<lambda>x. f -` {x} \<inter> space M" and G \<equiv> "\<lambda>x. g -` {x} \<inter> space M"
+  show ?thesis unfolding simple_function_def
+  proof safe
+    have "?IF ` space M \<subseteq> f ` space M \<union> g ` space M" by auto
+    from finite_subset[OF this] assms
+    show "finite (?IF ` space M)" unfolding simple_function_def by auto
+  next
+    fix x assume "x \<in> space M"
+    then have *: "?IF -` {?IF x} \<inter> space M = (if x \<in> A
+      then ((F (f x) \<inter> A) \<union> (G (f x) - (G (f x) \<inter> A)))
+      else ((F (g x) \<inter> A) \<union> (G (g x) - (G (g x) \<inter> A))))"
+      using sets_into_space[OF A] by (auto split: split_if_asm simp: G_def F_def)
+    have [intro]: "\<And>x. F x \<in> sets M" "\<And>x. G x \<in> sets M"
+      unfolding F_def G_def using sf[THEN simple_functionD(2)] by auto
+    show "?IF -` {?IF x} \<inter> space M \<in> sets M" unfolding * using A by auto
+  qed
+qed
+
lemma (in measure_space) simple_integral_mono_AE:
assumes "simple_function f" and "simple_function g"
and mono: "AE x. f x \<le> g x"
@@ -652,8 +669,8 @@
obtain N where N: "{x\<in>space M. \<not> f x \<le> g x} \<subseteq> N" "N \<in> sets M" "\<mu> N = 0"
using mono by (auto elim!: AE_E)
have "?S x \<subseteq> N" using N `x \<in> space M` False by auto
-      moreover have "?S x \<in> sets M" using assms `x \<in> space M`
-        by (rule_tac Int) (auto intro!: simple_functionD(2))
+      moreover have "?S x \<in> sets M" using assms
+        by (rule_tac Int) (auto intro!: simple_functionD)
ultimately have "\<mu> (?S x) \<le> \<mu> N"
using `N \<in> sets M` by (auto intro!: measure_mono)
then show ?thesis using `\<mu> N = 0` by auto
@@ -1008,6 +1025,12 @@
shows "positive_integral u \<le> positive_integral v"
using mono by (auto intro!: AE_cong positive_integral_mono_AE)

+lemma image_set_cong:
+  assumes A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y\<in>B. f x = g y"
+  assumes B: "\<And>y. y \<in> B \<Longrightarrow> \<exists>x\<in>A. g y = f x"
+  shows "f ` A = g ` B"
+  using assms by blast
+
lemma (in measure_space) positive_integral_vimage:
fixes g :: "'a \<Rightarrow> pinfreal" and f :: "'d \<Rightarrow> 'a"
assumes f: "bij_betw f S (space M)"
@@ -1030,6 +1053,7 @@

from simple_integral_vimage[OF assms, symmetric]
have *: "simple_integral = T.simple_integral \<circ> (\<lambda>g. g \<circ> f)" by (simp add: comp_def)
+
show ?thesis
unfolding positive_integral_alt1 T.positive_integral_alt1 SUPR_def * image_compose
proof (safe intro!: arg_cong[where f=Sup] image_set_cong, simp_all add: comp_def)```
```--- a/src/HOL/Probability/Lebesgue_Measure.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Lebesgue_Measure.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -4,89 +4,6 @@
imports Product_Measure Gauge_Measure Complete_Measure
begin

-lemma (in complete_lattice) SUP_pair:
-  "(SUP i:A. SUP j:B. f i j) = (SUP p:A\<times>B. (\<lambda> (i, j). f i j) p)" (is "?l = ?r")
-proof (intro antisym SUP_leI)
-  fix i j assume "i \<in> A" "j \<in> B"
-  then have "(case (i,j) of (i,j) \<Rightarrow> f i j) \<le> ?r"
-    by (intro SUPR_upper) auto
-  then show "f i j \<le> ?r" by auto
-next
-  fix p assume "p \<in> A \<times> B"
-  then obtain i j where "p = (i,j)" "i \<in> A" "j \<in> B" by auto
-  have "f i j \<le> (SUP j:B. f i j)" using `j \<in> B` by (intro SUPR_upper)
-  also have "(SUP j:B. f i j) \<le> ?l" using `i \<in> A` by (intro SUPR_upper)
-  finally show "(case p of (i, j) \<Rightarrow> f i j) \<le> ?l" using `p = (i,j)` by simp
-qed
-
-lemma (in complete_lattice) SUP_surj_compose:
-  assumes *: "f`A = B" shows "SUPR A (g \<circ> f) = SUPR B g"
-  unfolding SUPR_def unfolding *[symmetric]
-
-lemma (in complete_lattice) SUP_swap:
-  "(SUP i:A. SUP j:B. f i j) = (SUP j:B. SUP i:A. f i j)"
-proof -
-  have *: "(\<lambda>(i,j). (j,i)) ` (B \<times> A) = A \<times> B" by auto
-  show ?thesis
-    unfolding SUP_pair SUP_surj_compose[symmetric, OF *]
-    by (auto intro!: arg_cong[where f=Sup] image_eqI simp: comp_def SUPR_def)
-qed
-
-lemma SUP_\<omega>: "(SUP i:A. f i) = \<omega> \<longleftrightarrow> (\<forall>x<\<omega>. \<exists>i\<in>A. x < f i)"
-proof
-  assume *: "(SUP i:A. f i) = \<omega>"
-  show "(\<forall>x<\<omega>. \<exists>i\<in>A. x < f i)" unfolding *[symmetric]
-  proof (intro allI impI)
-    fix x assume "x < SUPR A f" then show "\<exists>i\<in>A. x < f i"
-      unfolding less_SUP_iff by auto
-  qed
-next
-  assume *: "\<forall>x<\<omega>. \<exists>i\<in>A. x < f i"
-  show "(SUP i:A. f i) = \<omega>"
-  proof (rule pinfreal_SUPI)
-    fix y assume **: "\<And>i. i \<in> A \<Longrightarrow> f i \<le> y"
-    show "\<omega> \<le> y"
-    proof cases
-      assume "y < \<omega>"
-      from *[THEN spec, THEN mp, OF this]
-      obtain i where "i \<in> A" "\<not> (f i \<le> y)" by auto
-      with ** show ?thesis by auto
-    qed auto
-  qed auto
-qed
-
-lemma psuminf_commute:
-  shows "(\<Sum>\<^isub>\<infinity> i j. f i j) = (\<Sum>\<^isub>\<infinity> j i. f i j)"
-proof -
-  have "(SUP n. \<Sum> i < n. SUP m. \<Sum> j < m. f i j) = (SUP n. SUP m. \<Sum> i < n. \<Sum> j < m. f i j)"
-    apply (subst SUPR_pinfreal_setsum)
-    by auto
-  also have "\<dots> = (SUP m n. \<Sum> j < m. \<Sum> i < n. f i j)"
-    apply (subst SUP_swap)
-    apply (subst setsum_commute)
-    by auto
-  also have "\<dots> = (SUP m. \<Sum> j < m. SUP n. \<Sum> i < n. f i j)"
-    apply (subst SUPR_pinfreal_setsum)
-    by auto
-  finally show ?thesis
-    unfolding psuminf_def by auto
-qed
-
-lemma psuminf_SUP_eq:
-  assumes "\<And>n i. f n i \<le> f (Suc n) i"
-  shows "(\<Sum>\<^isub>\<infinity> i. SUP n::nat. f n i) = (SUP n::nat. \<Sum>\<^isub>\<infinity> i. f n i)"
-proof -
-  { fix n :: nat
-    have "(\<Sum>i<n. SUP k. f k i) = (SUP k. \<Sum>i<n. f k i)"
-      using assms by (auto intro!: SUPR_pinfreal_setsum[symmetric]) }
-  note * = this
-  show ?thesis
-    unfolding psuminf_def
-    unfolding *
-    apply (subst SUP_swap) ..
-qed
-
subsection {* Standard Cubes *}

definition cube :: "nat \<Rightarrow> 'a::ordered_euclidean_space set" where```
```--- a/src/HOL/Probability/Measure.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Measure.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -651,27 +651,6 @@

abbreviation (in measure_space) "null_sets \<equiv> {N\<in>sets M. \<mu> N = 0}"

-definition (in measure_space)
-  almost_everywhere :: "('a \<Rightarrow> bool) \<Rightarrow> bool" (binder "AE " 10) where
-  "almost_everywhere P \<longleftrightarrow> (\<exists>N\<in>null_sets. { x \<in> space M. \<not> P x } \<subseteq> N)"
-
-lemma (in measure_space) AE_I':
-  "N \<in> null_sets \<Longrightarrow> {x\<in>space M. \<not> P x} \<subseteq> N \<Longrightarrow> (AE x. P x)"
-  unfolding almost_everywhere_def by auto
-
-lemma (in measure_space) AE_iff_null_set:
-  assumes "{x\<in>space M. \<not> P x} \<in> sets M" (is "?P \<in> sets M")
-  shows "(AE x. P x) \<longleftrightarrow> {x\<in>space M. \<not> P x} \<in> null_sets"
-proof
-  assume "AE x. P x" then obtain N where N: "N \<in> sets M" "?P \<subseteq> N" "\<mu> N = 0"
-    unfolding almost_everywhere_def by auto
-  moreover have "\<mu> ?P \<le> \<mu> N"
-    using assms N(1,2) by (auto intro: measure_mono)
-  ultimately show "?P \<in> null_sets" using assms by auto
-next
-  assume "?P \<in> null_sets" with assms show "AE x. P x" by (auto intro: AE_I')
-qed
-
lemma (in measure_space) null_sets_Un[intro]:
assumes "N \<in> null_sets" "N' \<in> null_sets"
shows "N \<union> N' \<in> null_sets"
@@ -703,6 +682,17 @@
using assms by auto
qed

+lemma (in measure_space) null_sets_finite_UN:
+  assumes "finite S" "\<And>i. i \<in> S \<Longrightarrow> A i \<in> null_sets"
+  shows "(\<Union>i\<in>S. A i) \<in> null_sets"
+proof (intro CollectI conjI)
+  show "(\<Union>i\<in>S. A i) \<in> sets M" using assms by (intro finite_UN) auto
+  have "\<mu> (\<Union>i\<in>S. A i) \<le> (\<Sum>i\<in>S. \<mu> (A i))"
+    using assms by (intro measure_finitely_subadditive) auto
+  then show "\<mu> (\<Union>i\<in>S. A i) = 0"
+    using assms by auto
+qed
+
lemma (in measure_space) null_set_Int1:
assumes "B \<in> null_sets" "A \<in> sets M" shows "A \<inter> B \<in> null_sets"
using assms proof (intro CollectI conjI)
@@ -741,6 +731,29 @@
qed

+section "Formalise almost everywhere"
+
+definition (in measure_space)
+  almost_everywhere :: "('a \<Rightarrow> bool) \<Rightarrow> bool" (binder "AE " 10) where
+  "almost_everywhere P \<longleftrightarrow> (\<exists>N\<in>null_sets. { x \<in> space M. \<not> P x } \<subseteq> N)"
+
+lemma (in measure_space) AE_I':
+  "N \<in> null_sets \<Longrightarrow> {x\<in>space M. \<not> P x} \<subseteq> N \<Longrightarrow> (AE x. P x)"
+  unfolding almost_everywhere_def by auto
+
+lemma (in measure_space) AE_iff_null_set:
+  assumes "{x\<in>space M. \<not> P x} \<in> sets M" (is "?P \<in> sets M")
+  shows "(AE x. P x) \<longleftrightarrow> {x\<in>space M. \<not> P x} \<in> null_sets"
+proof
+  assume "AE x. P x" then obtain N where N: "N \<in> sets M" "?P \<subseteq> N" "\<mu> N = 0"
+    unfolding almost_everywhere_def by auto
+  moreover have "\<mu> ?P \<le> \<mu> N"
+    using assms N(1,2) by (auto intro: measure_mono)
+  ultimately show "?P \<in> null_sets" using assms by auto
+next
+  assume "?P \<in> null_sets" with assms show "AE x. P x" by (auto intro: AE_I')
+qed
+
lemma (in measure_space) AE_True[intro, simp]: "AE x. True"
unfolding almost_everywhere_def by auto

@@ -1409,7 +1422,7 @@
show "\<mu> {x} \<noteq> \<omega>" by (auto simp: insert_absorb[OF *] Diff_subset) }
qed

-sublocale finite_measure_space < finite_measure
+sublocale finite_measure_space \<subseteq> finite_measure
proof
show "\<mu> (space M) \<noteq> \<omega>"
unfolding sum_over_space[symmetric] setsum_\<omega>```
```--- a/src/HOL/Probability/Positive_Infinite_Real.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Positive_Infinite_Real.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -6,6 +6,49 @@
imports Complex_Main Nat_Bijection Multivariate_Analysis
begin

+lemma (in complete_lattice) SUPR_upper:
+  "x \<in> A \<Longrightarrow> f x \<le> SUPR A f"
+  unfolding SUPR_def apply(rule Sup_upper) by auto
+
+lemma (in complete_lattice) SUPR_subset:
+  assumes "A \<subseteq> B" shows "SUPR A f \<le> SUPR B f"
+  apply(rule SUP_leI) apply(rule SUPR_upper) using assms by auto
+
+lemma (in complete_lattice) SUPR_mono:
+  assumes "\<forall>a\<in>A. \<exists>b\<in>B. f b \<ge> f a"
+  shows "SUPR A f \<le> SUPR B f"
+  unfolding SUPR_def apply(rule Sup_mono)
+  using assms by auto
+
+lemma (in complete_lattice) SUP_pair:
+  "(SUP i:A. SUP j:B. f i j) = (SUP p:A\<times>B. (\<lambda> (i, j). f i j) p)" (is "?l = ?r")
+proof (intro antisym SUP_leI)
+  fix i j assume "i \<in> A" "j \<in> B"
+  then have "(case (i,j) of (i,j) \<Rightarrow> f i j) \<le> ?r"
+    by (intro SUPR_upper) auto
+  then show "f i j \<le> ?r" by auto
+next
+  fix p assume "p \<in> A \<times> B"
+  then obtain i j where "p = (i,j)" "i \<in> A" "j \<in> B" by auto
+  have "f i j \<le> (SUP j:B. f i j)" using `j \<in> B` by (intro SUPR_upper)
+  also have "(SUP j:B. f i j) \<le> ?l" using `i \<in> A` by (intro SUPR_upper)
+  finally show "(case p of (i, j) \<Rightarrow> f i j) \<le> ?l" using `p = (i,j)` by simp
+qed
+
+lemma (in complete_lattice) SUP_surj_compose:
+  assumes *: "f`A = B" shows "SUPR A (g \<circ> f) = SUPR B g"
+  unfolding SUPR_def unfolding *[symmetric]
+
+lemma (in complete_lattice) SUP_swap:
+  "(SUP i:A. SUP j:B. f i j) = (SUP j:B. SUP i:A. f i j)"
+proof -
+  have *: "(\<lambda>(i,j). (j,i)) ` (B \<times> A) = A \<times> B" by auto
+  show ?thesis
+    unfolding SUP_pair SUP_surj_compose[symmetric, OF *]
+    by (auto intro!: arg_cong[where f=Sup] image_eqI simp: comp_def SUPR_def)
+qed
+
lemma range_const[simp]: "range (\<lambda>x. c) = {c}" by auto

lemma (in complete_lattice) SUPR_const[simp]: "(SUP i. c) = c"
@@ -549,6 +592,14 @@
lemma pinfreal_of_nat[simp]: "of_nat m = Real (real m)"
by (induct m) (auto simp: real_of_nat_Suc one_pinfreal_def simp del: Real_1)

+lemma less_\<omega>_Ex_of_nat: "x < \<omega> \<longleftrightarrow> (\<exists>n. x < of_nat n)"
+proof safe
+  assume "x < \<omega>"
+  then obtain r where "0 \<le> r" "x = Real r" by (cases x) auto
+  moreover obtain n where "r < of_nat n" using ex_less_of_nat by auto
+  ultimately show "\<exists>n. x < of_nat n" by (auto simp: real_eq_of_nat)
+qed auto
+
lemma real_of_pinfreal_mono:
fixes a b :: pinfreal
assumes "b \<noteq> \<omega>" "a \<le> b"
@@ -831,6 +882,34 @@
qed simp
qed simp

+lemma less_SUP_iff:
+  fixes a :: "'a::{complete_lattice,linorder}"
+  shows "(a < (SUP i:A. f i)) \<longleftrightarrow> (\<exists>x\<in>A. a < f x)"
+  unfolding SUPR_def less_Sup_iff by auto
+
+lemma SUP_\<omega>: "(SUP i:A. f i) = \<omega> \<longleftrightarrow> (\<forall>x<\<omega>. \<exists>i\<in>A. x < f i)"
+proof
+  assume *: "(SUP i:A. f i) = \<omega>"
+  show "(\<forall>x<\<omega>. \<exists>i\<in>A. x < f i)" unfolding *[symmetric]
+  proof (intro allI impI)
+    fix x assume "x < SUPR A f" then show "\<exists>i\<in>A. x < f i"
+      unfolding less_SUP_iff by auto
+  qed
+next
+  assume *: "\<forall>x<\<omega>. \<exists>i\<in>A. x < f i"
+  show "(SUP i:A. f i) = \<omega>"
+  proof (rule pinfreal_SUPI)
+    fix y assume **: "\<And>i. i \<in> A \<Longrightarrow> f i \<le> y"
+    show "\<omega> \<le> y"
+    proof cases
+      assume "y < \<omega>"
+      from *[THEN spec, THEN mp, OF this]
+      obtain i where "i \<in> A" "\<not> (f i \<le> y)" by auto
+      with ** show ?thesis by auto
+    qed auto
+  qed auto
+qed
+
subsubsection {* Equivalence between @{text "f ----> x"} and @{text SUP} on @{typ pinfreal} *}

lemma monoseq_monoI: "mono f \<Longrightarrow> monoseq f"
@@ -1384,6 +1463,37 @@
qed simp
qed simp

+lemma psuminf_SUP_eq:
+  assumes "\<And>n i. f n i \<le> f (Suc n) i"
+  shows "(\<Sum>\<^isub>\<infinity> i. SUP n::nat. f n i) = (SUP n::nat. \<Sum>\<^isub>\<infinity> i. f n i)"
+proof -
+  { fix n :: nat
+    have "(\<Sum>i<n. SUP k. f k i) = (SUP k. \<Sum>i<n. f k i)"
+      using assms by (auto intro!: SUPR_pinfreal_setsum[symmetric]) }
+  note * = this
+  show ?thesis
+    unfolding psuminf_def
+    unfolding *
+    apply (subst SUP_swap) ..
+qed
+
+lemma psuminf_commute:
+  shows "(\<Sum>\<^isub>\<infinity> i j. f i j) = (\<Sum>\<^isub>\<infinity> j i. f i j)"
+proof -
+  have "(SUP n. \<Sum> i < n. SUP m. \<Sum> j < m. f i j) = (SUP n. SUP m. \<Sum> i < n. \<Sum> j < m. f i j)"
+    apply (subst SUPR_pinfreal_setsum)
+    by auto
+  also have "\<dots> = (SUP m n. \<Sum> j < m. \<Sum> i < n. f i j)"
+    apply (subst SUP_swap)
+    apply (subst setsum_commute)
+    by auto
+  also have "\<dots> = (SUP m. \<Sum> j < m. SUP n. \<Sum> i < n. f i j)"
+    apply (subst SUPR_pinfreal_setsum)
+    by auto
+  finally show ?thesis
+    unfolding psuminf_def by auto
+qed
+
lemma Real_max:
assumes "x \<ge> 0" "y \<ge> 0"
shows "Real (max x y) = max (Real x) (Real y)"
@@ -2076,20 +2186,6 @@
lemma real_Real_max:"real (Real x) = max x 0"
unfolding real_Real by auto

-lemma (in complete_lattice) SUPR_upper:
-  "x \<in> A \<Longrightarrow> f x \<le> SUPR A f"
-  unfolding SUPR_def apply(rule Sup_upper) by auto
-
-lemma (in complete_lattice) SUPR_subset:
-  assumes "A \<subseteq> B" shows "SUPR A f \<le> SUPR B f"
-  apply(rule SUP_leI) apply(rule SUPR_upper) using assms by auto
-
-lemma (in complete_lattice) SUPR_mono:
-  assumes "\<forall>a\<in>A. \<exists>b\<in>B. f b \<ge> f a"
-  shows "SUPR A f \<le> SUPR B f"
-  unfolding SUPR_def apply(rule Sup_mono)
-  using assms by auto
-
lemma Sup_lim:
assumes "\<forall>n. b n \<in> s" "b ----> (a::pinfreal)"
shows "a \<le> Sup s"
@@ -2161,11 +2257,6 @@
unfolding Real_real using om by auto
qed qed

-lemma less_SUP_iff:
-  fixes a :: pinfreal
-  shows "(a < (SUP i:A. f i)) \<longleftrightarrow> (\<exists>x\<in>A. a < f x)"
-  unfolding SUPR_def less_Sup_iff by auto
-
lemma Sup_mono_lim:
assumes "\<forall>a\<in>A. \<exists>b. \<forall>n. b n \<in> B \<and> b ----> (a::pinfreal)"
shows "Sup A \<le> Sup B"
@@ -2707,4 +2798,21 @@

lemma lessThan_0_Empty: "{..< 0 :: pinfreal} = {}" by auto

+lemma real_of_pinfreal_inverse[simp]:
+  fixes X :: pinfreal
+  shows "real (inverse X) = 1 / real X"
+  by (cases X) (auto simp: inverse_eq_divide)
+
+lemma real_of_pinfreal_le_0[simp]: "real (X :: pinfreal) \<le> 0 \<longleftrightarrow> (X = 0 \<or> X = \<omega>)"
+  by (cases X) auto
+
+lemma real_of_pinfreal_less_0[simp]: "\<not> (real (X :: pinfreal) < 0)"
+  by (cases X) auto
+
+lemma abs_real_of_pinfreal[simp]: "\<bar>real (X :: pinfreal)\<bar> = real X"
+  by simp
+
+lemma zero_less_real_of_pinfreal: "0 < real (X :: pinfreal) \<longleftrightarrow> X \<noteq> 0 \<and> X \<noteq> \<omega>"
+  by (cases X) auto
+
end```
```--- a/src/HOL/Probability/Product_Measure.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Product_Measure.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -2,28 +2,6 @@
imports Lebesgue_Integration
begin

-lemma in_sigma[intro, simp]: "A \<in> sets M \<Longrightarrow> A \<in> sets (sigma M)"
-  unfolding sigma_def by (auto intro!: sigma_sets.Basic)
-
-lemma (in sigma_algebra) sigma_eq[simp]: "sigma M = M"
-  unfolding sigma_def sigma_sets_eq by simp
-
-lemma vimage_algebra_sigma:
-  assumes E: "sets E \<subseteq> Pow (space E)"
-    and f: "f \<in> space F \<rightarrow> space E"
-    and "\<And>A. A \<in> sets F \<Longrightarrow> A \<in> (\<lambda>X. f -` X \<inter> space F) ` sets E"
-    and "\<And>A. A \<in> sets E \<Longrightarrow> f -` A \<inter> space F \<in> sets F"
-  shows "sigma_algebra.vimage_algebra (sigma E) (space F) f = sigma F"
-proof -
-  interpret sigma_algebra "sigma E"
-    using assms by (intro sigma_algebra_sigma) auto
-  have eq: "sets F = (\<lambda>X. f -` X \<inter> space F) ` sets E"
-    using assms by auto
-  show "vimage_algebra (space F) f = sigma F"
-    unfolding vimage_algebra_def using assms
-    by (simp add: sigma_def eq sigma_sets_vimage)
-qed
-
lemma times_Int_times: "A \<times> B \<inter> C \<times> D = (A \<inter> C) \<times> (B \<inter> D)"
by auto

@@ -786,13 +764,10 @@
positive_integral f"
proof -
interpret Q: pair_sigma_finite M2 \<mu>2 M1 \<mu>1 by default
-
have s: "\<And>x y. (case (x, y) of (x, y) \<Rightarrow> f (y, x)) = f (y, x)" by simp
have t: "(\<lambda>x. f (case x of (x, y) \<Rightarrow> (y, x))) = (\<lambda>(x, y). f (y, x))" by (auto simp: fun_eq_iff)
-
have bij: "bij_betw (\<lambda>(x, y). (y, x)) (space M2 \<times> space M1) (space P)"
by (auto intro!: inj_onI simp: space_pair_algebra bij_betw_def)
-
note pair_sigma_algebra_measurable[OF f]
from Q.positive_integral_fst_measurable[OF this]
have "M2.positive_integral (\<lambda>y. M1.positive_integral (\<lambda>x. f (x, y))) =
@@ -930,7 +905,6 @@
using E1 E2 by (auto simp add: pair_algebra_def)
interpret E: sigma_algebra ?E unfolding pair_algebra_def
using E1 E2 by (intro sigma_algebra_sigma) auto
-
{ fix A assume "A \<in> sets E1"
then have "fst -` A \<inter> space ?E = A \<times> (\<Union>i. S2 i)"
using E1 2 unfolding isoton_def pair_algebra_def by auto
@@ -954,7 +928,6 @@
"fst \<in> measurable ?E (sigma E1) \<and> snd \<in> measurable ?E (sigma E2)"
using E1 E2 by (subst (1 2) E.measurable_iff_sigma)
(auto simp: pair_algebra_def sets_sigma)
-
{ fix A B assume A: "A \<in> sets (sigma E1)" and B: "B \<in> sets (sigma E2)"
with proj have "fst -` A \<inter> space ?E \<in> sets ?E" "snd -` B \<inter> space ?E \<in> sets ?E"
unfolding measurable_def by simp_all
@@ -966,7 +939,6 @@
by (intro E.sigma_sets_subset) (auto simp add: pair_algebra_def sets_sigma)
then have subset: "sets ?S \<subseteq> sets ?E"
-
have "sets ?S = sets ?E"
proof (intro set_eqI iffI)
fix A assume "A \<in> sets ?E" then show "A \<in> sets ?S"
@@ -1304,7 +1276,6 @@
unfolding product_singleton_vimage_algebra_eq[OF `i \<notin> I` `finite I`, symmetric]
using bij_betw_restrict_I_i[OF `i \<notin> I`, of M]
by (intro P.measure_space_isomorphic) auto
-
show ?case
proof (intro exI[of _ ?\<nu>] conjI ballI)
{ fix A assume A: "A \<in> (\<Pi> i\<in>insert i I. sets (M i))"
@@ -1322,7 +1293,6 @@
apply fastsimp
using `i \<notin> I` `finite I` prod[of A] by (auto simp: ac_simps) }
note product = this
-
show "sigma_finite_measure I'.P ?\<nu>"
proof
from I'.sigma_finite_pairs guess F :: "'i \<Rightarrow> nat \<Rightarrow> 'a set" ..
@@ -1455,17 +1425,13 @@
have "finite (I \<union> J)" using fin by auto
interpret IJ: finite_product_sigma_finite M \<mu> "I \<union> J" by default fact
interpret P: pair_sigma_finite I.P I.measure J.P J.measure by default
-
let ?f = "\<lambda>x. ((\<lambda>i\<in>I. x i), (\<lambda>i\<in>J. x i))"
-
have P_borel: "(\<lambda>x. f (case x of (x, y) \<Rightarrow> merge I x J y)) \<in> borel_measurable P.P"
by (subst product_product_vimage_algebra_eq[OF IJ fin, symmetric])
(auto simp: space_pair_algebra intro!: IJ.measurable_vimage f)
-
have split_f_image[simp]: "\<And>F. ?f ` (Pi\<^isub>E (I \<union> J) F) = (Pi\<^isub>E I F) \<times> (Pi\<^isub>E J F)"
apply auto apply (rule_tac x="merge I a J b" in image_eqI)
by (auto dest: extensional_restrict)
-
have "IJ.positive_integral f =  IJ.positive_integral (\<lambda>x. f (restrict x (I \<union> J)))"
by (auto intro!: IJ.positive_integral_cong arg_cong[where f=f] dest!: extensional_restrict)
also have "\<dots> = I.positive_integral (\<lambda>x. J.positive_integral (\<lambda>y. f (merge I x J y)))"```
```--- a/src/HOL/Probability/Radon_Nikodym.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Radon_Nikodym.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -69,6 +69,8 @@
qed
qed

+subsection "Absolutely continuous"
+
definition (in measure_space)
"absolutely_continuous \<nu> = (\<forall>N\<in>null_sets. \<nu> N = (0 :: pinfreal))"

@@ -111,6 +113,14 @@
finally show "\<nu> N = 0" .
qed

+lemma (in measure_space) density_is_absolutely_continuous:
+  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
+  shows "absolutely_continuous \<nu>"
+  using assms unfolding absolutely_continuous_def
+
+subsection "Existence of the Radon-Nikodym derivative"
+
fixes e :: real assumes "0 < e"
assumes "finite_measure M s"
@@ -120,21 +130,17 @@
proof -
let "?d A" = "real (\<mu> A) - real (s A)"
interpret M': finite_measure M s by fact
-
let "?A A" = "if (\<forall>B\<in>sets M. B \<subseteq> space M - A \<longrightarrow> -e < ?d B)
then {}
else (SOME B. B \<in> sets M \<and> B \<subseteq> space M - A \<and> ?d B \<le> -e)"
def A \<equiv> "\<lambda>n. ((\<lambda>B. B \<union> ?A B) ^^ n) {}"
-
have A_simps[simp]:
"A 0 = {}"
"\<And>n. A (Suc n) = (A n \<union> ?A (A n))" unfolding A_def by simp_all
-
{ fix A assume "A \<in> sets M"
have "?A A \<in> sets M"
by (auto intro!: someI2[of _ _ "\<lambda>A. A \<in> sets M"] simp: not_less) }
note A'_in_sets = this
-
{ fix n have "A n \<in> sets M"
proof (induct n)
case (Suc n) thus "A (Suc n) \<in> sets M"
@@ -142,7 +148,6 @@
note A_in_sets = this
hence "range A \<subseteq> sets M" by auto
-
{ fix n B
assume Ex: "\<exists>B. B \<in> sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> -e"
hence False: "\<not> (\<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B)" by (auto simp: not_less)
@@ -156,7 +161,6 @@
finally show "?d (A n \<union> B) \<le> ?d (A n) - e" .
qed }
note dA_epsilon = this
-
{ fix n have "?d (A (Suc n)) \<le> ?d (A n)"
proof (cases "\<exists>B. B\<in>sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e")
case True from dA_epsilon[OF this] show ?thesis using `0 < e` by simp
@@ -166,7 +170,6 @@
thus ?thesis by simp
qed }
note dA_mono = this
-
show ?thesis
proof (cases "\<exists>n. \<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B")
case True then obtain n where B: "\<And>B. \<lbrakk> B \<in> sets M; B \<subseteq> space M - A n\<rbrakk> \<Longrightarrow> -e < ?d B" by blast
@@ -220,11 +223,8 @@
proof -
let "?d A" = "real (\<mu> A) - real (s A)"
let "?P A B n" = "A \<in> sets M \<and> A \<subseteq> B \<and> ?d B \<le> ?d A \<and> (\<forall>C\<in>sets M. C \<subseteq> A \<longrightarrow> - 1 / real (Suc n) < ?d C)"
-
interpret M': finite_measure M s by fact
-
let "?r S" = "restricted_space S"
-
{ fix S n
assume S: "S \<in> sets M"
hence **: "\<And>X. X \<in> op \<inter> S ` sets M \<longleftrightarrow> X \<in> sets M \<and> X \<subseteq> S" by auto
@@ -242,11 +242,9 @@
qed
hence "\<exists>A. ?P A S n" by auto }
note Ex_P = this
-
def A \<equiv> "nat_rec (space M) (\<lambda>n A. SOME B. ?P B A n)"
have A_Suc: "\<And>n. A (Suc n) = (SOME B. ?P B (A n) n)" by (simp add: A_def)
have A_0[simp]: "A 0 = space M" unfolding A_def by simp
-
{ fix i have "A i \<in> sets M" unfolding A_def
proof (induct i)
case (Suc i)
@@ -254,19 +252,15 @@
by (rule someI2_ex) simp
qed simp }
note A_in_sets = this
-
{ fix n have "?P (A (Suc n)) (A n) n"
using Ex_P[OF A_in_sets] unfolding A_Suc
by (rule someI2_ex) simp }
note P_A = this
-
have "range A \<subseteq> sets M" using A_in_sets by auto
-
have A_mono: "\<And>i. A (Suc i) \<subseteq> A i" using P_A by simp
have mono_dA: "mono (\<lambda>i. ?d (A i))" using P_A by (simp add: mono_iff_le_Suc)
have epsilon: "\<And>C i. \<lbrakk> C \<in> sets M; C \<subseteq> A (Suc i) \<rbrakk> \<Longrightarrow> - 1 / real (Suc i) < ?d C"
using P_A by auto
-
show ?thesis
proof (safe intro!: bexI[of _ "\<Inter>i. A i"])
show "(\<Inter>i. A i) \<in> sets M" using A_in_sets by auto
@@ -298,24 +292,19 @@
shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
proof -
interpret M': finite_measure M \<nu> using assms(1) .
-
def G \<equiv> "{g \<in> borel_measurable M. \<forall>A\<in>sets M. positive_integral (\<lambda>x. g x * indicator A x) \<le> \<nu> A}"
have "(\<lambda>x. 0) \<in> G" unfolding G_def by auto
hence "G \<noteq> {}" by auto
-
{ fix f g assume f: "f \<in> G" and g: "g \<in> G"
have "(\<lambda>x. max (g x) (f x)) \<in> G" (is "?max \<in> G") unfolding G_def
proof safe
show "?max \<in> borel_measurable M" using f g unfolding G_def by auto
-
let ?A = "{x \<in> space M. f x \<le> g x}"
have "?A \<in> sets M" using f g unfolding G_def by auto
-
fix A assume "A \<in> sets M"
hence sets: "?A \<inter> A \<in> sets M" "(space M - ?A) \<inter> A \<in> sets M" using `?A \<in> sets M` by auto
have union: "((?A \<inter> A) \<union> ((space M - ?A) \<inter> A)) = A"
using sets_into_space[OF `A \<in> sets M`] by auto
-
have "\<And>x. x \<in> space M \<Longrightarrow> max (g x) (f x) * indicator A x =
g x * indicator (?A \<inter> A) x + f x * indicator ((space M - ?A) \<inter> A) x"
by (auto simp: indicator_def max_def)
@@ -331,14 +320,12 @@
finally show "positive_integral (\<lambda>x. max (g x) (f x) * indicator A x) \<le> \<nu> A" .
qed }
note max_in_G = this
-
{ fix f g assume  "f \<up> g" and f: "\<And>i. f i \<in> G"
have "g \<in> G" unfolding G_def
proof safe
from `f \<up> g` have [simp]: "g = (SUP i. f i)" unfolding isoton_def by simp
have f_borel: "\<And>i. f i \<in> borel_measurable M" using f unfolding G_def by simp
thus "g \<in> borel_measurable M" by (auto intro!: borel_measurable_SUP)
-
fix A assume "A \<in> sets M"
hence "\<And>i. (\<lambda>x. f i x * indicator A x) \<in> borel_measurable M"
using f_borel by (auto intro!: borel_measurable_indicator)
@@ -350,7 +337,6 @@
using f `A \<in> sets M` unfolding G_def by (auto intro!: SUP_leI)
qed }
note SUP_in_G = this
-
let ?y = "SUP g : G. positive_integral g"
have "?y \<le> \<nu> (space M)" unfolding G_def
proof (safe intro!: SUP_leI)
@@ -385,7 +371,6 @@
hence isoton_g: "?g \<up> f" by (simp add: isoton_def le_fun_def f_def)
from SUP_in_G[OF this g_in_G] have "f \<in> G" .
hence [simp, intro]: "f \<in> borel_measurable M" unfolding G_def by auto
-
have "(\<lambda>i. positive_integral (?g i)) \<up> positive_integral f"
using isoton_g g_in_G by (auto intro!: positive_integral_isoton simp: G_def f_def)
hence "positive_integral f = (SUP i. positive_integral (?g i))"
@@ -398,9 +383,7 @@
by (auto intro!: SUP_mono positive_integral_mono Max_ge)
qed
finally have int_f_eq_y: "positive_integral f = ?y" .
-
let "?t A" = "\<nu> A - positive_integral (\<lambda>x. f x * indicator A x)"
-
have "finite_measure M ?t"
proof
show "?t {} = 0" by simp
@@ -435,9 +418,7 @@
qed
qed
then interpret M: finite_measure M ?t .
-
have ac: "absolutely_continuous ?t" using `absolutely_continuous \<nu>` unfolding absolutely_continuous_def by auto
-
have upper_bound: "\<forall>A\<in>sets M. ?t A \<le> 0"
proof (rule ccontr)
assume "\<not> ?thesis"
@@ -460,7 +441,6 @@
ultimately have b: "b \<noteq> 0" "b \<noteq> \<omega>"
using M'.finite_measure_of_space
by (auto simp: pinfreal_inverse_eq_0 finite_measure_of_space)
-
have "finite_measure M (\<lambda>A. b * \<mu> A)" (is "finite_measure M ?b")
proof
show "?b {} = 0" by simp
@@ -469,7 +449,6 @@
qed
-
obtain A0 where "A0 \<in> sets M" and
space_less_A0: "real (?t (space M)) - real (b * \<mu> (space M)) \<le> real (?t A0) - real (b * \<mu> A0)" and
@@ -479,9 +458,7 @@
using M'.finite_measure b finite_measure
by (cases "b * \<mu> B", cases "?t B") (auto simp: field_simps) }
note bM_le_t = this
-
let "?f0 x" = "f x + b * indicator A0 x"
-
{ fix A assume A: "A \<in> sets M"
hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
have "positive_integral (\<lambda>x. ?f0 x  * indicator A x) =
@@ -492,7 +469,6 @@
using `A0 \<in> sets M` `A \<inter> A0 \<in> sets M` A
note f0_eq = this
-
{ fix A assume A: "A \<in> sets M"
hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
have f_le_v: "positive_integral (\<lambda>x. f x * indicator A x) \<le> \<nu> A"
@@ -511,18 +487,15 @@
finally have "positive_integral (\<lambda>x. ?f0 x * indicator A x) \<le> \<nu> A" . }
hence "?f0 \<in> G" using `A0 \<in> sets M` unfolding G_def
by (auto intro!: borel_measurable_indicator borel_measurable_pinfreal_add borel_measurable_pinfreal_times)
-
have real: "?t (space M) \<noteq> \<omega>" "?t A0 \<noteq> \<omega>"
"b * \<mu> (space M) \<noteq> \<omega>" "b * \<mu> A0 \<noteq> \<omega>"
using `A0 \<in> sets M` b
finite_measure[of A0] M.finite_measure[of A0]
finite_measure_of_space M.finite_measure_of_space
by auto
-
have int_f_finite: "positive_integral f \<noteq> \<omega>"
using M'.finite_measure_of_space pos_t unfolding pinfreal_zero_less_diff_iff
by (auto cong: positive_integral_cong)
-
have "?t (space M) > b * \<mu> (space M)" unfolding b_def
apply (subst mult_assoc[symmetric])
@@ -539,18 +512,15 @@
hence "0 < \<mu> A0" using ac unfolding absolutely_continuous_def
using `A0 \<in> sets M` by auto
hence "0 < b * \<mu> A0" using b by auto
-
from int_f_finite this
have "?y + 0 < positive_integral f + b * \<mu> A0" unfolding int_f_eq_y
also have "\<dots> = positive_integral ?f0" using f0_eq[OF top] `A0 \<in> sets M` sets_into_space
by (simp cong: positive_integral_cong)
finally have "?y < positive_integral ?f0" by simp
-
moreover from `?f0 \<in> G` have "positive_integral ?f0 \<le> ?y" by (auto intro!: le_SUPI)
ultimately show False by auto
qed
-
show ?thesis
proof (safe intro!: bexI[of _ f])
fix A assume "A\<in>sets M"
@@ -575,10 +545,8 @@
interpret v: measure_space M \<nu> by fact
let ?Q = "{Q\<in>sets M. \<nu> Q \<noteq> \<omega>}"
let ?a = "SUP Q:?Q. \<mu> Q"
-
have "{} \<in> ?Q" using v.empty_measure by auto
then have Q_not_empty: "?Q \<noteq> {}" by blast
-
have "?a \<le> \<mu> (space M)" using sets_into_space
by (auto intro!: SUP_leI measure_mono top)
then have "?a \<noteq> \<omega>" using finite_measure_of_space
@@ -596,9 +564,7 @@
show "range ?O \<subseteq> sets M" using Q' by (auto intro!: finite_UN)
show "\<And>i. ?O i \<subseteq> ?O (Suc i)" by fastsimp
qed
-
have Q'_sets: "\<And>i. Q' i \<in> sets M" using Q' by auto
-
have O_sets: "\<And>i. ?O i \<in> sets M"
using Q' by (auto intro!: finite_UN Un)
then have O_in_G: "\<And>i. ?O i \<in> ?Q"
@@ -611,7 +577,6 @@
finally show "\<nu> (?O i) \<noteq> \<omega>" unfolding pinfreal_less_\<omega> by auto
qed auto
have O_mono: "\<And>n. ?O n \<subseteq> ?O (Suc n)" by fastsimp
-
have a_eq: "?a = \<mu> (\<Union>i. ?O i)" unfolding Union[symmetric]
proof (rule antisym)
show "?a \<le> (SUP i. \<mu> (?O i))" unfolding a_Lim
@@ -625,14 +590,11 @@
using O_in_G[of i] by (auto intro!: exI[of _ "?O i"])
qed
qed
-
let "?O_0" = "(\<Union>i. ?O i)"
have "?O_0 \<in> sets M" using Q' by auto
-
def Q \<equiv> "\<lambda>i. case i of 0 \<Rightarrow> Q' 0 | Suc n \<Rightarrow> ?O (Suc n) - ?O n"
{ fix i have "Q i \<in> sets M" unfolding Q_def using Q'[of 0] by (cases i) (auto intro: O_sets) }
note Q_sets = this
-
show ?thesis
proof (intro bexI exI conjI ballI impI allI)
show "disjoint_family Q"
@@ -640,7 +602,6 @@
split: nat.split_asm)
show "range Q \<subseteq> sets M"
using Q_sets by auto
-
{ fix A assume A: "A \<in> sets M" "A \<subseteq> space M - ?O_0"
show "\<mu> A = 0 \<and> \<nu> A = 0 \<or> 0 < \<mu> A \<and> \<nu> A = \<omega>"
proof (rule disjCI, simp)
@@ -677,7 +638,6 @@
with `\<mu> A \<noteq> 0` show ?thesis by auto
qed
qed }
-
{ fix i show "\<nu> (Q i) \<noteq> \<omega>"
proof (cases i)
case 0 then show ?thesis
@@ -688,9 +648,7 @@
using `?O n \<in> ?Q` `?O (Suc n) \<in> ?Q` O_mono
using v.measure_Diff[of "?O n" "?O (Suc n)"] by auto
qed }
-
show "space M - ?O_0 \<in> sets M" using Q'_sets by auto
-
{ fix j have "(\<Union>i\<le>j. ?O i) = (\<Union>i\<le>j. Q i)"
proof (induct j)
case 0 then show ?case by (simp add: Q_def)
@@ -713,7 +671,6 @@
shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
proof -
interpret v: measure_space M \<nu> by fact
-
from split_space_into_finite_sets_and_rest[OF assms]
obtain Q0 and Q :: "nat \<Rightarrow> 'a set"
where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
@@ -721,7 +678,6 @@
and in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<subseteq> Q0 \<Longrightarrow> \<mu> A = 0 \<and> \<nu> A = 0 \<or> 0 < \<mu> A \<and> \<nu> A = \<omega>"
and Q_fin: "\<And>i. \<nu> (Q i) \<noteq> \<omega>" by force
from Q have Q_sets: "\<And>i. Q i \<in> sets M" by auto
-
have "\<forall>i. \<exists>f. f\<in>borel_measurable M \<and> (\<forall>A\<in>sets M.
\<nu> (Q i \<inter> A) = positive_integral (\<lambda>x. f x * indicator (Q i \<inter> A) x))"
proof
@@ -729,7 +685,6 @@
have indicator_eq: "\<And>f x A. (f x :: pinfreal) * indicator (Q i \<inter> A) x * indicator (Q i) x
= (f x * indicator (Q i) x) * indicator A x"
unfolding indicator_def by auto
-
have fm: "finite_measure (restricted_space (Q i)) \<mu>"
(is "finite_measure ?R \<mu>") by (rule restricted_finite_measure[OF Q_sets[of i]])
then interpret R: finite_measure ?R .
@@ -843,12 +798,6 @@

section "Uniqueness of densities"

-lemma (in measure_space) density_is_absolutely_continuous:
-  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
-  shows "absolutely_continuous \<nu>"
-  using assms unfolding absolutely_continuous_def
-
lemma (in measure_space) finite_density_unique:
assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
and fin: "positive_integral f < \<omega>"
@@ -973,19 +922,16 @@
using h_borel by (rule measure_space_density)
interpret h: finite_measure M "\<lambda>A. positive_integral (\<lambda>x. h x * indicator A x)"
by default (simp cong: positive_integral_cong add: fin)
-
interpret f: measure_space M "\<lambda>A. positive_integral (\<lambda>x. f x * indicator A x)"
using borel(1) by (rule measure_space_density)
interpret f': measure_space M "\<lambda>A. positive_integral (\<lambda>x. f' x * indicator A x)"
using borel(2) by (rule measure_space_density)
-
{ fix A assume "A \<in> sets M"
then have " {x \<in> space M. h x \<noteq> 0 \<and> indicator A x \<noteq> (0::pinfreal)} = A"
using pos sets_into_space by (force simp: indicator_def)
then have "positive_integral (\<lambda>xa. h xa * indicator A xa) = 0 \<longleftrightarrow> A \<in> null_sets"
using h_borel `A \<in> sets M` by (simp add: positive_integral_0_iff) }
note h_null_sets = this
-
{ fix A assume "A \<in> sets M"
have "positive_integral (\<lambda>x. h x * (f x * indicator A x)) =
f.positive_integral (\<lambda>x. h x * indicator A x)"
@@ -1101,7 +1047,7 @@
qed
qed

definition (in sigma_finite_measure)
"RN_deriv \<nu> \<equiv> SOME f. f \<in> borel_measurable M \<and>```
```--- a/src/HOL/Probability/Sigma_Algebra.thy	Wed Dec 01 20:12:53 2010 +0100
+++ b/src/HOL/Probability/Sigma_Algebra.thy	Wed Dec 01 21:03:02 2010 +0100
@@ -403,6 +403,12 @@
shows "sets (sigma N) \<subseteq> sets M"
by (unfold assms sets_sigma, rule sigma_sets_subset, rule assms)

+lemma in_sigma[intro, simp]: "A \<in> sets M \<Longrightarrow> A \<in> sets (sigma M)"
+  unfolding sigma_def by (auto intro!: sigma_sets.Basic)
+
+lemma (in sigma_algebra) sigma_eq[simp]: "sigma M = M"
+  unfolding sigma_def sigma_sets_eq by simp
+
section {* Measurable functions *}

definition
@@ -865,6 +871,22 @@
qed
qed

+lemma vimage_algebra_sigma:
+  assumes E: "sets E \<subseteq> Pow (space E)"
+    and f: "f \<in> space F \<rightarrow> space E"
+    and "\<And>A. A \<in> sets F \<Longrightarrow> A \<in> (\<lambda>X. f -` X \<inter> space F) ` sets E"
+    and "\<And>A. A \<in> sets E \<Longrightarrow> f -` A \<inter> space F \<in> sets F"
+  shows "sigma_algebra.vimage_algebra (sigma E) (space F) f = sigma F"
+proof -
+  interpret sigma_algebra "sigma E"
+    using assms by (intro sigma_algebra_sigma) auto
+  have eq: "sets F = (\<lambda>X. f -` X \<inter> space F) ` sets E"
+    using assms by auto
+  show "vimage_algebra (space F) f = sigma F"
+    unfolding vimage_algebra_def using assms
+    by (simp add: sigma_def eq sigma_sets_vimage)
+qed
+
section {* Conditional space *}

definition (in algebra)```