src/HOL/Probability/Radon_Nikodym.thy
changeset 41689 3e39b0e730d6
parent 41661 baf1964bc468
child 41705 1100512e16d8
     1.1 --- a/src/HOL/Probability/Radon_Nikodym.thy	Wed Feb 02 10:35:41 2011 +0100
     1.2 +++ b/src/HOL/Probability/Radon_Nikodym.thy	Wed Feb 02 12:34:45 2011 +0100
     1.3 @@ -11,7 +11,7 @@
     1.4  qed auto
     1.5  
     1.6  lemma (in sigma_finite_measure) Ex_finite_integrable_function:
     1.7 -  shows "\<exists>h\<in>borel_measurable M. positive_integral h \<noteq> \<omega> \<and> (\<forall>x\<in>space M. 0 < h x \<and> h x < \<omega>)"
     1.8 +  shows "\<exists>h\<in>borel_measurable M. integral\<^isup>P M h \<noteq> \<omega> \<and> (\<forall>x\<in>space M. 0 < h x \<and> h x < \<omega>)"
     1.9  proof -
    1.10    obtain A :: "nat \<Rightarrow> 'a set" where
    1.11      range: "range A \<subseteq> sets M" and
    1.12 @@ -42,7 +42,7 @@
    1.13    proof (safe intro!: bexI[of _ ?h] del: notI)
    1.14      have "\<And>i. A i \<in> sets M"
    1.15        using range by fastsimp+
    1.16 -    then have "positive_integral ?h = (\<Sum>\<^isub>\<infinity> i. n i * \<mu> (A i))"
    1.17 +    then have "integral\<^isup>P M ?h = (\<Sum>\<^isub>\<infinity> i. n i * \<mu> (A i))"
    1.18        by (simp add: positive_integral_psuminf positive_integral_cmult_indicator)
    1.19      also have "\<dots> \<le> (\<Sum>\<^isub>\<infinity> i. Real ((1 / 2)^Suc i))"
    1.20      proof (rule psuminf_le)
    1.21 @@ -56,7 +56,7 @@
    1.22      qed
    1.23      also have "\<dots> = Real 1"
    1.24        by (rule suminf_imp_psuminf, rule power_half_series, auto)
    1.25 -    finally show "positive_integral ?h \<noteq> \<omega>" by auto
    1.26 +    finally show "integral\<^isup>P M ?h \<noteq> \<omega>" by auto
    1.27    next
    1.28      fix x assume "x \<in> space M"
    1.29      then obtain i where "x \<in> A i" using space[symmetric] by auto
    1.30 @@ -75,46 +75,47 @@
    1.31    "absolutely_continuous \<nu> = (\<forall>N\<in>null_sets. \<nu> N = (0 :: pextreal))"
    1.32  
    1.33  lemma (in sigma_finite_measure) absolutely_continuous_AE:
    1.34 -  assumes "measure_space M \<nu>" "absolutely_continuous \<nu>" "AE x. P x"
    1.35 -  shows "measure_space.almost_everywhere M \<nu> P"
    1.36 +  assumes "measure_space M'" and [simp]: "sets M' = sets M" "space M' = space M"
    1.37 +    and "absolutely_continuous (measure M')" "AE x. P x"
    1.38 +  shows "measure_space.almost_everywhere M' P"
    1.39  proof -
    1.40 -  interpret \<nu>: measure_space M \<nu> by fact
    1.41 +  interpret \<nu>: measure_space M' by fact
    1.42    from `AE x. P x` obtain N where N: "N \<in> null_sets" and "{x\<in>space M. \<not> P x} \<subseteq> N"
    1.43      unfolding almost_everywhere_def by auto
    1.44    show "\<nu>.almost_everywhere P"
    1.45    proof (rule \<nu>.AE_I')
    1.46 -    show "{x\<in>space M. \<not> P x} \<subseteq> N" by fact
    1.47 -    from `absolutely_continuous \<nu>` show "N \<in> \<nu>.null_sets"
    1.48 +    show "{x\<in>space M'. \<not> P x} \<subseteq> N" by simp fact
    1.49 +    from `absolutely_continuous (measure M')` show "N \<in> \<nu>.null_sets"
    1.50        using N unfolding absolutely_continuous_def by auto
    1.51    qed
    1.52  qed
    1.53  
    1.54  lemma (in finite_measure_space) absolutely_continuousI:
    1.55 -  assumes "finite_measure_space M \<nu>"
    1.56 +  assumes "finite_measure_space (M\<lparr> measure := \<nu>\<rparr>)" (is "finite_measure_space ?\<nu>")
    1.57    assumes v: "\<And>x. \<lbrakk> x \<in> space M ; \<mu> {x} = 0 \<rbrakk> \<Longrightarrow> \<nu> {x} = 0"
    1.58    shows "absolutely_continuous \<nu>"
    1.59  proof (unfold absolutely_continuous_def sets_eq_Pow, safe)
    1.60    fix N assume "\<mu> N = 0" "N \<subseteq> space M"
    1.61 -  interpret v: finite_measure_space M \<nu> by fact
    1.62 -  have "\<nu> N = \<nu> (\<Union>x\<in>N. {x})" by simp
    1.63 -  also have "\<dots> = (\<Sum>x\<in>N. \<nu> {x})"
    1.64 +  interpret v: finite_measure_space ?\<nu> by fact
    1.65 +  have "\<nu> N = measure ?\<nu> (\<Union>x\<in>N. {x})" by simp
    1.66 +  also have "\<dots> = (\<Sum>x\<in>N. measure ?\<nu> {x})"
    1.67    proof (rule v.measure_finitely_additive''[symmetric])
    1.68      show "finite N" using `N \<subseteq> space M` finite_space by (auto intro: finite_subset)
    1.69      show "disjoint_family_on (\<lambda>i. {i}) N" unfolding disjoint_family_on_def by auto
    1.70 -    fix x assume "x \<in> N" thus "{x} \<in> sets M" using `N \<subseteq> space M` sets_eq_Pow by auto
    1.71 +    fix x assume "x \<in> N" thus "{x} \<in> sets ?\<nu>" using `N \<subseteq> space M` sets_eq_Pow by auto
    1.72    qed
    1.73    also have "\<dots> = 0"
    1.74    proof (safe intro!: setsum_0')
    1.75      fix x assume "x \<in> N"
    1.76      hence "\<mu> {x} \<le> \<mu> N" using sets_eq_Pow `N \<subseteq> space M` by (auto intro!: measure_mono)
    1.77      hence "\<mu> {x} = 0" using `\<mu> N = 0` by simp
    1.78 -    thus "\<nu> {x} = 0" using v[of x] `x \<in> N` `N \<subseteq> space M` by auto
    1.79 +    thus "measure ?\<nu> {x} = 0" using v[of x] `x \<in> N` `N \<subseteq> space M` by auto
    1.80    qed
    1.81 -  finally show "\<nu> N = 0" .
    1.82 +  finally show "\<nu> N = 0" by simp
    1.83  qed
    1.84  
    1.85  lemma (in measure_space) density_is_absolutely_continuous:
    1.86 -  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
    1.87 +  assumes "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
    1.88    shows "absolutely_continuous \<nu>"
    1.89    using assms unfolding absolutely_continuous_def
    1.90    by (simp add: positive_integral_null_set)
    1.91 @@ -123,13 +124,13 @@
    1.92  
    1.93  lemma (in finite_measure) Radon_Nikodym_aux_epsilon:
    1.94    fixes e :: real assumes "0 < e"
    1.95 -  assumes "finite_measure M s"
    1.96 -  shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (s (space M)) \<le>
    1.97 -                    real (\<mu> A) - real (s A) \<and>
    1.98 -                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> - e < real (\<mu> B) - real (s B))"
    1.99 +  assumes "finite_measure (M\<lparr>measure := \<nu>\<rparr>)"
   1.100 +  shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (\<nu> (space M)) \<le>
   1.101 +                    real (\<mu> A) - real (\<nu> A) \<and>
   1.102 +                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> - e < real (\<mu> B) - real (\<nu> B))"
   1.103  proof -
   1.104 -  let "?d A" = "real (\<mu> A) - real (s A)"
   1.105 -  interpret M': finite_measure M s by fact
   1.106 +  let "?d A" = "real (\<mu> A) - real (\<nu> A)"
   1.107 +  interpret M': finite_measure "M\<lparr>measure := \<nu>\<rparr>" by fact
   1.108    let "?A A" = "if (\<forall>B\<in>sets M. B \<subseteq> space M - A \<longrightarrow> -e < ?d B)
   1.109      then {}
   1.110      else (SOME B. B \<in> sets M \<and> B \<subseteq> space M - A \<and> ?d B \<le> -e)"
   1.111 @@ -216,21 +217,24 @@
   1.112  qed
   1.113  
   1.114  lemma (in finite_measure) Radon_Nikodym_aux:
   1.115 -  assumes "finite_measure M s"
   1.116 -  shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (s (space M)) \<le>
   1.117 -                    real (\<mu> A) - real (s A) \<and>
   1.118 -                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> 0 \<le> real (\<mu> B) - real (s B))"
   1.119 +  assumes "finite_measure (M\<lparr>measure := \<nu>\<rparr>)" (is "finite_measure ?M'")
   1.120 +  shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (\<nu> (space M)) \<le>
   1.121 +                    real (\<mu> A) - real (\<nu> A) \<and>
   1.122 +                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> 0 \<le> real (\<mu> B) - real (\<nu> B))"
   1.123  proof -
   1.124 -  let "?d A" = "real (\<mu> A) - real (s A)"
   1.125 +  let "?d A" = "real (\<mu> A) - real (\<nu> A)"
   1.126    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)"
   1.127 -  interpret M': finite_measure M s by fact
   1.128 +  interpret M': finite_measure ?M' where
   1.129 +    "space ?M' = space M" and "sets ?M' = sets M" and "measure ?M' = \<nu>" by fact auto
   1.130    let "?r S" = "restricted_space S"
   1.131    { fix S n
   1.132      assume S: "S \<in> sets M"
   1.133      hence **: "\<And>X. X \<in> op \<inter> S ` sets M \<longleftrightarrow> X \<in> sets M \<and> X \<subseteq> S" by auto
   1.134 -    from M'.restricted_finite_measure[of S] restricted_finite_measure[of S] S
   1.135 -    have "finite_measure (?r S) \<mu>" "0 < 1 / real (Suc n)"
   1.136 -      "finite_measure (?r S) s" by auto
   1.137 +    have [simp]: "(restricted_space S\<lparr>measure := \<nu>\<rparr>) = M'.restricted_space S"
   1.138 +      by (cases M) simp
   1.139 +    from M'.restricted_finite_measure[of S] restricted_finite_measure[OF S] S
   1.140 +    have "finite_measure (?r S)" "0 < 1 / real (Suc n)"
   1.141 +      "finite_measure (?r S\<lparr>measure := \<nu>\<rparr>)" by auto
   1.142      from finite_measure.Radon_Nikodym_aux_epsilon[OF this] guess X ..
   1.143      hence "?P X S n"
   1.144      proof (simp add: **, safe)
   1.145 @@ -287,12 +291,14 @@
   1.146  qed
   1.147  
   1.148  lemma (in finite_measure) Radon_Nikodym_finite_measure:
   1.149 -  assumes "finite_measure M \<nu>"
   1.150 +  assumes "finite_measure (M\<lparr> measure := \<nu>\<rparr>)" (is "finite_measure ?M'")
   1.151    assumes "absolutely_continuous \<nu>"
   1.152 -  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.153 +  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.154  proof -
   1.155 -  interpret M': finite_measure M \<nu> using assms(1) .
   1.156 -  def G \<equiv> "{g \<in> borel_measurable M. \<forall>A\<in>sets M. (\<integral>\<^isup>+x. g x * indicator A x) \<le> \<nu> A}"
   1.157 +  interpret M': finite_measure ?M'
   1.158 +    where "space ?M' = space M" and "sets ?M' = sets M" and "measure ?M' = \<nu>"
   1.159 +    using assms(1) by auto
   1.160 +  def G \<equiv> "{g \<in> borel_measurable M. \<forall>A\<in>sets M. (\<integral>\<^isup>+x. g x * indicator A x \<partial>M) \<le> \<nu> A}"
   1.161    have "(\<lambda>x. 0) \<in> G" unfolding G_def by auto
   1.162    hence "G \<noteq> {}" by auto
   1.163    { fix f g assume f: "f \<in> G" and g: "g \<in> G"
   1.164 @@ -308,16 +314,16 @@
   1.165        have "\<And>x. x \<in> space M \<Longrightarrow> max (g x) (f x) * indicator A x =
   1.166          g x * indicator (?A \<inter> A) x + f x * indicator ((space M - ?A) \<inter> A) x"
   1.167          by (auto simp: indicator_def max_def)
   1.168 -      hence "(\<integral>\<^isup>+x. max (g x) (f x) * indicator A x) =
   1.169 -        (\<integral>\<^isup>+x. g x * indicator (?A \<inter> A) x) +
   1.170 -        (\<integral>\<^isup>+x. f x * indicator ((space M - ?A) \<inter> A) x)"
   1.171 +      hence "(\<integral>\<^isup>+x. max (g x) (f x) * indicator A x \<partial>M) =
   1.172 +        (\<integral>\<^isup>+x. g x * indicator (?A \<inter> A) x \<partial>M) +
   1.173 +        (\<integral>\<^isup>+x. f x * indicator ((space M - ?A) \<inter> A) x \<partial>M)"
   1.174          using f g sets unfolding G_def
   1.175          by (auto cong: positive_integral_cong intro!: positive_integral_add borel_measurable_indicator)
   1.176        also have "\<dots> \<le> \<nu> (?A \<inter> A) + \<nu> ((space M - ?A) \<inter> A)"
   1.177          using f g sets unfolding G_def by (auto intro!: add_mono)
   1.178        also have "\<dots> = \<nu> A"
   1.179          using M'.measure_additive[OF sets] union by auto
   1.180 -      finally show "(\<integral>\<^isup>+x. max (g x) (f x) * indicator A x) \<le> \<nu> A" .
   1.181 +      finally show "(\<integral>\<^isup>+x. max (g x) (f x) * indicator A x \<partial>M) \<le> \<nu> A" .
   1.182      qed }
   1.183    note max_in_G = this
   1.184    { fix f g assume  "f \<up> g" and f: "\<And>i. f i \<in> G"
   1.185 @@ -331,30 +337,30 @@
   1.186        hence "\<And>i. (\<lambda>x. f i x * indicator A x) \<in> borel_measurable M"
   1.187          using f_borel by (auto intro!: borel_measurable_indicator)
   1.188        from positive_integral_isoton[OF isoton_indicator[OF `f \<up> g`] this]
   1.189 -      have SUP: "(\<integral>\<^isup>+x. g x * indicator A x) =
   1.190 -          (SUP i. (\<integral>\<^isup>+x. f i x * indicator A x))"
   1.191 +      have SUP: "(\<integral>\<^isup>+x. g x * indicator A x \<partial>M) =
   1.192 +          (SUP i. (\<integral>\<^isup>+x. f i x * indicator A x \<partial>M))"
   1.193          unfolding isoton_def by simp
   1.194 -      show "(\<integral>\<^isup>+x. g x * indicator A x) \<le> \<nu> A" unfolding SUP
   1.195 +      show "(\<integral>\<^isup>+x. g x * indicator A x \<partial>M) \<le> \<nu> A" unfolding SUP
   1.196          using f `A \<in> sets M` unfolding G_def by (auto intro!: SUP_leI)
   1.197      qed }
   1.198    note SUP_in_G = this
   1.199 -  let ?y = "SUP g : G. positive_integral g"
   1.200 +  let ?y = "SUP g : G. integral\<^isup>P M g"
   1.201    have "?y \<le> \<nu> (space M)" unfolding G_def
   1.202    proof (safe intro!: SUP_leI)
   1.203 -    fix g assume "\<forall>A\<in>sets M. (\<integral>\<^isup>+x. g x * indicator A x) \<le> \<nu> A"
   1.204 -    from this[THEN bspec, OF top] show "positive_integral g \<le> \<nu> (space M)"
   1.205 +    fix g assume "\<forall>A\<in>sets M. (\<integral>\<^isup>+x. g x * indicator A x \<partial>M) \<le> \<nu> A"
   1.206 +    from this[THEN bspec, OF top] show "integral\<^isup>P M g \<le> \<nu> (space M)"
   1.207        by (simp cong: positive_integral_cong)
   1.208    qed
   1.209    hence "?y \<noteq> \<omega>" using M'.finite_measure_of_space by auto
   1.210    from SUPR_countable_SUPR[OF this `G \<noteq> {}`] guess ys .. note ys = this
   1.211 -  hence "\<forall>n. \<exists>g. g\<in>G \<and> positive_integral g = ys n"
   1.212 +  hence "\<forall>n. \<exists>g. g\<in>G \<and> integral\<^isup>P M g = ys n"
   1.213    proof safe
   1.214 -    fix n assume "range ys \<subseteq> positive_integral ` G"
   1.215 -    hence "ys n \<in> positive_integral ` G" by auto
   1.216 -    thus "\<exists>g. g\<in>G \<and> positive_integral g = ys n" by auto
   1.217 +    fix n assume "range ys \<subseteq> integral\<^isup>P M ` G"
   1.218 +    hence "ys n \<in> integral\<^isup>P M ` G" by auto
   1.219 +    thus "\<exists>g. g\<in>G \<and> integral\<^isup>P M g = ys n" by auto
   1.220    qed
   1.221 -  from choice[OF this] obtain gs where "\<And>i. gs i \<in> G" "\<And>n. positive_integral (gs n) = ys n" by auto
   1.222 -  hence y_eq: "?y = (SUP i. positive_integral (gs i))" using ys by auto
   1.223 +  from choice[OF this] obtain gs where "\<And>i. gs i \<in> G" "\<And>n. integral\<^isup>P M (gs n) = ys n" by auto
   1.224 +  hence y_eq: "?y = (SUP i. integral\<^isup>P M (gs i))" using ys by auto
   1.225    let "?g i x" = "Max ((\<lambda>n. gs n x) ` {..i})"
   1.226    def f \<equiv> "SUP i. ?g i"
   1.227    have gs_not_empty: "\<And>i. (\<lambda>n. gs n x) ` {..i} \<noteq> {}" by auto
   1.228 @@ -372,53 +378,53 @@
   1.229    hence isoton_g: "?g \<up> f" by (simp add: isoton_def le_fun_def f_def)
   1.230    from SUP_in_G[OF this g_in_G] have "f \<in> G" .
   1.231    hence [simp, intro]: "f \<in> borel_measurable M" unfolding G_def by auto
   1.232 -  have "(\<lambda>i. positive_integral (?g i)) \<up> positive_integral f"
   1.233 +  have "(\<lambda>i. integral\<^isup>P M (?g i)) \<up> integral\<^isup>P M f"
   1.234      using isoton_g g_in_G by (auto intro!: positive_integral_isoton simp: G_def f_def)
   1.235 -  hence "positive_integral f = (SUP i. positive_integral (?g i))"
   1.236 +  hence "integral\<^isup>P M f = (SUP i. integral\<^isup>P M (?g i))"
   1.237      unfolding isoton_def by simp
   1.238    also have "\<dots> = ?y"
   1.239    proof (rule antisym)
   1.240 -    show "(SUP i. positive_integral (?g i)) \<le> ?y"
   1.241 +    show "(SUP i. integral\<^isup>P M (?g i)) \<le> ?y"
   1.242        using g_in_G by (auto intro!: exI Sup_mono simp: SUPR_def)
   1.243 -    show "?y \<le> (SUP i. positive_integral (?g i))" unfolding y_eq
   1.244 +    show "?y \<le> (SUP i. integral\<^isup>P M (?g i))" unfolding y_eq
   1.245        by (auto intro!: SUP_mono positive_integral_mono Max_ge)
   1.246    qed
   1.247 -  finally have int_f_eq_y: "positive_integral f = ?y" .
   1.248 -  let "?t A" = "\<nu> A - (\<integral>\<^isup>+x. f x * indicator A x)"
   1.249 -  have "finite_measure M ?t"
   1.250 -  proof
   1.251 -    show "?t {} = 0" by simp
   1.252 -    show "?t (space M) \<noteq> \<omega>" using M'.finite_measure by simp
   1.253 -    show "countably_additive M ?t" unfolding countably_additive_def
   1.254 -    proof safe
   1.255 -      fix A :: "nat \<Rightarrow> 'a set"  assume A: "range A \<subseteq> sets M" "disjoint_family A"
   1.256 -      have "(\<Sum>\<^isub>\<infinity> n. (\<integral>\<^isup>+x. f x * indicator (A n) x))
   1.257 -        = (\<integral>\<^isup>+x. (\<Sum>\<^isub>\<infinity>n. f x * indicator (A n) x))"
   1.258 -        using `range A \<subseteq> sets M`
   1.259 -        by (rule_tac positive_integral_psuminf[symmetric]) (auto intro!: borel_measurable_indicator)
   1.260 -      also have "\<dots> = (\<integral>\<^isup>+x. f x * indicator (\<Union>n. A n) x)"
   1.261 -        apply (rule positive_integral_cong)
   1.262 -        apply (subst psuminf_cmult_right)
   1.263 -        unfolding psuminf_indicator[OF `disjoint_family A`] ..
   1.264 -      finally have "(\<Sum>\<^isub>\<infinity> n. (\<integral>\<^isup>+x. f x * indicator (A n) x))
   1.265 -        = (\<integral>\<^isup>+x. f x * indicator (\<Union>n. A n) x)" .
   1.266 -      moreover have "(\<Sum>\<^isub>\<infinity>n. \<nu> (A n)) = \<nu> (\<Union>n. A n)"
   1.267 -        using M'.measure_countably_additive A by (simp add: comp_def)
   1.268 -      moreover have "\<And>i. (\<integral>\<^isup>+x. f x * indicator (A i) x) \<le> \<nu> (A i)"
   1.269 -          using A `f \<in> G` unfolding G_def by auto
   1.270 -      moreover have v_fin: "\<nu> (\<Union>i. A i) \<noteq> \<omega>" using M'.finite_measure A by (simp add: countable_UN)
   1.271 -      moreover {
   1.272 -        have "(\<integral>\<^isup>+x. f x * indicator (\<Union>i. A i) x) \<le> \<nu> (\<Union>i. A i)"
   1.273 -          using A `f \<in> G` unfolding G_def by (auto simp: countable_UN)
   1.274 -        also have "\<nu> (\<Union>i. A i) < \<omega>" using v_fin by (simp add: pextreal_less_\<omega>)
   1.275 -        finally have "(\<integral>\<^isup>+x. f x * indicator (\<Union>i. A i) x) \<noteq> \<omega>"
   1.276 -          by (simp add: pextreal_less_\<omega>) }
   1.277 -      ultimately
   1.278 -      show "(\<Sum>\<^isub>\<infinity> n. ?t (A n)) = ?t (\<Union>i. A i)"
   1.279 -        apply (subst psuminf_minus) by simp_all
   1.280 -    qed
   1.281 +  finally have int_f_eq_y: "integral\<^isup>P M f = ?y" .
   1.282 +  let "?t A" = "\<nu> A - (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.283 +  let ?M = "M\<lparr> measure := ?t\<rparr>"
   1.284 +  interpret M: sigma_algebra ?M
   1.285 +    by (intro sigma_algebra_cong) auto
   1.286 +  have fmM: "finite_measure ?M"
   1.287 +  proof (default, simp_all add: countably_additive_def, safe)
   1.288 +    fix A :: "nat \<Rightarrow> 'a set"  assume A: "range A \<subseteq> sets M" "disjoint_family A"
   1.289 +    have "(\<Sum>\<^isub>\<infinity> n. (\<integral>\<^isup>+x. f x * indicator (A n) x \<partial>M))
   1.290 +      = (\<integral>\<^isup>+x. (\<Sum>\<^isub>\<infinity>n. f x * indicator (A n) x) \<partial>M)"
   1.291 +      using `range A \<subseteq> sets M`
   1.292 +      by (rule_tac positive_integral_psuminf[symmetric]) (auto intro!: borel_measurable_indicator)
   1.293 +    also have "\<dots> = (\<integral>\<^isup>+x. f x * indicator (\<Union>n. A n) x \<partial>M)"
   1.294 +      apply (rule positive_integral_cong)
   1.295 +      apply (subst psuminf_cmult_right)
   1.296 +      unfolding psuminf_indicator[OF `disjoint_family A`] ..
   1.297 +    finally have "(\<Sum>\<^isub>\<infinity> n. (\<integral>\<^isup>+x. f x * indicator (A n) x \<partial>M))
   1.298 +      = (\<integral>\<^isup>+x. f x * indicator (\<Union>n. A n) x \<partial>M)" .
   1.299 +    moreover have "(\<Sum>\<^isub>\<infinity>n. \<nu> (A n)) = \<nu> (\<Union>n. A n)"
   1.300 +      using M'.measure_countably_additive A by (simp add: comp_def)
   1.301 +    moreover have "\<And>i. (\<integral>\<^isup>+x. f x * indicator (A i) x \<partial>M) \<le> \<nu> (A i)"
   1.302 +        using A `f \<in> G` unfolding G_def by auto
   1.303 +    moreover have v_fin: "\<nu> (\<Union>i. A i) \<noteq> \<omega>" using M'.finite_measure A by (simp add: countable_UN)
   1.304 +    moreover {
   1.305 +      have "(\<integral>\<^isup>+x. f x * indicator (\<Union>i. A i) x \<partial>M) \<le> \<nu> (\<Union>i. A i)"
   1.306 +        using A `f \<in> G` unfolding G_def by (auto simp: countable_UN)
   1.307 +      also have "\<nu> (\<Union>i. A i) < \<omega>" using v_fin by (simp add: pextreal_less_\<omega>)
   1.308 +      finally have "(\<integral>\<^isup>+x. f x * indicator (\<Union>i. A i) x \<partial>M) \<noteq> \<omega>"
   1.309 +        by (simp add: pextreal_less_\<omega>) }
   1.310 +    ultimately
   1.311 +    show "(\<Sum>\<^isub>\<infinity> n. ?t (A n)) = ?t (\<Union>i. A i)"
   1.312 +      apply (subst psuminf_minus) by simp_all
   1.313    qed
   1.314 -  then interpret M: finite_measure M ?t .
   1.315 +  then interpret M: finite_measure ?M
   1.316 +    where "space ?M = space M" and "sets ?M = sets M" and "measure ?M = ?t"
   1.317 +    by (simp_all add: fmM)
   1.318    have ac: "absolutely_continuous ?t" using `absolutely_continuous \<nu>` unfolding absolutely_continuous_def by auto
   1.319    have upper_bound: "\<forall>A\<in>sets M. ?t A \<le> 0"
   1.320    proof (rule ccontr)
   1.321 @@ -433,23 +439,21 @@
   1.322      hence pos_M: "0 < \<mu> (space M)"
   1.323        using ac top unfolding absolutely_continuous_def by auto
   1.324      moreover
   1.325 -    have "(\<integral>\<^isup>+x. f x * indicator (space M) x) \<le> \<nu> (space M)"
   1.326 +    have "(\<integral>\<^isup>+x. f x * indicator (space M) x \<partial>M) \<le> \<nu> (space M)"
   1.327        using `f \<in> G` unfolding G_def by auto
   1.328 -    hence "(\<integral>\<^isup>+x. f x * indicator (space M) x) \<noteq> \<omega>"
   1.329 +    hence "(\<integral>\<^isup>+x. f x * indicator (space M) x \<partial>M) \<noteq> \<omega>"
   1.330        using M'.finite_measure_of_space by auto
   1.331      moreover
   1.332      def b \<equiv> "?t (space M) / \<mu> (space M) / 2"
   1.333      ultimately have b: "b \<noteq> 0" "b \<noteq> \<omega>"
   1.334        using M'.finite_measure_of_space
   1.335        by (auto simp: pextreal_inverse_eq_0 finite_measure_of_space)
   1.336 -    have "finite_measure M (\<lambda>A. b * \<mu> A)" (is "finite_measure M ?b")
   1.337 -    proof
   1.338 -      show "?b {} = 0" by simp
   1.339 -      show "?b (space M) \<noteq> \<omega>" using finite_measure_of_space b by auto
   1.340 -      show "countably_additive M ?b"
   1.341 -        unfolding countably_additive_def psuminf_cmult_right
   1.342 -        using measure_countably_additive by auto
   1.343 -    qed
   1.344 +    let ?Mb = "?M\<lparr>measure := \<lambda>A. b * \<mu> A\<rparr>"
   1.345 +    interpret b: sigma_algebra ?Mb by (intro sigma_algebra_cong) auto
   1.346 +    have "finite_measure ?Mb"
   1.347 +      by default
   1.348 +         (insert finite_measure_of_space b measure_countably_additive,
   1.349 +          auto simp: psuminf_cmult_right countably_additive_def)
   1.350      from M.Radon_Nikodym_aux[OF this]
   1.351      obtain A0 where "A0 \<in> sets M" and
   1.352        space_less_A0: "real (?t (space M)) - real (b * \<mu> (space M)) \<le> real (?t A0) - real (b * \<mu> A0)" and
   1.353 @@ -462,30 +466,30 @@
   1.354      let "?f0 x" = "f x + b * indicator A0 x"
   1.355      { fix A assume A: "A \<in> sets M"
   1.356        hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
   1.357 -      have "(\<integral>\<^isup>+x. ?f0 x  * indicator A x) =
   1.358 -        (\<integral>\<^isup>+x. f x * indicator A x + b * indicator (A \<inter> A0) x)"
   1.359 +      have "(\<integral>\<^isup>+x. ?f0 x  * indicator A x \<partial>M) =
   1.360 +        (\<integral>\<^isup>+x. f x * indicator A x + b * indicator (A \<inter> A0) x \<partial>M)"
   1.361          by (auto intro!: positive_integral_cong simp: field_simps indicator_inter_arith)
   1.362 -      hence "(\<integral>\<^isup>+x. ?f0 x * indicator A x) =
   1.363 -          (\<integral>\<^isup>+x. f x * indicator A x) + b * \<mu> (A \<inter> A0)"
   1.364 +      hence "(\<integral>\<^isup>+x. ?f0 x * indicator A x \<partial>M) =
   1.365 +          (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) + b * \<mu> (A \<inter> A0)"
   1.366          using `A0 \<in> sets M` `A \<inter> A0 \<in> sets M` A
   1.367          by (simp add: borel_measurable_indicator positive_integral_add positive_integral_cmult_indicator) }
   1.368      note f0_eq = this
   1.369      { fix A assume A: "A \<in> sets M"
   1.370        hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
   1.371 -      have f_le_v: "(\<integral>\<^isup>+x. f x * indicator A x) \<le> \<nu> A"
   1.372 +      have f_le_v: "(\<integral>\<^isup>+x. f x * indicator A x \<partial>M) \<le> \<nu> A"
   1.373          using `f \<in> G` A unfolding G_def by auto
   1.374        note f0_eq[OF A]
   1.375 -      also have "(\<integral>\<^isup>+x. f x * indicator A x) + b * \<mu> (A \<inter> A0) \<le>
   1.376 -          (\<integral>\<^isup>+x. f x * indicator A x) + ?t (A \<inter> A0)"
   1.377 +      also have "(\<integral>\<^isup>+x. f x * indicator A x \<partial>M) + b * \<mu> (A \<inter> A0) \<le>
   1.378 +          (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) + ?t (A \<inter> A0)"
   1.379          using bM_le_t[OF `A \<inter> A0 \<in> sets M`] `A \<in> sets M` `A0 \<in> sets M`
   1.380          by (auto intro!: add_left_mono)
   1.381 -      also have "\<dots> \<le> (\<integral>\<^isup>+x. f x * indicator A x) + ?t A"
   1.382 +      also have "\<dots> \<le> (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) + ?t A"
   1.383          using M.measure_mono[simplified, OF _ `A \<inter> A0 \<in> sets M` `A \<in> sets M`]
   1.384          by (auto intro!: add_left_mono)
   1.385        also have "\<dots> \<le> \<nu> A"
   1.386          using f_le_v M'.finite_measure[simplified, OF `A \<in> sets M`]
   1.387 -        by (cases "(\<integral>\<^isup>+x. f x * indicator A x)", cases "\<nu> A", auto)
   1.388 -      finally have "(\<integral>\<^isup>+x. ?f0 x * indicator A x) \<le> \<nu> A" . }
   1.389 +        by (cases "(\<integral>\<^isup>+x. f x * indicator A x \<partial>M)", cases "\<nu> A", auto)
   1.390 +      finally have "(\<integral>\<^isup>+x. ?f0 x * indicator A x \<partial>M) \<le> \<nu> A" . }
   1.391      hence "?f0 \<in> G" using `A0 \<in> sets M` unfolding G_def
   1.392        by (auto intro!: borel_measurable_indicator borel_measurable_pextreal_add borel_measurable_pextreal_times)
   1.393      have real: "?t (space M) \<noteq> \<omega>" "?t A0 \<noteq> \<omega>"
   1.394 @@ -494,7 +498,7 @@
   1.395          finite_measure[of A0] M.finite_measure[of A0]
   1.396          finite_measure_of_space M.finite_measure_of_space
   1.397        by auto
   1.398 -    have int_f_finite: "positive_integral f \<noteq> \<omega>"
   1.399 +    have int_f_finite: "integral\<^isup>P M f \<noteq> \<omega>"
   1.400        using M'.finite_measure_of_space pos_t unfolding pextreal_zero_less_diff_iff
   1.401        by (auto cong: positive_integral_cong)
   1.402      have "?t (space M) > b * \<mu> (space M)" unfolding b_def
   1.403 @@ -514,22 +518,22 @@
   1.404        using `A0 \<in> sets M` by auto
   1.405      hence "0 < b * \<mu> A0" using b by auto
   1.406      from int_f_finite this
   1.407 -    have "?y + 0 < positive_integral f + b * \<mu> A0" unfolding int_f_eq_y
   1.408 +    have "?y + 0 < integral\<^isup>P M f + b * \<mu> A0" unfolding int_f_eq_y
   1.409        by (rule pextreal_less_add)
   1.410 -    also have "\<dots> = positive_integral ?f0" using f0_eq[OF top] `A0 \<in> sets M` sets_into_space
   1.411 +    also have "\<dots> = integral\<^isup>P M ?f0" using f0_eq[OF top] `A0 \<in> sets M` sets_into_space
   1.412        by (simp cong: positive_integral_cong)
   1.413 -    finally have "?y < positive_integral ?f0" by simp
   1.414 -    moreover from `?f0 \<in> G` have "positive_integral ?f0 \<le> ?y" by (auto intro!: le_SUPI)
   1.415 +    finally have "?y < integral\<^isup>P M ?f0" by simp
   1.416 +    moreover from `?f0 \<in> G` have "integral\<^isup>P M ?f0 \<le> ?y" by (auto intro!: le_SUPI)
   1.417      ultimately show False by auto
   1.418    qed
   1.419    show ?thesis
   1.420    proof (safe intro!: bexI[of _ f])
   1.421      fix A assume "A\<in>sets M"
   1.422 -    show "\<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.423 +    show "\<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.424      proof (rule antisym)
   1.425 -      show "(\<integral>\<^isup>+x. f x * indicator A x) \<le> \<nu> A"
   1.426 +      show "(\<integral>\<^isup>+x. f x * indicator A x \<partial>M) \<le> \<nu> A"
   1.427          using `f \<in> G` `A \<in> sets M` unfolding G_def by auto
   1.428 -      show "\<nu> A \<le> (\<integral>\<^isup>+x. f x * indicator A x)"
   1.429 +      show "\<nu> A \<le> (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.430          using upper_bound[THEN bspec, OF `A \<in> sets M`]
   1.431           by (simp add: pextreal_zero_le_diff)
   1.432      qed
   1.433 @@ -537,13 +541,15 @@
   1.434  qed
   1.435  
   1.436  lemma (in finite_measure) split_space_into_finite_sets_and_rest:
   1.437 -  assumes "measure_space M \<nu>"
   1.438 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)" (is "measure_space ?N")
   1.439    assumes ac: "absolutely_continuous \<nu>"
   1.440    shows "\<exists>\<Omega>0\<in>sets M. \<exists>\<Omega>::nat\<Rightarrow>'a set. disjoint_family \<Omega> \<and> range \<Omega> \<subseteq> sets M \<and> \<Omega>0 = space M - (\<Union>i. \<Omega> i) \<and>
   1.441      (\<forall>A\<in>sets M. A \<subseteq> \<Omega>0 \<longrightarrow> (\<mu> A = 0 \<and> \<nu> A = 0) \<or> (\<mu> A > 0 \<and> \<nu> A = \<omega>)) \<and>
   1.442      (\<forall>i. \<nu> (\<Omega> i) \<noteq> \<omega>)"
   1.443  proof -
   1.444 -  interpret v: measure_space M \<nu> by fact
   1.445 +  interpret v: measure_space ?N
   1.446 +    where "space ?N = space M" and "sets ?N = sets M" and "measure ?N = \<nu>"
   1.447 +    by fact auto
   1.448    let ?Q = "{Q\<in>sets M. \<nu> Q \<noteq> \<omega>}"
   1.449    let ?a = "SUP Q:?Q. \<mu> Q"
   1.450    have "{} \<in> ?Q" using v.empty_measure by auto
   1.451 @@ -667,11 +673,13 @@
   1.452  qed
   1.453  
   1.454  lemma (in finite_measure) Radon_Nikodym_finite_measure_infinite:
   1.455 -  assumes "measure_space M \<nu>"
   1.456 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)" (is "measure_space ?N")
   1.457    assumes "absolutely_continuous \<nu>"
   1.458 -  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.459 +  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.460  proof -
   1.461 -  interpret v: measure_space M \<nu> by fact
   1.462 +  interpret v: measure_space ?N
   1.463 +    where "space ?N = space M" and "sets ?N = sets M" and "measure ?N = \<nu>"
   1.464 +    by fact auto
   1.465    from split_space_into_finite_sets_and_rest[OF assms]
   1.466    obtain Q0 and Q :: "nat \<Rightarrow> 'a set"
   1.467      where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
   1.468 @@ -680,39 +688,38 @@
   1.469      and Q_fin: "\<And>i. \<nu> (Q i) \<noteq> \<omega>" by force
   1.470    from Q have Q_sets: "\<And>i. Q i \<in> sets M" by auto
   1.471    have "\<forall>i. \<exists>f. f\<in>borel_measurable M \<and> (\<forall>A\<in>sets M.
   1.472 -    \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f x * indicator (Q i \<inter> A) x))"
   1.473 +    \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f x * indicator (Q i \<inter> A) x \<partial>M))"
   1.474    proof
   1.475      fix i
   1.476      have indicator_eq: "\<And>f x A. (f x :: pextreal) * indicator (Q i \<inter> A) x * indicator (Q i) x
   1.477        = (f x * indicator (Q i) x) * indicator A x"
   1.478        unfolding indicator_def by auto
   1.479 -    have fm: "finite_measure (restricted_space (Q i)) \<mu>"
   1.480 -      (is "finite_measure ?R \<mu>") by (rule restricted_finite_measure[OF Q_sets[of i]])
   1.481 +    have fm: "finite_measure (restricted_space (Q i))"
   1.482 +      (is "finite_measure ?R") by (rule restricted_finite_measure[OF Q_sets[of i]])
   1.483      then interpret R: finite_measure ?R .
   1.484 -    have fmv: "finite_measure ?R \<nu>"
   1.485 +    have fmv: "finite_measure (restricted_space (Q i) \<lparr> measure := \<nu>\<rparr>)" (is "finite_measure ?Q")
   1.486        unfolding finite_measure_def finite_measure_axioms_def
   1.487      proof
   1.488 -      show "measure_space ?R \<nu>"
   1.489 +      show "measure_space ?Q"
   1.490          using v.restricted_measure_space Q_sets[of i] by auto
   1.491 -      show "\<nu>  (space ?R) \<noteq> \<omega>"
   1.492 -        using Q_fin by simp
   1.493 +      show "measure ?Q (space ?Q) \<noteq> \<omega>" using Q_fin by simp
   1.494      qed
   1.495      have "R.absolutely_continuous \<nu>"
   1.496        using `absolutely_continuous \<nu>` `Q i \<in> sets M`
   1.497        by (auto simp: R.absolutely_continuous_def absolutely_continuous_def)
   1.498 -    from finite_measure.Radon_Nikodym_finite_measure[OF fm fmv this]
   1.499 +    from R.Radon_Nikodym_finite_measure[OF fmv this]
   1.500      obtain f where f: "(\<lambda>x. f x * indicator (Q i) x) \<in> borel_measurable M"
   1.501 -      and f_int: "\<And>A. A\<in>sets M \<Longrightarrow> \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. (f x * indicator (Q i) x) * indicator A x)"
   1.502 +      and f_int: "\<And>A. A\<in>sets M \<Longrightarrow> \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. (f x * indicator (Q i) x) * indicator A x \<partial>M)"
   1.503        unfolding Bex_def borel_measurable_restricted[OF `Q i \<in> sets M`]
   1.504          positive_integral_restricted[OF `Q i \<in> sets M`] by (auto simp: indicator_eq)
   1.505      then show "\<exists>f. f\<in>borel_measurable M \<and> (\<forall>A\<in>sets M.
   1.506 -      \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f x * indicator (Q i \<inter> A) x))"
   1.507 +      \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f x * indicator (Q i \<inter> A) x \<partial>M))"
   1.508        by (fastsimp intro!: exI[of _ "\<lambda>x. f x * indicator (Q i) x"] positive_integral_cong
   1.509            simp: indicator_def)
   1.510    qed
   1.511    from choice[OF this] obtain f where borel: "\<And>i. f i \<in> borel_measurable M"
   1.512      and f: "\<And>A i. A \<in> sets M \<Longrightarrow>
   1.513 -      \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f i x * indicator (Q i \<inter> A) x)"
   1.514 +      \<nu> (Q i \<inter> A) = (\<integral>\<^isup>+x. f i x * indicator (Q i \<inter> A) x \<partial>M)"
   1.515      by auto
   1.516    let "?f x" =
   1.517      "(\<Sum>\<^isub>\<infinity> i. f i x * indicator (Q i) x) + \<omega> * indicator Q0 x"
   1.518 @@ -728,7 +735,7 @@
   1.519          f i x * indicator (Q i \<inter> A) x"
   1.520        "\<And>x i. (indicator A x * indicator Q0 x :: pextreal) =
   1.521          indicator (Q0 \<inter> A) x" by (auto simp: indicator_def)
   1.522 -    have "(\<integral>\<^isup>+x. ?f x * indicator A x) =
   1.523 +    have "(\<integral>\<^isup>+x. ?f x * indicator A x \<partial>M) =
   1.524        (\<Sum>\<^isub>\<infinity> i. \<nu> (Q i \<inter> A)) + \<omega> * \<mu> (Q0 \<inter> A)"
   1.525        unfolding f[OF `A \<in> sets M`]
   1.526        apply (simp del: pextreal_times(2) add: field_simps *)
   1.527 @@ -755,27 +762,29 @@
   1.528        using Q_sets `A \<in> sets M` Q0(1) by (auto intro!: countable_UN)
   1.529      moreover have "((\<Union>i. Q i) \<inter> A) \<union> (Q0 \<inter> A) = A" "((\<Union>i. Q i) \<inter> A) \<inter> (Q0 \<inter> A) = {}"
   1.530        using `A \<in> sets M` sets_into_space Q0 by auto
   1.531 -    ultimately show "\<nu> A = (\<integral>\<^isup>+x. ?f x * indicator A x)"
   1.532 +    ultimately show "\<nu> A = (\<integral>\<^isup>+x. ?f x * indicator A x \<partial>M)"
   1.533        using v.measure_additive[simplified, of "(\<Union>i. Q i) \<inter> A" "Q0 \<inter> A"]
   1.534        by simp
   1.535    qed
   1.536  qed
   1.537  
   1.538  lemma (in sigma_finite_measure) Radon_Nikodym:
   1.539 -  assumes "measure_space M \<nu>"
   1.540 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)" (is "measure_space ?N")
   1.541    assumes "absolutely_continuous \<nu>"
   1.542 -  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.543 +  shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.544  proof -
   1.545    from Ex_finite_integrable_function
   1.546 -  obtain h where finite: "positive_integral h \<noteq> \<omega>" and
   1.547 +  obtain h where finite: "integral\<^isup>P M h \<noteq> \<omega>" and
   1.548      borel: "h \<in> borel_measurable M" and
   1.549      pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x" and
   1.550      "\<And>x. x \<in> space M \<Longrightarrow> h x < \<omega>" by auto
   1.551 -  let "?T A" = "(\<integral>\<^isup>+x. h x * indicator A x)"
   1.552 +  let "?T A" = "(\<integral>\<^isup>+x. h x * indicator A x \<partial>M)"
   1.553 +  let ?MT = "M\<lparr> measure := ?T \<rparr>"
   1.554    from measure_space_density[OF borel] finite
   1.555 -  interpret T: finite_measure M ?T
   1.556 +  interpret T: finite_measure ?MT
   1.557 +    where "space ?MT = space M" and "sets ?MT = sets M" and "measure ?MT = ?T"
   1.558      unfolding finite_measure_def finite_measure_axioms_def
   1.559 -    by (simp cong: positive_integral_cong)
   1.560 +    by (simp_all cong: positive_integral_cong)
   1.561    have "\<And>N. N \<in> sets M \<Longrightarrow> {x \<in> space M. h x \<noteq> 0 \<and> indicator N x \<noteq> (0::pextreal)} = N"
   1.562      using sets_into_space pos by (force simp: indicator_def)
   1.563    then have "T.absolutely_continuous \<nu>" using assms(2) borel
   1.564 @@ -783,7 +792,8 @@
   1.565      by (fastsimp simp: borel_measurable_indicator positive_integral_0_iff)
   1.566    from T.Radon_Nikodym_finite_measure_infinite[simplified, OF assms(1) this]
   1.567    obtain f where f_borel: "f \<in> borel_measurable M" and
   1.568 -    fT: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = T.positive_integral (\<lambda>x. f x * indicator A x)" by auto
   1.569 +    fT: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+ x. f x * indicator A x \<partial>?MT)"
   1.570 +    by (auto simp: measurable_def)
   1.571    show ?thesis
   1.572    proof (safe intro!: bexI[of _ "\<lambda>x. h x * f x"])
   1.573      show "(\<lambda>x. h x * f x) \<in> borel_measurable M"
   1.574 @@ -792,7 +802,7 @@
   1.575      then have "(\<lambda>x. f x * indicator A x) \<in> borel_measurable M"
   1.576        using f_borel by (auto intro: borel_measurable_pextreal_times borel_measurable_indicator)
   1.577      from positive_integral_translated_density[OF borel this]
   1.578 -    show "\<nu> A = (\<integral>\<^isup>+x. h x * f x * indicator A x)"
   1.579 +    show "\<nu> A = (\<integral>\<^isup>+x. h x * f x * indicator A x \<partial>M)"
   1.580        unfolding fT[OF `A \<in> sets M`] by (simp add: field_simps)
   1.581    qed
   1.582  qed
   1.583 @@ -801,8 +811,8 @@
   1.584  
   1.585  lemma (in measure_space) finite_density_unique:
   1.586    assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
   1.587 -  and fin: "positive_integral f < \<omega>"
   1.588 -  shows "(\<forall>A\<in>sets M. (\<integral>\<^isup>+x. f x * indicator A x) = (\<integral>\<^isup>+x. g x * indicator A x))
   1.589 +  and fin: "integral\<^isup>P M f < \<omega>"
   1.590 +  shows "(\<forall>A\<in>sets M. (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^isup>+x. g x * indicator A x \<partial>M))
   1.591      \<longleftrightarrow> (AE x. f x = g x)"
   1.592      (is "(\<forall>A\<in>sets M. ?P f A = ?P g A) \<longleftrightarrow> _")
   1.593  proof (intro iffI ballI)
   1.594 @@ -812,18 +822,18 @@
   1.595  next
   1.596    assume eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
   1.597    from this[THEN bspec, OF top] fin
   1.598 -  have g_fin: "positive_integral g < \<omega>" by (simp cong: positive_integral_cong)
   1.599 +  have g_fin: "integral\<^isup>P M g < \<omega>" by (simp cong: positive_integral_cong)
   1.600    { fix f g assume borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
   1.601 -      and g_fin: "positive_integral g < \<omega>" and eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
   1.602 +      and g_fin: "integral\<^isup>P M g < \<omega>" and eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
   1.603      let ?N = "{x\<in>space M. g x < f x}"
   1.604      have N: "?N \<in> sets M" using borel by simp
   1.605 -    have "?P (\<lambda>x. (f x - g x)) ?N = (\<integral>\<^isup>+x. f x * indicator ?N x - g x * indicator ?N x)"
   1.606 +    have "?P (\<lambda>x. (f x - g x)) ?N = (\<integral>\<^isup>+x. f x * indicator ?N x - g x * indicator ?N x \<partial>M)"
   1.607        by (auto intro!: positive_integral_cong simp: indicator_def)
   1.608      also have "\<dots> = ?P f ?N - ?P g ?N"
   1.609      proof (rule positive_integral_diff)
   1.610        show "(\<lambda>x. f x * indicator ?N x) \<in> borel_measurable M" "(\<lambda>x. g x * indicator ?N x) \<in> borel_measurable M"
   1.611          using borel N by auto
   1.612 -      have "?P g ?N \<le> positive_integral g"
   1.613 +      have "?P g ?N \<le> integral\<^isup>P M g"
   1.614          by (auto intro!: positive_integral_mono simp: indicator_def)
   1.615        then show "?P g ?N \<noteq> \<omega>" using g_fin by auto
   1.616        fix x assume "x \<in> space M"
   1.617 @@ -848,17 +858,17 @@
   1.618  
   1.619  lemma (in finite_measure) density_unique_finite_measure:
   1.620    assumes borel: "f \<in> borel_measurable M" "f' \<in> borel_measurable M"
   1.621 -  assumes f: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+x. f x * indicator A x) = (\<integral>\<^isup>+x. f' x * indicator A x)"
   1.622 +  assumes f: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^isup>+x. f' x * indicator A x \<partial>M)"
   1.623      (is "\<And>A. A \<in> sets M \<Longrightarrow> ?P f A = ?P f' A")
   1.624    shows "AE x. f x = f' x"
   1.625  proof -
   1.626    let "?\<nu> A" = "?P f A" and "?\<nu>' A" = "?P f' A"
   1.627    let "?f A x" = "f x * indicator A x" and "?f' A x" = "f' x * indicator A x"
   1.628 -  interpret M: measure_space M ?\<nu>
   1.629 -    using borel(1) by (rule measure_space_density)
   1.630 +  interpret M: measure_space "M\<lparr> measure := ?\<nu>\<rparr>"
   1.631 +    using borel(1) by (rule measure_space_density) simp
   1.632    have ac: "absolutely_continuous ?\<nu>"
   1.633      using f by (rule density_is_absolutely_continuous)
   1.634 -  from split_space_into_finite_sets_and_rest[OF `measure_space M ?\<nu>` ac]
   1.635 +  from split_space_into_finite_sets_and_rest[OF `measure_space (M\<lparr> measure := ?\<nu>\<rparr>)` ac]
   1.636    obtain Q0 and Q :: "nat \<Rightarrow> 'a set"
   1.637      where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
   1.638      and Q0: "Q0 \<in> sets M" "Q0 = space M - (\<Union>i. Q i)"
   1.639 @@ -876,13 +886,13 @@
   1.640    have 2: "AE x. ?f Q0 x = ?f' Q0 x"
   1.641    proof (rule AE_I')
   1.642      { fix f :: "'a \<Rightarrow> pextreal" assume borel: "f \<in> borel_measurable M"
   1.643 -        and eq: "\<And>A. A \<in> sets M \<Longrightarrow> ?\<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.644 +        and eq: "\<And>A. A \<in> sets M \<Longrightarrow> ?\<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.645        let "?A i" = "Q0 \<inter> {x \<in> space M. f x < of_nat i}"
   1.646        have "(\<Union>i. ?A i) \<in> null_sets"
   1.647        proof (rule null_sets_UN)
   1.648          fix i have "?A i \<in> sets M"
   1.649            using borel Q0(1) by auto
   1.650 -        have "?\<nu> (?A i) \<le> (\<integral>\<^isup>+x. of_nat i * indicator (?A i) x)"
   1.651 +        have "?\<nu> (?A i) \<le> (\<integral>\<^isup>+x. of_nat i * indicator (?A i) x \<partial>M)"
   1.652            unfolding eq[OF `?A i \<in> sets M`]
   1.653            by (auto intro!: positive_integral_mono simp: indicator_def)
   1.654          also have "\<dots> = of_nat i * \<mu> (?A i)"
   1.655 @@ -912,63 +922,72 @@
   1.656  
   1.657  lemma (in sigma_finite_measure) density_unique:
   1.658    assumes borel: "f \<in> borel_measurable M" "f' \<in> borel_measurable M"
   1.659 -  assumes f: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+x. f x * indicator A x) = (\<integral>\<^isup>+x. f' x * indicator A x)"
   1.660 +  assumes f: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^isup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^isup>+x. f' x * indicator A x \<partial>M)"
   1.661      (is "\<And>A. A \<in> sets M \<Longrightarrow> ?P f A = ?P f' A")
   1.662    shows "AE x. f x = f' x"
   1.663  proof -
   1.664    obtain h where h_borel: "h \<in> borel_measurable M"
   1.665 -    and fin: "positive_integral h \<noteq> \<omega>" and pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x \<and> h x < \<omega>"
   1.666 +    and fin: "integral\<^isup>P M h \<noteq> \<omega>" and pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x \<and> h x < \<omega>"
   1.667      using Ex_finite_integrable_function by auto
   1.668 -  interpret h: measure_space M "\<lambda>A. (\<integral>\<^isup>+x. h x * indicator A x)"
   1.669 -    using h_borel by (rule measure_space_density)
   1.670 -  interpret h: finite_measure M "\<lambda>A. (\<integral>\<^isup>+x. h x * indicator A x)"
   1.671 +  interpret h: measure_space "M\<lparr> measure := \<lambda>A. (\<integral>\<^isup>+x. h x * indicator A x \<partial>M) \<rparr>"
   1.672 +    using h_borel by (rule measure_space_density) simp
   1.673 +  interpret h: finite_measure "M\<lparr> measure := \<lambda>A. (\<integral>\<^isup>+x. h x * indicator A x \<partial>M) \<rparr>"
   1.674      by default (simp cong: positive_integral_cong add: fin)
   1.675 -  interpret f: measure_space M "\<lambda>A. (\<integral>\<^isup>+x. f x * indicator A x)"
   1.676 -    using borel(1) by (rule measure_space_density)
   1.677 -  interpret f': measure_space M "\<lambda>A. (\<integral>\<^isup>+x. f' x * indicator A x)"
   1.678 -    using borel(2) by (rule measure_space_density)
   1.679 +  let ?fM = "M\<lparr>measure := \<lambda>A. (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)\<rparr>"
   1.680 +  interpret f: measure_space ?fM
   1.681 +    using borel(1) by (rule measure_space_density) simp
   1.682 +  let ?f'M = "M\<lparr>measure := \<lambda>A. (\<integral>\<^isup>+x. f' x * indicator A x \<partial>M)\<rparr>"
   1.683 +  interpret f': measure_space ?f'M
   1.684 +    using borel(2) by (rule measure_space_density) simp
   1.685    { fix A assume "A \<in> sets M"
   1.686      then have " {x \<in> space M. h x \<noteq> 0 \<and> indicator A x \<noteq> (0::pextreal)} = A"
   1.687        using pos sets_into_space by (force simp: indicator_def)
   1.688 -    then have "(\<integral>\<^isup>+x. h x * indicator A x) = 0 \<longleftrightarrow> A \<in> null_sets"
   1.689 +    then have "(\<integral>\<^isup>+x. h x * indicator A x \<partial>M) = 0 \<longleftrightarrow> A \<in> null_sets"
   1.690        using h_borel `A \<in> sets M` by (simp add: positive_integral_0_iff) }
   1.691    note h_null_sets = this
   1.692    { fix A assume "A \<in> sets M"
   1.693 -    have "(\<integral>\<^isup>+x. h x * (f x * indicator A x)) =
   1.694 -      f.positive_integral (\<lambda>x. h x * indicator A x)"
   1.695 +    have "(\<integral>\<^isup>+x. h x * (f x * indicator A x) \<partial>M) = (\<integral>\<^isup>+x. h x * indicator A x \<partial>?fM)"
   1.696 +      using `A \<in> sets M` h_borel borel
   1.697 +      by (simp add: positive_integral_translated_density ac_simps cong: positive_integral_cong)
   1.698 +    also have "\<dots> = (\<integral>\<^isup>+x. h x * indicator A x \<partial>?f'M)"
   1.699 +      by (rule f'.positive_integral_cong_measure) (simp_all add: f)
   1.700 +    also have "\<dots> = (\<integral>\<^isup>+x. h x * (f' x * indicator A x) \<partial>M)"
   1.701        using `A \<in> sets M` h_borel borel
   1.702        by (simp add: positive_integral_translated_density ac_simps cong: positive_integral_cong)
   1.703 -    also have "\<dots> = f'.positive_integral (\<lambda>x. h x * indicator A x)"
   1.704 -      by (rule f'.positive_integral_cong_measure) (rule f)
   1.705 -    also have "\<dots> = (\<integral>\<^isup>+x. h x * (f' x * indicator A x))"
   1.706 -      using `A \<in> sets M` h_borel borel
   1.707 -      by (simp add: positive_integral_translated_density ac_simps cong: positive_integral_cong)
   1.708 -    finally have "(\<integral>\<^isup>+x. h x * (f x * indicator A x)) = (\<integral>\<^isup>+x. h x * (f' x * indicator A x))" . }
   1.709 +    finally have "(\<integral>\<^isup>+x. h x * (f x * indicator A x) \<partial>M) = (\<integral>\<^isup>+x. h x * (f' x * indicator A x) \<partial>M)" . }
   1.710    then have "h.almost_everywhere (\<lambda>x. f x = f' x)"
   1.711      using h_borel borel
   1.712 -    by (intro h.density_unique_finite_measure[OF borel])
   1.713 -       (simp add: positive_integral_translated_density)
   1.714 +    apply (intro h.density_unique_finite_measure)
   1.715 +    apply (simp add: measurable_def)
   1.716 +    apply (simp add: measurable_def)
   1.717 +    by (simp add: positive_integral_translated_density)
   1.718    then show "AE x. f x = f' x"
   1.719      unfolding h.almost_everywhere_def almost_everywhere_def
   1.720      by (auto simp add: h_null_sets)
   1.721  qed
   1.722  
   1.723  lemma (in sigma_finite_measure) sigma_finite_iff_density_finite:
   1.724 -  assumes \<nu>: "measure_space M \<nu>" and f: "f \<in> borel_measurable M"
   1.725 -    and eq: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.726 -  shows "sigma_finite_measure M \<nu> \<longleftrightarrow> (AE x. f x \<noteq> \<omega>)"
   1.727 +  assumes \<nu>: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" (is "measure_space ?N")
   1.728 +    and f: "f \<in> borel_measurable M"
   1.729 +    and eq: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.730 +  shows "sigma_finite_measure (M\<lparr>measure := \<nu>\<rparr>) \<longleftrightarrow> (AE x. f x \<noteq> \<omega>)"
   1.731  proof
   1.732 -  assume "sigma_finite_measure M \<nu>"
   1.733 -  then interpret \<nu>: sigma_finite_measure M \<nu> .
   1.734 +  assume "sigma_finite_measure ?N"
   1.735 +  then interpret \<nu>: sigma_finite_measure ?N
   1.736 +    where "borel_measurable ?N = borel_measurable M" and "measure ?N = \<nu>"
   1.737 +    and "sets ?N = sets M" and "space ?N = space M" by (auto simp: measurable_def)
   1.738    from \<nu>.Ex_finite_integrable_function obtain h where
   1.739 -    h: "h \<in> borel_measurable M" "\<nu>.positive_integral h \<noteq> \<omega>"
   1.740 +    h: "h \<in> borel_measurable M" "integral\<^isup>P ?N h \<noteq> \<omega>"
   1.741      and fin: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x \<and> h x < \<omega>" by auto
   1.742    have "AE x. f x * h x \<noteq> \<omega>"
   1.743    proof (rule AE_I')
   1.744 -    have "\<nu>.positive_integral h = (\<integral>\<^isup>+x. f x * h x)"
   1.745 -      by (simp add: \<nu>.positive_integral_cong_measure[symmetric, OF eq[symmetric]])
   1.746 -         (intro positive_integral_translated_density f h)
   1.747 -    then have "(\<integral>\<^isup>+x. f x * h x) \<noteq> \<omega>"
   1.748 +    have "integral\<^isup>P ?N h = (\<integral>\<^isup>+x. f x * h x \<partial>M)"
   1.749 +      apply (subst \<nu>.positive_integral_cong_measure[symmetric,
   1.750 +        of "M\<lparr> measure := \<lambda> A. \<integral>\<^isup>+x. f x * indicator A x \<partial>M \<rparr>"])
   1.751 +      apply (simp_all add: eq)
   1.752 +      apply (rule positive_integral_translated_density)
   1.753 +      using f h by auto
   1.754 +    then have "(\<integral>\<^isup>+x. f x * h x \<partial>M) \<noteq> \<omega>"
   1.755        using h(2) by simp
   1.756      then show "(\<lambda>x. f x * h x) -` {\<omega>} \<inter> space M \<in> null_sets"
   1.757        using f h(1) by (auto intro!: positive_integral_omega borel_measurable_vimage)
   1.758 @@ -981,7 +1000,9 @@
   1.759  next
   1.760    assume AE: "AE x. f x \<noteq> \<omega>"
   1.761    from sigma_finite guess Q .. note Q = this
   1.762 -  interpret \<nu>: measure_space M \<nu> by fact
   1.763 +  interpret \<nu>: measure_space ?N
   1.764 +    where "borel_measurable ?N = borel_measurable M" and "measure ?N = \<nu>"
   1.765 +    and "sets ?N = sets M" and "space ?N = space M" using \<nu> by (auto simp: measurable_def)
   1.766    def A \<equiv> "\<lambda>i. f -` (case i of 0 \<Rightarrow> {\<omega>} | Suc n \<Rightarrow> {.. of_nat (Suc n)}) \<inter> space M"
   1.767    { fix i j have "A i \<inter> Q j \<in> sets M"
   1.768      unfolding A_def using f Q
   1.769 @@ -989,11 +1010,11 @@
   1.770      by (cases i) (auto intro: measurable_sets[OF f]) }
   1.771    note A_in_sets = this
   1.772    let "?A n" = "case prod_decode n of (i,j) \<Rightarrow> A i \<inter> Q j"
   1.773 -  show "sigma_finite_measure M \<nu>"
   1.774 +  show "sigma_finite_measure ?N"
   1.775    proof (default, intro exI conjI subsetI allI)
   1.776      fix x assume "x \<in> range ?A"
   1.777      then obtain n where n: "x = ?A n" by auto
   1.778 -    then show "x \<in> sets M" using A_in_sets by (cases "prod_decode n") auto
   1.779 +    then show "x \<in> sets ?N" using A_in_sets by (cases "prod_decode n") auto
   1.780    next
   1.781      have "(\<Union>i. ?A i) = (\<Union>i j. A i \<inter> Q j)"
   1.782      proof safe
   1.783 @@ -1014,16 +1035,16 @@
   1.784          then show ?thesis using x preal unfolding A_def by (auto intro!: exI[of _ "Suc n"])
   1.785        qed
   1.786      qed (auto simp: A_def)
   1.787 -    finally show "(\<Union>i. ?A i) = space M" by simp
   1.788 +    finally show "(\<Union>i. ?A i) = space ?N" by simp
   1.789    next
   1.790      fix n obtain i j where
   1.791        [simp]: "prod_decode n = (i, j)" by (cases "prod_decode n") auto
   1.792 -    have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x) \<noteq> \<omega>"
   1.793 +    have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<noteq> \<omega>"
   1.794      proof (cases i)
   1.795        case 0
   1.796        have "AE x. f x * indicator (A i \<inter> Q j) x = 0"
   1.797          using AE by (rule AE_mp) (auto intro!: AE_cong simp: A_def `i = 0`)
   1.798 -      then have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x) = 0"
   1.799 +      then have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) = 0"
   1.800          using A_in_sets f
   1.801          apply (subst positive_integral_0_iff)
   1.802          apply fast
   1.803 @@ -1034,8 +1055,8 @@
   1.804        then show ?thesis by simp
   1.805      next
   1.806        case (Suc n)
   1.807 -      then have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x) \<le>
   1.808 -        (\<integral>\<^isup>+x. of_nat (Suc n) * indicator (Q j) x)"
   1.809 +      then have "(\<integral>\<^isup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<le>
   1.810 +        (\<integral>\<^isup>+x. of_nat (Suc n) * indicator (Q j) x \<partial>M)"
   1.811          by (auto intro!: positive_integral_mono simp: indicator_def A_def)
   1.812        also have "\<dots> = of_nat (Suc n) * \<mu> (Q j)"
   1.813          using Q by (auto intro!: positive_integral_cmult_indicator)
   1.814 @@ -1043,33 +1064,34 @@
   1.815          using Q by auto
   1.816        finally show ?thesis by simp
   1.817      qed
   1.818 -    then show "\<nu> (?A n) \<noteq> \<omega>"
   1.819 +    then show "measure ?N (?A n) \<noteq> \<omega>"
   1.820        using A_in_sets Q eq by auto
   1.821    qed
   1.822  qed
   1.823  
   1.824  section "Radon-Nikodym derivative"
   1.825  
   1.826 -definition (in sigma_finite_measure)
   1.827 -  "RN_deriv \<nu> \<equiv> SOME f. f \<in> borel_measurable M \<and>
   1.828 -    (\<forall>A \<in> sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x))"
   1.829 +definition
   1.830 +  "RN_deriv M \<nu> \<equiv> SOME f. f \<in> borel_measurable M \<and>
   1.831 +    (\<forall>A \<in> sets M. \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M))"
   1.832  
   1.833  lemma (in sigma_finite_measure) RN_deriv_cong:
   1.834 -  assumes cong: "\<And>A. A \<in> sets M \<Longrightarrow> \<mu>' A = \<mu> A" "\<And>A. A \<in> sets M \<Longrightarrow> \<nu>' A = \<nu> A"
   1.835 -  shows "sigma_finite_measure.RN_deriv M \<mu>' \<nu>' x = RN_deriv \<nu> x"
   1.836 +  assumes cong: "\<And>A. A \<in> sets M \<Longrightarrow> measure M' A = \<mu> A" "sets M' = sets M" "space M' = space M"
   1.837 +    and \<nu>: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu>' A = \<nu> A"
   1.838 +  shows "RN_deriv M' \<nu>' x = RN_deriv M \<nu> x"
   1.839  proof -
   1.840 -  interpret \<mu>': sigma_finite_measure M \<mu>'
   1.841 -    using cong(1) by (rule sigma_finite_measure_cong)
   1.842 +  interpret \<mu>': sigma_finite_measure M'
   1.843 +    using cong by (rule sigma_finite_measure_cong)
   1.844    show ?thesis
   1.845 -    unfolding RN_deriv_def \<mu>'.RN_deriv_def
   1.846 -    by (simp add: cong positive_integral_cong_measure[OF cong(1)])
   1.847 +    unfolding RN_deriv_def
   1.848 +    by (simp add: cong \<nu> positive_integral_cong_measure[OF cong] measurable_def)
   1.849  qed
   1.850  
   1.851  lemma (in sigma_finite_measure) RN_deriv:
   1.852 -  assumes "measure_space M \<nu>"
   1.853 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)"
   1.854    assumes "absolutely_continuous \<nu>"
   1.855 -  shows "RN_deriv \<nu> \<in> borel_measurable M" (is ?borel)
   1.856 -  and "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. RN_deriv \<nu> x * indicator A x)"
   1.857 +  shows "RN_deriv M \<nu> \<in> borel_measurable M" (is ?borel)
   1.858 +  and "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. RN_deriv M \<nu> x * indicator A x \<partial>M)"
   1.859      (is "\<And>A. _ \<Longrightarrow> ?int A")
   1.860  proof -
   1.861    note Ex = Radon_Nikodym[OF assms, unfolded Bex_def]
   1.862 @@ -1080,87 +1102,92 @@
   1.863  qed
   1.864  
   1.865  lemma (in sigma_finite_measure) RN_deriv_positive_integral:
   1.866 -  assumes \<nu>: "measure_space M \<nu>" "absolutely_continuous \<nu>"
   1.867 +  assumes \<nu>: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" "absolutely_continuous \<nu>"
   1.868      and f: "f \<in> borel_measurable M"
   1.869 -  shows "measure_space.positive_integral M \<nu> f = (\<integral>\<^isup>+x. RN_deriv \<nu> x * f x)"
   1.870 +  shows "integral\<^isup>P (M\<lparr>measure := \<nu>\<rparr>) f = (\<integral>\<^isup>+x. RN_deriv M \<nu> x * f x \<partial>M)"
   1.871  proof -
   1.872 -  interpret \<nu>: measure_space M \<nu> by fact
   1.873 -  have "\<nu>.positive_integral f =
   1.874 -    measure_space.positive_integral M (\<lambda>A. (\<integral>\<^isup>+x. RN_deriv \<nu> x * indicator A x)) f"
   1.875 -    by (intro \<nu>.positive_integral_cong_measure[symmetric] RN_deriv(2)[OF \<nu>, symmetric])
   1.876 -  also have "\<dots> = (\<integral>\<^isup>+x. RN_deriv \<nu> x * f x)"
   1.877 -    by (intro positive_integral_translated_density RN_deriv[OF \<nu>] f)
   1.878 +  interpret \<nu>: measure_space "M\<lparr>measure := \<nu>\<rparr>" by fact
   1.879 +  have "integral\<^isup>P (M\<lparr>measure := \<nu>\<rparr>) f =
   1.880 +    integral\<^isup>P (M\<lparr>measure := \<lambda>A. (\<integral>\<^isup>+x. RN_deriv M \<nu> x * indicator A x \<partial>M)\<rparr>) f"
   1.881 +    by (intro \<nu>.positive_integral_cong_measure[symmetric])
   1.882 +       (simp_all add:  RN_deriv(2)[OF \<nu>, symmetric])
   1.883 +  also have "\<dots> = (\<integral>\<^isup>+x. RN_deriv M \<nu> x * f x \<partial>M)"
   1.884 +    by (intro positive_integral_translated_density)
   1.885 +       (simp_all add: RN_deriv[OF \<nu>] f)
   1.886    finally show ?thesis .
   1.887  qed
   1.888  
   1.889  lemma (in sigma_finite_measure) RN_deriv_unique:
   1.890 -  assumes \<nu>: "measure_space M \<nu>" "absolutely_continuous \<nu>"
   1.891 +  assumes \<nu>: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" "absolutely_continuous \<nu>"
   1.892    and f: "f \<in> borel_measurable M"
   1.893 -  and eq: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x)"
   1.894 -  shows "AE x. f x = RN_deriv \<nu> x"
   1.895 +  and eq: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = (\<integral>\<^isup>+x. f x * indicator A x \<partial>M)"
   1.896 +  shows "AE x. f x = RN_deriv M \<nu> x"
   1.897  proof (rule density_unique[OF f RN_deriv(1)[OF \<nu>]])
   1.898    fix A assume A: "A \<in> sets M"
   1.899 -  show "(\<integral>\<^isup>+x. f x * indicator A x) = (\<integral>\<^isup>+x. RN_deriv \<nu> x * indicator A x)"
   1.900 +  show "(\<integral>\<^isup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^isup>+x. RN_deriv M \<nu> x * indicator A x \<partial>M)"
   1.901      unfolding eq[OF A, symmetric] RN_deriv(2)[OF \<nu> A, symmetric] ..
   1.902  qed
   1.903  
   1.904 -
   1.905  lemma (in sigma_finite_measure) RN_deriv_finite:
   1.906 -  assumes sfm: "sigma_finite_measure M \<nu>" and ac: "absolutely_continuous \<nu>"
   1.907 -  shows "AE x. RN_deriv \<nu> x \<noteq> \<omega>"
   1.908 +  assumes sfm: "sigma_finite_measure (M\<lparr>measure := \<nu>\<rparr>)" and ac: "absolutely_continuous \<nu>"
   1.909 +  shows "AE x. RN_deriv M \<nu> x \<noteq> \<omega>"
   1.910  proof -
   1.911 -  interpret \<nu>: sigma_finite_measure M \<nu> by fact
   1.912 -  have \<nu>: "measure_space M \<nu>" by default
   1.913 +  interpret \<nu>: sigma_finite_measure "M\<lparr>measure := \<nu>\<rparr>" by fact
   1.914 +  have \<nu>: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" by default
   1.915    from sfm show ?thesis
   1.916      using sigma_finite_iff_density_finite[OF \<nu> RN_deriv[OF \<nu> ac]] by simp
   1.917  qed
   1.918  
   1.919  lemma (in sigma_finite_measure)
   1.920 -  assumes \<nu>: "sigma_finite_measure M \<nu>" "absolutely_continuous \<nu>"
   1.921 +  assumes \<nu>: "sigma_finite_measure (M\<lparr>measure := \<nu>\<rparr>)" "absolutely_continuous \<nu>"
   1.922      and f: "f \<in> borel_measurable M"
   1.923 -  shows RN_deriv_integral: "measure_space.integral M \<nu> f = (\<integral>x. real (RN_deriv \<nu> x) * f x)" (is ?integral)
   1.924 -    and RN_deriv_integrable: "measure_space.integrable M \<nu> f \<longleftrightarrow> integrable (\<lambda>x. real (RN_deriv \<nu> x) * f x)" (is ?integrable)
   1.925 +  shows RN_deriv_integrable: "integrable (M\<lparr>measure := \<nu>\<rparr>) f \<longleftrightarrow>
   1.926 +      integrable M (\<lambda>x. real (RN_deriv M \<nu> x) * f x)" (is ?integrable)
   1.927 +    and RN_deriv_integral: "integral\<^isup>L (M\<lparr>measure := \<nu>\<rparr>) f =
   1.928 +      (\<integral>x. real (RN_deriv M \<nu> x) * f x \<partial>M)" (is ?integral)
   1.929  proof -
   1.930 -  interpret \<nu>: sigma_finite_measure M \<nu> by fact
   1.931 -  have ms: "measure_space M \<nu>" by default
   1.932 +  interpret \<nu>: sigma_finite_measure "M\<lparr>measure := \<nu>\<rparr>" by fact
   1.933 +  have ms: "measure_space (M\<lparr>measure := \<nu>\<rparr>)" by default
   1.934    have minus_cong: "\<And>A B A' B'::pextreal. A = A' \<Longrightarrow> B = B' \<Longrightarrow> real A - real B = real A' - real B'" by simp
   1.935    have f': "(\<lambda>x. - f x) \<in> borel_measurable M" using f by auto
   1.936 -  { fix f :: "'a \<Rightarrow> real" assume "f \<in> borel_measurable M"
   1.937 -    { fix x assume *: "RN_deriv \<nu> x \<noteq> \<omega>"
   1.938 -      have "Real (real (RN_deriv \<nu> x)) * Real (f x) = Real (real (RN_deriv \<nu> x) * f x)"
   1.939 +  have Nf: "f \<in> borel_measurable (M\<lparr>measure := \<nu>\<rparr>)" using f unfolding measurable_def by auto
   1.940 +  { fix f :: "'a \<Rightarrow> real"
   1.941 +    { fix x assume *: "RN_deriv M \<nu> x \<noteq> \<omega>"
   1.942 +      have "Real (real (RN_deriv M \<nu> x)) * Real (f x) = Real (real (RN_deriv M \<nu> x) * f x)"
   1.943          by (simp add: mult_le_0_iff)
   1.944 -      then have "RN_deriv \<nu> x * Real (f x) = Real (real (RN_deriv \<nu> x) * f x)"
   1.945 +      then have "RN_deriv M \<nu> x * Real (f x) = Real (real (RN_deriv M \<nu> x) * f x)"
   1.946          using * by (simp add: Real_real) }
   1.947      note * = this
   1.948 -    have "(\<integral>\<^isup>+x. RN_deriv \<nu> x * Real (f x)) = (\<integral>\<^isup>+x. Real (real (RN_deriv \<nu> x) * f x))"
   1.949 +    have "(\<integral>\<^isup>+x. RN_deriv M \<nu> x * Real (f x) \<partial>M) = (\<integral>\<^isup>+x. Real (real (RN_deriv M \<nu> x) * f x) \<partial>M)"
   1.950        apply (rule positive_integral_cong_AE)
   1.951        apply (rule AE_mp[OF RN_deriv_finite[OF \<nu>]])
   1.952        by (auto intro!: AE_cong simp: *) }
   1.953 -  with this[OF f] this[OF f'] f f'
   1.954 +  with this this f f' Nf
   1.955    show ?integral ?integrable
   1.956 -    unfolding \<nu>.integral_def integral_def \<nu>.integrable_def integrable_def
   1.957 -    by (auto intro!: RN_deriv(1)[OF ms \<nu>(2)] minus_cong simp: RN_deriv_positive_integral[OF ms \<nu>(2)])
   1.958 +    unfolding lebesgue_integral_def integrable_def
   1.959 +    by (auto intro!: RN_deriv(1)[OF ms \<nu>(2)] minus_cong
   1.960 +             simp: RN_deriv_positive_integral[OF ms \<nu>(2)])
   1.961  qed
   1.962  
   1.963  lemma (in sigma_finite_measure) RN_deriv_singleton:
   1.964 -  assumes "measure_space M \<nu>"
   1.965 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)"
   1.966    and ac: "absolutely_continuous \<nu>"
   1.967    and "{x} \<in> sets M"
   1.968 -  shows "\<nu> {x} = RN_deriv \<nu> x * \<mu> {x}"
   1.969 +  shows "\<nu> {x} = RN_deriv M \<nu> x * \<mu> {x}"
   1.970  proof -
   1.971    note deriv = RN_deriv[OF assms(1, 2)]
   1.972    from deriv(2)[OF `{x} \<in> sets M`]
   1.973 -  have "\<nu> {x} = (\<integral>\<^isup>+w. RN_deriv \<nu> x * indicator {x} w)"
   1.974 +  have "\<nu> {x} = (\<integral>\<^isup>+w. RN_deriv M \<nu> x * indicator {x} w \<partial>M)"
   1.975      by (auto simp: indicator_def intro!: positive_integral_cong)
   1.976    thus ?thesis using positive_integral_cmult_indicator[OF `{x} \<in> sets M`]
   1.977      by auto
   1.978  qed
   1.979  
   1.980  theorem (in finite_measure_space) RN_deriv_finite_measure:
   1.981 -  assumes "measure_space M \<nu>"
   1.982 +  assumes "measure_space (M\<lparr>measure := \<nu>\<rparr>)"
   1.983    and ac: "absolutely_continuous \<nu>"
   1.984    and "x \<in> space M"
   1.985 -  shows "\<nu> {x} = RN_deriv \<nu> x * \<mu> {x}"
   1.986 +  shows "\<nu> {x} = RN_deriv M \<nu> x * \<mu> {x}"
   1.987  proof -
   1.988    have "{x} \<in> sets M" using sets_eq_Pow `x \<in> space M` by auto
   1.989    from RN_deriv_singleton[OF assms(1,2) this] show ?thesis .