src/HOL/Analysis/Radon_Nikodym.thy
author wenzelm
Sun Sep 18 20:33:48 2016 +0200 (2016-09-18)
changeset 63915 bab633745c7f
parent 63627 6ddb43c6b711
child 64283 979cdfdf7a79
permissions -rw-r--r--
tuned proofs;
hoelzl@63627
     1
(*  Title:      HOL/Analysis/Radon_Nikodym.thy
hoelzl@42067
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42067
     3
*)
hoelzl@42067
     4
wenzelm@61808
     5
section \<open>Radon-Nikod{\'y}m derivative\<close>
hoelzl@42067
     6
hoelzl@38656
     7
theory Radon_Nikodym
hoelzl@56993
     8
imports Bochner_Integration
hoelzl@38656
     9
begin
hoelzl@38656
    10
hoelzl@63329
    11
definition diff_measure :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a measure"
hoelzl@63329
    12
where
hoelzl@63329
    13
  "diff_measure M N = measure_of (space M) (sets M) (\<lambda>A. emeasure M A - emeasure N A)"
hoelzl@47694
    14
lp15@61609
    15
lemma
hoelzl@47694
    16
  shows space_diff_measure[simp]: "space (diff_measure M N) = space M"
hoelzl@47694
    17
    and sets_diff_measure[simp]: "sets (diff_measure M N) = sets M"
hoelzl@47694
    18
  by (auto simp: diff_measure_def)
hoelzl@47694
    19
hoelzl@47694
    20
lemma emeasure_diff_measure:
hoelzl@47694
    21
  assumes fin: "finite_measure M" "finite_measure N" and sets_eq: "sets M = sets N"
hoelzl@47694
    22
  assumes pos: "\<And>A. A \<in> sets M \<Longrightarrow> emeasure N A \<le> emeasure M A" and A: "A \<in> sets M"
hoelzl@47694
    23
  shows "emeasure (diff_measure M N) A = emeasure M A - emeasure N A" (is "_ = ?\<mu> A")
hoelzl@47694
    24
  unfolding diff_measure_def
hoelzl@47694
    25
proof (rule emeasure_measure_of_sigma)
hoelzl@47694
    26
  show "sigma_algebra (space M) (sets M)" ..
hoelzl@47694
    27
  show "positive (sets M) ?\<mu>"
hoelzl@62975
    28
    using pos by (simp add: positive_def)
hoelzl@47694
    29
  show "countably_additive (sets M) ?\<mu>"
hoelzl@47694
    30
  proof (rule countably_additiveI)
hoelzl@47694
    31
    fix A :: "nat \<Rightarrow> _"  assume A: "range A \<subseteq> sets M" and "disjoint_family A"
hoelzl@47694
    32
    then have suminf:
hoelzl@47694
    33
      "(\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
hoelzl@47694
    34
      "(\<Sum>i. emeasure N (A i)) = emeasure N (\<Union>i. A i)"
hoelzl@47694
    35
      by (simp_all add: suminf_emeasure sets_eq)
hoelzl@47694
    36
    with A have "(\<Sum>i. emeasure M (A i) - emeasure N (A i)) =
hoelzl@47694
    37
      (\<Sum>i. emeasure M (A i)) - (\<Sum>i. emeasure N (A i))"
hoelzl@62975
    38
      using fin pos[of "A _"]
hoelzl@62975
    39
      by (intro ennreal_suminf_minus)
hoelzl@63329
    40
         (auto simp: sets_eq finite_measure.emeasure_eq_measure suminf_emeasure)
hoelzl@47694
    41
    then show "(\<Sum>i. emeasure M (A i) - emeasure N (A i)) =
hoelzl@47694
    42
      emeasure M (\<Union>i. A i) - emeasure N (\<Union>i. A i) "
hoelzl@47694
    43
      by (simp add: suminf)
hoelzl@47694
    44
  qed
hoelzl@47694
    45
qed fact
hoelzl@47694
    46
hoelzl@38656
    47
lemma (in sigma_finite_measure) Ex_finite_integrable_function:
hoelzl@62975
    48
  "\<exists>h\<in>borel_measurable M. integral\<^sup>N M h \<noteq> \<infinity> \<and> (\<forall>x\<in>space M. 0 < h x \<and> h x < \<infinity>)"
hoelzl@38656
    49
proof -
hoelzl@38656
    50
  obtain A :: "nat \<Rightarrow> 'a set" where
hoelzl@50003
    51
    range[measurable]: "range A \<subseteq> sets M" and
hoelzl@38656
    52
    space: "(\<Union>i. A i) = space M" and
hoelzl@47694
    53
    measure: "\<And>i. emeasure M (A i) \<noteq> \<infinity>" and
hoelzl@38656
    54
    disjoint: "disjoint_family A"
haftmann@62343
    55
    using sigma_finite_disjoint by blast
hoelzl@47694
    56
  let ?B = "\<lambda>i. 2^Suc i * emeasure M (A i)"
hoelzl@63329
    57
  have [measurable]: "\<And>i. A i \<in> sets M"
hoelzl@63329
    58
    using range by fastforce+
hoelzl@38656
    59
  have "\<forall>i. \<exists>x. 0 < x \<and> x < inverse (?B i)"
hoelzl@38656
    60
  proof
hoelzl@47694
    61
    fix i show "\<exists>x. 0 < x \<and> x < inverse (?B i)"
hoelzl@62975
    62
      using measure[of i]
hoelzl@62975
    63
      by (auto intro!: dense simp: ennreal_inverse_positive ennreal_mult_eq_top_iff power_eq_top_ennreal)
hoelzl@38656
    64
  qed
hoelzl@38656
    65
  from choice[OF this] obtain n where n: "\<And>i. 0 < n i"
hoelzl@47694
    66
    "\<And>i. n i < inverse (2^Suc i * emeasure M (A i))" by auto
hoelzl@41981
    67
  { fix i have "0 \<le> n i" using n(1)[of i] by auto } note pos = this
wenzelm@46731
    68
  let ?h = "\<lambda>x. \<Sum>i. n i * indicator (A i) x"
hoelzl@38656
    69
  show ?thesis
hoelzl@38656
    70
  proof (safe intro!: bexI[of _ ?h] del: notI)
hoelzl@63329
    71
    have "integral\<^sup>N M ?h = (\<Sum>i. n i * emeasure M (A i))" using pos
hoelzl@56996
    72
      by (simp add: nn_integral_suminf nn_integral_cmult_indicator)
hoelzl@62975
    73
    also have "\<dots> \<le> (\<Sum>i. ennreal ((1/2)^Suc i))"
hoelzl@62975
    74
    proof (intro suminf_le allI)
hoelzl@41981
    75
      fix N
hoelzl@47694
    76
      have "n N * emeasure M (A N) \<le> inverse (2^Suc N * emeasure M (A N)) * emeasure M (A N)"
hoelzl@62975
    77
        using n[of N] by (intro mult_right_mono) auto
hoelzl@62975
    78
      also have "\<dots> = (1/2)^Suc N * (inverse (emeasure M (A N)) * emeasure M (A N))"
hoelzl@62975
    79
        using measure[of N]
hoelzl@62975
    80
        by (simp add: ennreal_inverse_power divide_ennreal_def ennreal_inverse_mult
hoelzl@62975
    81
                      power_eq_top_ennreal less_top[symmetric] mult_ac
hoelzl@62975
    82
                 del: power_Suc)
hoelzl@62975
    83
      also have "\<dots> \<le> inverse (ennreal 2) ^ Suc N"
hoelzl@62975
    84
        using measure[of N]
hoelzl@63329
    85
        by (cases "emeasure M (A N)"; cases "emeasure M (A N) = 0")
hoelzl@63329
    86
           (auto simp: inverse_ennreal ennreal_mult[symmetric] divide_ennreal_def simp del: power_Suc)
hoelzl@62975
    87
      also have "\<dots> = ennreal (inverse 2 ^ Suc N)"
hoelzl@62975
    88
        by (subst ennreal_power[symmetric], simp) (simp add: inverse_ennreal)
hoelzl@62975
    89
      finally show "n N * emeasure M (A N) \<le> ennreal ((1/2)^Suc N)"
hoelzl@62975
    90
        by simp
hoelzl@62975
    91
    qed auto
hoelzl@62975
    92
    also have "\<dots> < top"
hoelzl@62975
    93
      unfolding less_top[symmetric]
hoelzl@63329
    94
      by (rule ennreal_suminf_neq_top)
hoelzl@63329
    95
         (auto simp: summable_geometric summable_Suc_iff simp del: power_Suc)
hoelzl@62975
    96
    finally show "integral\<^sup>N M ?h \<noteq> \<infinity>"
hoelzl@62975
    97
      by (auto simp: top_unique)
hoelzl@38656
    98
  next
hoelzl@41981
    99
    { fix x assume "x \<in> space M"
hoelzl@41981
   100
      then obtain i where "x \<in> A i" using space[symmetric] by auto
hoelzl@41981
   101
      with disjoint n have "?h x = n i"
hoelzl@41981
   102
        by (auto intro!: suminf_cmult_indicator intro: less_imp_le)
hoelzl@62975
   103
      then show "0 < ?h x" and "?h x < \<infinity>" using n[of i] by (auto simp: less_top[symmetric]) }
hoelzl@41981
   104
    note pos = this
hoelzl@50003
   105
  qed measurable
hoelzl@38656
   106
qed
hoelzl@38656
   107
hoelzl@40871
   108
subsection "Absolutely continuous"
hoelzl@40871
   109
hoelzl@47694
   110
definition absolutely_continuous :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> bool" where
hoelzl@47694
   111
  "absolutely_continuous M N \<longleftrightarrow> null_sets M \<subseteq> null_sets N"
hoelzl@47694
   112
hoelzl@47694
   113
lemma absolutely_continuousI_count_space: "absolutely_continuous (count_space A) M"
hoelzl@47694
   114
  unfolding absolutely_continuous_def by (auto simp: null_sets_count_space)
hoelzl@38656
   115
hoelzl@47694
   116
lemma absolutely_continuousI_density:
hoelzl@47694
   117
  "f \<in> borel_measurable M \<Longrightarrow> absolutely_continuous M (density M f)"
hoelzl@47694
   118
  by (force simp add: absolutely_continuous_def null_sets_density_iff dest: AE_not_in)
hoelzl@47694
   119
hoelzl@47694
   120
lemma absolutely_continuousI_point_measure_finite:
hoelzl@47694
   121
  "(\<And>x. \<lbrakk> x \<in> A ; f x \<le> 0 \<rbrakk> \<Longrightarrow> g x \<le> 0) \<Longrightarrow> absolutely_continuous (point_measure A f) (point_measure A g)"
hoelzl@47694
   122
  unfolding absolutely_continuous_def by (force simp: null_sets_point_measure_iff)
hoelzl@47694
   123
hoelzl@63330
   124
lemma absolutely_continuousD:
hoelzl@63330
   125
  "absolutely_continuous M N \<Longrightarrow> A \<in> sets M \<Longrightarrow> emeasure M A = 0 \<Longrightarrow> emeasure N A = 0"
hoelzl@63330
   126
  by (auto simp: absolutely_continuous_def null_sets_def)
hoelzl@63330
   127
hoelzl@47694
   128
lemma absolutely_continuous_AE:
hoelzl@47694
   129
  assumes sets_eq: "sets M' = sets M"
hoelzl@47694
   130
    and "absolutely_continuous M M'" "AE x in M. P x"
hoelzl@41981
   131
   shows "AE x in M'. P x"
hoelzl@40859
   132
proof -
wenzelm@61808
   133
  from \<open>AE x in M. P x\<close> obtain N where N: "N \<in> null_sets M" "{x\<in>space M. \<not> P x} \<subseteq> N"
hoelzl@47694
   134
    unfolding eventually_ae_filter by auto
hoelzl@41981
   135
  show "AE x in M'. P x"
hoelzl@47694
   136
  proof (rule AE_I')
hoelzl@47694
   137
    show "{x\<in>space M'. \<not> P x} \<subseteq> N" using sets_eq_imp_space_eq[OF sets_eq] N(2) by simp
wenzelm@61808
   138
    from \<open>absolutely_continuous M M'\<close> show "N \<in> null_sets M'"
hoelzl@47694
   139
      using N unfolding absolutely_continuous_def sets_eq null_sets_def by auto
hoelzl@40859
   140
  qed
hoelzl@40859
   141
qed
hoelzl@40859
   142
hoelzl@40871
   143
subsection "Existence of the Radon-Nikodym derivative"
hoelzl@40871
   144
hoelzl@38656
   145
lemma (in finite_measure) Radon_Nikodym_finite_measure:
hoelzl@63330
   146
  assumes "finite_measure N" and sets_eq[simp]: "sets N = sets M"
hoelzl@47694
   147
  assumes "absolutely_continuous M N"
hoelzl@63329
   148
  shows "\<exists>f \<in> borel_measurable M. density M f = N"
hoelzl@38656
   149
proof -
hoelzl@47694
   150
  interpret N: finite_measure N by fact
hoelzl@63329
   151
  define G where "G = {g \<in> borel_measurable M. \<forall>A\<in>sets M. (\<integral>\<^sup>+x. g x * indicator A x \<partial>M) \<le> N A}"
hoelzl@63330
   152
  have [measurable_dest]: "f \<in> G \<Longrightarrow> f \<in> borel_measurable M"
hoelzl@63330
   153
    and G_D: "\<And>A. f \<in> G \<Longrightarrow> A \<in> sets M \<Longrightarrow> (\<integral>\<^sup>+x. f x * indicator A x \<partial>M) \<le> N A" for f
hoelzl@63330
   154
    by (auto simp: G_def)
hoelzl@50003
   155
  note this[measurable_dest]
hoelzl@38656
   156
  have "(\<lambda>x. 0) \<in> G" unfolding G_def by auto
hoelzl@38656
   157
  hence "G \<noteq> {}" by auto
hoelzl@63329
   158
  { fix f g assume f[measurable]: "f \<in> G" and g[measurable]: "g \<in> G"
hoelzl@38656
   159
    have "(\<lambda>x. max (g x) (f x)) \<in> G" (is "?max \<in> G") unfolding G_def
hoelzl@38656
   160
    proof safe
hoelzl@38656
   161
      let ?A = "{x \<in> space M. f x \<le> g x}"
hoelzl@38656
   162
      have "?A \<in> sets M" using f g unfolding G_def by auto
hoelzl@63329
   163
      fix A assume [measurable]: "A \<in> sets M"
hoelzl@38656
   164
      have union: "((?A \<inter> A) \<union> ((space M - ?A) \<inter> A)) = A"
wenzelm@61808
   165
        using sets.sets_into_space[OF \<open>A \<in> sets M\<close>] by auto
hoelzl@38656
   166
      have "\<And>x. x \<in> space M \<Longrightarrow> max (g x) (f x) * indicator A x =
hoelzl@38656
   167
        g x * indicator (?A \<inter> A) x + f x * indicator ((space M - ?A) \<inter> A) x"
hoelzl@38656
   168
        by (auto simp: indicator_def max_def)
wenzelm@53015
   169
      hence "(\<integral>\<^sup>+x. max (g x) (f x) * indicator A x \<partial>M) =
wenzelm@53015
   170
        (\<integral>\<^sup>+x. g x * indicator (?A \<inter> A) x \<partial>M) +
wenzelm@53015
   171
        (\<integral>\<^sup>+x. f x * indicator ((space M - ?A) \<inter> A) x \<partial>M)"
hoelzl@56996
   172
        by (auto cong: nn_integral_cong intro!: nn_integral_add)
hoelzl@47694
   173
      also have "\<dots> \<le> N (?A \<inter> A) + N ((space M - ?A) \<inter> A)"
hoelzl@63329
   174
        using f g unfolding G_def by (auto intro!: add_mono)
hoelzl@47694
   175
      also have "\<dots> = N A"
hoelzl@63330
   176
        using union by (subst plus_emeasure) auto
wenzelm@53015
   177
      finally show "(\<integral>\<^sup>+x. max (g x) (f x) * indicator A x \<partial>M) \<le> N A" .
hoelzl@63329
   178
    qed auto }
hoelzl@38656
   179
  note max_in_G = this
hoelzl@41981
   180
  { fix f assume  "incseq f" and f: "\<And>i. f i \<in> G"
hoelzl@50003
   181
    then have [measurable]: "\<And>i. f i \<in> borel_measurable M" by (auto simp: G_def)
hoelzl@41981
   182
    have "(\<lambda>x. SUP i. f i x) \<in> G" unfolding G_def
hoelzl@38656
   183
    proof safe
hoelzl@50003
   184
      show "(\<lambda>x. SUP i. f i x) \<in> borel_measurable M" by measurable
hoelzl@41981
   185
    next
hoelzl@38656
   186
      fix A assume "A \<in> sets M"
wenzelm@53015
   187
      have "(\<integral>\<^sup>+x. (SUP i. f i x) * indicator A x \<partial>M) =
wenzelm@53015
   188
        (\<integral>\<^sup>+x. (SUP i. f i x * indicator A x) \<partial>M)"
hoelzl@56996
   189
        by (intro nn_integral_cong) (simp split: split_indicator)
wenzelm@53015
   190
      also have "\<dots> = (SUP i. (\<integral>\<^sup>+x. f i x * indicator A x \<partial>M))"
wenzelm@61808
   191
        using \<open>incseq f\<close> f \<open>A \<in> sets M\<close>
hoelzl@56996
   192
        by (intro nn_integral_monotone_convergence_SUP)
hoelzl@41981
   193
           (auto simp: G_def incseq_Suc_iff le_fun_def split: split_indicator)
wenzelm@53015
   194
      finally show "(\<integral>\<^sup>+x. (SUP i. f i x) * indicator A x \<partial>M) \<le> N A"
hoelzl@63330
   195
        using f \<open>A \<in> sets M\<close> by (auto intro!: SUP_least simp: G_D)
hoelzl@38656
   196
    qed }
hoelzl@38656
   197
  note SUP_in_G = this
hoelzl@56996
   198
  let ?y = "SUP g : G. integral\<^sup>N M g"
hoelzl@47694
   199
  have y_le: "?y \<le> N (space M)" unfolding G_def
hoelzl@44928
   200
  proof (safe intro!: SUP_least)
wenzelm@53015
   201
    fix g assume "\<forall>A\<in>sets M. (\<integral>\<^sup>+x. g x * indicator A x \<partial>M) \<le> N A"
hoelzl@56996
   202
    from this[THEN bspec, OF sets.top] show "integral\<^sup>N M g \<le> N (space M)"
hoelzl@56996
   203
      by (simp cong: nn_integral_cong)
hoelzl@38656
   204
  qed
hoelzl@62975
   205
  from ennreal_SUP_countable_SUP [OF \<open>G \<noteq> {}\<close>, of "integral\<^sup>N M"] guess ys .. note ys = this
hoelzl@56996
   206
  then have "\<forall>n. \<exists>g. g\<in>G \<and> integral\<^sup>N M g = ys n"
hoelzl@38656
   207
  proof safe
hoelzl@56996
   208
    fix n assume "range ys \<subseteq> integral\<^sup>N M ` G"
hoelzl@56996
   209
    hence "ys n \<in> integral\<^sup>N M ` G" by auto
hoelzl@56996
   210
    thus "\<exists>g. g\<in>G \<and> integral\<^sup>N M g = ys n" by auto
hoelzl@38656
   211
  qed
hoelzl@56996
   212
  from choice[OF this] obtain gs where "\<And>i. gs i \<in> G" "\<And>n. integral\<^sup>N M (gs n) = ys n" by auto
hoelzl@56996
   213
  hence y_eq: "?y = (SUP i. integral\<^sup>N M (gs i))" using ys by auto
wenzelm@46731
   214
  let ?g = "\<lambda>i x. Max ((\<lambda>n. gs n x) ` {..i})"
wenzelm@63040
   215
  define f where [abs_def]: "f x = (SUP i. ?g i x)" for x
wenzelm@46731
   216
  let ?F = "\<lambda>A x. f x * indicator A x"
hoelzl@41981
   217
  have gs_not_empty: "\<And>i x. (\<lambda>n. gs n x) ` {..i} \<noteq> {}" by auto
hoelzl@38656
   218
  { fix i have "?g i \<in> G"
hoelzl@38656
   219
    proof (induct i)
hoelzl@38656
   220
      case 0 thus ?case by simp fact
hoelzl@38656
   221
    next
hoelzl@38656
   222
      case (Suc i)
wenzelm@61808
   223
      with Suc gs_not_empty \<open>gs (Suc i) \<in> G\<close> show ?case
hoelzl@38656
   224
        by (auto simp add: atMost_Suc intro!: max_in_G)
hoelzl@38656
   225
    qed }
hoelzl@38656
   226
  note g_in_G = this
hoelzl@41981
   227
  have "incseq ?g" using gs_not_empty
hoelzl@41981
   228
    by (auto intro!: incseq_SucI le_funI simp add: atMost_Suc)
hoelzl@63330
   229
hoelzl@50003
   230
  from SUP_in_G[OF this g_in_G] have [measurable]: "f \<in> G" unfolding f_def .
hoelzl@63330
   231
  then have [measurable]: "f \<in> borel_measurable M" unfolding G_def by auto
hoelzl@63330
   232
hoelzl@56996
   233
  have "integral\<^sup>N M f = (SUP i. integral\<^sup>N M (?g i))" unfolding f_def
hoelzl@63330
   234
    using g_in_G \<open>incseq ?g\<close> by (auto intro!: nn_integral_monotone_convergence_SUP simp: G_def)
hoelzl@38656
   235
  also have "\<dots> = ?y"
hoelzl@38656
   236
  proof (rule antisym)
hoelzl@56996
   237
    show "(SUP i. integral\<^sup>N M (?g i)) \<le> ?y"
haftmann@56166
   238
      using g_in_G by (auto intro: SUP_mono)
hoelzl@56996
   239
    show "?y \<le> (SUP i. integral\<^sup>N M (?g i))" unfolding y_eq
hoelzl@56996
   240
      by (auto intro!: SUP_mono nn_integral_mono Max_ge)
hoelzl@38656
   241
  qed
hoelzl@56996
   242
  finally have int_f_eq_y: "integral\<^sup>N M f = ?y" .
hoelzl@47694
   243
hoelzl@63330
   244
  have upper_bound: "\<forall>A\<in>sets M. N A \<le> density M f A"
hoelzl@38656
   245
  proof (rule ccontr)
hoelzl@38656
   246
    assume "\<not> ?thesis"
hoelzl@63330
   247
    then obtain A where A[measurable]: "A \<in> sets M" and f_less_N: "density M f A < N A"
hoelzl@63330
   248
      by (auto simp: not_le)
hoelzl@63330
   249
    then have pos_A: "0 < M A"
hoelzl@63330
   250
      using \<open>absolutely_continuous M N\<close>[THEN absolutely_continuousD, OF A]
hoelzl@62975
   251
      by (auto simp: zero_less_iff_neq_zero)
hoelzl@63330
   252
hoelzl@63330
   253
    define b where "b = (N A - density M f A) / M A / 2"
hoelzl@63330
   254
    with f_less_N pos_A have "0 < b" "b \<noteq> top"
hoelzl@63330
   255
      by (auto intro!: diff_gr0_ennreal simp: zero_less_iff_neq_zero diff_eq_0_iff_ennreal ennreal_divide_eq_top_iff)
hoelzl@63330
   256
hoelzl@63330
   257
    let ?f = "\<lambda>x. f x + b"
hoelzl@63330
   258
    have "nn_integral M f \<noteq> top"
hoelzl@63330
   259
      using `f \<in> G`[THEN G_D, of "space M"] by (auto simp: top_unique cong: nn_integral_cong)
hoelzl@63330
   260
    with \<open>b \<noteq> top\<close> interpret Mf: finite_measure "density M ?f"
hoelzl@63330
   261
      by (intro finite_measureI)
hoelzl@63330
   262
         (auto simp: field_simps mult_indicator_subset ennreal_mult_eq_top_iff
hoelzl@63330
   263
                     emeasure_density nn_integral_cmult_indicator nn_integral_add
hoelzl@63330
   264
               cong: nn_integral_cong)
hoelzl@63330
   265
hoelzl@63330
   266
    from unsigned_Hahn_decomposition[of "density M ?f" N A]
hoelzl@63330
   267
    obtain Y where [measurable]: "Y \<in> sets M" and [simp]: "Y \<subseteq> A"
hoelzl@63330
   268
       and Y1: "\<And>C. C \<in> sets M \<Longrightarrow> C \<subseteq> Y \<Longrightarrow> density M ?f C \<le> N C"
hoelzl@63330
   269
       and Y2: "\<And>C. C \<in> sets M \<Longrightarrow> C \<subseteq> A \<Longrightarrow> C \<inter> Y = {} \<Longrightarrow> N C \<le> density M ?f C"
hoelzl@63330
   270
       by auto
hoelzl@63330
   271
hoelzl@63330
   272
    let ?f' = "\<lambda>x. f x + b * indicator Y x"
hoelzl@63330
   273
    have "M Y \<noteq> 0"
hoelzl@63330
   274
    proof
hoelzl@63330
   275
      assume "M Y = 0"
hoelzl@63330
   276
      then have "N Y = 0"
hoelzl@63330
   277
        using \<open>absolutely_continuous M N\<close>[THEN absolutely_continuousD, of Y] by auto
hoelzl@63330
   278
      then have "N A = N (A - Y)"
hoelzl@63330
   279
        by (subst emeasure_Diff) auto
hoelzl@63330
   280
      also have "\<dots> \<le> density M ?f (A - Y)"
hoelzl@63330
   281
        by (rule Y2) auto
hoelzl@63330
   282
      also have "\<dots> \<le> density M ?f A - density M ?f Y"
hoelzl@63330
   283
        by (subst emeasure_Diff) auto
hoelzl@63330
   284
      also have "\<dots> \<le> density M ?f A - 0"
hoelzl@63330
   285
        by (intro ennreal_minus_mono) auto
hoelzl@63330
   286
      also have "density M ?f A = b * M A + density M f A"
hoelzl@63330
   287
        by (simp add: emeasure_density field_simps mult_indicator_subset nn_integral_add nn_integral_cmult_indicator)
hoelzl@63330
   288
      also have "\<dots> < N A"
hoelzl@63330
   289
        using f_less_N pos_A
hoelzl@63330
   290
        by (cases "density M f A"; cases "M A"; cases "N A")
hoelzl@63330
   291
           (auto simp: b_def ennreal_less_iff ennreal_minus divide_ennreal ennreal_numeral[symmetric]
hoelzl@63330
   292
                       ennreal_plus[symmetric] ennreal_mult[symmetric] field_simps
hoelzl@63330
   293
                    simp del: ennreal_numeral ennreal_plus)
hoelzl@63330
   294
      finally show False
hoelzl@63330
   295
        by simp
hoelzl@63330
   296
    qed
hoelzl@63330
   297
    then have "nn_integral M f < nn_integral M ?f'"
hoelzl@63330
   298
      using \<open>0 < b\<close> \<open>nn_integral M f \<noteq> top\<close>
hoelzl@63330
   299
      by (simp add: nn_integral_add nn_integral_cmult_indicator ennreal_zero_less_mult_iff zero_less_iff_neq_zero)
hoelzl@38656
   300
    moreover
hoelzl@63330
   301
    have "?f' \<in> G"
hoelzl@63330
   302
      unfolding G_def
hoelzl@63330
   303
    proof safe
hoelzl@63330
   304
      fix X assume [measurable]: "X \<in> sets M"
hoelzl@63330
   305
      have "(\<integral>\<^sup>+ x. ?f' x * indicator X x \<partial>M) = density M f (X - Y) + density M ?f (X \<inter> Y)"
hoelzl@63330
   306
        by (auto simp add: emeasure_density nn_integral_add[symmetric] split: split_indicator intro!: nn_integral_cong)
hoelzl@63330
   307
      also have "\<dots> \<le> N (X - Y) + N (X \<inter> Y)"
hoelzl@63330
   308
        using G_D[OF \<open>f \<in> G\<close>] by (intro add_mono Y1) (auto simp: emeasure_density)
hoelzl@63330
   309
      also have "\<dots> = N X"
hoelzl@63330
   310
        by (subst plus_emeasure) (auto intro!: arg_cong2[where f=emeasure])
hoelzl@63330
   311
      finally show "(\<integral>\<^sup>+ x. ?f' x * indicator X x \<partial>M) \<le> N X" .
hoelzl@63330
   312
    qed simp
hoelzl@63330
   313
    then have "nn_integral M ?f' \<le> ?y"
hoelzl@63330
   314
      by (rule SUP_upper)
hoelzl@63330
   315
    ultimately show False
hoelzl@63330
   316
      by (simp add: int_f_eq_y)
hoelzl@38656
   317
  qed
hoelzl@38656
   318
  show ?thesis
hoelzl@63330
   319
  proof (intro bexI[of _ f] measure_eqI conjI antisym)
hoelzl@63330
   320
    fix A assume "A \<in> sets (density M f)" then show "emeasure (density M f) A \<le> emeasure N A"
hoelzl@63330
   321
      by (auto simp: emeasure_density intro!: G_D[OF \<open>f \<in> G\<close>])
hoelzl@63330
   322
  next
hoelzl@63330
   323
    fix A assume A: "A \<in> sets (density M f)" then show "emeasure N A \<le> emeasure (density M f) A"
hoelzl@63330
   324
      using upper_bound by auto
hoelzl@47694
   325
  qed auto
hoelzl@38656
   326
qed
hoelzl@38656
   327
hoelzl@40859
   328
lemma (in finite_measure) split_space_into_finite_sets_and_rest:
hoelzl@63330
   329
  assumes ac: "absolutely_continuous M N" and sets_eq[simp]: "sets N = sets M"
hoelzl@63330
   330
  shows "\<exists>B::nat\<Rightarrow>'a set. disjoint_family B \<and> range B \<subseteq> sets M \<and> (\<forall>i. N (B i) \<noteq> \<infinity>) \<and>
hoelzl@63330
   331
    (\<forall>A\<in>sets M. A \<inter> (\<Union>i. B i) = {} \<longrightarrow> (emeasure M A = 0 \<and> N A = 0) \<or> (emeasure M A > 0 \<and> N A = \<infinity>))"
hoelzl@38656
   332
proof -
hoelzl@47694
   333
  let ?Q = "{Q\<in>sets M. N Q \<noteq> \<infinity>}"
hoelzl@47694
   334
  let ?a = "SUP Q:?Q. emeasure M Q"
hoelzl@47694
   335
  have "{} \<in> ?Q" by auto
hoelzl@38656
   336
  then have Q_not_empty: "?Q \<noteq> {}" by blast
immler@50244
   337
  have "?a \<le> emeasure M (space M)" using sets.sets_into_space
hoelzl@47694
   338
    by (auto intro!: SUP_least emeasure_mono)
hoelzl@62975
   339
  then have "?a \<noteq> \<infinity>"
hoelzl@62975
   340
    using finite_emeasure_space
hoelzl@62975
   341
    by (auto simp: less_top[symmetric] top_unique simp del: SUP_eq_top_iff Sup_eq_top_iff)
hoelzl@62975
   342
  from ennreal_SUP_countable_SUP [OF Q_not_empty, of "emeasure M"]
hoelzl@47694
   343
  obtain Q'' where "range Q'' \<subseteq> emeasure M ` ?Q" and a: "?a = (SUP i::nat. Q'' i)"
hoelzl@38656
   344
    by auto
hoelzl@47694
   345
  then have "\<forall>i. \<exists>Q'. Q'' i = emeasure M Q' \<and> Q' \<in> ?Q" by auto
hoelzl@47694
   346
  from choice[OF this] obtain Q' where Q': "\<And>i. Q'' i = emeasure M (Q' i)" "\<And>i. Q' i \<in> ?Q"
hoelzl@38656
   347
    by auto
hoelzl@47694
   348
  then have a_Lim: "?a = (SUP i::nat. emeasure M (Q' i))" using a by simp
wenzelm@46731
   349
  let ?O = "\<lambda>n. \<Union>i\<le>n. Q' i"
hoelzl@47694
   350
  have Union: "(SUP i. emeasure M (?O i)) = emeasure M (\<Union>i. ?O i)"
hoelzl@47694
   351
  proof (rule SUP_emeasure_incseq[of ?O])
hoelzl@47694
   352
    show "range ?O \<subseteq> sets M" using Q' by auto
nipkow@44890
   353
    show "incseq ?O" by (fastforce intro!: incseq_SucI)
hoelzl@38656
   354
  qed
hoelzl@63330
   355
  have Q'_sets[measurable]: "\<And>i. Q' i \<in> sets M" using Q' by auto
hoelzl@47694
   356
  have O_sets: "\<And>i. ?O i \<in> sets M" using Q' by auto
hoelzl@38656
   357
  then have O_in_G: "\<And>i. ?O i \<in> ?Q"
hoelzl@38656
   358
  proof (safe del: notI)
hoelzl@47694
   359
    fix i have "Q' ` {..i} \<subseteq> sets M" using Q' by auto
hoelzl@47694
   360
    then have "N (?O i) \<le> (\<Sum>i\<le>i. N (Q' i))"
hoelzl@63330
   361
      by (simp add: emeasure_subadditive_finite)
hoelzl@62975
   362
    also have "\<dots> < \<infinity>" using Q' by (simp add: less_top)
hoelzl@47694
   363
    finally show "N (?O i) \<noteq> \<infinity>" by simp
hoelzl@38656
   364
  qed auto
nipkow@44890
   365
  have O_mono: "\<And>n. ?O n \<subseteq> ?O (Suc n)" by fastforce
hoelzl@47694
   366
  have a_eq: "?a = emeasure M (\<Union>i. ?O i)" unfolding Union[symmetric]
hoelzl@38656
   367
  proof (rule antisym)
hoelzl@47694
   368
    show "?a \<le> (SUP i. emeasure M (?O i))" unfolding a_Lim
hoelzl@47694
   369
      using Q' by (auto intro!: SUP_mono emeasure_mono)
haftmann@62343
   370
    show "(SUP i. emeasure M (?O i)) \<le> ?a"
hoelzl@38656
   371
    proof (safe intro!: Sup_mono, unfold bex_simps)
hoelzl@38656
   372
      fix i
haftmann@52141
   373
      have *: "(\<Union>(Q' ` {..i})) = ?O i" by auto
hoelzl@47694
   374
      then show "\<exists>x. (x \<in> sets M \<and> N x \<noteq> \<infinity>) \<and>
haftmann@52141
   375
        emeasure M (\<Union>(Q' ` {..i})) \<le> emeasure M x"
hoelzl@38656
   376
        using O_in_G[of i] by (auto intro!: exI[of _ "?O i"])
hoelzl@38656
   377
    qed
hoelzl@38656
   378
  qed
wenzelm@46731
   379
  let ?O_0 = "(\<Union>i. ?O i)"
hoelzl@38656
   380
  have "?O_0 \<in> sets M" using Q' by auto
hoelzl@63330
   381
  have "disjointed Q' i \<in> sets M" for i
hoelzl@63330
   382
    using sets.range_disjointed_sets[of Q' M] using Q'_sets by (auto simp: subset_eq)
hoelzl@38656
   383
  note Q_sets = this
hoelzl@40859
   384
  show ?thesis
hoelzl@40859
   385
  proof (intro bexI exI conjI ballI impI allI)
hoelzl@63330
   386
    show "disjoint_family (disjointed Q')"
hoelzl@63330
   387
      by (rule disjoint_family_disjointed)
hoelzl@63330
   388
    show "range (disjointed Q') \<subseteq> sets M"
hoelzl@63330
   389
      using Q'_sets by (intro sets.range_disjointed_sets) auto
hoelzl@63330
   390
    { fix A assume A: "A \<in> sets M" "A \<inter> (\<Union>i. disjointed Q' i) = {}"
hoelzl@63330
   391
      then have A1: "A \<inter> (\<Union>i. Q' i) = {}"
hoelzl@63330
   392
        unfolding UN_disjointed_eq by auto
hoelzl@47694
   393
      show "emeasure M A = 0 \<and> N A = 0 \<or> 0 < emeasure M A \<and> N A = \<infinity>"
hoelzl@40859
   394
      proof (rule disjCI, simp)
hoelzl@62975
   395
        assume *: "emeasure M A = 0 \<or> N A \<noteq> top"
hoelzl@47694
   396
        show "emeasure M A = 0 \<and> N A = 0"
wenzelm@53374
   397
        proof (cases "emeasure M A = 0")
wenzelm@53374
   398
          case True
wenzelm@53374
   399
          with ac A have "N A = 0"
hoelzl@40859
   400
            unfolding absolutely_continuous_def by auto
wenzelm@53374
   401
          with True show ?thesis by simp
hoelzl@40859
   402
        next
wenzelm@53374
   403
          case False
hoelzl@62975
   404
          with * have "N A \<noteq> \<infinity>" by auto
hoelzl@47694
   405
          with A have "emeasure M ?O_0 + emeasure M A = emeasure M (?O_0 \<union> A)"
hoelzl@63330
   406
            using Q' A1 by (auto intro!: plus_emeasure simp: set_eq_iff)
hoelzl@47694
   407
          also have "\<dots> = (SUP i. emeasure M (?O i \<union> A))"
hoelzl@47694
   408
          proof (rule SUP_emeasure_incseq[of "\<lambda>i. ?O i \<union> A", symmetric, simplified])
hoelzl@40859
   409
            show "range (\<lambda>i. ?O i \<union> A) \<subseteq> sets M"
wenzelm@61808
   410
              using \<open>N A \<noteq> \<infinity>\<close> O_sets A by auto
nipkow@44890
   411
          qed (fastforce intro!: incseq_SucI)
hoelzl@40859
   412
          also have "\<dots> \<le> ?a"
hoelzl@44928
   413
          proof (safe intro!: SUP_least)
hoelzl@40859
   414
            fix i have "?O i \<union> A \<in> ?Q"
hoelzl@40859
   415
            proof (safe del: notI)
hoelzl@40859
   416
              show "?O i \<union> A \<in> sets M" using O_sets A by auto
hoelzl@47694
   417
              from O_in_G[of i] have "N (?O i \<union> A) \<le> N (?O i) + N A"
hoelzl@63330
   418
                using emeasure_subadditive[of "?O i" N A] A O_sets by auto
hoelzl@47694
   419
              with O_in_G[of i] show "N (?O i \<union> A) \<noteq> \<infinity>"
hoelzl@62975
   420
                using \<open>N A \<noteq> \<infinity>\<close> by (auto simp: top_unique)
hoelzl@40859
   421
            qed
hoelzl@47694
   422
            then show "emeasure M (?O i \<union> A) \<le> ?a" by (rule SUP_upper)
hoelzl@40859
   423
          qed
hoelzl@47694
   424
          finally have "emeasure M A = 0"
hoelzl@47694
   425
            unfolding a_eq using measure_nonneg[of M A] by (simp add: emeasure_eq_measure)
wenzelm@61808
   426
          with \<open>emeasure M A \<noteq> 0\<close> show ?thesis by auto
hoelzl@40859
   427
        qed
hoelzl@40859
   428
      qed }
hoelzl@63330
   429
    { fix i
hoelzl@63330
   430
      have "N (disjointed Q' i) \<le> N (Q' i)"
hoelzl@63330
   431
        by (auto intro!: emeasure_mono simp: disjointed_def)
hoelzl@63330
   432
      then show "N (disjointed Q' i) \<noteq> \<infinity>"
hoelzl@63330
   433
        using Q'(2)[of i] by (auto simp: top_unique) }
hoelzl@40859
   434
  qed
hoelzl@40859
   435
qed
hoelzl@40859
   436
hoelzl@40859
   437
lemma (in finite_measure) Radon_Nikodym_finite_measure_infinite:
hoelzl@47694
   438
  assumes "absolutely_continuous M N" and sets_eq: "sets N = sets M"
hoelzl@63329
   439
  shows "\<exists>f\<in>borel_measurable M. density M f = N"
hoelzl@40859
   440
proof -
hoelzl@40859
   441
  from split_space_into_finite_sets_and_rest[OF assms]
hoelzl@63330
   442
  obtain Q :: "nat \<Rightarrow> 'a set"
hoelzl@40859
   443
    where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
hoelzl@63330
   444
    and in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<inter> (\<Union>i. Q i) = {} \<Longrightarrow> emeasure M A = 0 \<and> N A = 0 \<or> 0 < emeasure M A \<and> N A = \<infinity>"
hoelzl@47694
   445
    and Q_fin: "\<And>i. N (Q i) \<noteq> \<infinity>" by force
hoelzl@40859
   446
  from Q have Q_sets: "\<And>i. Q i \<in> sets M" by auto
hoelzl@47694
   447
  let ?N = "\<lambda>i. density N (indicator (Q i))" and ?M = "\<lambda>i. density M (indicator (Q i))"
hoelzl@63329
   448
  have "\<forall>i. \<exists>f\<in>borel_measurable (?M i). density (?M i) f = ?N i"
hoelzl@47694
   449
  proof (intro allI finite_measure.Radon_Nikodym_finite_measure)
hoelzl@38656
   450
    fix i
hoelzl@47694
   451
    from Q show "finite_measure (?M i)"
hoelzl@56996
   452
      by (auto intro!: finite_measureI cong: nn_integral_cong
hoelzl@47694
   453
               simp add: emeasure_density subset_eq sets_eq)
hoelzl@47694
   454
    from Q have "emeasure (?N i) (space N) = emeasure N (Q i)"
hoelzl@56996
   455
      by (simp add: sets_eq[symmetric] emeasure_density subset_eq cong: nn_integral_cong)
hoelzl@47694
   456
    with Q_fin show "finite_measure (?N i)"
hoelzl@47694
   457
      by (auto intro!: finite_measureI)
hoelzl@47694
   458
    show "sets (?N i) = sets (?M i)" by (simp add: sets_eq)
hoelzl@50003
   459
    have [measurable]: "\<And>A. A \<in> sets M \<Longrightarrow> A \<in> sets N" by (simp add: sets_eq)
hoelzl@47694
   460
    show "absolutely_continuous (?M i) (?N i)"
wenzelm@61808
   461
      using \<open>absolutely_continuous M N\<close> \<open>Q i \<in> sets M\<close>
hoelzl@47694
   462
      by (auto simp: absolutely_continuous_def null_sets_density_iff sets_eq
hoelzl@47694
   463
               intro!: absolutely_continuous_AE[OF sets_eq])
hoelzl@38656
   464
  qed
hoelzl@47694
   465
  from choice[OF this[unfolded Bex_def]]
hoelzl@47694
   466
  obtain f where borel: "\<And>i. f i \<in> borel_measurable M" "\<And>i x. 0 \<le> f i x"
hoelzl@47694
   467
    and f_density: "\<And>i. density (?M i) (f i) = ?N i"
immler@54776
   468
    by force
hoelzl@47694
   469
  { fix A i assume A: "A \<in> sets M"
wenzelm@53015
   470
    with Q borel have "(\<integral>\<^sup>+x. f i x * indicator (Q i \<inter> A) x \<partial>M) = emeasure (density (?M i) (f i)) A"
hoelzl@56996
   471
      by (auto simp add: emeasure_density nn_integral_density subset_eq
hoelzl@56996
   472
               intro!: nn_integral_cong split: split_indicator)
hoelzl@47694
   473
    also have "\<dots> = emeasure N (Q i \<inter> A)"
hoelzl@47694
   474
      using A Q by (simp add: f_density emeasure_restricted subset_eq sets_eq)
wenzelm@53015
   475
    finally have "emeasure N (Q i \<inter> A) = (\<integral>\<^sup>+x. f i x * indicator (Q i \<inter> A) x \<partial>M)" .. }
hoelzl@47694
   476
  note integral_eq = this
hoelzl@63330
   477
  let ?f = "\<lambda>x. (\<Sum>i. f i x * indicator (Q i) x) + \<infinity> * indicator (space M - (\<Union>i. Q i)) x"
hoelzl@38656
   478
  show ?thesis
hoelzl@38656
   479
  proof (safe intro!: bexI[of _ ?f])
hoelzl@63330
   480
    show "?f \<in> borel_measurable M" using borel Q_sets
hoelzl@41981
   481
      by (auto intro!: measurable_If)
hoelzl@47694
   482
    show "density M ?f = N"
hoelzl@47694
   483
    proof (rule measure_eqI)
hoelzl@47694
   484
      fix A assume "A \<in> sets (density M ?f)"
hoelzl@47694
   485
      then have "A \<in> sets M" by simp
hoelzl@47694
   486
      have Qi: "\<And>i. Q i \<in> sets M" using Q by auto
hoelzl@47694
   487
      have [intro,simp]: "\<And>i. (\<lambda>x. f i x * indicator (Q i \<inter> A) x) \<in> borel_measurable M"
hoelzl@47694
   488
        "\<And>i. AE x in M. 0 \<le> f i x * indicator (Q i \<inter> A) x"
hoelzl@63330
   489
        using borel Qi \<open>A \<in> sets M\<close> by auto
hoelzl@63330
   490
      have "(\<integral>\<^sup>+x. ?f x * indicator A x \<partial>M) = (\<integral>\<^sup>+x. (\<Sum>i. f i x * indicator (Q i \<inter> A) x) + \<infinity> * indicator ((space M - (\<Union>i. Q i)) \<inter> A) x \<partial>M)"
hoelzl@56996
   491
        using borel by (intro nn_integral_cong) (auto simp: indicator_def)
hoelzl@63330
   492
      also have "\<dots> = (\<integral>\<^sup>+x. (\<Sum>i. f i x * indicator (Q i \<inter> A) x) \<partial>M) + \<infinity> * emeasure M ((space M - (\<Union>i. Q i)) \<inter> A)"
hoelzl@63330
   493
        using borel Qi \<open>A \<in> sets M\<close>
hoelzl@62975
   494
        by (subst nn_integral_add)
hoelzl@62975
   495
           (auto simp add: nn_integral_cmult_indicator sets.Int intro!: suminf_0_le)
hoelzl@63330
   496
      also have "\<dots> = (\<Sum>i. N (Q i \<inter> A)) + \<infinity> * emeasure M ((space M - (\<Union>i. Q i)) \<inter> A)"
wenzelm@61808
   497
        by (subst integral_eq[OF \<open>A \<in> sets M\<close>], subst nn_integral_suminf) auto
hoelzl@63330
   498
      finally have "(\<integral>\<^sup>+x. ?f x * indicator A x \<partial>M) = (\<Sum>i. N (Q i \<inter> A)) + \<infinity> * emeasure M ((space M - (\<Union>i. Q i)) \<inter> A)" .
hoelzl@47694
   499
      moreover have "(\<Sum>i. N (Q i \<inter> A)) = N ((\<Union>i. Q i) \<inter> A)"
wenzelm@61808
   500
        using Q Q_sets \<open>A \<in> sets M\<close>
hoelzl@47694
   501
        by (subst suminf_emeasure) (auto simp: disjoint_family_on_def sets_eq)
hoelzl@63330
   502
      moreover
hoelzl@63330
   503
      have "(space M - (\<Union>x. Q x)) \<inter> A \<inter> (\<Union>x. Q x) = {}"
hoelzl@63330
   504
        by auto
hoelzl@63330
   505
      then have "\<infinity> * emeasure M ((space M - (\<Union>i. Q i)) \<inter> A) = N ((space M - (\<Union>i. Q i)) \<inter> A)"
hoelzl@63330
   506
        using in_Q0[of "(space M - (\<Union>i. Q i)) \<inter> A"] \<open>A \<in> sets M\<close> Q by (auto simp: ennreal_top_mult)
hoelzl@63330
   507
      moreover have "(space M - (\<Union>i. Q i)) \<inter> A \<in> sets M" "((\<Union>i. Q i) \<inter> A) \<in> sets M"
hoelzl@63330
   508
        using Q_sets \<open>A \<in> sets M\<close> by auto
hoelzl@63330
   509
      moreover have "((\<Union>i. Q i) \<inter> A) \<union> ((space M - (\<Union>i. Q i)) \<inter> A) = A" "((\<Union>i. Q i) \<inter> A) \<inter> ((space M - (\<Union>i. Q i)) \<inter> A) = {}"
hoelzl@63330
   510
        using \<open>A \<in> sets M\<close> sets.sets_into_space by auto
wenzelm@53015
   511
      ultimately have "N A = (\<integral>\<^sup>+x. ?f x * indicator A x \<partial>M)"
hoelzl@63330
   512
        using plus_emeasure[of "(\<Union>i. Q i) \<inter> A" N "(space M - (\<Union>i. Q i)) \<inter> A"] by (simp add: sets_eq)
hoelzl@63330
   513
      with \<open>A \<in> sets M\<close> borel Q show "emeasure (density M ?f) A = N A"
hoelzl@50003
   514
        by (auto simp: subset_eq emeasure_density)
hoelzl@47694
   515
    qed (simp add: sets_eq)
hoelzl@38656
   516
  qed
hoelzl@38656
   517
qed
hoelzl@38656
   518
hoelzl@38656
   519
lemma (in sigma_finite_measure) Radon_Nikodym:
hoelzl@47694
   520
  assumes ac: "absolutely_continuous M N" assumes sets_eq: "sets N = sets M"
hoelzl@63329
   521
  shows "\<exists>f \<in> borel_measurable M. density M f = N"
hoelzl@38656
   522
proof -
hoelzl@38656
   523
  from Ex_finite_integrable_function
hoelzl@56996
   524
  obtain h where finite: "integral\<^sup>N M h \<noteq> \<infinity>" and
hoelzl@38656
   525
    borel: "h \<in> borel_measurable M" and
hoelzl@41981
   526
    nn: "\<And>x. 0 \<le> h x" and
hoelzl@38656
   527
    pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x" and
hoelzl@41981
   528
    "\<And>x. x \<in> space M \<Longrightarrow> h x < \<infinity>" by auto
wenzelm@53015
   529
  let ?T = "\<lambda>A. (\<integral>\<^sup>+x. h x * indicator A x \<partial>M)"
hoelzl@47694
   530
  let ?MT = "density M h"
hoelzl@47694
   531
  from borel finite nn interpret T: finite_measure ?MT
hoelzl@56996
   532
    by (auto intro!: finite_measureI cong: nn_integral_cong simp: emeasure_density)
hoelzl@47694
   533
  have "absolutely_continuous ?MT N" "sets N = sets ?MT"
hoelzl@47694
   534
  proof (unfold absolutely_continuous_def, safe)
hoelzl@47694
   535
    fix A assume "A \<in> null_sets ?MT"
hoelzl@47694
   536
    with borel have "A \<in> sets M" "AE x in M. x \<in> A \<longrightarrow> h x \<le> 0"
hoelzl@47694
   537
      by (auto simp add: null_sets_density_iff)
immler@50244
   538
    with pos sets.sets_into_space have "AE x in M. x \<notin> A"
lp15@61810
   539
      by (elim eventually_mono) (auto simp: not_le[symmetric])
hoelzl@47694
   540
    then have "A \<in> null_sets M"
wenzelm@61808
   541
      using \<open>A \<in> sets M\<close> by (simp add: AE_iff_null_sets)
hoelzl@47694
   542
    with ac show "A \<in> null_sets N"
hoelzl@47694
   543
      by (auto simp: absolutely_continuous_def)
hoelzl@47694
   544
  qed (auto simp add: sets_eq)
hoelzl@47694
   545
  from T.Radon_Nikodym_finite_measure_infinite[OF this]
hoelzl@63329
   546
  obtain f where f_borel: "f \<in> borel_measurable M" "density ?MT f = N" by auto
hoelzl@47694
   547
  with nn borel show ?thesis
hoelzl@47694
   548
    by (auto intro!: bexI[of _ "\<lambda>x. h x * f x"] simp: density_density_eq)
hoelzl@38656
   549
qed
hoelzl@38656
   550
wenzelm@61808
   551
subsection \<open>Uniqueness of densities\<close>
hoelzl@40859
   552
hoelzl@47694
   553
lemma finite_density_unique:
hoelzl@40859
   554
  assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@47694
   555
  assumes pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> g x"
hoelzl@56996
   556
  and fin: "integral\<^sup>N M f \<noteq> \<infinity>"
hoelzl@49785
   557
  shows "density M f = density M g \<longleftrightarrow> (AE x in M. f x = g x)"
hoelzl@40859
   558
proof (intro iffI ballI)
hoelzl@47694
   559
  fix A assume eq: "AE x in M. f x = g x"
hoelzl@49785
   560
  with borel show "density M f = density M g"
hoelzl@49785
   561
    by (auto intro: density_cong)
hoelzl@40859
   562
next
wenzelm@53015
   563
  let ?P = "\<lambda>f A. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M"
hoelzl@49785
   564
  assume "density M f = density M g"
hoelzl@49785
   565
  with borel have eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
hoelzl@49785
   566
    by (simp add: emeasure_density[symmetric])
immler@50244
   567
  from this[THEN bspec, OF sets.top] fin
hoelzl@56996
   568
  have g_fin: "integral\<^sup>N M g \<noteq> \<infinity>" by (simp cong: nn_integral_cong)
hoelzl@40859
   569
  { fix f g assume borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@47694
   570
      and pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> g x"
hoelzl@56996
   571
      and g_fin: "integral\<^sup>N M g \<noteq> \<infinity>" and eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
hoelzl@40859
   572
    let ?N = "{x\<in>space M. g x < f x}"
hoelzl@40859
   573
    have N: "?N \<in> sets M" using borel by simp
hoelzl@56996
   574
    have "?P g ?N \<le> integral\<^sup>N M g" using pos
hoelzl@56996
   575
      by (intro nn_integral_mono_AE) (auto split: split_indicator)
hoelzl@62975
   576
    then have Pg_fin: "?P g ?N \<noteq> \<infinity>" using g_fin by (auto simp: top_unique)
wenzelm@53015
   577
    have "?P (\<lambda>x. (f x - g x)) ?N = (\<integral>\<^sup>+x. f x * indicator ?N x - g x * indicator ?N x \<partial>M)"
hoelzl@56996
   578
      by (auto intro!: nn_integral_cong simp: indicator_def)
hoelzl@40859
   579
    also have "\<dots> = ?P f ?N - ?P g ?N"
hoelzl@56996
   580
    proof (rule nn_integral_diff)
hoelzl@40859
   581
      show "(\<lambda>x. f x * indicator ?N x) \<in> borel_measurable M" "(\<lambda>x. g x * indicator ?N x) \<in> borel_measurable M"
hoelzl@40859
   582
        using borel N by auto
hoelzl@47694
   583
      show "AE x in M. g x * indicator ?N x \<le> f x * indicator ?N x"
hoelzl@41981
   584
        using pos by (auto split: split_indicator)
hoelzl@41981
   585
    qed fact
hoelzl@40859
   586
    also have "\<dots> = 0"
hoelzl@62975
   587
      unfolding eq[THEN bspec, OF N] using Pg_fin by auto
hoelzl@47694
   588
    finally have "AE x in M. f x \<le> g x"
hoelzl@56996
   589
      using pos borel nn_integral_PInf_AE[OF borel(2) g_fin]
hoelzl@56996
   590
      by (subst (asm) nn_integral_0_iff_AE)
hoelzl@62975
   591
         (auto split: split_indicator simp: not_less ennreal_minus_eq_0) }
hoelzl@41981
   592
  from this[OF borel pos g_fin eq] this[OF borel(2,1) pos(2,1) fin] eq
hoelzl@47694
   593
  show "AE x in M. f x = g x" by auto
hoelzl@40859
   594
qed
hoelzl@40859
   595
hoelzl@40859
   596
lemma (in finite_measure) density_unique_finite_measure:
hoelzl@40859
   597
  assumes borel: "f \<in> borel_measurable M" "f' \<in> borel_measurable M"
hoelzl@47694
   598
  assumes pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> f' x"
wenzelm@53015
   599
  assumes f: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^sup>+x. f' x * indicator A x \<partial>M)"
hoelzl@40859
   600
    (is "\<And>A. A \<in> sets M \<Longrightarrow> ?P f A = ?P f' A")
hoelzl@47694
   601
  shows "AE x in M. f x = f' x"
hoelzl@40859
   602
proof -
hoelzl@47694
   603
  let ?D = "\<lambda>f. density M f"
hoelzl@47694
   604
  let ?N = "\<lambda>A. ?P f A" and ?N' = "\<lambda>A. ?P f' A"
wenzelm@46731
   605
  let ?f = "\<lambda>A x. f x * indicator A x" and ?f' = "\<lambda>A x. f' x * indicator A x"
hoelzl@47694
   606
hoelzl@47694
   607
  have ac: "absolutely_continuous M (density M f)" "sets (density M f) = sets M"
lp15@61609
   608
    using borel by (auto intro!: absolutely_continuousI_density)
hoelzl@47694
   609
  from split_space_into_finite_sets_and_rest[OF this]
hoelzl@63330
   610
  obtain Q :: "nat \<Rightarrow> 'a set"
hoelzl@40859
   611
    where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
hoelzl@63330
   612
    and in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<inter> (\<Union>i. Q i) = {} \<Longrightarrow> emeasure M A = 0 \<and> ?D f A = 0 \<or> 0 < emeasure M A \<and> ?D f A = \<infinity>"
hoelzl@47694
   613
    and Q_fin: "\<And>i. ?D f (Q i) \<noteq> \<infinity>" by force
hoelzl@63330
   614
  with borel pos have in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<inter> (\<Union>i. Q i) = {} \<Longrightarrow> emeasure M A = 0 \<and> ?N A = 0 \<or> 0 < emeasure M A \<and> ?N A = \<infinity>"
hoelzl@47694
   615
    and Q_fin: "\<And>i. ?N (Q i) \<noteq> \<infinity>" by (auto simp: emeasure_density subset_eq)
hoelzl@47694
   616
hoelzl@63330
   617
  from Q have Q_sets[measurable]: "\<And>i. Q i \<in> sets M" by auto
hoelzl@47694
   618
  let ?D = "{x\<in>space M. f x \<noteq> f' x}"
hoelzl@47694
   619
  have "?D \<in> sets M" using borel by auto
hoelzl@62975
   620
  have *: "\<And>i x A. \<And>y::ennreal. y * indicator (Q i) x * indicator A x = y * indicator (Q i \<inter> A) x"
hoelzl@40859
   621
    unfolding indicator_def by auto
hoelzl@47694
   622
  have "\<forall>i. AE x in M. ?f (Q i) x = ?f' (Q i) x" using borel Q_fin Q pos
hoelzl@40859
   623
    by (intro finite_density_unique[THEN iffD1] allI)
hoelzl@50003
   624
       (auto intro!: f measure_eqI simp: emeasure_density * subset_eq)
hoelzl@63330
   625
  moreover have "AE x in M. ?f (space M - (\<Union>i. Q i)) x = ?f' (space M - (\<Union>i. Q i)) x"
hoelzl@40859
   626
  proof (rule AE_I')
hoelzl@62975
   627
    { fix f :: "'a \<Rightarrow> ennreal" assume borel: "f \<in> borel_measurable M"
wenzelm@53015
   628
        and eq: "\<And>A. A \<in> sets M \<Longrightarrow> ?N A = (\<integral>\<^sup>+x. f x * indicator A x \<partial>M)"
hoelzl@63330
   629
      let ?A = "\<lambda>i. (space M - (\<Union>i. Q i)) \<inter> {x \<in> space M. f x < (i::nat)}"
hoelzl@47694
   630
      have "(\<Union>i. ?A i) \<in> null_sets M"
hoelzl@40859
   631
      proof (rule null_sets_UN)
hoelzl@43923
   632
        fix i ::nat have "?A i \<in> sets M"
hoelzl@63330
   633
          using borel by auto
hoelzl@62975
   634
        have "?N (?A i) \<le> (\<integral>\<^sup>+x. (i::ennreal) * indicator (?A i) x \<partial>M)"
wenzelm@61808
   635
          unfolding eq[OF \<open>?A i \<in> sets M\<close>]
hoelzl@56996
   636
          by (auto intro!: nn_integral_mono simp: indicator_def)
hoelzl@47694
   637
        also have "\<dots> = i * emeasure M (?A i)"
wenzelm@61808
   638
          using \<open>?A i \<in> sets M\<close> by (auto intro!: nn_integral_cmult_indicator)
hoelzl@62975
   639
        also have "\<dots> < \<infinity>" using emeasure_real[of "?A i"] by (auto simp: ennreal_mult_less_top of_nat_less_top)
hoelzl@47694
   640
        finally have "?N (?A i) \<noteq> \<infinity>" by simp
wenzelm@61808
   641
        then show "?A i \<in> null_sets M" using in_Q0[OF \<open>?A i \<in> sets M\<close>] \<open>?A i \<in> sets M\<close> by auto
hoelzl@40859
   642
      qed
hoelzl@63330
   643
      also have "(\<Union>i. ?A i) = (space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f x \<noteq> \<infinity>}"
hoelzl@62975
   644
        by (auto simp: ennreal_Ex_less_of_nat less_top[symmetric])
hoelzl@63330
   645
      finally have "(space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f x \<noteq> \<infinity>} \<in> null_sets M" by simp }
hoelzl@40859
   646
    from this[OF borel(1) refl] this[OF borel(2) f]
hoelzl@63330
   647
    have "(space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f x \<noteq> \<infinity>} \<in> null_sets M" "(space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f' x \<noteq> \<infinity>} \<in> null_sets M" by simp_all
hoelzl@63330
   648
    then show "((space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f x \<noteq> \<infinity>}) \<union> ((space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f' x \<noteq> \<infinity>}) \<in> null_sets M" by (rule null_sets.Un)
hoelzl@63330
   649
    show "{x \<in> space M. ?f (space M - (\<Union>i. Q i)) x \<noteq> ?f' (space M - (\<Union>i. Q i)) x} \<subseteq>
hoelzl@63330
   650
      ((space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f x \<noteq> \<infinity>}) \<union> ((space M - (\<Union>i. Q i)) \<inter> {x\<in>space M. f' x \<noteq> \<infinity>})" by (auto simp: indicator_def)
hoelzl@40859
   651
  qed
hoelzl@63330
   652
  moreover have "AE x in M. (?f (space M - (\<Union>i. Q i)) x = ?f' (space M - (\<Union>i. Q i)) x) \<longrightarrow> (\<forall>i. ?f (Q i) x = ?f' (Q i) x) \<longrightarrow>
hoelzl@40859
   653
    ?f (space M) x = ?f' (space M) x"
hoelzl@63330
   654
    by (auto simp: indicator_def)
hoelzl@47694
   655
  ultimately have "AE x in M. ?f (space M) x = ?f' (space M) x"
hoelzl@47694
   656
    unfolding AE_all_countable[symmetric]
hoelzl@63330
   657
    by eventually_elim (auto split: if_split_asm simp: indicator_def)
hoelzl@47694
   658
  then show "AE x in M. f x = f' x" by auto
hoelzl@40859
   659
qed
hoelzl@40859
   660
hoelzl@40859
   661
lemma (in sigma_finite_measure) density_unique:
hoelzl@62975
   662
  assumes f: "f \<in> borel_measurable M"
hoelzl@62975
   663
  assumes f': "f' \<in> borel_measurable M"
hoelzl@47694
   664
  assumes density_eq: "density M f = density M f'"
hoelzl@47694
   665
  shows "AE x in M. f x = f' x"
hoelzl@40859
   666
proof -
hoelzl@40859
   667
  obtain h where h_borel: "h \<in> borel_measurable M"
hoelzl@56996
   668
    and fin: "integral\<^sup>N M h \<noteq> \<infinity>" and pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x \<and> h x < \<infinity>" "\<And>x. 0 \<le> h x"
hoelzl@40859
   669
    using Ex_finite_integrable_function by auto
hoelzl@47694
   670
  then have h_nn: "AE x in M. 0 \<le> h x" by auto
hoelzl@47694
   671
  let ?H = "density M h"
hoelzl@47694
   672
  interpret h: finite_measure ?H
hoelzl@47694
   673
    using fin h_borel pos
hoelzl@56996
   674
    by (intro finite_measureI) (simp cong: nn_integral_cong emeasure_density add: fin)
hoelzl@47694
   675
  let ?fM = "density M f"
hoelzl@47694
   676
  let ?f'M = "density M f'"
hoelzl@40859
   677
  { fix A assume "A \<in> sets M"
hoelzl@41981
   678
    then have "{x \<in> space M. h x * indicator A x \<noteq> 0} = A"
immler@50244
   679
      using pos(1) sets.sets_into_space by (force simp: indicator_def)
wenzelm@53015
   680
    then have "(\<integral>\<^sup>+x. h x * indicator A x \<partial>M) = 0 \<longleftrightarrow> A \<in> null_sets M"
wenzelm@61808
   681
      using h_borel \<open>A \<in> sets M\<close> h_nn by (subst nn_integral_0_iff) auto }
hoelzl@40859
   682
  note h_null_sets = this
hoelzl@40859
   683
  { fix A assume "A \<in> sets M"
wenzelm@53015
   684
    have "(\<integral>\<^sup>+x. f x * (h x * indicator A x) \<partial>M) = (\<integral>\<^sup>+x. h x * indicator A x \<partial>?fM)"
wenzelm@61808
   685
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
hoelzl@56996
   686
      by (intro nn_integral_density[symmetric]) auto
wenzelm@53015
   687
    also have "\<dots> = (\<integral>\<^sup>+x. h x * indicator A x \<partial>?f'M)"
hoelzl@47694
   688
      by (simp_all add: density_eq)
wenzelm@53015
   689
    also have "\<dots> = (\<integral>\<^sup>+x. f' x * (h x * indicator A x) \<partial>M)"
wenzelm@61808
   690
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
hoelzl@56996
   691
      by (intro nn_integral_density) auto
wenzelm@53015
   692
    finally have "(\<integral>\<^sup>+x. h x * (f x * indicator A x) \<partial>M) = (\<integral>\<^sup>+x. h x * (f' x * indicator A x) \<partial>M)"
hoelzl@41981
   693
      by (simp add: ac_simps)
wenzelm@53015
   694
    then have "(\<integral>\<^sup>+x. (f x * indicator A x) \<partial>?H) = (\<integral>\<^sup>+x. (f' x * indicator A x) \<partial>?H)"
wenzelm@61808
   695
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
hoelzl@56996
   696
      by (subst (asm) (1 2) nn_integral_density[symmetric]) auto }
hoelzl@41981
   697
  then have "AE x in ?H. f x = f' x" using h_borel h_nn f f'
hoelzl@62975
   698
    by (intro h.density_unique_finite_measure absolutely_continuous_AE[of M]) auto
hoelzl@62975
   699
  with AE_space[of M] pos show "AE x in M. f x = f' x"
hoelzl@62975
   700
    unfolding AE_density[OF h_borel] by auto
hoelzl@40859
   701
qed
hoelzl@40859
   702
hoelzl@47694
   703
lemma (in sigma_finite_measure) density_unique_iff:
hoelzl@62975
   704
  assumes f: "f \<in> borel_measurable M" and f': "f' \<in> borel_measurable M"
hoelzl@47694
   705
  shows "density M f = density M f' \<longleftrightarrow> (AE x in M. f x = f' x)"
hoelzl@47694
   706
  using density_unique[OF assms] density_cong[OF f f'] by auto
hoelzl@47694
   707
hoelzl@49785
   708
lemma sigma_finite_density_unique:
hoelzl@49785
   709
  assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@49785
   710
  and fin: "sigma_finite_measure (density M f)"
hoelzl@49785
   711
  shows "density M f = density M g \<longleftrightarrow> (AE x in M. f x = g x)"
hoelzl@49785
   712
proof
lp15@61609
   713
  assume "AE x in M. f x = g x" with borel show "density M f = density M g"
hoelzl@49785
   714
    by (auto intro: density_cong)
hoelzl@49785
   715
next
hoelzl@49785
   716
  assume eq: "density M f = density M g"
wenzelm@61605
   717
  interpret f: sigma_finite_measure "density M f" by fact
hoelzl@49785
   718
  from f.sigma_finite_incseq guess A . note cover = this
hoelzl@49785
   719
hoelzl@49785
   720
  have "AE x in M. \<forall>i. x \<in> A i \<longrightarrow> f x = g x"
hoelzl@49785
   721
    unfolding AE_all_countable
hoelzl@49785
   722
  proof
hoelzl@49785
   723
    fix i
hoelzl@49785
   724
    have "density (density M f) (indicator (A i)) = density (density M g) (indicator (A i))"
hoelzl@49785
   725
      unfolding eq ..
wenzelm@53015
   726
    moreover have "(\<integral>\<^sup>+x. f x * indicator (A i) x \<partial>M) \<noteq> \<infinity>"
hoelzl@49785
   727
      using cover(1) cover(3)[of i] borel by (auto simp: emeasure_density subset_eq)
hoelzl@49785
   728
    ultimately have "AE x in M. f x * indicator (A i) x = g x * indicator (A i) x"
hoelzl@62975
   729
      using borel cover(1)
hoelzl@62975
   730
      by (intro finite_density_unique[THEN iffD1]) (auto simp: density_density_eq subset_eq)
hoelzl@49785
   731
    then show "AE x in M. x \<in> A i \<longrightarrow> f x = g x"
hoelzl@49785
   732
      by auto
hoelzl@49785
   733
  qed
hoelzl@49785
   734
  with AE_space show "AE x in M. f x = g x"
hoelzl@49785
   735
    apply eventually_elim
hoelzl@49785
   736
    using cover(2)[symmetric]
hoelzl@49785
   737
    apply auto
hoelzl@49785
   738
    done
hoelzl@49785
   739
qed
hoelzl@49785
   740
hoelzl@49778
   741
lemma (in sigma_finite_measure) sigma_finite_iff_density_finite':
hoelzl@62975
   742
  assumes f: "f \<in> borel_measurable M"
hoelzl@47694
   743
  shows "sigma_finite_measure (density M f) \<longleftrightarrow> (AE x in M. f x \<noteq> \<infinity>)"
hoelzl@47694
   744
    (is "sigma_finite_measure ?N \<longleftrightarrow> _")
hoelzl@40859
   745
proof
hoelzl@41689
   746
  assume "sigma_finite_measure ?N"
hoelzl@47694
   747
  then interpret N: sigma_finite_measure ?N .
hoelzl@47694
   748
  from N.Ex_finite_integrable_function obtain h where
hoelzl@56996
   749
    h: "h \<in> borel_measurable M" "integral\<^sup>N ?N h \<noteq> \<infinity>" and
hoelzl@62975
   750
    fin: "\<forall>x\<in>space M. 0 < h x \<and> h x < \<infinity>"
hoelzl@62975
   751
    by auto
hoelzl@47694
   752
  have "AE x in M. f x * h x \<noteq> \<infinity>"
hoelzl@40859
   753
  proof (rule AE_I')
hoelzl@62975
   754
    have "integral\<^sup>N ?N h = (\<integral>\<^sup>+x. f x * h x \<partial>M)"
hoelzl@62975
   755
      using f h by (auto intro!: nn_integral_density)
wenzelm@53015
   756
    then have "(\<integral>\<^sup>+x. f x * h x \<partial>M) \<noteq> \<infinity>"
hoelzl@40859
   757
      using h(2) by simp
hoelzl@47694
   758
    then show "(\<lambda>x. f x * h x) -` {\<infinity>} \<inter> space M \<in> null_sets M"
hoelzl@62975
   759
      using f h(1) by (auto intro!: nn_integral_PInf[unfolded infinity_ennreal_def] borel_measurable_vimage)
hoelzl@40859
   760
  qed auto
hoelzl@47694
   761
  then show "AE x in M. f x \<noteq> \<infinity>"
hoelzl@62975
   762
    using fin by (auto elim!: AE_Ball_mp simp: less_top ennreal_mult_less_top)
hoelzl@40859
   763
next
hoelzl@47694
   764
  assume AE: "AE x in M. f x \<noteq> \<infinity>"
hoelzl@57447
   765
  from sigma_finite guess Q . note Q = this
wenzelm@63040
   766
  define A where "A i =
wenzelm@63040
   767
    f -` (case i of 0 \<Rightarrow> {\<infinity>} | Suc n \<Rightarrow> {.. ennreal(of_nat (Suc n))}) \<inter> space M" for i
hoelzl@40859
   768
  { fix i j have "A i \<inter> Q j \<in> sets M"
hoelzl@40859
   769
    unfolding A_def using f Q
immler@50244
   770
    apply (rule_tac sets.Int)
hoelzl@41981
   771
    by (cases i) (auto intro: measurable_sets[OF f(1)]) }
hoelzl@40859
   772
  note A_in_sets = this
hoelzl@57447
   773
hoelzl@41689
   774
  show "sigma_finite_measure ?N"
wenzelm@61169
   775
  proof (standard, intro exI conjI ballI)
hoelzl@57447
   776
    show "countable (range (\<lambda>(i, j). A i \<inter> Q j))"
hoelzl@57447
   777
      by auto
hoelzl@57447
   778
    show "range (\<lambda>(i, j). A i \<inter> Q j) \<subseteq> sets (density M f)"
hoelzl@57447
   779
      using A_in_sets by auto
hoelzl@40859
   780
  next
hoelzl@57447
   781
    have "\<Union>range (\<lambda>(i, j). A i \<inter> Q j) = (\<Union>i j. A i \<inter> Q j)"
hoelzl@57447
   782
      by auto
hoelzl@40859
   783
    also have "\<dots> = (\<Union>i. A i) \<inter> space M" using Q by auto
hoelzl@40859
   784
    also have "(\<Union>i. A i) = space M"
hoelzl@40859
   785
    proof safe
hoelzl@40859
   786
      fix x assume x: "x \<in> space M"
hoelzl@40859
   787
      show "x \<in> (\<Union>i. A i)"
hoelzl@62975
   788
      proof (cases "f x" rule: ennreal_cases)
hoelzl@62975
   789
        case top with x show ?thesis unfolding A_def by (auto intro: exI[of _ 0])
hoelzl@40859
   790
      next
hoelzl@41981
   791
        case (real r)
hoelzl@62975
   792
        with ennreal_Ex_less_of_nat[of "f x"] obtain n :: nat where "f x < n"
hoelzl@62975
   793
          by auto
hoelzl@62975
   794
        also have "n < (Suc n :: ennreal)"
hoelzl@62975
   795
          by simp
hoelzl@62975
   796
        finally show ?thesis
hoelzl@62975
   797
          using x real by (auto simp: A_def ennreal_of_nat_eq_real_of_nat intro!: exI[of _ "Suc n"])
hoelzl@40859
   798
      qed
hoelzl@40859
   799
    qed (auto simp: A_def)
hoelzl@57447
   800
    finally show "\<Union>range (\<lambda>(i, j). A i \<inter> Q j) = space ?N" by simp
hoelzl@40859
   801
  next
hoelzl@57447
   802
    fix X assume "X \<in> range (\<lambda>(i, j). A i \<inter> Q j)"
hoelzl@57447
   803
    then obtain i j where [simp]:"X = A i \<inter> Q j" by auto
wenzelm@53015
   804
    have "(\<integral>\<^sup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<noteq> \<infinity>"
hoelzl@40859
   805
    proof (cases i)
hoelzl@40859
   806
      case 0
hoelzl@47694
   807
      have "AE x in M. f x * indicator (A i \<inter> Q j) x = 0"
wenzelm@61808
   808
        using AE by (auto simp: A_def \<open>i = 0\<close>)
hoelzl@56996
   809
      from nn_integral_cong_AE[OF this] show ?thesis by simp
hoelzl@40859
   810
    next
hoelzl@40859
   811
      case (Suc n)
wenzelm@53015
   812
      then have "(\<integral>\<^sup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<le>
hoelzl@62975
   813
        (\<integral>\<^sup>+x. (Suc n :: ennreal) * indicator (Q j) x \<partial>M)"
hoelzl@62975
   814
        by (auto intro!: nn_integral_mono simp: indicator_def A_def ennreal_of_nat_eq_real_of_nat)
hoelzl@47694
   815
      also have "\<dots> = Suc n * emeasure M (Q j)"
hoelzl@56996
   816
        using Q by (auto intro!: nn_integral_cmult_indicator)
hoelzl@41981
   817
      also have "\<dots> < \<infinity>"
hoelzl@62975
   818
        using Q by (auto simp: ennreal_mult_less_top less_top of_nat_less_top)
hoelzl@40859
   819
      finally show ?thesis by simp
hoelzl@40859
   820
    qed
hoelzl@57447
   821
    then show "emeasure ?N X \<noteq> \<infinity>"
hoelzl@47694
   822
      using A_in_sets Q f by (auto simp: emeasure_density)
hoelzl@40859
   823
  qed
hoelzl@40859
   824
qed
hoelzl@40859
   825
hoelzl@49778
   826
lemma (in sigma_finite_measure) sigma_finite_iff_density_finite:
hoelzl@49778
   827
  "f \<in> borel_measurable M \<Longrightarrow> sigma_finite_measure (density M f) \<longleftrightarrow> (AE x in M. f x \<noteq> \<infinity>)"
hoelzl@62975
   828
  by (subst sigma_finite_iff_density_finite')
hoelzl@62975
   829
     (auto simp: max_def intro!: measurable_If)
hoelzl@49778
   830
wenzelm@61808
   831
subsection \<open>Radon-Nikodym derivative\<close>
hoelzl@38656
   832
hoelzl@62975
   833
definition RN_deriv :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a \<Rightarrow> ennreal" where
hoelzl@56993
   834
  "RN_deriv M N =
hoelzl@62975
   835
    (if \<exists>f. f \<in> borel_measurable M \<and> density M f = N
hoelzl@62975
   836
       then SOME f. f \<in> borel_measurable M \<and> density M f = N
hoelzl@56993
   837
       else (\<lambda>_. 0))"
hoelzl@38656
   838
lp15@61609
   839
lemma RN_derivI:
hoelzl@62975
   840
  assumes "f \<in> borel_measurable M" "density M f = N"
hoelzl@56993
   841
  shows "density M (RN_deriv M N) = N"
hoelzl@40859
   842
proof -
wenzelm@63540
   843
  have *: "\<exists>f. f \<in> borel_measurable M \<and> density M f = N"
hoelzl@56993
   844
    using assms by auto
wenzelm@63540
   845
  then have "density M (SOME f. f \<in> borel_measurable M \<and> density M f = N) = N"
hoelzl@56993
   846
    by (rule someI2_ex) auto
wenzelm@63540
   847
  with * show ?thesis
hoelzl@56993
   848
    by (auto simp: RN_deriv_def)
hoelzl@40859
   849
qed
hoelzl@40859
   850
hoelzl@62975
   851
lemma borel_measurable_RN_deriv[measurable]: "RN_deriv M N \<in> borel_measurable M"
hoelzl@38656
   852
proof -
hoelzl@62975
   853
  { assume ex: "\<exists>f. f \<in> borel_measurable M \<and> density M f = N"
hoelzl@62975
   854
    have 1: "(SOME f. f \<in> borel_measurable M \<and> density M f = N) \<in> borel_measurable M"
hoelzl@62975
   855
      using ex by (rule someI2_ex) auto }
hoelzl@62975
   856
  from this show ?thesis
hoelzl@56993
   857
    by (auto simp: RN_deriv_def)
hoelzl@38656
   858
qed
hoelzl@38656
   859
hoelzl@56993
   860
lemma density_RN_deriv_density:
hoelzl@62975
   861
  assumes f: "f \<in> borel_measurable M"
hoelzl@56993
   862
  shows "density M (RN_deriv M (density M f)) = density M f"
hoelzl@62975
   863
  by (rule RN_derivI[OF f]) simp
hoelzl@56993
   864
hoelzl@56993
   865
lemma (in sigma_finite_measure) density_RN_deriv:
hoelzl@56993
   866
  "absolutely_continuous M N \<Longrightarrow> sets N = sets M \<Longrightarrow> density M (RN_deriv M N) = N"
hoelzl@56993
   867
  by (metis RN_derivI Radon_Nikodym)
hoelzl@56993
   868
hoelzl@56996
   869
lemma (in sigma_finite_measure) RN_deriv_nn_integral:
hoelzl@47694
   870
  assumes N: "absolutely_continuous M N" "sets N = sets M"
hoelzl@40859
   871
    and f: "f \<in> borel_measurable M"
hoelzl@56996
   872
  shows "integral\<^sup>N N f = (\<integral>\<^sup>+x. RN_deriv M N x * f x \<partial>M)"
hoelzl@40859
   873
proof -
hoelzl@56996
   874
  have "integral\<^sup>N N f = integral\<^sup>N (density M (RN_deriv M N)) f"
hoelzl@47694
   875
    using N by (simp add: density_RN_deriv)
wenzelm@53015
   876
  also have "\<dots> = (\<integral>\<^sup>+x. RN_deriv M N x * f x \<partial>M)"
hoelzl@62975
   877
    using f by (simp add: nn_integral_density)
hoelzl@47694
   878
  finally show ?thesis by simp
hoelzl@40859
   879
qed
hoelzl@40859
   880
hoelzl@47694
   881
lemma null_setsD_AE: "N \<in> null_sets M \<Longrightarrow> AE x in M. x \<notin> N"
hoelzl@47694
   882
  using AE_iff_null_sets[of N M] by auto
hoelzl@47694
   883
hoelzl@47694
   884
lemma (in sigma_finite_measure) RN_deriv_unique:
hoelzl@62975
   885
  assumes f: "f \<in> borel_measurable M"
hoelzl@47694
   886
  and eq: "density M f = N"
hoelzl@47694
   887
  shows "AE x in M. f x = RN_deriv M N x"
hoelzl@49785
   888
  unfolding eq[symmetric]
hoelzl@56993
   889
  by (intro density_unique_iff[THEN iffD1] f borel_measurable_RN_deriv
hoelzl@62975
   890
            density_RN_deriv_density[symmetric])
hoelzl@49785
   891
hoelzl@49785
   892
lemma RN_deriv_unique_sigma_finite:
hoelzl@62975
   893
  assumes f: "f \<in> borel_measurable M"
hoelzl@49785
   894
  and eq: "density M f = N" and fin: "sigma_finite_measure N"
hoelzl@49785
   895
  shows "AE x in M. f x = RN_deriv M N x"
hoelzl@49785
   896
  using fin unfolding eq[symmetric]
hoelzl@56993
   897
  by (intro sigma_finite_density_unique[THEN iffD1] f borel_measurable_RN_deriv
hoelzl@62975
   898
            density_RN_deriv_density[symmetric])
hoelzl@47694
   899
hoelzl@47694
   900
lemma (in sigma_finite_measure) RN_deriv_distr:
hoelzl@47694
   901
  fixes T :: "'a \<Rightarrow> 'b"
hoelzl@47694
   902
  assumes T: "T \<in> measurable M M'" and T': "T' \<in> measurable M' M"
hoelzl@47694
   903
    and inv: "\<forall>x\<in>space M. T' (T x) = x"
hoelzl@50021
   904
  and ac[simp]: "absolutely_continuous (distr M M' T) (distr N M' T)"
hoelzl@47694
   905
  and N: "sets N = sets M"
hoelzl@47694
   906
  shows "AE x in M. RN_deriv (distr M M' T) (distr N M' T) (T x) = RN_deriv M N x"
hoelzl@41832
   907
proof (rule RN_deriv_unique)
hoelzl@47694
   908
  have [simp]: "sets N = sets M" by fact
hoelzl@47694
   909
  note sets_eq_imp_space_eq[OF N, simp]
hoelzl@47694
   910
  have measurable_N[simp]: "\<And>M'. measurable N M' = measurable M M'" by (auto simp: measurable_def)
hoelzl@47694
   911
  { fix A assume "A \<in> sets M"
immler@50244
   912
    with inv T T' sets.sets_into_space[OF this]
hoelzl@47694
   913
    have "T -` T' -` A \<inter> T -` space M' \<inter> space M = A"
hoelzl@47694
   914
      by (auto simp: measurable_def) }
hoelzl@47694
   915
  note eq = this[simp]
hoelzl@47694
   916
  { fix A assume "A \<in> sets M"
immler@50244
   917
    with inv T T' sets.sets_into_space[OF this]
hoelzl@47694
   918
    have "(T' \<circ> T) -` A \<inter> space M = A"
hoelzl@47694
   919
      by (auto simp: measurable_def) }
hoelzl@47694
   920
  note eq2 = this[simp]
hoelzl@47694
   921
  let ?M' = "distr M M' T" and ?N' = "distr N M' T"
hoelzl@47694
   922
  interpret M': sigma_finite_measure ?M'
hoelzl@41832
   923
  proof
hoelzl@57447
   924
    from sigma_finite_countable guess F .. note F = this
hoelzl@57447
   925
    show "\<exists>A. countable A \<and> A \<subseteq> sets (distr M M' T) \<and> \<Union>A = space (distr M M' T) \<and> (\<forall>a\<in>A. emeasure (distr M M' T) a \<noteq> \<infinity>)"
hoelzl@57447
   926
    proof (intro exI conjI ballI)
hoelzl@57447
   927
      show *: "(\<lambda>A. T' -` A \<inter> space ?M') ` F \<subseteq> sets ?M'"
hoelzl@47694
   928
        using F T' by (auto simp: measurable_def)
hoelzl@57447
   929
      show "\<Union>((\<lambda>A. T' -` A \<inter> space ?M')`F) = space ?M'"
hoelzl@57447
   930
        using F T'[THEN measurable_space] by (auto simp: set_eq_iff)
hoelzl@57447
   931
    next
hoelzl@57447
   932
      fix X assume "X \<in> (\<lambda>A. T' -` A \<inter> space ?M')`F"
hoelzl@57447
   933
      then obtain A where [simp]: "X = T' -` A \<inter> space ?M'" and "A \<in> F" by auto
wenzelm@61808
   934
      have "X \<in> sets M'" using F T' \<open>A\<in>F\<close> by auto
hoelzl@41832
   935
      moreover
wenzelm@61808
   936
      have Fi: "A \<in> sets M" using F \<open>A\<in>F\<close> by auto
hoelzl@57447
   937
      ultimately show "emeasure ?M' X \<noteq> \<infinity>"
wenzelm@61808
   938
        using F T T' \<open>A\<in>F\<close> by (simp add: emeasure_distr)
hoelzl@57447
   939
    qed (insert F, auto)
hoelzl@41832
   940
  qed
hoelzl@47694
   941
  have "(RN_deriv ?M' ?N') \<circ> T \<in> borel_measurable M"
hoelzl@50021
   942
    using T ac by measurable
hoelzl@47694
   943
  then show "(\<lambda>x. RN_deriv ?M' ?N' (T x)) \<in> borel_measurable M"
hoelzl@41832
   944
    by (simp add: comp_def)
hoelzl@47694
   945
hoelzl@47694
   946
  have "N = distr N M (T' \<circ> T)"
hoelzl@47694
   947
    by (subst measure_of_of_measure[of N, symmetric])
immler@50244
   948
       (auto simp add: distr_def sets.sigma_sets_eq intro!: measure_of_eq sets.space_closed)
hoelzl@47694
   949
  also have "\<dots> = distr (distr N M' T) M T'"
hoelzl@47694
   950
    using T T' by (simp add: distr_distr)
hoelzl@47694
   951
  also have "\<dots> = distr (density (distr M M' T) (RN_deriv (distr M M' T) (distr N M' T))) M T'"
hoelzl@47694
   952
    using ac by (simp add: M'.density_RN_deriv)
hoelzl@47694
   953
  also have "\<dots> = density M (RN_deriv (distr M M' T) (distr N M' T) \<circ> T)"
hoelzl@56993
   954
    by (simp add: distr_density_distr[OF T T', OF inv])
hoelzl@47694
   955
  finally show "density M (\<lambda>x. RN_deriv (distr M M' T) (distr N M' T) (T x)) = N"
hoelzl@47694
   956
    by (simp add: comp_def)
hoelzl@41832
   957
qed
hoelzl@41832
   958
hoelzl@40859
   959
lemma (in sigma_finite_measure) RN_deriv_finite:
hoelzl@47694
   960
  assumes N: "sigma_finite_measure N" and ac: "absolutely_continuous M N" "sets N = sets M"
hoelzl@47694
   961
  shows "AE x in M. RN_deriv M N x \<noteq> \<infinity>"
hoelzl@40859
   962
proof -
hoelzl@47694
   963
  interpret N: sigma_finite_measure N by fact
hoelzl@47694
   964
  from N show ?thesis
hoelzl@62975
   965
    using sigma_finite_iff_density_finite[OF borel_measurable_RN_deriv, of N] density_RN_deriv[OF ac]
hoelzl@62975
   966
    by simp
hoelzl@40859
   967
qed
hoelzl@40859
   968
hoelzl@40859
   969
lemma (in sigma_finite_measure)
hoelzl@47694
   970
  assumes N: "sigma_finite_measure N" and ac: "absolutely_continuous M N" "sets N = sets M"
hoelzl@40859
   971
    and f: "f \<in> borel_measurable M"
hoelzl@47694
   972
  shows RN_deriv_integrable: "integrable N f \<longleftrightarrow>
hoelzl@62975
   973
      integrable M (\<lambda>x. enn2real (RN_deriv M N x) * f x)" (is ?integrable)
hoelzl@62975
   974
    and RN_deriv_integral: "integral\<^sup>L N f = (\<integral>x. enn2real (RN_deriv M N x) * f x \<partial>M)" (is ?integral)
hoelzl@40859
   975
proof -
hoelzl@47694
   976
  note ac(2)[simp] and sets_eq_imp_space_eq[OF ac(2), simp]
hoelzl@47694
   977
  interpret N: sigma_finite_measure N by fact
hoelzl@56993
   978
hoelzl@62975
   979
  have eq: "density M (RN_deriv M N) = density M (\<lambda>x. enn2real (RN_deriv M N x))"
hoelzl@56993
   980
  proof (rule density_cong)
hoelzl@56993
   981
    from RN_deriv_finite[OF assms(1,2,3)]
hoelzl@62975
   982
    show "AE x in M. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
hoelzl@62975
   983
      by eventually_elim (auto simp: less_top)
hoelzl@56993
   984
  qed (insert ac, auto)
hoelzl@56993
   985
hoelzl@56993
   986
  show ?integrable
hoelzl@56993
   987
    apply (subst density_RN_deriv[OF ac, symmetric])
hoelzl@56993
   988
    unfolding eq
hoelzl@62975
   989
    apply (intro integrable_real_density f AE_I2 enn2real_nonneg)
hoelzl@56993
   990
    apply (insert ac, auto)
hoelzl@56993
   991
    done
hoelzl@56993
   992
hoelzl@56993
   993
  show ?integral
hoelzl@56993
   994
    apply (subst density_RN_deriv[OF ac, symmetric])
hoelzl@56993
   995
    unfolding eq
hoelzl@62975
   996
    apply (intro integral_real_density f AE_I2 enn2real_nonneg)
hoelzl@56993
   997
    apply (insert ac, auto)
hoelzl@56993
   998
    done
hoelzl@40859
   999
qed
hoelzl@40859
  1000
hoelzl@43340
  1001
lemma (in sigma_finite_measure) real_RN_deriv:
hoelzl@47694
  1002
  assumes "finite_measure N"
hoelzl@47694
  1003
  assumes ac: "absolutely_continuous M N" "sets N = sets M"
hoelzl@43340
  1004
  obtains D where "D \<in> borel_measurable M"
hoelzl@62975
  1005
    and "AE x in M. RN_deriv M N x = ennreal (D x)"
hoelzl@47694
  1006
    and "AE x in N. 0 < D x"
hoelzl@43340
  1007
    and "\<And>x. 0 \<le> D x"
hoelzl@43340
  1008
proof
hoelzl@47694
  1009
  interpret N: finite_measure N by fact
lp15@61609
  1010
hoelzl@62975
  1011
  note RN = borel_measurable_RN_deriv density_RN_deriv[OF ac]
hoelzl@43340
  1012
hoelzl@47694
  1013
  let ?RN = "\<lambda>t. {x \<in> space M. RN_deriv M N x = t}"
hoelzl@43340
  1014
hoelzl@62975
  1015
  show "(\<lambda>x. enn2real (RN_deriv M N x)) \<in> borel_measurable M"
hoelzl@43340
  1016
    using RN by auto
hoelzl@43340
  1017
wenzelm@53015
  1018
  have "N (?RN \<infinity>) = (\<integral>\<^sup>+ x. RN_deriv M N x * indicator (?RN \<infinity>) x \<partial>M)"
hoelzl@62975
  1019
    using RN(1) by (subst RN(2)[symmetric]) (auto simp: emeasure_density)
wenzelm@53015
  1020
  also have "\<dots> = (\<integral>\<^sup>+ x. \<infinity> * indicator (?RN \<infinity>) x \<partial>M)"
hoelzl@56996
  1021
    by (intro nn_integral_cong) (auto simp: indicator_def)
hoelzl@47694
  1022
  also have "\<dots> = \<infinity> * emeasure M (?RN \<infinity>)"
hoelzl@56996
  1023
    using RN by (intro nn_integral_cmult_indicator) auto
hoelzl@47694
  1024
  finally have eq: "N (?RN \<infinity>) = \<infinity> * emeasure M (?RN \<infinity>)" .
hoelzl@43340
  1025
  moreover
hoelzl@47694
  1026
  have "emeasure M (?RN \<infinity>) = 0"
hoelzl@43340
  1027
  proof (rule ccontr)
hoelzl@47694
  1028
    assume "emeasure M {x \<in> space M. RN_deriv M N x = \<infinity>} \<noteq> 0"
hoelzl@62975
  1029
    then have "0 < emeasure M {x \<in> space M. RN_deriv M N x = \<infinity>}"
hoelzl@62975
  1030
      by (auto simp: zero_less_iff_neq_zero)
hoelzl@62975
  1031
    with eq have "N (?RN \<infinity>) = \<infinity>" by (simp add: ennreal_mult_eq_top_iff)
hoelzl@47694
  1032
    with N.emeasure_finite[of "?RN \<infinity>"] RN show False by auto
hoelzl@43340
  1033
  qed
hoelzl@47694
  1034
  ultimately have "AE x in M. RN_deriv M N x < \<infinity>"
hoelzl@62975
  1035
    using RN by (intro AE_iff_measurable[THEN iffD2]) (auto simp: less_top[symmetric])
hoelzl@62975
  1036
  then show "AE x in M. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
hoelzl@62975
  1037
    by auto
hoelzl@62975
  1038
  then have eq: "AE x in N. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
hoelzl@47694
  1039
    using ac absolutely_continuous_AE by auto
hoelzl@43340
  1040
hoelzl@43340
  1041
wenzelm@53015
  1042
  have "N (?RN 0) = (\<integral>\<^sup>+ x. RN_deriv M N x * indicator (?RN 0) x \<partial>M)"
hoelzl@62975
  1043
    by (subst RN(2)[symmetric]) (auto simp: emeasure_density)
wenzelm@53015
  1044
  also have "\<dots> = (\<integral>\<^sup>+ x. 0 \<partial>M)"
hoelzl@56996
  1045
    by (intro nn_integral_cong) (auto simp: indicator_def)
hoelzl@47694
  1046
  finally have "AE x in N. RN_deriv M N x \<noteq> 0"
hoelzl@47694
  1047
    using RN by (subst AE_iff_measurable[OF _ refl]) (auto simp: ac cong: sets_eq_imp_space_eq)
hoelzl@62975
  1048
  with eq show "AE x in N. 0 < enn2real (RN_deriv M N x)"
hoelzl@62975
  1049
    by (auto simp: enn2real_positive_iff less_top[symmetric] zero_less_iff_neq_zero)
hoelzl@62975
  1050
qed (rule enn2real_nonneg)
hoelzl@43340
  1051
hoelzl@38656
  1052
lemma (in sigma_finite_measure) RN_deriv_singleton:
hoelzl@47694
  1053
  assumes ac: "absolutely_continuous M N" "sets N = sets M"
hoelzl@47694
  1054
  and x: "{x} \<in> sets M"
hoelzl@47694
  1055
  shows "N {x} = RN_deriv M N x * emeasure M {x}"
hoelzl@38656
  1056
proof -
wenzelm@61808
  1057
  from \<open>{x} \<in> sets M\<close>
wenzelm@53015
  1058
  have "density M (RN_deriv M N) {x} = (\<integral>\<^sup>+w. RN_deriv M N x * indicator {x} w \<partial>M)"
hoelzl@56996
  1059
    by (auto simp: indicator_def emeasure_density intro!: nn_integral_cong)
hoelzl@62975
  1060
  with x density_RN_deriv[OF ac] show ?thesis
hoelzl@62083
  1061
    by (auto simp: max_def)
hoelzl@38656
  1062
qed
hoelzl@38656
  1063
hoelzl@38656
  1064
end