src/HOL/Probability/Radon_Nikodym.thy
 author hoelzl Thu Sep 02 17:12:40 2010 +0200 (2010-09-02) changeset 39092 98de40859858 parent 38656 d5d342611edb child 39097 943c7b348524 permissions -rw-r--r--
move lemmas to correct theory files
```     1 theory Radon_Nikodym
```
```     2 imports Lebesgue_Integration
```
```     3 begin
```
```     4
```
```     5 lemma (in sigma_finite_measure) Ex_finite_integrable_function:
```
```     6   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>)"
```
```     7 proof -
```
```     8   obtain A :: "nat \<Rightarrow> 'a set" where
```
```     9     range: "range A \<subseteq> sets M" and
```
```    10     space: "(\<Union>i. A i) = space M" and
```
```    11     measure: "\<And>i. \<mu> (A i) \<noteq> \<omega>" and
```
```    12     disjoint: "disjoint_family A"
```
```    13     using disjoint_sigma_finite by auto
```
```    14   let "?B i" = "2^Suc i * \<mu> (A i)"
```
```    15   have "\<forall>i. \<exists>x. 0 < x \<and> x < inverse (?B i)"
```
```    16   proof
```
```    17     fix i show "\<exists>x. 0 < x \<and> x < inverse (?B i)"
```
```    18     proof cases
```
```    19       assume "\<mu> (A i) = 0"
```
```    20       then show ?thesis by (auto intro!: exI[of _ 1])
```
```    21     next
```
```    22       assume not_0: "\<mu> (A i) \<noteq> 0"
```
```    23       then have "?B i \<noteq> \<omega>" using measure[of i] by auto
```
```    24       then have "inverse (?B i) \<noteq> 0" unfolding pinfreal_inverse_eq_0 by simp
```
```    25       then show ?thesis using measure[of i] not_0
```
```    26         by (auto intro!: exI[of _ "inverse (?B i) / 2"]
```
```    27                  simp: pinfreal_noteq_omega_Ex zero_le_mult_iff zero_less_mult_iff mult_le_0_iff power_le_zero_eq)
```
```    28     qed
```
```    29   qed
```
```    30   from choice[OF this] obtain n where n: "\<And>i. 0 < n i"
```
```    31     "\<And>i. n i < inverse (2^Suc i * \<mu> (A i))" by auto
```
```    32   let "?h x" = "\<Sum>\<^isub>\<infinity> i. n i * indicator (A i) x"
```
```    33   show ?thesis
```
```    34   proof (safe intro!: bexI[of _ ?h] del: notI)
```
```    35     have "\<And>i. A i \<in> sets M"
```
```    36       using range by fastsimp+
```
```    37     then have "positive_integral ?h = (\<Sum>\<^isub>\<infinity> i. n i * \<mu> (A i))"
```
```    38       by (simp add: positive_integral_psuminf positive_integral_cmult_indicator)
```
```    39     also have "\<dots> \<le> (\<Sum>\<^isub>\<infinity> i. Real ((1 / 2)^Suc i))"
```
```    40     proof (rule psuminf_le)
```
```    41       fix N show "n N * \<mu> (A N) \<le> Real ((1 / 2) ^ Suc N)"
```
```    42         using measure[of N] n[of N]
```
```    43         by (cases "n N")
```
```    44            (auto simp: pinfreal_noteq_omega_Ex field_simps zero_le_mult_iff
```
```    45                        mult_le_0_iff mult_less_0_iff power_less_zero_eq
```
```    46                        power_le_zero_eq inverse_eq_divide less_divide_eq
```
```    47                        power_divide split: split_if_asm)
```
```    48     qed
```
```    49     also have "\<dots> = Real 1"
```
```    50       by (rule suminf_imp_psuminf, rule power_half_series, auto)
```
```    51     finally show "positive_integral ?h \<noteq> \<omega>" by auto
```
```    52   next
```
```    53     fix x assume "x \<in> space M"
```
```    54     then obtain i where "x \<in> A i" using space[symmetric] by auto
```
```    55     from psuminf_cmult_indicator[OF disjoint, OF this]
```
```    56     have "?h x = n i" by simp
```
```    57     then show "0 < ?h x" and "?h x < \<omega>" using n[of i] by auto
```
```    58   next
```
```    59     show "?h \<in> borel_measurable M" using range
```
```    60       by (auto intro!: borel_measurable_psuminf borel_measurable_pinfreal_times)
```
```    61   qed
```
```    62 qed
```
```    63
```
```    64 definition (in measure_space)
```
```    65   "absolutely_continuous \<nu> = (\<forall>N\<in>null_sets. \<nu> N = (0 :: pinfreal))"
```
```    66
```
```    67 lemma (in finite_measure) Radon_Nikodym_aux_epsilon:
```
```    68   fixes e :: real assumes "0 < e"
```
```    69   assumes "finite_measure M s"
```
```    70   shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (s (space M)) \<le>
```
```    71                     real (\<mu> A) - real (s A) \<and>
```
```    72                     (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> - e < real (\<mu> B) - real (s B))"
```
```    73 proof -
```
```    74   let "?d A" = "real (\<mu> A) - real (s A)"
```
```    75   interpret M': finite_measure M s by fact
```
```    76
```
```    77   let "?A A" = "if (\<forall>B\<in>sets M. B \<subseteq> space M - A \<longrightarrow> -e < ?d B)
```
```    78     then {}
```
```    79     else (SOME B. B \<in> sets M \<and> B \<subseteq> space M - A \<and> ?d B \<le> -e)"
```
```    80   def A \<equiv> "\<lambda>n. ((\<lambda>B. B \<union> ?A B) ^^ n) {}"
```
```    81
```
```    82   have A_simps[simp]:
```
```    83     "A 0 = {}"
```
```    84     "\<And>n. A (Suc n) = (A n \<union> ?A (A n))" unfolding A_def by simp_all
```
```    85
```
```    86   { fix A assume "A \<in> sets M"
```
```    87     have "?A A \<in> sets M"
```
```    88       by (auto intro!: someI2[of _ _ "\<lambda>A. A \<in> sets M"] simp: not_less) }
```
```    89   note A'_in_sets = this
```
```    90
```
```    91   { fix n have "A n \<in> sets M"
```
```    92     proof (induct n)
```
```    93       case (Suc n) thus "A (Suc n) \<in> sets M"
```
```    94         using A'_in_sets[of "A n"] by (auto split: split_if_asm)
```
```    95     qed (simp add: A_def) }
```
```    96   note A_in_sets = this
```
```    97   hence "range A \<subseteq> sets M" by auto
```
```    98
```
```    99   { fix n B
```
```   100     assume Ex: "\<exists>B. B \<in> sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> -e"
```
```   101     hence False: "\<not> (\<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B)" by (auto simp: not_less)
```
```   102     have "?d (A (Suc n)) \<le> ?d (A n) - e" unfolding A_simps if_not_P[OF False]
```
```   103     proof (rule someI2_ex[OF Ex])
```
```   104       fix B assume "B \<in> sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e"
```
```   105       hence "A n \<inter> B = {}" "B \<in> sets M" and dB: "?d B \<le> -e" by auto
```
```   106       hence "?d (A n \<union> B) = ?d (A n) + ?d B"
```
```   107         using `A n \<in> sets M` real_finite_measure_Union M'.real_finite_measure_Union by simp
```
```   108       also have "\<dots> \<le> ?d (A n) - e" using dB by simp
```
```   109       finally show "?d (A n \<union> B) \<le> ?d (A n) - e" .
```
```   110     qed }
```
```   111   note dA_epsilon = this
```
```   112
```
```   113   { fix n have "?d (A (Suc n)) \<le> ?d (A n)"
```
```   114     proof (cases "\<exists>B. B\<in>sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e")
```
```   115       case True from dA_epsilon[OF this] show ?thesis using `0 < e` by simp
```
```   116     next
```
```   117       case False
```
```   118       hence "\<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B" by (auto simp: not_le)
```
```   119       thus ?thesis by simp
```
```   120     qed }
```
```   121   note dA_mono = this
```
```   122
```
```   123   show ?thesis
```
```   124   proof (cases "\<exists>n. \<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B")
```
```   125     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
```
```   126     show ?thesis
```
```   127     proof (safe intro!: bexI[of _ "space M - A n"])
```
```   128       fix B assume "B \<in> sets M" "B \<subseteq> space M - A n"
```
```   129       from B[OF this] show "-e < ?d B" .
```
```   130     next
```
```   131       show "space M - A n \<in> sets M" by (rule compl_sets) fact
```
```   132     next
```
```   133       show "?d (space M) \<le> ?d (space M - A n)"
```
```   134       proof (induct n)
```
```   135         fix n assume "?d (space M) \<le> ?d (space M - A n)"
```
```   136         also have "\<dots> \<le> ?d (space M - A (Suc n))"
```
```   137           using A_in_sets sets_into_space dA_mono[of n]
```
```   138             real_finite_measure_Diff[of "space M"]
```
```   139             real_finite_measure_Diff[of "space M"]
```
```   140             M'.real_finite_measure_Diff[of "space M"]
```
```   141             M'.real_finite_measure_Diff[of "space M"]
```
```   142           by (simp del: A_simps)
```
```   143         finally show "?d (space M) \<le> ?d (space M - A (Suc n))" .
```
```   144       qed simp
```
```   145     qed
```
```   146   next
```
```   147     case False hence B: "\<And>n. \<exists>B. B\<in>sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e"
```
```   148       by (auto simp add: not_less)
```
```   149     { fix n have "?d (A n) \<le> - real n * e"
```
```   150       proof (induct n)
```
```   151         case (Suc n) with dA_epsilon[of n, OF B] show ?case by (simp del: A_simps add: real_of_nat_Suc field_simps)
```
```   152       qed simp } note dA_less = this
```
```   153     have decseq: "decseq (\<lambda>n. ?d (A n))" unfolding decseq_eq_incseq
```
```   154     proof (rule incseq_SucI)
```
```   155       fix n show "- ?d (A n) \<le> - ?d (A (Suc n))" using dA_mono[of n] by auto
```
```   156     qed
```
```   157     from real_finite_continuity_from_below[of A] `range A \<subseteq> sets M`
```
```   158       M'.real_finite_continuity_from_below[of A]
```
```   159     have convergent: "(\<lambda>i. ?d (A i)) ----> ?d (\<Union>i. A i)"
```
```   160       by (auto intro!: LIMSEQ_diff)
```
```   161     obtain n :: nat where "- ?d (\<Union>i. A i) / e < real n" using reals_Archimedean2 by auto
```
```   162     moreover from order_trans[OF decseq_le[OF decseq convergent] dA_less]
```
```   163     have "real n \<le> - ?d (\<Union>i. A i) / e" using `0<e` by (simp add: field_simps)
```
```   164     ultimately show ?thesis by auto
```
```   165   qed
```
```   166 qed
```
```   167
```
```   168 lemma (in finite_measure) Radon_Nikodym_aux:
```
```   169   assumes "finite_measure M s"
```
```   170   shows "\<exists>A\<in>sets M. real (\<mu> (space M)) - real (s (space M)) \<le>
```
```   171                     real (\<mu> A) - real (s A) \<and>
```
```   172                     (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> 0 \<le> real (\<mu> B) - real (s B))"
```
```   173 proof -
```
```   174   let "?d A" = "real (\<mu> A) - real (s A)"
```
```   175   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)"
```
```   176
```
```   177   interpret M': finite_measure M s by fact
```
```   178
```
```   179   let "?r S" = "restricted_space S"
```
```   180
```
```   181   { fix S n
```
```   182     assume S: "S \<in> sets M"
```
```   183     hence **: "\<And>X. X \<in> op \<inter> S ` sets M \<longleftrightarrow> X \<in> sets M \<and> X \<subseteq> S" by auto
```
```   184     from M'.restricted_finite_measure[of S] restricted_finite_measure[of S] S
```
```   185     have "finite_measure (?r S) \<mu>" "0 < 1 / real (Suc n)"
```
```   186       "finite_measure (?r S) s" by auto
```
```   187     from finite_measure.Radon_Nikodym_aux_epsilon[OF this] guess X ..
```
```   188     hence "?P X S n"
```
```   189     proof (simp add: **, safe)
```
```   190       fix C assume C: "C \<in> sets M" "C \<subseteq> X" "X \<subseteq> S" and
```
```   191         *: "\<forall>B\<in>sets M. S \<inter> B \<subseteq> X \<longrightarrow> - (1 / real (Suc n)) < ?d (S \<inter> B)"
```
```   192       hence "C \<subseteq> S" "C \<subseteq> X" "S \<inter> C = C" by auto
```
```   193       with *[THEN bspec, OF `C \<in> sets M`]
```
```   194       show "- (1 / real (Suc n)) < ?d C" by auto
```
```   195     qed
```
```   196     hence "\<exists>A. ?P A S n" by auto }
```
```   197   note Ex_P = this
```
```   198
```
```   199   def A \<equiv> "nat_rec (space M) (\<lambda>n A. SOME B. ?P B A n)"
```
```   200   have A_Suc: "\<And>n. A (Suc n) = (SOME B. ?P B (A n) n)" by (simp add: A_def)
```
```   201   have A_0[simp]: "A 0 = space M" unfolding A_def by simp
```
```   202
```
```   203   { fix i have "A i \<in> sets M" unfolding A_def
```
```   204     proof (induct i)
```
```   205       case (Suc i)
```
```   206       from Ex_P[OF this, of i] show ?case unfolding nat_rec_Suc
```
```   207         by (rule someI2_ex) simp
```
```   208     qed simp }
```
```   209   note A_in_sets = this
```
```   210
```
```   211   { fix n have "?P (A (Suc n)) (A n) n"
```
```   212       using Ex_P[OF A_in_sets] unfolding A_Suc
```
```   213       by (rule someI2_ex) simp }
```
```   214   note P_A = this
```
```   215
```
```   216   have "range A \<subseteq> sets M" using A_in_sets by auto
```
```   217
```
```   218   have A_mono: "\<And>i. A (Suc i) \<subseteq> A i" using P_A by simp
```
```   219   have mono_dA: "mono (\<lambda>i. ?d (A i))" using P_A by (simp add: mono_iff_le_Suc)
```
```   220   have epsilon: "\<And>C i. \<lbrakk> C \<in> sets M; C \<subseteq> A (Suc i) \<rbrakk> \<Longrightarrow> - 1 / real (Suc i) < ?d C"
```
```   221       using P_A by auto
```
```   222
```
```   223   show ?thesis
```
```   224   proof (safe intro!: bexI[of _ "\<Inter>i. A i"])
```
```   225     show "(\<Inter>i. A i) \<in> sets M" using A_in_sets by auto
```
```   226     from `range A \<subseteq> sets M` A_mono
```
```   227       real_finite_continuity_from_above[of A]
```
```   228       M'.real_finite_continuity_from_above[of A]
```
```   229     have "(\<lambda>i. ?d (A i)) ----> ?d (\<Inter>i. A i)" by (auto intro!: LIMSEQ_diff)
```
```   230     thus "?d (space M) \<le> ?d (\<Inter>i. A i)" using mono_dA[THEN monoD, of 0 _]
```
```   231       by (rule_tac LIMSEQ_le_const) (auto intro!: exI)
```
```   232   next
```
```   233     fix B assume B: "B \<in> sets M" "B \<subseteq> (\<Inter>i. A i)"
```
```   234     show "0 \<le> ?d B"
```
```   235     proof (rule ccontr)
```
```   236       assume "\<not> 0 \<le> ?d B"
```
```   237       hence "0 < - ?d B" by auto
```
```   238       from ex_inverse_of_nat_Suc_less[OF this]
```
```   239       obtain n where *: "?d B < - 1 / real (Suc n)"
```
```   240         by (auto simp: real_eq_of_nat inverse_eq_divide field_simps)
```
```   241       have "B \<subseteq> A (Suc n)" using B by (auto simp del: nat_rec_Suc)
```
```   242       from epsilon[OF B(1) this] *
```
```   243       show False by auto
```
```   244     qed
```
```   245   qed
```
```   246 qed
```
```   247
```
```   248 lemma (in finite_measure) Radon_Nikodym_finite_measure:
```
```   249   assumes "finite_measure M \<nu>"
```
```   250   assumes "absolutely_continuous \<nu>"
```
```   251   shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
```
```   252 proof -
```
```   253   interpret M': finite_measure M \<nu> using assms(1) .
```
```   254
```
```   255   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}"
```
```   256   have "(\<lambda>x. 0) \<in> G" unfolding G_def by auto
```
```   257   hence "G \<noteq> {}" by auto
```
```   258
```
```   259   { fix f g assume f: "f \<in> G" and g: "g \<in> G"
```
```   260     have "(\<lambda>x. max (g x) (f x)) \<in> G" (is "?max \<in> G") unfolding G_def
```
```   261     proof safe
```
```   262       show "?max \<in> borel_measurable M" using f g unfolding G_def by auto
```
```   263
```
```   264       let ?A = "{x \<in> space M. f x \<le> g x}"
```
```   265       have "?A \<in> sets M" using f g unfolding G_def by auto
```
```   266
```
```   267       fix A assume "A \<in> sets M"
```
```   268       hence sets: "?A \<inter> A \<in> sets M" "(space M - ?A) \<inter> A \<in> sets M" using `?A \<in> sets M` by auto
```
```   269       have union: "((?A \<inter> A) \<union> ((space M - ?A) \<inter> A)) = A"
```
```   270         using sets_into_space[OF `A \<in> sets M`] by auto
```
```   271
```
```   272       have "\<And>x. x \<in> space M \<Longrightarrow> max (g x) (f x) * indicator A x =
```
```   273         g x * indicator (?A \<inter> A) x + f x * indicator ((space M - ?A) \<inter> A) x"
```
```   274         by (auto simp: indicator_def max_def)
```
```   275       hence "positive_integral (\<lambda>x. max (g x) (f x) * indicator A x) =
```
```   276         positive_integral (\<lambda>x. g x * indicator (?A \<inter> A) x) +
```
```   277         positive_integral (\<lambda>x. f x * indicator ((space M - ?A) \<inter> A) x)"
```
```   278         using f g sets unfolding G_def
```
```   279         by (auto cong: positive_integral_cong intro!: positive_integral_add borel_measurable_indicator)
```
```   280       also have "\<dots> \<le> \<nu> (?A \<inter> A) + \<nu> ((space M - ?A) \<inter> A)"
```
```   281         using f g sets unfolding G_def by (auto intro!: add_mono)
```
```   282       also have "\<dots> = \<nu> A"
```
```   283         using M'.measure_additive[OF sets] union by auto
```
```   284       finally show "positive_integral (\<lambda>x. max (g x) (f x) * indicator A x) \<le> \<nu> A" .
```
```   285     qed }
```
```   286   note max_in_G = this
```
```   287
```
```   288   { fix f g assume  "f \<up> g" and f: "\<And>i. f i \<in> G"
```
```   289     have "g \<in> G" unfolding G_def
```
```   290     proof safe
```
```   291       from `f \<up> g` have [simp]: "g = (SUP i. f i)" unfolding isoton_def by simp
```
```   292       have f_borel: "\<And>i. f i \<in> borel_measurable M" using f unfolding G_def by simp
```
```   293       thus "g \<in> borel_measurable M" by (auto intro!: borel_measurable_SUP)
```
```   294
```
```   295       fix A assume "A \<in> sets M"
```
```   296       hence "\<And>i. (\<lambda>x. f i x * indicator A x) \<in> borel_measurable M"
```
```   297         using f_borel by (auto intro!: borel_measurable_indicator)
```
```   298       from positive_integral_isoton[OF isoton_indicator[OF `f \<up> g`] this]
```
```   299       have SUP: "positive_integral (\<lambda>x. g x * indicator A x) =
```
```   300           (SUP i. positive_integral (\<lambda>x. f i x * indicator A x))"
```
```   301         unfolding isoton_def by simp
```
```   302       show "positive_integral (\<lambda>x. g x * indicator A x) \<le> \<nu> A" unfolding SUP
```
```   303         using f `A \<in> sets M` unfolding G_def by (auto intro!: SUP_leI)
```
```   304     qed }
```
```   305   note SUP_in_G = this
```
```   306
```
```   307   let ?y = "SUP g : G. positive_integral g"
```
```   308   have "?y \<le> \<nu> (space M)" unfolding G_def
```
```   309   proof (safe intro!: SUP_leI)
```
```   310     fix g assume "\<forall>A\<in>sets M. positive_integral (\<lambda>x. g x * indicator A x) \<le> \<nu> A"
```
```   311     from this[THEN bspec, OF top] show "positive_integral g \<le> \<nu> (space M)"
```
```   312       by (simp cong: positive_integral_cong)
```
```   313   qed
```
```   314   hence "?y \<noteq> \<omega>" using M'.finite_measure_of_space by auto
```
```   315   from SUPR_countable_SUPR[OF this `G \<noteq> {}`] guess ys .. note ys = this
```
```   316   hence "\<forall>n. \<exists>g. g\<in>G \<and> positive_integral g = ys n"
```
```   317   proof safe
```
```   318     fix n assume "range ys \<subseteq> positive_integral ` G"
```
```   319     hence "ys n \<in> positive_integral ` G" by auto
```
```   320     thus "\<exists>g. g\<in>G \<and> positive_integral g = ys n" by auto
```
```   321   qed
```
```   322   from choice[OF this] obtain gs where "\<And>i. gs i \<in> G" "\<And>n. positive_integral (gs n) = ys n" by auto
```
```   323   hence y_eq: "?y = (SUP i. positive_integral (gs i))" using ys by auto
```
```   324   let "?g i x" = "Max ((\<lambda>n. gs n x) ` {..i})"
```
```   325   def f \<equiv> "SUP i. ?g i"
```
```   326   have gs_not_empty: "\<And>i. (\<lambda>n. gs n x) ` {..i} \<noteq> {}" by auto
```
```   327   { fix i have "?g i \<in> G"
```
```   328     proof (induct i)
```
```   329       case 0 thus ?case by simp fact
```
```   330     next
```
```   331       case (Suc i)
```
```   332       with Suc gs_not_empty `gs (Suc i) \<in> G` show ?case
```
```   333         by (auto simp add: atMost_Suc intro!: max_in_G)
```
```   334     qed }
```
```   335   note g_in_G = this
```
```   336   have "\<And>x. \<forall>i. ?g i x \<le> ?g (Suc i) x"
```
```   337     using gs_not_empty by (simp add: atMost_Suc)
```
```   338   hence isoton_g: "?g \<up> f" by (simp add: isoton_def le_fun_def f_def)
```
```   339   from SUP_in_G[OF this g_in_G] have "f \<in> G" .
```
```   340   hence [simp, intro]: "f \<in> borel_measurable M" unfolding G_def by auto
```
```   341
```
```   342   have "(\<lambda>i. positive_integral (?g i)) \<up> positive_integral f"
```
```   343     using isoton_g g_in_G by (auto intro!: positive_integral_isoton simp: G_def f_def)
```
```   344   hence "positive_integral f = (SUP i. positive_integral (?g i))"
```
```   345     unfolding isoton_def by simp
```
```   346   also have "\<dots> = ?y"
```
```   347   proof (rule antisym)
```
```   348     show "(SUP i. positive_integral (?g i)) \<le> ?y"
```
```   349       using g_in_G by (auto intro!: exI Sup_mono simp: SUPR_def)
```
```   350     show "?y \<le> (SUP i. positive_integral (?g i))" unfolding y_eq
```
```   351       by (auto intro!: SUP_mono positive_integral_mono Max_ge)
```
```   352   qed
```
```   353   finally have int_f_eq_y: "positive_integral f = ?y" .
```
```   354
```
```   355   let "?t A" = "\<nu> A - positive_integral (\<lambda>x. f x * indicator A x)"
```
```   356
```
```   357   have "finite_measure M ?t"
```
```   358   proof
```
```   359     show "?t {} = 0" by simp
```
```   360     show "?t (space M) \<noteq> \<omega>" using M'.finite_measure by simp
```
```   361     show "countably_additive M ?t" unfolding countably_additive_def
```
```   362     proof safe
```
```   363       fix A :: "nat \<Rightarrow> 'a set"  assume A: "range A \<subseteq> sets M" "disjoint_family A"
```
```   364       have "(\<Sum>\<^isub>\<infinity> n. positive_integral (\<lambda>x. f x * indicator (A n) x))
```
```   365         = positive_integral (\<lambda>x. (\<Sum>\<^isub>\<infinity>n. f x * indicator (A n) x))"
```
```   366         using `range A \<subseteq> sets M`
```
```   367         by (rule_tac positive_integral_psuminf[symmetric]) (auto intro!: borel_measurable_indicator)
```
```   368       also have "\<dots> = positive_integral (\<lambda>x. f x * indicator (\<Union>n. A n) x)"
```
```   369         apply (rule positive_integral_cong)
```
```   370         apply (subst psuminf_cmult_right)
```
```   371         unfolding psuminf_indicator[OF `disjoint_family A`] ..
```
```   372       finally have "(\<Sum>\<^isub>\<infinity> n. positive_integral (\<lambda>x. f x * indicator (A n) x))
```
```   373         = positive_integral (\<lambda>x. f x * indicator (\<Union>n. A n) x)" .
```
```   374       moreover have "(\<Sum>\<^isub>\<infinity>n. \<nu> (A n)) = \<nu> (\<Union>n. A n)"
```
```   375         using M'.measure_countably_additive A by (simp add: comp_def)
```
```   376       moreover have "\<And>i. positive_integral (\<lambda>x. f x * indicator (A i) x) \<le> \<nu> (A i)"
```
```   377           using A `f \<in> G` unfolding G_def by auto
```
```   378       moreover have v_fin: "\<nu> (\<Union>i. A i) \<noteq> \<omega>" using M'.finite_measure A by (simp add: countable_UN)
```
```   379       moreover {
```
```   380         have "positive_integral (\<lambda>x. f x * indicator (\<Union>i. A i) x) \<le> \<nu> (\<Union>i. A i)"
```
```   381           using A `f \<in> G` unfolding G_def by (auto simp: countable_UN)
```
```   382         also have "\<nu> (\<Union>i. A i) < \<omega>" using v_fin by (simp add: pinfreal_less_\<omega>)
```
```   383         finally have "positive_integral (\<lambda>x. f x * indicator (\<Union>i. A i) x) \<noteq> \<omega>"
```
```   384           by (simp add: pinfreal_less_\<omega>) }
```
```   385       ultimately
```
```   386       show "(\<Sum>\<^isub>\<infinity> n. ?t (A n)) = ?t (\<Union>i. A i)"
```
```   387         apply (subst psuminf_minus) by simp_all
```
```   388     qed
```
```   389   qed
```
```   390   then interpret M: finite_measure M ?t .
```
```   391
```
```   392   have ac: "absolutely_continuous ?t" using `absolutely_continuous \<nu>` unfolding absolutely_continuous_def by auto
```
```   393
```
```   394   have upper_bound: "\<forall>A\<in>sets M. ?t A \<le> 0"
```
```   395   proof (rule ccontr)
```
```   396     assume "\<not> ?thesis"
```
```   397     then obtain A where A: "A \<in> sets M" and pos: "0 < ?t A"
```
```   398       by (auto simp: not_le)
```
```   399     note pos
```
```   400     also have "?t A \<le> ?t (space M)"
```
```   401       using M.measure_mono[of A "space M"] A sets_into_space by simp
```
```   402     finally have pos_t: "0 < ?t (space M)" by simp
```
```   403     moreover
```
```   404     hence pos_M: "0 < \<mu> (space M)"
```
```   405       using ac top unfolding absolutely_continuous_def by auto
```
```   406     moreover
```
```   407     have "positive_integral (\<lambda>x. f x * indicator (space M) x) \<le> \<nu> (space M)"
```
```   408       using `f \<in> G` unfolding G_def by auto
```
```   409     hence "positive_integral (\<lambda>x. f x * indicator (space M) x) \<noteq> \<omega>"
```
```   410       using M'.finite_measure_of_space by auto
```
```   411     moreover
```
```   412     def b \<equiv> "?t (space M) / \<mu> (space M) / 2"
```
```   413     ultimately have b: "b \<noteq> 0" "b \<noteq> \<omega>"
```
```   414       using M'.finite_measure_of_space
```
```   415       by (auto simp: pinfreal_inverse_eq_0 finite_measure_of_space)
```
```   416
```
```   417     have "finite_measure M (\<lambda>A. b * \<mu> A)" (is "finite_measure M ?b")
```
```   418     proof
```
```   419       show "?b {} = 0" by simp
```
```   420       show "?b (space M) \<noteq> \<omega>" using finite_measure_of_space b by auto
```
```   421       show "countably_additive M ?b"
```
```   422         unfolding countably_additive_def psuminf_cmult_right
```
```   423         using measure_countably_additive by auto
```
```   424     qed
```
```   425
```
```   426     from M.Radon_Nikodym_aux[OF this]
```
```   427     obtain A0 where "A0 \<in> sets M" and
```
```   428       space_less_A0: "real (?t (space M)) - real (b * \<mu> (space M)) \<le> real (?t A0) - real (b * \<mu> A0)" and
```
```   429       *: "\<And>B. \<lbrakk> B \<in> sets M ; B \<subseteq> A0 \<rbrakk> \<Longrightarrow> 0 \<le> real (?t B) - real (b * \<mu> B)" by auto
```
```   430     { fix B assume "B \<in> sets M" "B \<subseteq> A0"
```
```   431       with *[OF this] have "b * \<mu> B \<le> ?t B"
```
```   432         using M'.finite_measure b finite_measure
```
```   433         by (cases "b * \<mu> B", cases "?t B") (auto simp: field_simps) }
```
```   434     note bM_le_t = this
```
```   435
```
```   436     let "?f0 x" = "f x + b * indicator A0 x"
```
```   437
```
```   438     { fix A assume A: "A \<in> sets M"
```
```   439       hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
```
```   440       have "positive_integral (\<lambda>x. ?f0 x  * indicator A x) =
```
```   441         positive_integral (\<lambda>x. f x * indicator A x + b * indicator (A \<inter> A0) x)"
```
```   442         by (auto intro!: positive_integral_cong simp: field_simps indicator_inter_arith)
```
```   443       hence "positive_integral (\<lambda>x. ?f0 x * indicator A x) =
```
```   444           positive_integral (\<lambda>x. f x * indicator A x) + b * \<mu> (A \<inter> A0)"
```
```   445         using `A0 \<in> sets M` `A \<inter> A0 \<in> sets M` A
```
```   446         by (simp add: borel_measurable_indicator positive_integral_add positive_integral_cmult_indicator) }
```
```   447     note f0_eq = this
```
```   448
```
```   449     { fix A assume A: "A \<in> sets M"
```
```   450       hence "A \<inter> A0 \<in> sets M" using `A0 \<in> sets M` by auto
```
```   451       have f_le_v: "positive_integral (\<lambda>x. f x * indicator A x) \<le> \<nu> A"
```
```   452         using `f \<in> G` A unfolding G_def by auto
```
```   453       note f0_eq[OF A]
```
```   454       also have "positive_integral (\<lambda>x. f x * indicator A x) + b * \<mu> (A \<inter> A0) \<le>
```
```   455           positive_integral (\<lambda>x. f x * indicator A x) + ?t (A \<inter> A0)"
```
```   456         using bM_le_t[OF `A \<inter> A0 \<in> sets M`] `A \<in> sets M` `A0 \<in> sets M`
```
```   457         by (auto intro!: add_left_mono)
```
```   458       also have "\<dots> \<le> positive_integral (\<lambda>x. f x * indicator A x) + ?t A"
```
```   459         using M.measure_mono[simplified, OF _ `A \<inter> A0 \<in> sets M` `A \<in> sets M`]
```
```   460         by (auto intro!: add_left_mono)
```
```   461       also have "\<dots> \<le> \<nu> A"
```
```   462         using f_le_v M'.finite_measure[simplified, OF `A \<in> sets M`]
```
```   463         by (cases "positive_integral (\<lambda>x. f x * indicator A x)", cases "\<nu> A", auto)
```
```   464       finally have "positive_integral (\<lambda>x. ?f0 x * indicator A x) \<le> \<nu> A" . }
```
```   465     hence "?f0 \<in> G" using `A0 \<in> sets M` unfolding G_def
```
```   466       by (auto intro!: borel_measurable_indicator borel_measurable_pinfreal_add borel_measurable_pinfreal_times)
```
```   467
```
```   468     have real: "?t (space M) \<noteq> \<omega>" "?t A0 \<noteq> \<omega>"
```
```   469       "b * \<mu> (space M) \<noteq> \<omega>" "b * \<mu> A0 \<noteq> \<omega>"
```
```   470       using `A0 \<in> sets M` b
```
```   471         finite_measure[of A0] M.finite_measure[of A0]
```
```   472         finite_measure_of_space M.finite_measure_of_space
```
```   473       by auto
```
```   474
```
```   475     have int_f_finite: "positive_integral f \<noteq> \<omega>"
```
```   476       using M'.finite_measure_of_space pos_t unfolding pinfreal_zero_less_diff_iff
```
```   477       by (auto cong: positive_integral_cong)
```
```   478
```
```   479     have "?t (space M) > b * \<mu> (space M)" unfolding b_def
```
```   480       apply (simp add: field_simps)
```
```   481       apply (subst mult_assoc[symmetric])
```
```   482       apply (subst pinfreal_mult_inverse)
```
```   483       using finite_measure_of_space M'.finite_measure_of_space pos_t pos_M
```
```   484       using pinfreal_mult_strict_right_mono[of "Real (1/2)" 1 "?t (space M)"]
```
```   485       by simp_all
```
```   486     hence  "0 < ?t (space M) - b * \<mu> (space M)"
```
```   487       by (simp add: pinfreal_zero_less_diff_iff)
```
```   488     also have "\<dots> \<le> ?t A0 - b * \<mu> A0"
```
```   489       using space_less_A0 pos_M pos_t b real[unfolded pinfreal_noteq_omega_Ex] by auto
```
```   490     finally have "b * \<mu> A0 < ?t A0" unfolding pinfreal_zero_less_diff_iff .
```
```   491     hence "0 < ?t A0" by auto
```
```   492     hence "0 < \<mu> A0" using ac unfolding absolutely_continuous_def
```
```   493       using `A0 \<in> sets M` by auto
```
```   494     hence "0 < b * \<mu> A0" using b by auto
```
```   495
```
```   496     from int_f_finite this
```
```   497     have "?y + 0 < positive_integral f + b * \<mu> A0" unfolding int_f_eq_y
```
```   498       by (rule pinfreal_less_add)
```
```   499     also have "\<dots> = positive_integral ?f0" using f0_eq[OF top] `A0 \<in> sets M` sets_into_space
```
```   500       by (simp cong: positive_integral_cong)
```
```   501     finally have "?y < positive_integral ?f0" by simp
```
```   502
```
```   503     moreover from `?f0 \<in> G` have "positive_integral ?f0 \<le> ?y" by (auto intro!: le_SUPI)
```
```   504     ultimately show False by auto
```
```   505   qed
```
```   506
```
```   507   show ?thesis
```
```   508   proof (safe intro!: bexI[of _ f])
```
```   509     fix A assume "A\<in>sets M"
```
```   510     show "\<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
```
```   511     proof (rule antisym)
```
```   512       show "positive_integral (\<lambda>x. f x * indicator A x) \<le> \<nu> A"
```
```   513         using `f \<in> G` `A \<in> sets M` unfolding G_def by auto
```
```   514       show "\<nu> A \<le> positive_integral (\<lambda>x. f x * indicator A x)"
```
```   515         using upper_bound[THEN bspec, OF `A \<in> sets M`]
```
```   516          by (simp add: pinfreal_zero_le_diff)
```
```   517     qed
```
```   518   qed simp
```
```   519 qed
```
```   520
```
```   521 lemma (in finite_measure) Radon_Nikodym_finite_measure_infinite:
```
```   522   assumes "measure_space M \<nu>"
```
```   523   assumes "absolutely_continuous \<nu>"
```
```   524   shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
```
```   525 proof -
```
```   526   interpret v: measure_space M \<nu> by fact
```
```   527   let ?Q = "{Q\<in>sets M. \<nu> Q \<noteq> \<omega>}"
```
```   528   let ?a = "SUP Q:?Q. \<mu> Q"
```
```   529
```
```   530   have "{} \<in> ?Q" using v.empty_measure by auto
```
```   531   then have Q_not_empty: "?Q \<noteq> {}" by blast
```
```   532
```
```   533   have "?a \<le> \<mu> (space M)" using sets_into_space
```
```   534     by (auto intro!: SUP_leI measure_mono top)
```
```   535   then have "?a \<noteq> \<omega>" using finite_measure_of_space
```
```   536     by auto
```
```   537   from SUPR_countable_SUPR[OF this Q_not_empty]
```
```   538   obtain Q'' where "range Q'' \<subseteq> \<mu> ` ?Q" and a: "?a = (SUP i::nat. Q'' i)"
```
```   539     by auto
```
```   540   then have "\<forall>i. \<exists>Q'. Q'' i = \<mu> Q' \<and> Q' \<in> ?Q" by auto
```
```   541   from choice[OF this] obtain Q' where Q': "\<And>i. Q'' i = \<mu> (Q' i)" "\<And>i. Q' i \<in> ?Q"
```
```   542     by auto
```
```   543   then have a_Lim: "?a = (SUP i::nat. \<mu> (Q' i))" using a by simp
```
```   544   let "?O n" = "\<Union>i\<le>n. Q' i"
```
```   545   have Union: "(SUP i. \<mu> (?O i)) = \<mu> (\<Union>i. ?O i)"
```
```   546   proof (rule continuity_from_below[of ?O])
```
```   547     show "range ?O \<subseteq> sets M" using Q' by (auto intro!: finite_UN)
```
```   548     show "\<And>i. ?O i \<subseteq> ?O (Suc i)" by fastsimp
```
```   549   qed
```
```   550
```
```   551   have Q'_sets: "\<And>i. Q' i \<in> sets M" using Q' by auto
```
```   552
```
```   553   have O_sets: "\<And>i. ?O i \<in> sets M"
```
```   554      using Q' by (auto intro!: finite_UN Un)
```
```   555   then have O_in_G: "\<And>i. ?O i \<in> ?Q"
```
```   556   proof (safe del: notI)
```
```   557     fix i have "Q' ` {..i} \<subseteq> sets M"
```
```   558       using Q' by (auto intro: finite_UN)
```
```   559     with v.measure_finitely_subadditive[of "{.. i}" Q']
```
```   560     have "\<nu> (?O i) \<le> (\<Sum>i\<le>i. \<nu> (Q' i))" by auto
```
```   561     also have "\<dots> < \<omega>" unfolding setsum_\<omega> pinfreal_less_\<omega> using Q' by auto
```
```   562     finally show "\<nu> (?O i) \<noteq> \<omega>" unfolding pinfreal_less_\<omega> by auto
```
```   563   qed auto
```
```   564   have O_mono: "\<And>n. ?O n \<subseteq> ?O (Suc n)" by fastsimp
```
```   565
```
```   566   have a_eq: "?a = \<mu> (\<Union>i. ?O i)" unfolding Union[symmetric]
```
```   567   proof (rule antisym)
```
```   568     show "?a \<le> (SUP i. \<mu> (?O i))" unfolding a_Lim
```
```   569       using Q' by (auto intro!: SUP_mono measure_mono finite_UN)
```
```   570     show "(SUP i. \<mu> (?O i)) \<le> ?a" unfolding SUPR_def
```
```   571     proof (safe intro!: Sup_mono, unfold bex_simps)
```
```   572       fix i
```
```   573       have *: "(\<Union>Q' ` {..i}) = ?O i" by auto
```
```   574       then show "\<exists>x. (x \<in> sets M \<and> \<nu> x \<noteq> \<omega>) \<and>
```
```   575         \<mu> (\<Union>Q' ` {..i}) \<le> \<mu> x"
```
```   576         using O_in_G[of i] by (auto intro!: exI[of _ "?O i"])
```
```   577     qed
```
```   578   qed
```
```   579
```
```   580   let "?O_0" = "(\<Union>i. ?O i)"
```
```   581   have "?O_0 \<in> sets M" using Q' by auto
```
```   582
```
```   583   { fix A assume *: "A \<in> ?Q" "A \<subseteq> space M - ?O_0"
```
```   584     then have "\<mu> ?O_0 + \<mu> A = \<mu> (?O_0 \<union> A)"
```
```   585       using Q' by (auto intro!: measure_additive countable_UN)
```
```   586     also have "\<dots> = (SUP i. \<mu> (?O i \<union> A))"
```
```   587     proof (rule continuity_from_below[of "\<lambda>i. ?O i \<union> A", symmetric, simplified])
```
```   588       show "range (\<lambda>i. ?O i \<union> A) \<subseteq> sets M"
```
```   589         using * O_sets by auto
```
```   590     qed fastsimp
```
```   591     also have "\<dots> \<le> ?a"
```
```   592     proof (safe intro!: SUPR_bound)
```
```   593       fix i have "?O i \<union> A \<in> ?Q"
```
```   594       proof (safe del: notI)
```
```   595         show "?O i \<union> A \<in> sets M" using O_sets * by auto
```
```   596         from O_in_G[of i]
```
```   597         moreover have "\<nu> (?O i \<union> A) \<le> \<nu> (?O i) + \<nu> A"
```
```   598           using v.measure_subadditive[of "?O i" A] * O_sets by auto
```
```   599         ultimately show "\<nu> (?O i \<union> A) \<noteq> \<omega>"
```
```   600           using * by auto
```
```   601       qed
```
```   602       then show "\<mu> (?O i \<union> A) \<le> ?a" by (rule le_SUPI)
```
```   603     qed
```
```   604     finally have "\<mu> A = 0" unfolding a_eq using finite_measure[OF `?O_0 \<in> sets M`]
```
```   605       by (cases "\<mu> A") (auto simp: pinfreal_noteq_omega_Ex) }
```
```   606   note stetic = this
```
```   607
```
```   608   def Q \<equiv> "\<lambda>i. case i of 0 \<Rightarrow> ?O 0 | Suc n \<Rightarrow> ?O (Suc n) - ?O n"
```
```   609
```
```   610   { fix i have "Q i \<in> sets M" unfolding Q_def using Q'[of 0] by (cases i) (auto intro: O_sets) }
```
```   611   note Q_sets = this
```
```   612
```
```   613   { fix i have "\<nu> (Q i) \<noteq> \<omega>"
```
```   614     proof (cases i)
```
```   615       case 0 then show ?thesis
```
```   616         unfolding Q_def using Q'[of 0] by simp
```
```   617     next
```
```   618       case (Suc n)
```
```   619       then show ?thesis unfolding Q_def
```
```   620         using `?O n \<in> ?Q` `?O (Suc n) \<in> ?Q` O_mono
```
```   621         using v.measure_Diff[of "?O n" "?O (Suc n)"] by auto
```
```   622     qed }
```
```   623   note Q_omega = this
```
```   624
```
```   625   { fix j have "(\<Union>i\<le>j. ?O i) = (\<Union>i\<le>j. Q i)"
```
```   626     proof (induct j)
```
```   627       case 0 then show ?case by (simp add: Q_def)
```
```   628     next
```
```   629       case (Suc j)
```
```   630       have eq: "\<And>j. (\<Union>i\<le>j. ?O i) = (\<Union>i\<le>j. Q' i)" by fastsimp
```
```   631       have "{..j} \<union> {..Suc j} = {..Suc j}" by auto
```
```   632       then have "(\<Union>i\<le>Suc j. Q' i) = (\<Union>i\<le>j. Q' i) \<union> Q (Suc j)"
```
```   633         by (simp add: UN_Un[symmetric] Q_def del: UN_Un)
```
```   634       then show ?case using Suc by (auto simp add: eq atMost_Suc)
```
```   635     qed }
```
```   636   then have "(\<Union>j. (\<Union>i\<le>j. ?O i)) = (\<Union>j. (\<Union>i\<le>j. Q i))" by simp
```
```   637   then have O_0_eq_Q: "?O_0 = (\<Union>j. Q j)" by fastsimp
```
```   638
```
```   639   have "\<forall>i. \<exists>f. f\<in>borel_measurable M \<and> (\<forall>A\<in>sets M.
```
```   640     \<nu> (Q i \<inter> A) = positive_integral (\<lambda>x. f x * indicator (Q i \<inter> A) x))"
```
```   641   proof
```
```   642     fix i
```
```   643     have indicator_eq: "\<And>f x A. (f x :: pinfreal) * indicator (Q i \<inter> A) x * indicator (Q i) x
```
```   644       = (f x * indicator (Q i) x) * indicator A x"
```
```   645       unfolding indicator_def by auto
```
```   646
```
```   647     have fm: "finite_measure (restricted_space (Q i)) \<mu>"
```
```   648       (is "finite_measure ?R \<mu>") by (rule restricted_finite_measure[OF Q_sets[of i]])
```
```   649     then interpret R: finite_measure ?R .
```
```   650     have fmv: "finite_measure ?R \<nu>"
```
```   651       unfolding finite_measure_def finite_measure_axioms_def
```
```   652     proof
```
```   653       show "measure_space ?R \<nu>"
```
```   654         using v.restricted_measure_space Q_sets[of i] by auto
```
```   655       show "\<nu>  (space ?R) \<noteq> \<omega>"
```
```   656         using Q_omega by simp
```
```   657     qed
```
```   658     have "R.absolutely_continuous \<nu>"
```
```   659       using `absolutely_continuous \<nu>` `Q i \<in> sets M`
```
```   660       by (auto simp: R.absolutely_continuous_def absolutely_continuous_def)
```
```   661     from finite_measure.Radon_Nikodym_finite_measure[OF fm fmv this]
```
```   662     obtain f where f: "(\<lambda>x. f x * indicator (Q i) x) \<in> borel_measurable M"
```
```   663       and f_int: "\<And>A. A\<in>sets M \<Longrightarrow> \<nu> (Q i \<inter> A) = positive_integral (\<lambda>x. (f x * indicator (Q i) x) * indicator A x)"
```
```   664       unfolding Bex_def borel_measurable_restricted[OF `Q i \<in> sets M`]
```
```   665         positive_integral_restricted[OF `Q i \<in> sets M`] by (auto simp: indicator_eq)
```
```   666     then show "\<exists>f. f\<in>borel_measurable M \<and> (\<forall>A\<in>sets M.
```
```   667       \<nu> (Q i \<inter> A) = positive_integral (\<lambda>x. f x * indicator (Q i \<inter> A) x))"
```
```   668       by (fastsimp intro!: exI[of _ "\<lambda>x. f x * indicator (Q i) x"] positive_integral_cong
```
```   669           simp: indicator_def)
```
```   670   qed
```
```   671   from choice[OF this] obtain f where borel: "\<And>i. f i \<in> borel_measurable M"
```
```   672     and f: "\<And>A i. A \<in> sets M \<Longrightarrow>
```
```   673       \<nu> (Q i \<inter> A) = positive_integral (\<lambda>x. f i x * indicator (Q i \<inter> A) x)"
```
```   674     by auto
```
```   675   let "?f x" =
```
```   676     "(\<Sum>\<^isub>\<infinity> i. f i x * indicator (Q i) x) + \<omega> * indicator (space M - ?O_0) x"
```
```   677   show ?thesis
```
```   678   proof (safe intro!: bexI[of _ ?f])
```
```   679     show "?f \<in> borel_measurable M"
```
```   680       by (safe intro!: borel_measurable_psuminf borel_measurable_pinfreal_times
```
```   681         borel_measurable_pinfreal_add borel_measurable_indicator
```
```   682         borel_measurable_const borel Q_sets O_sets Diff countable_UN)
```
```   683     fix A assume "A \<in> sets M"
```
```   684     let ?C = "(space M - (\<Union>i. Q i)) \<inter> A"
```
```   685     have *:
```
```   686       "\<And>x i. indicator A x * (f i x * indicator (Q i) x) =
```
```   687         f i x * indicator (Q i \<inter> A) x"
```
```   688       "\<And>x i. (indicator A x * indicator (space M - (\<Union>i. UNION {..i} Q')) x :: pinfreal) =
```
```   689         indicator ?C x" unfolding O_0_eq_Q by (auto simp: indicator_def)
```
```   690     have "positive_integral (\<lambda>x. ?f x * indicator A x) =
```
```   691       (\<Sum>\<^isub>\<infinity> i. \<nu> (Q i \<inter> A)) + \<omega> * \<mu> ?C"
```
```   692       unfolding f[OF `A \<in> sets M`]
```
```   693       apply (simp del: pinfreal_times(2) add: field_simps)
```
```   694       apply (subst positive_integral_add)
```
```   695       apply (safe intro!: borel_measurable_pinfreal_times Diff borel_measurable_const
```
```   696         borel_measurable_psuminf borel_measurable_indicator `A \<in> sets M` Q_sets borel countable_UN Q'_sets)
```
```   697       unfolding psuminf_cmult_right[symmetric]
```
```   698       apply (subst positive_integral_psuminf)
```
```   699       apply (safe intro!: borel_measurable_pinfreal_times Diff borel_measurable_const
```
```   700         borel_measurable_psuminf borel_measurable_indicator `A \<in> sets M` Q_sets borel countable_UN Q'_sets)
```
```   701       apply (subst positive_integral_cmult)
```
```   702       apply (safe intro!: borel_measurable_pinfreal_times Diff borel_measurable_const
```
```   703         borel_measurable_psuminf borel_measurable_indicator `A \<in> sets M` Q_sets borel countable_UN Q'_sets)
```
```   704       unfolding *
```
```   705       apply (subst positive_integral_indicator)
```
```   706       apply (safe intro!: borel_measurable_pinfreal_times Diff borel_measurable_const Int
```
```   707         borel_measurable_psuminf borel_measurable_indicator `A \<in> sets M` Q_sets borel countable_UN Q'_sets)
```
```   708       by simp
```
```   709     moreover have "(\<Sum>\<^isub>\<infinity>i. \<nu> (Q i \<inter> A)) = \<nu> ((\<Union>i. Q i) \<inter> A)"
```
```   710     proof (rule v.measure_countably_additive[of "\<lambda>i. Q i \<inter> A", unfolded comp_def, simplified])
```
```   711       show "range (\<lambda>i. Q i \<inter> A) \<subseteq> sets M"
```
```   712         using Q_sets `A \<in> sets M` by auto
```
```   713       show "disjoint_family (\<lambda>i. Q i \<inter> A)"
```
```   714         by (fastsimp simp: disjoint_family_on_def Q_def
```
```   715           split: nat.split_asm)
```
```   716     qed
```
```   717     moreover have "\<omega> * \<mu> ?C = \<nu> ?C"
```
```   718     proof cases
```
```   719       assume null: "\<mu> ?C = 0"
```
```   720       hence "?C \<in> null_sets" using Q_sets `A \<in> sets M` by auto
```
```   721       with `absolutely_continuous \<nu>` and null
```
```   722       show ?thesis by (simp add: absolutely_continuous_def)
```
```   723     next
```
```   724       assume not_null: "\<mu> ?C \<noteq> 0"
```
```   725       have "\<nu> ?C = \<omega>"
```
```   726       proof (rule ccontr)
```
```   727         assume "\<nu> ?C \<noteq> \<omega>"
```
```   728         then have "?C \<in> ?Q"
```
```   729           using Q_sets `A \<in> sets M` by auto
```
```   730         from stetic[OF this] not_null
```
```   731         show False unfolding O_0_eq_Q by auto
```
```   732       qed
```
```   733       then show ?thesis using not_null by simp
```
```   734     qed
```
```   735     moreover have "?C \<in> sets M" "((\<Union>i. Q i) \<inter> A) \<in> sets M"
```
```   736       using Q_sets `A \<in> sets M` by (auto intro!: countable_UN)
```
```   737     moreover have "((\<Union>i. Q i) \<inter> A) \<union> ?C = A" "((\<Union>i. Q i) \<inter> A) \<inter> ?C = {}"
```
```   738       using `A \<in> sets M` sets_into_space by auto
```
```   739     ultimately show "\<nu> A = positive_integral (\<lambda>x. ?f x * indicator A x)"
```
```   740       using v.measure_additive[simplified, of "(\<Union>i. Q i) \<inter> A" ?C] by auto
```
```   741   qed
```
```   742 qed
```
```   743
```
```   744 lemma (in sigma_finite_measure) Radon_Nikodym:
```
```   745   assumes "measure_space M \<nu>"
```
```   746   assumes "absolutely_continuous \<nu>"
```
```   747   shows "\<exists>f \<in> borel_measurable M. \<forall>A\<in>sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x)"
```
```   748 proof -
```
```   749   from Ex_finite_integrable_function
```
```   750   obtain h where finite: "positive_integral h \<noteq> \<omega>" and
```
```   751     borel: "h \<in> borel_measurable M" and
```
```   752     pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x" and
```
```   753     "\<And>x. x \<in> space M \<Longrightarrow> h x < \<omega>" by auto
```
```   754   let "?T A" = "positive_integral (\<lambda>x. h x * indicator A x)"
```
```   755   from measure_space_density[OF borel] finite
```
```   756   interpret T: finite_measure M ?T
```
```   757     unfolding finite_measure_def finite_measure_axioms_def
```
```   758     by (simp cong: positive_integral_cong)
```
```   759   have "\<And>N. N \<in> sets M \<Longrightarrow> {x \<in> space M. h x \<noteq> 0 \<and> indicator N x \<noteq> (0::pinfreal)} = N"
```
```   760     using sets_into_space pos by (force simp: indicator_def)
```
```   761   then have "T.absolutely_continuous \<nu>" using assms(2) borel
```
```   762     unfolding T.absolutely_continuous_def absolutely_continuous_def
```
```   763     by (fastsimp simp: borel_measurable_indicator positive_integral_0_iff)
```
```   764   from T.Radon_Nikodym_finite_measure_infinite[simplified, OF assms(1) this]
```
```   765   obtain f where f_borel: "f \<in> borel_measurable M" and
```
```   766     fT: "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = T.positive_integral (\<lambda>x. f x * indicator A x)" by auto
```
```   767   show ?thesis
```
```   768   proof (safe intro!: bexI[of _ "\<lambda>x. h x * f x"])
```
```   769     show "(\<lambda>x. h x * f x) \<in> borel_measurable M"
```
```   770       using borel f_borel by (auto intro: borel_measurable_pinfreal_times)
```
```   771     fix A assume "A \<in> sets M"
```
```   772     then have "(\<lambda>x. f x * indicator A x) \<in> borel_measurable M"
```
```   773       using f_borel by (auto intro: borel_measurable_pinfreal_times borel_measurable_indicator)
```
```   774     from positive_integral_translated_density[OF borel this]
```
```   775     show "\<nu> A = positive_integral (\<lambda>x. h x * f x * indicator A x)"
```
```   776       unfolding fT[OF `A \<in> sets M`] by (simp add: field_simps)
```
```   777   qed
```
```   778 qed
```
```   779
```
```   780 section "Radon Nikodym derivative"
```
```   781
```
```   782 definition (in sigma_finite_measure)
```
```   783   "RN_deriv \<nu> \<equiv> SOME f. f \<in> borel_measurable M \<and>
```
```   784     (\<forall>A \<in> sets M. \<nu> A = positive_integral (\<lambda>x. f x * indicator A x))"
```
```   785
```
```   786 lemma (in sigma_finite_measure) RN_deriv:
```
```   787   assumes "measure_space M \<nu>"
```
```   788   assumes "absolutely_continuous \<nu>"
```
```   789   shows "RN_deriv \<nu> \<in> borel_measurable M" (is ?borel)
```
```   790   and "\<And>A. A \<in> sets M \<Longrightarrow> \<nu> A = positive_integral (\<lambda>x. RN_deriv \<nu> x * indicator A x)"
```
```   791     (is "\<And>A. _ \<Longrightarrow> ?int A")
```
```   792 proof -
```
```   793   note Ex = Radon_Nikodym[OF assms, unfolded Bex_def]
```
```   794   thus ?borel unfolding RN_deriv_def by (rule someI2_ex) auto
```
```   795   fix A assume "A \<in> sets M"
```
```   796   from Ex show "?int A" unfolding RN_deriv_def
```
```   797     by (rule someI2_ex) (simp add: `A \<in> sets M`)
```
```   798 qed
```
```   799
```
```   800 lemma (in sigma_finite_measure) RN_deriv_singleton:
```
```   801   assumes "measure_space M \<nu>"
```
```   802   and ac: "absolutely_continuous \<nu>"
```
```   803   and "{x} \<in> sets M"
```
```   804   shows "\<nu> {x} = RN_deriv \<nu> x * \<mu> {x}"
```
```   805 proof -
```
```   806   note deriv = RN_deriv[OF assms(1, 2)]
```
```   807   from deriv(2)[OF `{x} \<in> sets M`]
```
```   808   have "\<nu> {x} = positive_integral (\<lambda>w. RN_deriv \<nu> x * indicator {x} w)"
```
```   809     by (auto simp: indicator_def intro!: positive_integral_cong)
```
```   810   thus ?thesis using positive_integral_cmult_indicator[OF `{x} \<in> sets M`]
```
```   811     by auto
```
```   812 qed
```
```   813
```
```   814 theorem (in finite_measure_space) RN_deriv_finite_measure:
```
```   815   assumes "measure_space M \<nu>"
```
```   816   and ac: "absolutely_continuous \<nu>"
```
```   817   and "x \<in> space M"
```
```   818   shows "\<nu> {x} = RN_deriv \<nu> x * \<mu> {x}"
```
```   819 proof -
```
```   820   have "{x} \<in> sets M" using sets_eq_Pow `x \<in> space M` by auto
```
```   821   from RN_deriv_singleton[OF assms(1,2) this] show ?thesis .
```
```   822 qed
```
```   823
```
```   824 end
```