src/HOL/Probability/Radon_Nikodym.thy
author wenzelm
Mon, 25 Apr 2016 16:09:26 +0200
changeset 63040 eb4ddd18d635
parent 62975 1d066f6ab25d
child 63329 6b26c378ab35
permissions -rw-r--r--
eliminated old 'def'; tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42067
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     1
(*  Title:      HOL/Probability/Radon_Nikodym.thy
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     2
    Author:     Johannes Hölzl, TU München
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     3
*)
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     4
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
     5
section \<open>Radon-Nikod{\'y}m derivative\<close>
42067
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     6
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     7
theory Radon_Nikodym
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
     8
imports Bochner_Integration
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
     9
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    10
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    11
definition "diff_measure M N =
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    12
  measure_of (space M) (sets M) (\<lambda>A. emeasure M A - emeasure N A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    13
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
    14
lemma
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    15
  shows space_diff_measure[simp]: "space (diff_measure M N) = space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    16
    and sets_diff_measure[simp]: "sets (diff_measure M N) = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    17
  by (auto simp: diff_measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    18
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    19
lemma emeasure_diff_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    20
  assumes fin: "finite_measure M" "finite_measure N" and sets_eq: "sets M = sets N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    21
  assumes pos: "\<And>A. A \<in> sets M \<Longrightarrow> emeasure N A \<le> emeasure M A" and A: "A \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    22
  shows "emeasure (diff_measure M N) A = emeasure M A - emeasure N A" (is "_ = ?\<mu> A")
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    23
  unfolding diff_measure_def
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    24
proof (rule emeasure_measure_of_sigma)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    25
  show "sigma_algebra (space M) (sets M)" ..
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    26
  show "positive (sets M) ?\<mu>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    27
    using pos by (simp add: positive_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    28
  show "countably_additive (sets M) ?\<mu>"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    29
  proof (rule countably_additiveI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    30
    fix A :: "nat \<Rightarrow> _"  assume A: "range A \<subseteq> sets M" and "disjoint_family A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    31
    then have suminf:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    32
      "(\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    33
      "(\<Sum>i. emeasure N (A i)) = emeasure N (\<Union>i. A i)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    34
      by (simp_all add: suminf_emeasure sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    35
    with A have "(\<Sum>i. emeasure M (A i) - emeasure N (A i)) =
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    36
      (\<Sum>i. emeasure M (A i)) - (\<Sum>i. emeasure N (A i))"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    37
      using fin pos[of "A _"]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    38
      by (intro ennreal_suminf_minus)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    39
         (auto simp: sets_eq finite_measure.emeasure_eq_measure suminf_emeasure measure_nonneg)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    40
    then show "(\<Sum>i. emeasure M (A i) - emeasure N (A i)) =
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    41
      emeasure M (\<Union>i. A i) - emeasure N (\<Union>i. A i) "
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    42
      by (simp add: suminf)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    43
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    44
qed fact
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    45
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    46
lemma (in sigma_finite_measure) Ex_finite_integrable_function:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    47
  "\<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>)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    48
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    49
  obtain A :: "nat \<Rightarrow> 'a set" where
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
    50
    range[measurable]: "range A \<subseteq> sets M" and
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    51
    space: "(\<Union>i. A i) = space M" and
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    52
    measure: "\<And>i. emeasure M (A i) \<noteq> \<infinity>" and
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    53
    disjoint: "disjoint_family A"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 62083
diff changeset
    54
    using sigma_finite_disjoint by blast
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    55
  let ?B = "\<lambda>i. 2^Suc i * emeasure M (A i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    56
  have "\<forall>i. \<exists>x. 0 < x \<and> x < inverse (?B i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    57
  proof
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    58
    fix i show "\<exists>x. 0 < x \<and> x < inverse (?B i)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    59
      using measure[of i]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    60
      by (auto intro!: dense simp: ennreal_inverse_positive ennreal_mult_eq_top_iff power_eq_top_ennreal)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    61
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    62
  from choice[OF this] obtain n where n: "\<And>i. 0 < n i"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    63
    "\<And>i. n i < inverse (2^Suc i * emeasure M (A i))" by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
    64
  { fix i have "0 \<le> n i" using n(1)[of i] by auto } note pos = this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
    65
  let ?h = "\<lambda>x. \<Sum>i. n i * indicator (A i) x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    66
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
    67
  proof (safe intro!: bexI[of _ ?h] del: notI)
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 38656
diff changeset
    68
    have "\<And>i. A i \<in> sets M"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
    69
      using range by fastforce+
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
    70
    then have "integral\<^sup>N M ?h = (\<Sum>i. n i * emeasure M (A i))" using pos
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
    71
      by (simp add: nn_integral_suminf nn_integral_cmult_indicator)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    72
    also have "\<dots> \<le> (\<Sum>i. ennreal ((1/2)^Suc i))"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    73
    proof (intro suminf_le allI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
    74
      fix N
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    75
      have "n N * emeasure M (A N) \<le> inverse (2^Suc N * emeasure M (A N)) * emeasure M (A N)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    76
        using n[of N] by (intro mult_right_mono) auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    77
      also have "\<dots> = (1/2)^Suc N * (inverse (emeasure M (A N)) * emeasure M (A N))"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    78
        using measure[of N]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    79
        by (simp add: ennreal_inverse_power divide_ennreal_def ennreal_inverse_mult
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    80
                      power_eq_top_ennreal less_top[symmetric] mult_ac
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    81
                 del: power_Suc)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    82
      also have "\<dots> \<le> inverse (ennreal 2) ^ Suc N"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    83
        using measure[of N]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    84
        apply (cases "emeasure M (A N)" rule: ennreal_cases)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    85
        apply (cases "emeasure M (A N) = 0")
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    86
        apply (auto simp: inverse_ennreal ennreal_mult[symmetric] divide_ennreal_def simp del: power_Suc)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    87
        done
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    88
      also have "\<dots> = ennreal (inverse 2 ^ Suc N)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    89
        by (subst ennreal_power[symmetric], simp) (simp add: inverse_ennreal)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    90
      finally show "n N * emeasure M (A N) \<le> ennreal ((1/2)^Suc N)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    91
        by simp
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    92
    qed auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    93
    also have "\<dots> < top"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    94
      unfolding less_top[symmetric]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    95
      apply (rule ennreal_suminf_neq_top)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    96
      apply (subst summable_Suc_iff)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    97
      apply (subst summable_geometric)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    98
      apply auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
    99
      done
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   100
    finally show "integral\<^sup>N M ?h \<noteq> \<infinity>"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   101
      by (auto simp: top_unique)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   102
  next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   103
    { fix x assume "x \<in> space M"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   104
      then obtain i where "x \<in> A i" using space[symmetric] by auto
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   105
      with disjoint n have "?h x = n i"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   106
        by (auto intro!: suminf_cmult_indicator intro: less_imp_le)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   107
      then show "0 < ?h x" and "?h x < \<infinity>" using n[of i] by (auto simp: less_top[symmetric]) }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   108
    note pos = this
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   109
  qed measurable
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   110
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   111
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   112
subsection "Absolutely continuous"
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   113
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   114
definition absolutely_continuous :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> bool" where
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   115
  "absolutely_continuous M N \<longleftrightarrow> null_sets M \<subseteq> null_sets N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   116
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   117
lemma absolutely_continuousI_count_space: "absolutely_continuous (count_space A) M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   118
  unfolding absolutely_continuous_def by (auto simp: null_sets_count_space)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   119
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   120
lemma absolutely_continuousI_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   121
  "f \<in> borel_measurable M \<Longrightarrow> absolutely_continuous M (density M f)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   122
  by (force simp add: absolutely_continuous_def null_sets_density_iff dest: AE_not_in)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   123
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   124
lemma absolutely_continuousI_point_measure_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   125
  "(\<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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   126
  unfolding absolutely_continuous_def by (force simp: null_sets_point_measure_iff)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   127
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   128
lemma absolutely_continuous_AE:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   129
  assumes sets_eq: "sets M' = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   130
    and "absolutely_continuous M M'" "AE x in M. P x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   131
   shows "AE x in M'. P x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   132
proof -
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   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"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   134
    unfolding eventually_ae_filter by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   135
  show "AE x in M'. P x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   136
  proof (rule AE_I')
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   137
    show "{x\<in>space M'. \<not> P x} \<subseteq> N" using sets_eq_imp_space_eq[OF sets_eq] N(2) by simp
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   138
    from \<open>absolutely_continuous M M'\<close> show "N \<in> null_sets M'"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   139
      using N unfolding absolutely_continuous_def sets_eq null_sets_def by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   140
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   141
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   142
40871
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   143
subsection "Existence of the Radon-Nikodym derivative"
688f6ff859e1 Generalized simple_functionD and less_SUP_iff.
hoelzl
parents: 40859
diff changeset
   144
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   145
lemma (in finite_measure) Radon_Nikodym_aux_epsilon:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   146
  fixes e :: real assumes "0 < e"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   147
  assumes "finite_measure N" and sets_eq: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   148
  shows "\<exists>A\<in>sets M. measure M (space M) - measure N (space M) \<le> measure M A - measure N A \<and>
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   149
                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> - e < measure M B - measure N B)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   150
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   151
  interpret M': finite_measure N by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   152
  let ?d = "\<lambda>A. measure M A - measure N A"
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   153
  let ?A = "\<lambda>A. if (\<forall>B\<in>sets M. B \<subseteq> space M - A \<longrightarrow> -e < ?d B)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   154
    then {}
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   155
    else (SOME B. B \<in> sets M \<and> B \<subseteq> space M - A \<and> ?d B \<le> -e)"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   156
  define A where "A n = ((\<lambda>B. B \<union> ?A B) ^^ n) {}" for n
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   157
  have A_simps[simp]:
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   158
    "A 0 = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   159
    "\<And>n. A (Suc n) = (A n \<union> ?A (A n))" unfolding A_def by simp_all
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   160
  { fix A assume "A \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   161
    have "?A A \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   162
      by (auto intro!: someI2[of _ _ "\<lambda>A. A \<in> sets M"] simp: not_less) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   163
  note A'_in_sets = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   164
  { fix n have "A n \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   165
    proof (induct n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   166
      case (Suc n) thus "A (Suc n) \<in> sets M"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   167
        using A'_in_sets[of "A n"] by (auto split: if_split_asm)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   168
    qed (simp add: A_def) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   169
  note A_in_sets = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   170
  hence "range A \<subseteq> sets M" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   171
  { fix n B
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   172
    assume Ex: "\<exists>B. B \<in> sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> -e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   173
    hence False: "\<not> (\<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B)" by (auto simp: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   174
    have "?d (A (Suc n)) \<le> ?d (A n) - e" unfolding A_simps if_not_P[OF False]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   175
    proof (rule someI2_ex[OF Ex])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   176
      fix B assume "B \<in> sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   177
      hence "A n \<inter> B = {}" "B \<in> sets M" and dB: "?d B \<le> -e" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   178
      hence "?d (A n \<union> B) = ?d (A n) + ?d B"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   179
        using \<open>A n \<in> sets M\<close> finite_measure_Union M'.finite_measure_Union by (simp add: sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   180
      also have "\<dots> \<le> ?d (A n) - e" using dB by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   181
      finally show "?d (A n \<union> B) \<le> ?d (A n) - e" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   182
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   183
  note dA_epsilon = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   184
  { fix n have "?d (A (Suc n)) \<le> ?d (A n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   185
    proof (cases "\<exists>B. B\<in>sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e")
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   186
      case True from dA_epsilon[OF this] show ?thesis using \<open>0 < e\<close> by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   187
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   188
      case False
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   189
      hence "\<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B" by (auto simp: not_le)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   190
      thus ?thesis by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   191
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   192
  note dA_mono = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   193
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   194
  proof (cases "\<exists>n. \<forall>B\<in>sets M. B \<subseteq> space M - A n \<longrightarrow> -e < ?d B")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   195
    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
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   196
    show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   197
    proof (safe intro!: bexI[of _ "space M - A n"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   198
      fix B assume "B \<in> sets M" "B \<subseteq> space M - A n"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   199
      from B[OF this] show "-e < ?d B" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   200
    next
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   201
      show "space M - A n \<in> sets M" by (rule sets.compl_sets) fact
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   202
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   203
      show "?d (space M) \<le> ?d (space M - A n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   204
      proof (induct n)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   205
        fix n assume "?d (space M) \<le> ?d (space M - A n)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   206
        also have "\<dots> \<le> ?d (space M - A (Suc n))"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   207
          using A_in_sets sets.sets_into_space dA_mono[of n] finite_measure_compl M'.finite_measure_compl
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   208
          by (simp del: A_simps add: sets_eq sets_eq_imp_space_eq[OF sets_eq])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   209
        finally show "?d (space M) \<le> ?d (space M - A (Suc n))" .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   210
      qed simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   211
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   212
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   213
    case False hence B: "\<And>n. \<exists>B. B\<in>sets M \<and> B \<subseteq> space M - A n \<and> ?d B \<le> - e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   214
      by (auto simp add: not_less)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   215
    { fix n have "?d (A n) \<le> - real n * e"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   216
      proof (induct n)
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
   217
        case (Suc n) with dA_epsilon[of n, OF B] show ?case by (simp del: A_simps add: of_nat_Suc field_simps)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   218
      next
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   219
        case 0 with measure_empty show ?case by (simp add: zero_ennreal_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   220
      qed } note dA_less = this
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   221
    have decseq: "decseq (\<lambda>n. ?d (A n))" unfolding decseq_eq_incseq
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   222
    proof (rule incseq_SucI)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   223
      fix n show "- ?d (A n) \<le> - ?d (A (Suc n))" using dA_mono[of n] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   224
    qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   225
    have A: "incseq A" by (auto intro!: incseq_SucI)
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   226
    from finite_Lim_measure_incseq[OF _ A] \<open>range A \<subseteq> sets M\<close>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   227
      M'.finite_Lim_measure_incseq[OF _ A]
61969
e01015e49041 more symbols;
wenzelm
parents: 61810
diff changeset
   228
    have convergent: "(\<lambda>i. ?d (A i)) \<longlonglongrightarrow> ?d (\<Union>i. A i)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   229
      by (auto intro!: tendsto_diff simp: sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   230
    obtain n :: nat where "- ?d (\<Union>i. A i) / e < real n" using reals_Archimedean2 by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   231
    moreover from order_trans[OF decseq_le[OF decseq convergent] dA_less]
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   232
    have "real n \<le> - ?d (\<Union>i. A i) / e" using \<open>0<e\<close> by (simp add: field_simps)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   233
    ultimately show ?thesis by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   234
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   235
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   236
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   237
lemma (in finite_measure) Radon_Nikodym_aux:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   238
  assumes "finite_measure N" and sets_eq: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   239
  shows "\<exists>A\<in>sets M. measure M (space M) - measure N (space M) \<le>
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   240
                    measure M A - measure N A \<and>
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   241
                    (\<forall>B\<in>sets M. B \<subseteq> A \<longrightarrow> 0 \<le> measure M B - measure N B)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   242
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   243
  interpret N: finite_measure N by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   244
  let ?d = "\<lambda>A. measure M A - measure N A"
58184
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   245
  let ?P = "\<lambda>A n. if n = 0 then A = space M else (\<forall>C\<in>sets M. C \<subseteq> A \<longrightarrow> - 1 / real (Suc n) < ?d C)"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   246
  let ?Q = "\<lambda>A B. A \<subseteq> B \<and> ?d B \<le> ?d A"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   247
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   248
  have "\<exists>A. \<forall>n. (A n \<in> sets M \<and> ?P (A n) n) \<and> ?Q (A (Suc n)) (A n)"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   249
  proof (rule dependent_nat_choice)
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   250
    show "\<exists>A. A \<in> sets M \<and> ?P A 0"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   251
      by auto
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   252
  next
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   253
    fix A n assume "A \<in> sets M \<and> ?P A n"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   254
    then have A: "A \<in> sets M" by auto
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   255
    then have "finite_measure (density M (indicator A))" "0 < 1 / real (Suc (Suc n))"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   256
         "finite_measure (density N (indicator A))" "sets (density N (indicator A)) = sets (density M (indicator A))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   257
      by (auto simp: finite_measure_restricted N.finite_measure_restricted sets_eq)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   258
    from finite_measure.Radon_Nikodym_aux_epsilon[OF this] guess X .. note X = this
58184
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   259
    with A have "A \<inter> X \<in> sets M \<and> ?P (A \<inter> X) (Suc n) \<and> ?Q (A \<inter> X) A"
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56409
diff changeset
   260
      by (simp add: measure_restricted sets_eq sets.Int) (metis inf_absorb2)
58184
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   261
    then show "\<exists>B. (B \<in> sets M \<and> ?P B (Suc n)) \<and> ?Q B A"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   262
      by blast
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   263
  qed
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   264
  then obtain A where A: "\<And>n. A n \<in> sets M" "\<And>n. ?P (A n) n" "\<And>n. ?Q (A (Suc n)) (A n)"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   265
    by metis
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   266
  then have mono_dA: "mono (\<lambda>i. ?d (A i))" and A_0[simp]: "A 0 = space M"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   267
    by (auto simp add: mono_iff_le_Suc)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   268
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   269
  proof (safe intro!: bexI[of _ "\<Inter>i. A i"])
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   270
    show "(\<Inter>i. A i) \<in> sets M" using \<open>\<And>n. A n \<in> sets M\<close> by auto
58184
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   271
    have "decseq A" using A by (auto intro!: decseq_SucI)
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   272
    from A(1) finite_Lim_measure_decseq[OF _ this] N.finite_Lim_measure_decseq[OF _ this]
61969
e01015e49041 more symbols;
wenzelm
parents: 61810
diff changeset
   273
    have "(\<lambda>i. ?d (A i)) \<longlonglongrightarrow> ?d (\<Inter>i. A i)" by (auto intro!: tendsto_diff simp: sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   274
    thus "?d (space M) \<le> ?d (\<Inter>i. A i)" using mono_dA[THEN monoD, of 0 _]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   275
      by (rule_tac LIMSEQ_le_const) auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   276
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   277
    fix B assume B: "B \<in> sets M" "B \<subseteq> (\<Inter>i. A i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   278
    show "0 \<le> ?d B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   279
    proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   280
      assume "\<not> 0 \<le> ?d B"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   281
      hence "0 < - ?d B" by auto
62623
dbc62f86a1a9 rationalisation of theorem names esp about "real Archimedian" etc.
paulson <lp15@cam.ac.uk>
parents: 62390
diff changeset
   282
      from reals_Archimedean[OF this]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   283
      obtain n where *: "?d B < - 1 / real (Suc n)"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
   284
        by (auto simp: field_simps)
58184
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   285
      also have "\<dots> \<le> - 1 / real (Suc (Suc n))"
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   286
        by (auto simp: field_simps)
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   287
      finally show False
db1381d811ab cleanup Wfrec; introduce dependent_wf/wellorder_choice
hoelzl
parents: 57447
diff changeset
   288
        using * A(2)[of "Suc n"] B by (auto elim!: ballE[of _ _ B])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   289
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   290
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   291
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   292
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   293
lemma (in finite_measure) Radon_Nikodym_finite_measure:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   294
  assumes "finite_measure N" and sets_eq: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   295
  assumes "absolutely_continuous M N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   296
  shows "\<exists>f \<in> borel_measurable M. (\<forall>x. 0 \<le> f x) \<and> density M f = N"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   297
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   298
  interpret N: finite_measure N by fact
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   299
  define G where "G =
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   300
    {g \<in> borel_measurable M. (\<forall>x. 0 \<le> g x) \<and> (\<forall>A\<in>sets M. (\<integral>\<^sup>+x. g x * indicator A x \<partial>M) \<le> N A)}"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   301
  { fix f have "f \<in> G \<Longrightarrow> f \<in> borel_measurable M" by (auto simp: G_def) }
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   302
  note this[measurable_dest]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   303
  have "(\<lambda>x. 0) \<in> G" unfolding G_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   304
  hence "G \<noteq> {}" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   305
  { fix f g assume f: "f \<in> G" and g: "g \<in> G"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   306
    have "(\<lambda>x. max (g x) (f x)) \<in> G" (is "?max \<in> G") unfolding G_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   307
    proof safe
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   308
      show "?max \<in> borel_measurable M" using f g unfolding G_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   309
      let ?A = "{x \<in> space M. f x \<le> g x}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   310
      have "?A \<in> sets M" using f g unfolding G_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   311
      fix A assume "A \<in> sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   312
      hence sets: "?A \<inter> A \<in> sets M" "(space M - ?A) \<inter> A \<in> sets M" using \<open>?A \<in> sets M\<close> by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   313
      hence sets': "?A \<inter> A \<in> sets N" "(space M - ?A) \<inter> A \<in> sets N" by (auto simp: sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   314
      have union: "((?A \<inter> A) \<union> ((space M - ?A) \<inter> A)) = A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   315
        using sets.sets_into_space[OF \<open>A \<in> sets M\<close>] by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   316
      have "\<And>x. x \<in> space M \<Longrightarrow> max (g x) (f x) * indicator A x =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   317
        g x * indicator (?A \<inter> A) x + f x * indicator ((space M - ?A) \<inter> A) x"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   318
        by (auto simp: indicator_def max_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   319
      hence "(\<integral>\<^sup>+x. max (g x) (f x) * indicator A x \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   320
        (\<integral>\<^sup>+x. g x * indicator (?A \<inter> A) x \<partial>M) +
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   321
        (\<integral>\<^sup>+x. f x * indicator ((space M - ?A) \<inter> A) x \<partial>M)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   322
        using f g sets unfolding G_def
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   323
        by (auto cong: nn_integral_cong intro!: nn_integral_add)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   324
      also have "\<dots> \<le> N (?A \<inter> A) + N ((space M - ?A) \<inter> A)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   325
        using f g sets unfolding G_def by (auto intro!: add_mono)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   326
      also have "\<dots> = N A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   327
        using plus_emeasure[OF sets'] union by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   328
      finally show "(\<integral>\<^sup>+x. max (g x) (f x) * indicator A x \<partial>M) \<le> N A" .
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   329
    next
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   330
      fix x show "0 \<le> max (g x) (f x)" using f g by (auto simp: G_def split: split_max)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   331
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   332
  note max_in_G = this
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   333
  { fix f assume  "incseq f" and f: "\<And>i. f i \<in> G"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   334
    then have [measurable]: "\<And>i. f i \<in> borel_measurable M" by (auto simp: G_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   335
    have "(\<lambda>x. SUP i. f i x) \<in> G" unfolding G_def
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   336
    proof safe
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   337
      show "(\<lambda>x. SUP i. f i x) \<in> borel_measurable M" by measurable
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   338
      { fix x show "0 \<le> (SUP i. f i x)"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44918
diff changeset
   339
          using f by (auto simp: G_def intro: SUP_upper2) }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   340
    next
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   341
      fix A assume "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   342
      have "(\<integral>\<^sup>+x. (SUP i. f i x) * indicator A x \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   343
        (\<integral>\<^sup>+x. (SUP i. f i x * indicator A x) \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   344
        by (intro nn_integral_cong) (simp split: split_indicator)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   345
      also have "\<dots> = (SUP i. (\<integral>\<^sup>+x. f i x * indicator A x \<partial>M))"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   346
        using \<open>incseq f\<close> f \<open>A \<in> sets M\<close>
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   347
        by (intro nn_integral_monotone_convergence_SUP)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   348
           (auto simp: G_def incseq_Suc_iff le_fun_def split: split_indicator)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   349
      finally show "(\<integral>\<^sup>+x. (SUP i. f i x) * indicator A x \<partial>M) \<le> N A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   350
        using f \<open>A \<in> sets M\<close> by (auto intro!: SUP_least simp: G_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   351
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   352
  note SUP_in_G = this
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   353
  let ?y = "SUP g : G. integral\<^sup>N M g"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   354
  have y_le: "?y \<le> N (space M)" unfolding G_def
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44918
diff changeset
   355
  proof (safe intro!: SUP_least)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   356
    fix g assume "\<forall>A\<in>sets M. (\<integral>\<^sup>+x. g x * indicator A x \<partial>M) \<le> N A"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   357
    from this[THEN bspec, OF sets.top] show "integral\<^sup>N M g \<le> N (space M)"
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   358
      by (simp cong: nn_integral_cong)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   359
  qed
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   360
  from ennreal_SUP_countable_SUP [OF \<open>G \<noteq> {}\<close>, of "integral\<^sup>N M"] guess ys .. note ys = this
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   361
  then have "\<forall>n. \<exists>g. g\<in>G \<and> integral\<^sup>N M g = ys n"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   362
  proof safe
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   363
    fix n assume "range ys \<subseteq> integral\<^sup>N M ` G"
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   364
    hence "ys n \<in> integral\<^sup>N M ` G" by auto
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   365
    thus "\<exists>g. g\<in>G \<and> integral\<^sup>N M g = ys n" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   366
  qed
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   367
  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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   368
  hence y_eq: "?y = (SUP i. integral\<^sup>N M (gs i))" using ys by auto
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   369
  let ?g = "\<lambda>i x. Max ((\<lambda>n. gs n x) ` {..i})"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   370
  define f where [abs_def]: "f x = (SUP i. ?g i x)" for x
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   371
  let ?F = "\<lambda>A x. f x * indicator A x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   372
  have gs_not_empty: "\<And>i x. (\<lambda>n. gs n x) ` {..i} \<noteq> {}" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   373
  { fix i have "?g i \<in> G"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   374
    proof (induct i)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   375
      case 0 thus ?case by simp fact
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   376
    next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   377
      case (Suc i)
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   378
      with Suc gs_not_empty \<open>gs (Suc i) \<in> G\<close> show ?case
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   379
        by (auto simp add: atMost_Suc intro!: max_in_G)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   380
    qed }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   381
  note g_in_G = this
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   382
  have "incseq ?g" using gs_not_empty
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   383
    by (auto intro!: incseq_SucI le_funI simp add: atMost_Suc)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   384
  from SUP_in_G[OF this g_in_G] have [measurable]: "f \<in> G" unfolding f_def .
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   385
  then have [simp, intro]: "f \<in> borel_measurable M" unfolding G_def by auto
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   386
  have "integral\<^sup>N M f = (SUP i. integral\<^sup>N M (?g i))" unfolding f_def
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   387
    using g_in_G \<open>incseq ?g\<close>
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   388
    by (auto intro!: nn_integral_monotone_convergence_SUP simp: G_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   389
  also have "\<dots> = ?y"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   390
  proof (rule antisym)
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   391
    show "(SUP i. integral\<^sup>N M (?g i)) \<le> ?y"
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55642
diff changeset
   392
      using g_in_G by (auto intro: SUP_mono)
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   393
    show "?y \<le> (SUP i. integral\<^sup>N M (?g i))" unfolding y_eq
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   394
      by (auto intro!: SUP_mono nn_integral_mono Max_ge)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   395
  qed
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   396
  finally have int_f_eq_y: "integral\<^sup>N M f = ?y" .
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   397
  have "\<And>x. 0 \<le> f x"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   398
    unfolding f_def using \<open>\<And>i. gs i \<in> G\<close>
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44918
diff changeset
   399
    by (auto intro!: SUP_upper2 Max_ge_iff[THEN iffD2] simp: G_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   400
  let ?t = "\<lambda>A. N A - (\<integral>\<^sup>+x. ?F A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   401
  let ?M = "diff_measure N (density M f)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   402
  have f_le_N: "\<And>A. A \<in> sets M \<Longrightarrow> (\<integral>\<^sup>+x. ?F A x \<partial>M) \<le> N A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   403
    using \<open>f \<in> G\<close> unfolding G_def by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   404
  have emeasure_M: "\<And>A. A \<in> sets M \<Longrightarrow> emeasure ?M A = ?t A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   405
  proof (subst emeasure_diff_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   406
    from f_le_N[of "space M"] show "finite_measure N" "finite_measure (density M f)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   407
      by (auto intro!: finite_measureI simp: emeasure_density top_unique cong: nn_integral_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   408
  next
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   409
    fix B assume "B \<in> sets N" with f_le_N[of B] show "emeasure (density M f) B \<le> emeasure N B"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   410
      by (auto simp: sets_eq emeasure_density cong: nn_integral_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   411
  qed (auto simp: sets_eq emeasure_density)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   412
  from emeasure_M[of "space M"] N.finite_emeasure_space
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   413
  interpret M': finite_measure ?M
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   414
    by (auto intro!: finite_measureI simp: sets_eq_imp_space_eq[OF sets_eq] N.emeasure_eq_measure )
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   415
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   416
  have ac: "absolutely_continuous M ?M" unfolding absolutely_continuous_def
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45769
diff changeset
   417
  proof
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   418
    fix A assume A_M: "A \<in> null_sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   419
    with \<open>absolutely_continuous M N\<close> have A_N: "A \<in> null_sets N"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   420
      unfolding absolutely_continuous_def by auto
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   421
    moreover from A_M A_N have "(\<integral>\<^sup>+ x. ?F A x \<partial>M) \<le> N A" using \<open>f \<in> G\<close> by (auto simp: G_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   422
    ultimately have "N A - (\<integral>\<^sup>+ x. ?F A x \<partial>M) = 0"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   423
      by (auto intro!: antisym)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   424
    then show "A \<in> null_sets ?M"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   425
      using A_M by (simp add: emeasure_M null_sets_def sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   426
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   427
  have upper_bound: "\<forall>A\<in>sets M. ?M A \<le> 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   428
  proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   429
    assume "\<not> ?thesis"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   430
    then obtain A where A: "A \<in> sets M" and pos: "0 < ?M A"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   431
      by (auto simp: zero_less_iff_neq_zero)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   432
    note pos
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   433
    also have "?M A \<le> ?M (space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   434
      using emeasure_space[of ?M A] by (simp add: sets_eq[THEN sets_eq_imp_space_eq])
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   435
    finally have pos_t: "0 < ?M (space M)" by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   436
    moreover
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   437
    from pos_t have "emeasure M (space M) \<noteq> 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   438
      using ac unfolding absolutely_continuous_def by (auto simp: null_sets_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   439
    then have pos_M: "0 < emeasure M (space M)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   440
      by (simp add: zero_less_iff_neq_zero)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   441
    moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   442
    have "(\<integral>\<^sup>+x. f x * indicator (space M) x \<partial>M) \<le> N (space M)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   443
      using \<open>f \<in> G\<close> unfolding G_def by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   444
    hence "(\<integral>\<^sup>+x. f x * indicator (space M) x \<partial>M) \<noteq> \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   445
      using M'.finite_emeasure_space by (auto simp: top_unique)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   446
    moreover
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   447
    define b where "b = ?M (space M) / emeasure M (space M) / 2"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   448
    ultimately have b: "b \<noteq> 0 \<and> 0 \<le> b \<and> b \<noteq> \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   449
      by (auto simp: ennreal_divide_eq_top_iff)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   450
    then have b: "b \<noteq> 0" "0 \<le> b" "0 < b"  "b \<noteq> \<infinity>"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   451
      by (auto simp: less_le)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   452
    let ?Mb = "density M (\<lambda>_. b)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   453
    have Mb: "finite_measure ?Mb" "sets ?Mb = sets ?M"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   454
        using b by (auto simp: emeasure_density_const sets_eq ennreal_mult_eq_top_iff intro!: finite_measureI)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   455
    from M'.Radon_Nikodym_aux[OF this] guess A0 ..
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   456
    then have "A0 \<in> sets M"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   457
      and space_le_A0: "measure ?M (space M) - enn2real b * measure M (space M) \<le> measure ?M A0 - enn2real b * measure M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   458
      and *: "\<And>B. B \<in> sets M \<Longrightarrow> B \<subseteq> A0 \<Longrightarrow> 0 \<le> measure ?M B - enn2real b * measure M B"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   459
      using b by (simp_all add: measure_density_const sets_eq_imp_space_eq[OF sets_eq] sets_eq)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   460
    { fix B assume B: "B \<in> sets M" "B \<subseteq> A0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   461
      with *[OF this] have "b * emeasure M B \<le> ?M B"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   462
        using b unfolding M'.emeasure_eq_measure emeasure_eq_measure
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   463
        by (cases b rule: ennreal_cases) (auto simp: ennreal_mult[symmetric] measure_nonneg) }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   464
    note bM_le_t = this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   465
    let ?f0 = "\<lambda>x. f x + b * indicator A0 x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   466
    { fix A assume A: "A \<in> sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   467
      hence "A \<inter> A0 \<in> sets M" using \<open>A0 \<in> sets M\<close> by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   468
      have "(\<integral>\<^sup>+x. ?f0 x  * indicator A x \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   469
        (\<integral>\<^sup>+x. f x * indicator A x + b * indicator (A \<inter> A0) x \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   470
        by (auto intro!: nn_integral_cong split: split_indicator)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   471
      hence "(\<integral>\<^sup>+x. ?f0 x * indicator A x \<partial>M) =
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   472
          (\<integral>\<^sup>+x. f x * indicator A x \<partial>M) + b * emeasure M (A \<inter> A0)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   473
        using \<open>A0 \<in> sets M\<close> \<open>A \<inter> A0 \<in> sets M\<close> A b \<open>f \<in> G\<close>
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   474
        by (simp add: nn_integral_add nn_integral_cmult_indicator G_def) }
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   475
    note f0_eq = this
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   476
    { fix A assume A: "A \<in> sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   477
      hence "A \<inter> A0 \<in> sets M" using \<open>A0 \<in> sets M\<close> by auto
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   478
      have f_le_v: "(\<integral>\<^sup>+x. ?F A x \<partial>M) \<le> N A" using \<open>f \<in> G\<close> A unfolding G_def by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   479
      note f0_eq[OF A]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   480
      also have "(\<integral>\<^sup>+x. ?F A x \<partial>M) + b * emeasure M (A \<inter> A0) \<le> (\<integral>\<^sup>+x. ?F A x \<partial>M) + ?M (A \<inter> A0)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   481
        using bM_le_t[OF \<open>A \<inter> A0 \<in> sets M\<close>] \<open>A \<in> sets M\<close> \<open>A0 \<in> sets M\<close>
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   482
        by (auto intro!: add_left_mono)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   483
      also have "\<dots> \<le> (\<integral>\<^sup>+x. f x * indicator A x \<partial>M) + ?M A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   484
        using emeasure_mono[of "A \<inter> A0" A ?M] \<open>A \<in> sets M\<close> \<open>A0 \<in> sets M\<close>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   485
        by (auto intro!: add_left_mono simp: sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   486
      also have "\<dots> \<le> N A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   487
        unfolding emeasure_M[OF \<open>A \<in> sets M\<close>]
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   488
        using f_le_v N.emeasure_eq_measure[of A]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   489
        by (cases "\<integral>\<^sup>+x. ?F A x \<partial>M" "N A" rule: ennreal2_cases)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   490
           (auto simp: top_unique measure_nonneg ennreal_minus ennreal_plus[symmetric] simp del: ennreal_plus)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   491
      finally have "(\<integral>\<^sup>+x. ?f0 x * indicator A x \<partial>M) \<le> N A" . }
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   492
    hence "?f0 \<in> G" using \<open>A0 \<in> sets M\<close> b \<open>f \<in> G\<close> by (auto simp: G_def)
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   493
    have int_f_finite: "integral\<^sup>N M f \<noteq> \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   494
      by (metis top_unique infinity_ennreal_def int_f_eq_y y_le N.emeasure_finite)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   495
    have pos: "0 < measure ?M (space M) - enn2real b * measure M (space M)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   496
      using pos_t pos_M
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   497
      by (simp add: M'.emeasure_eq_measure emeasure_eq_measure b_def divide_ennreal ennreal_divide_numeral)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   498
    also have "\<dots> \<le> measure ?M A0 - enn2real b * measure M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   499
      by (rule space_le_A0)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   500
    finally have "enn2real b * measure M A0 < measure ?M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   501
      by simp
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   502
    with b have "?M A0 \<noteq> 0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   503
      by (cases b rule: ennreal_cases)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   504
         (auto simp: M'.emeasure_eq_measure measure_nonneg mult_less_0_iff not_le[symmetric])
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   505
    then have "emeasure M A0 \<noteq> 0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   506
      using ac \<open>A0 \<in> sets M\<close> by (auto simp: absolutely_continuous_def null_sets_def)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   507
    then have "0 < emeasure M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   508
      by (auto simp: zero_less_iff_neq_zero)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   509
    hence "0 < b * emeasure M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   510
      using b by (auto simp: ennreal_zero_less_mult_iff)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   511
    with int_f_finite have "?y < integral\<^sup>N M f + b * emeasure M A0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   512
      unfolding int_f_eq_y by auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   513
    also have "\<dots> = integral\<^sup>N M ?f0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   514
      using f0_eq[OF sets.top] \<open>A0 \<in> sets M\<close> sets.sets_into_space by (simp cong: nn_integral_cong)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   515
    finally have "?y < integral\<^sup>N M ?f0"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   516
      by simp
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   517
    moreover have "integral\<^sup>N M ?f0 \<le> ?y"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   518
      using \<open>?f0 \<in> G\<close> by (auto intro!: SUP_upper)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   519
    ultimately show False by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   520
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   521
  show ?thesis
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   522
  proof (intro bexI[of _ f] measure_eqI conjI)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   523
    show "sets (density M f) = sets N"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   524
      by (simp add: sets_eq)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   525
    fix A assume A: "A\<in>sets (density M f)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   526
    then show "emeasure (density M f) A = emeasure N A"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   527
      using \<open>f \<in> G\<close> A upper_bound[THEN bspec, of A] N.emeasure_eq_measure[of A]
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   528
      by (cases "integral\<^sup>N M (?F A)")
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   529
         (auto intro!: antisym simp: emeasure_density G_def emeasure_M ennreal_minus_eq_0 top_unique
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   530
                               simp del: measure_nonneg)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   531
  qed auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   532
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   533
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   534
lemma (in finite_measure) split_space_into_finite_sets_and_rest:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   535
  assumes ac: "absolutely_continuous M N" and sets_eq: "sets N = sets M"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   536
  shows "\<exists>A0\<in>sets M. \<exists>B::nat\<Rightarrow>'a set. disjoint_family B \<and> range B \<subseteq> sets M \<and> A0 = space M - (\<Union>i. B i) \<and>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   537
    (\<forall>A\<in>sets M. A \<subseteq> A0 \<longrightarrow> (emeasure M A = 0 \<and> N A = 0) \<or> (emeasure M A > 0 \<and> N A = \<infinity>)) \<and>
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   538
    (\<forall>i. N (B i) \<noteq> \<infinity>)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   539
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   540
  let ?Q = "{Q\<in>sets M. N Q \<noteq> \<infinity>}"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   541
  let ?a = "SUP Q:?Q. emeasure M Q"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   542
  have "{} \<in> ?Q" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   543
  then have Q_not_empty: "?Q \<noteq> {}" by blast
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   544
  have "?a \<le> emeasure M (space M)" using sets.sets_into_space
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   545
    by (auto intro!: SUP_least emeasure_mono)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   546
  then have "?a \<noteq> \<infinity>"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   547
    using finite_emeasure_space
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   548
    by (auto simp: less_top[symmetric] top_unique simp del: SUP_eq_top_iff Sup_eq_top_iff)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   549
  from ennreal_SUP_countable_SUP [OF Q_not_empty, of "emeasure M"]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   550
  obtain Q'' where "range Q'' \<subseteq> emeasure M ` ?Q" and a: "?a = (SUP i::nat. Q'' i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   551
    by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   552
  then have "\<forall>i. \<exists>Q'. Q'' i = emeasure M Q' \<and> Q' \<in> ?Q" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   553
  from choice[OF this] obtain Q' where Q': "\<And>i. Q'' i = emeasure M (Q' i)" "\<And>i. Q' i \<in> ?Q"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   554
    by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   555
  then have a_Lim: "?a = (SUP i::nat. emeasure M (Q' i))" using a by simp
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   556
  let ?O = "\<lambda>n. \<Union>i\<le>n. Q' i"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   557
  have Union: "(SUP i. emeasure M (?O i)) = emeasure M (\<Union>i. ?O i)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   558
  proof (rule SUP_emeasure_incseq[of ?O])
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   559
    show "range ?O \<subseteq> sets M" using Q' by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   560
    show "incseq ?O" by (fastforce intro!: incseq_SucI)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   561
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   562
  have Q'_sets: "\<And>i. Q' i \<in> sets M" using Q' by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   563
  have O_sets: "\<And>i. ?O i \<in> sets M" using Q' by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   564
  then have O_in_G: "\<And>i. ?O i \<in> ?Q"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   565
  proof (safe del: notI)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   566
    fix i have "Q' ` {..i} \<subseteq> sets M" using Q' by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   567
    then have "N (?O i) \<le> (\<Sum>i\<le>i. N (Q' i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   568
      by (simp add: sets_eq emeasure_subadditive_finite)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   569
    also have "\<dots> < \<infinity>" using Q' by (simp add: less_top)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   570
    finally show "N (?O i) \<noteq> \<infinity>" by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   571
  qed auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   572
  have O_mono: "\<And>n. ?O n \<subseteq> ?O (Suc n)" by fastforce
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   573
  have a_eq: "?a = emeasure M (\<Union>i. ?O i)" unfolding Union[symmetric]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   574
  proof (rule antisym)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   575
    show "?a \<le> (SUP i. emeasure M (?O i))" unfolding a_Lim
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   576
      using Q' by (auto intro!: SUP_mono emeasure_mono)
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 62083
diff changeset
   577
    show "(SUP i. emeasure M (?O i)) \<le> ?a"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   578
    proof (safe intro!: Sup_mono, unfold bex_simps)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   579
      fix i
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51329
diff changeset
   580
      have *: "(\<Union>(Q' ` {..i})) = ?O i" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   581
      then show "\<exists>x. (x \<in> sets M \<and> N x \<noteq> \<infinity>) \<and>
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51329
diff changeset
   582
        emeasure M (\<Union>(Q' ` {..i})) \<le> emeasure M x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   583
        using O_in_G[of i] by (auto intro!: exI[of _ "?O i"])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   584
    qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   585
  qed
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   586
  let ?O_0 = "(\<Union>i. ?O i)"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   587
  have "?O_0 \<in> sets M" using Q' by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   588
  define Q where "Q i = (case i of 0 \<Rightarrow> Q' 0 | Suc n \<Rightarrow> ?O (Suc n) - ?O n)" for i
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   589
  { fix i have "Q i \<in> sets M" unfolding Q_def using Q'[of 0] by (cases i) (auto intro: O_sets) }
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   590
  note Q_sets = this
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   591
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   592
  proof (intro bexI exI conjI ballI impI allI)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   593
    show "disjoint_family Q"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   594
      by (fastforce simp: disjoint_family_on_def Q_def
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   595
        split: nat.split_asm)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   596
    show "range Q \<subseteq> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   597
      using Q_sets by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   598
    { fix A assume A: "A \<in> sets M" "A \<subseteq> space M - ?O_0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   599
      show "emeasure M A = 0 \<and> N A = 0 \<or> 0 < emeasure M A \<and> N A = \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   600
      proof (rule disjCI, simp)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   601
        assume *: "emeasure M A = 0 \<or> N A \<noteq> top"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   602
        show "emeasure M A = 0 \<and> N A = 0"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   603
        proof (cases "emeasure M A = 0")
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   604
          case True
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   605
          with ac A have "N A = 0"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   606
            unfolding absolutely_continuous_def by auto
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   607
          with True show ?thesis by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   608
        next
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   609
          case False
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   610
          with * have "N A \<noteq> \<infinity>" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   611
          with A have "emeasure M ?O_0 + emeasure M A = emeasure M (?O_0 \<union> A)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   612
            using Q' by (auto intro!: plus_emeasure sets.countable_UN)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   613
          also have "\<dots> = (SUP i. emeasure M (?O i \<union> A))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   614
          proof (rule SUP_emeasure_incseq[of "\<lambda>i. ?O i \<union> A", symmetric, simplified])
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   615
            show "range (\<lambda>i. ?O i \<union> A) \<subseteq> sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   616
              using \<open>N A \<noteq> \<infinity>\<close> O_sets A by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   617
          qed (fastforce intro!: incseq_SucI)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   618
          also have "\<dots> \<le> ?a"
44928
7ef6505bde7f renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents: 44918
diff changeset
   619
          proof (safe intro!: SUP_least)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   620
            fix i have "?O i \<union> A \<in> ?Q"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   621
            proof (safe del: notI)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   622
              show "?O i \<union> A \<in> sets M" using O_sets A by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   623
              from O_in_G[of i] have "N (?O i \<union> A) \<le> N (?O i) + N A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   624
                using emeasure_subadditive[of "?O i" N A] A O_sets by (auto simp: sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   625
              with O_in_G[of i] show "N (?O i \<union> A) \<noteq> \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   626
                using \<open>N A \<noteq> \<infinity>\<close> by (auto simp: top_unique)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   627
            qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   628
            then show "emeasure M (?O i \<union> A) \<le> ?a" by (rule SUP_upper)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   629
          qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   630
          finally have "emeasure M A = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   631
            unfolding a_eq using measure_nonneg[of M A] by (simp add: emeasure_eq_measure)
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   632
          with \<open>emeasure M A \<noteq> 0\<close> show ?thesis by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   633
        qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   634
      qed }
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   635
    { fix i show "N (Q i) \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   636
      proof (cases i)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   637
        case 0 then show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   638
          unfolding Q_def using Q'[of 0] by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   639
      next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   640
        case (Suc n)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   641
        with \<open>?O n \<in> ?Q\<close> \<open>?O (Suc n) \<in> ?Q\<close> emeasure_Diff[OF _ _ _ O_mono, of N n]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   642
        show ?thesis
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   643
          by (auto simp: sets_eq Q_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   644
      qed }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   645
    show "space M - ?O_0 \<in> sets M" using Q'_sets by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   646
    { fix j have "(\<Union>i\<le>j. ?O i) = (\<Union>i\<le>j. Q i)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   647
      proof (induct j)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   648
        case 0 then show ?case by (simp add: Q_def)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   649
      next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   650
        case (Suc j)
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   651
        have eq: "\<And>j. (\<Union>i\<le>j. ?O i) = (\<Union>i\<le>j. Q' i)" by fastforce
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   652
        have "{..j} \<union> {..Suc j} = {..Suc j}" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   653
        then have "(\<Union>i\<le>Suc j. Q' i) = (\<Union>i\<le>j. Q' i) \<union> Q (Suc j)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   654
          by (simp add: UN_Un[symmetric] Q_def del: UN_Un)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   655
        then show ?case using Suc by (auto simp add: eq atMost_Suc)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   656
      qed }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   657
    then have "(\<Union>j. (\<Union>i\<le>j. ?O i)) = (\<Union>j. (\<Union>i\<le>j. Q i))" by simp
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44568
diff changeset
   658
    then show "space M - ?O_0 = space M - (\<Union>i. Q i)" by fastforce
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   659
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   660
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   661
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   662
lemma (in finite_measure) Radon_Nikodym_finite_measure_infinite:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   663
  assumes "absolutely_continuous M N" and sets_eq: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   664
  shows "\<exists>f\<in>borel_measurable M. (\<forall>x. 0 \<le> f x) \<and> density M f = N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   665
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   666
  from split_space_into_finite_sets_and_rest[OF assms]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   667
  obtain Q0 and Q :: "nat \<Rightarrow> 'a set"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   668
    where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   669
    and Q0: "Q0 \<in> sets M" "Q0 = space M - (\<Union>i. Q i)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   670
    and in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<subseteq> Q0 \<Longrightarrow> emeasure M A = 0 \<and> N A = 0 \<or> 0 < emeasure M A \<and> N A = \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   671
    and Q_fin: "\<And>i. N (Q i) \<noteq> \<infinity>" by force
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   672
  from Q have Q_sets: "\<And>i. Q i \<in> sets M" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   673
  let ?N = "\<lambda>i. density N (indicator (Q i))" and ?M = "\<lambda>i. density M (indicator (Q i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   674
  have "\<forall>i. \<exists>f\<in>borel_measurable (?M i). (\<forall>x. 0 \<le> f x) \<and> density (?M i) f = ?N i"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   675
  proof (intro allI finite_measure.Radon_Nikodym_finite_measure)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   676
    fix i
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   677
    from Q show "finite_measure (?M i)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   678
      by (auto intro!: finite_measureI cong: nn_integral_cong
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   679
               simp add: emeasure_density subset_eq sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   680
    from Q have "emeasure (?N i) (space N) = emeasure N (Q i)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   681
      by (simp add: sets_eq[symmetric] emeasure_density subset_eq cong: nn_integral_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   682
    with Q_fin show "finite_measure (?N i)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   683
      by (auto intro!: finite_measureI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   684
    show "sets (?N i) = sets (?M i)" by (simp add: sets_eq)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   685
    have [measurable]: "\<And>A. A \<in> sets M \<Longrightarrow> A \<in> sets N" by (simp add: sets_eq)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   686
    show "absolutely_continuous (?M i) (?N i)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   687
      using \<open>absolutely_continuous M N\<close> \<open>Q i \<in> sets M\<close>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   688
      by (auto simp: absolutely_continuous_def null_sets_density_iff sets_eq
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   689
               intro!: absolutely_continuous_AE[OF sets_eq])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   690
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   691
  from choice[OF this[unfolded Bex_def]]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   692
  obtain f where borel: "\<And>i. f i \<in> borel_measurable M" "\<And>i x. 0 \<le> f i x"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   693
    and f_density: "\<And>i. density (?M i) (f i) = ?N i"
54776
db890d9fc5c2 ordered_euclidean_space compatible with more standard pointwise ordering on products; conditionally complete lattice with product order
immler
parents: 53374
diff changeset
   694
    by force
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   695
  { fix A i assume A: "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   696
    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"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   697
      by (auto simp add: emeasure_density nn_integral_density subset_eq
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   698
               intro!: nn_integral_cong split: split_indicator)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   699
    also have "\<dots> = emeasure N (Q i \<inter> A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   700
      using A Q by (simp add: f_density emeasure_restricted subset_eq sets_eq)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   701
    finally have "emeasure N (Q i \<inter> A) = (\<integral>\<^sup>+x. f i x * indicator (Q i \<inter> A) x \<partial>M)" .. }
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   702
  note integral_eq = this
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   703
  let ?f = "\<lambda>x. (\<Sum>i. f i x * indicator (Q i) x) + \<infinity> * indicator Q0 x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   704
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   705
  proof (safe intro!: bexI[of _ ?f])
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   706
    show "?f \<in> borel_measurable M" using Q0 borel Q_sets
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   707
      by (auto intro!: measurable_If)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   708
    show "\<And>x. 0 \<le> ?f x" using borel by (auto intro!: suminf_0_le simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   709
    show "density M ?f = N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   710
    proof (rule measure_eqI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   711
      fix A assume "A \<in> sets (density M ?f)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   712
      then have "A \<in> sets M" by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   713
      have Qi: "\<And>i. Q i \<in> sets M" using Q by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   714
      have [intro,simp]: "\<And>i. (\<lambda>x. f i x * indicator (Q i \<inter> A) x) \<in> borel_measurable M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   715
        "\<And>i. AE x in M. 0 \<le> f i x * indicator (Q i \<inter> A) x"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   716
        using borel Qi Q0(1) \<open>A \<in> sets M\<close> by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   717
      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 (Q0 \<inter> A) x \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   718
        using borel by (intro nn_integral_cong) (auto simp: indicator_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   719
      also have "\<dots> = (\<integral>\<^sup>+x. (\<Sum>i. f i x * indicator (Q i \<inter> A) x) \<partial>M) + \<infinity> * emeasure M (Q0 \<inter> A)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   720
        using borel Qi Q0(1) \<open>A \<in> sets M\<close>
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   721
        by (subst nn_integral_add)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   722
           (auto simp add: nn_integral_cmult_indicator sets.Int intro!: suminf_0_le)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   723
      also have "\<dots> = (\<Sum>i. N (Q i \<inter> A)) + \<infinity> * emeasure M (Q0 \<inter> A)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   724
        by (subst integral_eq[OF \<open>A \<in> sets M\<close>], subst nn_integral_suminf) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   725
      finally have "(\<integral>\<^sup>+x. ?f x * indicator A x \<partial>M) = (\<Sum>i. N (Q i \<inter> A)) + \<infinity> * emeasure M (Q0 \<inter> A)" .
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   726
      moreover have "(\<Sum>i. N (Q i \<inter> A)) = N ((\<Union>i. Q i) \<inter> A)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   727
        using Q Q_sets \<open>A \<in> sets M\<close>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   728
        by (subst suminf_emeasure) (auto simp: disjoint_family_on_def sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   729
      moreover have "\<infinity> * emeasure M (Q0 \<inter> A) = N (Q0 \<inter> A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   730
      proof -
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   731
        have "Q0 \<inter> A \<in> sets M" using Q0(1) \<open>A \<in> sets M\<close> by blast
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   732
        from in_Q0[OF this] show ?thesis by (auto simp: ennreal_top_mult)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   733
      qed
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   734
      moreover have "Q0 \<inter> A \<in> sets M" "((\<Union>i. Q i) \<inter> A) \<in> sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   735
        using Q_sets \<open>A \<in> sets M\<close> Q0(1) by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   736
      moreover have "((\<Union>i. Q i) \<inter> A) \<union> (Q0 \<inter> A) = A" "((\<Union>i. Q i) \<inter> A) \<inter> (Q0 \<inter> A) = {}"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   737
        using \<open>A \<in> sets M\<close> sets.sets_into_space Q0 by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   738
      ultimately have "N A = (\<integral>\<^sup>+x. ?f x * indicator A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   739
        using plus_emeasure[of "(\<Union>i. Q i) \<inter> A" N "Q0 \<inter> A"] by (simp add: sets_eq)
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   740
      with \<open>A \<in> sets M\<close> borel Q Q0(1) show "emeasure (density M ?f) A = N A"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   741
        by (auto simp: subset_eq emeasure_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   742
    qed (simp add: sets_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   743
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   744
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   745
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   746
lemma (in sigma_finite_measure) Radon_Nikodym:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   747
  assumes ac: "absolutely_continuous M N" assumes sets_eq: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   748
  shows "\<exists>f \<in> borel_measurable M. (\<forall>x. 0 \<le> f x) \<and> density M f = N"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   749
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   750
  from Ex_finite_integrable_function
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   751
  obtain h where finite: "integral\<^sup>N M h \<noteq> \<infinity>" and
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   752
    borel: "h \<in> borel_measurable M" and
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   753
    nn: "\<And>x. 0 \<le> h x" and
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   754
    pos: "\<And>x. x \<in> space M \<Longrightarrow> 0 < h x" and
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   755
    "\<And>x. x \<in> space M \<Longrightarrow> h x < \<infinity>" by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   756
  let ?T = "\<lambda>A. (\<integral>\<^sup>+x. h x * indicator A x \<partial>M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   757
  let ?MT = "density M h"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   758
  from borel finite nn interpret T: finite_measure ?MT
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   759
    by (auto intro!: finite_measureI cong: nn_integral_cong simp: emeasure_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   760
  have "absolutely_continuous ?MT N" "sets N = sets ?MT"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   761
  proof (unfold absolutely_continuous_def, safe)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   762
    fix A assume "A \<in> null_sets ?MT"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   763
    with borel have "A \<in> sets M" "AE x in M. x \<in> A \<longrightarrow> h x \<le> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   764
      by (auto simp add: null_sets_density_iff)
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   765
    with pos sets.sets_into_space have "AE x in M. x \<notin> A"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
   766
      by (elim eventually_mono) (auto simp: not_le[symmetric])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   767
    then have "A \<in> null_sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   768
      using \<open>A \<in> sets M\<close> by (simp add: AE_iff_null_sets)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   769
    with ac show "A \<in> null_sets N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   770
      by (auto simp: absolutely_continuous_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   771
  qed (auto simp add: sets_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   772
  from T.Radon_Nikodym_finite_measure_infinite[OF this]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   773
  obtain f where f_borel: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "density ?MT f = N" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   774
  with nn borel show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   775
    by (auto intro!: bexI[of _ "\<lambda>x. h x * f x"] simp: density_density_eq)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   776
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
   777
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   778
subsection \<open>Uniqueness of densities\<close>
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   779
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   780
lemma finite_density_unique:
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   781
  assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   782
  assumes pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> g x"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   783
  and fin: "integral\<^sup>N M f \<noteq> \<infinity>"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   784
  shows "density M f = density M g \<longleftrightarrow> (AE x in M. f x = g x)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   785
proof (intro iffI ballI)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   786
  fix A assume eq: "AE x in M. f x = g x"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   787
  with borel show "density M f = density M g"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   788
    by (auto intro: density_cong)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   789
next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   790
  let ?P = "\<lambda>f A. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   791
  assume "density M f = density M g"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   792
  with borel have eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   793
    by (simp add: emeasure_density[symmetric])
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   794
  from this[THEN bspec, OF sets.top] fin
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   795
  have g_fin: "integral\<^sup>N M g \<noteq> \<infinity>" by (simp cong: nn_integral_cong)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   796
  { fix f g assume borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   797
      and pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> g x"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   798
      and g_fin: "integral\<^sup>N M g \<noteq> \<infinity>" and eq: "\<forall>A\<in>sets M. ?P f A = ?P g A"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   799
    let ?N = "{x\<in>space M. g x < f x}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   800
    have N: "?N \<in> sets M" using borel by simp
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   801
    have "?P g ?N \<le> integral\<^sup>N M g" using pos
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   802
      by (intro nn_integral_mono_AE) (auto split: split_indicator)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   803
    then have Pg_fin: "?P g ?N \<noteq> \<infinity>" using g_fin by (auto simp: top_unique)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   804
    have "?P (\<lambda>x. (f x - g x)) ?N = (\<integral>\<^sup>+x. f x * indicator ?N x - g x * indicator ?N x \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   805
      by (auto intro!: nn_integral_cong simp: indicator_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   806
    also have "\<dots> = ?P f ?N - ?P g ?N"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   807
    proof (rule nn_integral_diff)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   808
      show "(\<lambda>x. f x * indicator ?N x) \<in> borel_measurable M" "(\<lambda>x. g x * indicator ?N x) \<in> borel_measurable M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   809
        using borel N by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   810
      show "AE x in M. g x * indicator ?N x \<le> f x * indicator ?N x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   811
        using pos by (auto split: split_indicator)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   812
    qed fact
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   813
    also have "\<dots> = 0"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   814
      unfolding eq[THEN bspec, OF N] using Pg_fin by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   815
    finally have "AE x in M. f x \<le> g x"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   816
      using pos borel nn_integral_PInf_AE[OF borel(2) g_fin]
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   817
      by (subst (asm) nn_integral_0_iff_AE)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   818
         (auto split: split_indicator simp: not_less ennreal_minus_eq_0) }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   819
  from this[OF borel pos g_fin eq] this[OF borel(2,1) pos(2,1) fin] eq
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   820
  show "AE x in M. f x = g x" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   821
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   822
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   823
lemma (in finite_measure) density_unique_finite_measure:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   824
  assumes borel: "f \<in> borel_measurable M" "f' \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   825
  assumes pos: "AE x in M. 0 \<le> f x" "AE x in M. 0 \<le> f' x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   826
  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)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   827
    (is "\<And>A. A \<in> sets M \<Longrightarrow> ?P f A = ?P f' A")
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   828
  shows "AE x in M. f x = f' x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   829
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   830
  let ?D = "\<lambda>f. density M f"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   831
  let ?N = "\<lambda>A. ?P f A" and ?N' = "\<lambda>A. ?P f' A"
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   832
  let ?f = "\<lambda>A x. f x * indicator A x" and ?f' = "\<lambda>A x. f' x * indicator A x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   833
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   834
  have ac: "absolutely_continuous M (density M f)" "sets (density M f) = sets M"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
   835
    using borel by (auto intro!: absolutely_continuousI_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   836
  from split_space_into_finite_sets_and_rest[OF this]
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   837
  obtain Q0 and Q :: "nat \<Rightarrow> 'a set"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   838
    where Q: "disjoint_family Q" "range Q \<subseteq> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   839
    and Q0: "Q0 \<in> sets M" "Q0 = space M - (\<Union>i. Q i)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   840
    and in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<subseteq> Q0 \<Longrightarrow> emeasure M A = 0 \<and> ?D f A = 0 \<or> 0 < emeasure M A \<and> ?D f A = \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   841
    and Q_fin: "\<And>i. ?D f (Q i) \<noteq> \<infinity>" by force
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   842
  with borel pos have in_Q0: "\<And>A. A \<in> sets M \<Longrightarrow> A \<subseteq> Q0 \<Longrightarrow> emeasure M A = 0 \<and> ?N A = 0 \<or> 0 < emeasure M A \<and> ?N A = \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   843
    and Q_fin: "\<And>i. ?N (Q i) \<noteq> \<infinity>" by (auto simp: emeasure_density subset_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   844
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   845
  from Q have Q_sets: "\<And>i. Q i \<in> sets M" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   846
  let ?D = "{x\<in>space M. f x \<noteq> f' x}"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   847
  have "?D \<in> sets M" using borel by auto
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   848
  have *: "\<And>i x A. \<And>y::ennreal. y * indicator (Q i) x * indicator A x = y * indicator (Q i \<inter> A) x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   849
    unfolding indicator_def by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   850
  have "\<forall>i. AE x in M. ?f (Q i) x = ?f' (Q i) x" using borel Q_fin Q pos
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   851
    by (intro finite_density_unique[THEN iffD1] allI)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 49785
diff changeset
   852
       (auto intro!: f measure_eqI simp: emeasure_density * subset_eq)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   853
  moreover have "AE x in M. ?f Q0 x = ?f' Q0 x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   854
  proof (rule AE_I')
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   855
    { fix f :: "'a \<Rightarrow> ennreal" assume borel: "f \<in> borel_measurable M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   856
        and eq: "\<And>A. A \<in> sets M \<Longrightarrow> ?N A = (\<integral>\<^sup>+x. f x * indicator A x \<partial>M)"
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45777
diff changeset
   857
      let ?A = "\<lambda>i. Q0 \<inter> {x \<in> space M. f x < (i::nat)}"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   858
      have "(\<Union>i. ?A i) \<in> null_sets M"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   859
      proof (rule null_sets_UN)
43923
ab93d0190a5d add ereal to typeclass infinity
hoelzl
parents: 43920
diff changeset
   860
        fix i ::nat have "?A i \<in> sets M"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   861
          using borel Q0(1) by auto
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   862
        have "?N (?A i) \<le> (\<integral>\<^sup>+x. (i::ennreal) * indicator (?A i) x \<partial>M)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   863
          unfolding eq[OF \<open>?A i \<in> sets M\<close>]
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   864
          by (auto intro!: nn_integral_mono simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   865
        also have "\<dots> = i * emeasure M (?A i)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   866
          using \<open>?A i \<in> sets M\<close> by (auto intro!: nn_integral_cmult_indicator)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   867
        also have "\<dots> < \<infinity>" using emeasure_real[of "?A i"] by (auto simp: ennreal_mult_less_top of_nat_less_top)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   868
        finally have "?N (?A i) \<noteq> \<infinity>" by simp
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   869
        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
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   870
      qed
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   871
      also have "(\<Union>i. ?A i) = Q0 \<inter> {x\<in>space M. f x \<noteq> \<infinity>}"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   872
        by (auto simp: ennreal_Ex_less_of_nat less_top[symmetric])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   873
      finally have "Q0 \<inter> {x\<in>space M. f x \<noteq> \<infinity>} \<in> null_sets M" by simp }
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   874
    from this[OF borel(1) refl] this[OF borel(2) f]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   875
    have "Q0 \<inter> {x\<in>space M. f x \<noteq> \<infinity>} \<in> null_sets M" "Q0 \<inter> {x\<in>space M. f' x \<noteq> \<infinity>} \<in> null_sets M" by simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   876
    then show "(Q0 \<inter> {x\<in>space M. f x \<noteq> \<infinity>}) \<union> (Q0 \<inter> {x\<in>space M. f' x \<noteq> \<infinity>}) \<in> null_sets M" by (rule null_sets.Un)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   877
    show "{x \<in> space M. ?f Q0 x \<noteq> ?f' Q0 x} \<subseteq>
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   878
      (Q0 \<inter> {x\<in>space M. f x \<noteq> \<infinity>}) \<union> (Q0 \<inter> {x\<in>space M. f' x \<noteq> \<infinity>})" by (auto simp: indicator_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   879
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   880
  moreover have "AE x in M. (?f Q0 x = ?f' Q0 x) \<longrightarrow> (\<forall>i. ?f (Q i) x = ?f' (Q i) x) \<longrightarrow>
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   881
    ?f (space M) x = ?f' (space M) x"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   882
    by (auto simp: indicator_def Q0)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   883
  ultimately have "AE x in M. ?f (space M) x = ?f' (space M) x"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   884
    unfolding AE_all_countable[symmetric]
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   885
    by eventually_elim (auto intro!: AE_I2 split: if_split_asm simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   886
  then show "AE x in M. f x = f' x" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   887
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   888
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   889
lemma (in sigma_finite_measure) density_unique:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   890
  assumes f: "f \<in> borel_measurable M"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   891
  assumes f': "f' \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   892
  assumes density_eq: "density M f = density M f'"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   893
  shows "AE x in M. f x = f' x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   894
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   895
  obtain h where h_borel: "h \<in> borel_measurable M"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   896
    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"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   897
    using Ex_finite_integrable_function by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   898
  then have h_nn: "AE x in M. 0 \<le> h x" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   899
  let ?H = "density M h"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   900
  interpret h: finite_measure ?H
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   901
    using fin h_borel pos
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   902
    by (intro finite_measureI) (simp cong: nn_integral_cong emeasure_density add: fin)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   903
  let ?fM = "density M f"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   904
  let ?f'M = "density M f'"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   905
  { fix A assume "A \<in> sets M"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   906
    then have "{x \<in> space M. h x * indicator A x \<noteq> 0} = A"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   907
      using pos(1) sets.sets_into_space by (force simp: indicator_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   908
    then have "(\<integral>\<^sup>+x. h x * indicator A x \<partial>M) = 0 \<longleftrightarrow> A \<in> null_sets M"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   909
      using h_borel \<open>A \<in> sets M\<close> h_nn by (subst nn_integral_0_iff) auto }
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   910
  note h_null_sets = this
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   911
  { fix A assume "A \<in> sets M"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   912
    have "(\<integral>\<^sup>+x. f x * (h x * indicator A x) \<partial>M) = (\<integral>\<^sup>+x. h x * indicator A x \<partial>?fM)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   913
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   914
      by (intro nn_integral_density[symmetric]) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   915
    also have "\<dots> = (\<integral>\<^sup>+x. h x * indicator A x \<partial>?f'M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   916
      by (simp_all add: density_eq)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   917
    also have "\<dots> = (\<integral>\<^sup>+x. f' x * (h x * indicator A x) \<partial>M)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   918
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   919
      by (intro nn_integral_density) auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   920
    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)"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   921
      by (simp add: ac_simps)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   922
    then have "(\<integral>\<^sup>+x. (f x * indicator A x) \<partial>?H) = (\<integral>\<^sup>+x. (f' x * indicator A x) \<partial>?H)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
   923
      using \<open>A \<in> sets M\<close> h_borel h_nn f f'
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   924
      by (subst (asm) (1 2) nn_integral_density[symmetric]) auto }
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   925
  then have "AE x in ?H. f x = f' x" using h_borel h_nn f f'
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   926
    by (intro h.density_unique_finite_measure absolutely_continuous_AE[of M]) auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   927
  with AE_space[of M] pos show "AE x in M. f x = f' x"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   928
    unfolding AE_density[OF h_borel] by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   929
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   930
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   931
lemma (in sigma_finite_measure) density_unique_iff:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   932
  assumes f: "f \<in> borel_measurable M" and f': "f' \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   933
  shows "density M f = density M f' \<longleftrightarrow> (AE x in M. f x = f' x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   934
  using density_unique[OF assms] density_cong[OF f f'] by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   935
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   936
lemma sigma_finite_density_unique:
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   937
  assumes borel: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   938
  and fin: "sigma_finite_measure (density M f)"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   939
  shows "density M f = density M g \<longleftrightarrow> (AE x in M. f x = g x)"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   940
proof
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
   941
  assume "AE x in M. f x = g x" with borel show "density M f = density M g"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   942
    by (auto intro: density_cong)
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   943
next
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   944
  assume eq: "density M f = density M g"
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61169
diff changeset
   945
  interpret f: sigma_finite_measure "density M f" by fact
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   946
  from f.sigma_finite_incseq guess A . note cover = this
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   947
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   948
  have "AE x in M. \<forall>i. x \<in> A i \<longrightarrow> f x = g x"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   949
    unfolding AE_all_countable
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   950
  proof
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   951
    fix i
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   952
    have "density (density M f) (indicator (A i)) = density (density M g) (indicator (A i))"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   953
      unfolding eq ..
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   954
    moreover have "(\<integral>\<^sup>+x. f x * indicator (A i) x \<partial>M) \<noteq> \<infinity>"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   955
      using cover(1) cover(3)[of i] borel by (auto simp: emeasure_density subset_eq)
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   956
    ultimately have "AE x in M. f x * indicator (A i) x = g x * indicator (A i) x"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   957
      using borel cover(1)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   958
      by (intro finite_density_unique[THEN iffD1]) (auto simp: density_density_eq subset_eq)
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   959
    then show "AE x in M. x \<in> A i \<longrightarrow> f x = g x"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   960
      by auto
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   961
  qed
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   962
  with AE_space show "AE x in M. f x = g x"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   963
    apply eventually_elim
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   964
    using cover(2)[symmetric]
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   965
    apply auto
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   966
    done
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   967
qed
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
   968
49778
bbbc0f492780 sigma_finite_iff_density_finite does not require a positive density function
hoelzl
parents: 47694
diff changeset
   969
lemma (in sigma_finite_measure) sigma_finite_iff_density_finite':
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   970
  assumes f: "f \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   971
  shows "sigma_finite_measure (density M f) \<longleftrightarrow> (AE x in M. f x \<noteq> \<infinity>)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   972
    (is "sigma_finite_measure ?N \<longleftrightarrow> _")
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   973
proof
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
   974
  assume "sigma_finite_measure ?N"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   975
  then interpret N: sigma_finite_measure ?N .
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   976
  from N.Ex_finite_integrable_function obtain h where
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   977
    h: "h \<in> borel_measurable M" "integral\<^sup>N ?N h \<noteq> \<infinity>" and
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   978
    fin: "\<forall>x\<in>space M. 0 < h x \<and> h x < \<infinity>"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   979
    by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   980
  have "AE x in M. f x * h x \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   981
  proof (rule AE_I')
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   982
    have "integral\<^sup>N ?N h = (\<integral>\<^sup>+x. f x * h x \<partial>M)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   983
      using f h by (auto intro!: nn_integral_density)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   984
    then have "(\<integral>\<^sup>+x. f x * h x \<partial>M) \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   985
      using h(2) by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   986
    then show "(\<lambda>x. f x * h x) -` {\<infinity>} \<inter> space M \<in> null_sets M"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   987
      using f h(1) by (auto intro!: nn_integral_PInf[unfolded infinity_ennreal_def] borel_measurable_vimage)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   988
  qed auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   989
  then show "AE x in M. f x \<noteq> \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
   990
    using fin by (auto elim!: AE_Ball_mp simp: less_top ennreal_mult_less_top)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   991
next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   992
  assume AE: "AE x in M. f x \<noteq> \<infinity>"
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
   993
  from sigma_finite guess Q . note Q = this
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   994
  define A where "A i =
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62975
diff changeset
   995
    f -` (case i of 0 \<Rightarrow> {\<infinity>} | Suc n \<Rightarrow> {.. ennreal(of_nat (Suc n))}) \<inter> space M" for i
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   996
  { fix i j have "A i \<inter> Q j \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
   997
    unfolding A_def using f Q
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
   998
    apply (rule_tac sets.Int)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
   999
    by (cases i) (auto intro: measurable_sets[OF f(1)]) }
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1000
  note A_in_sets = this
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1001
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41661
diff changeset
  1002
  show "sigma_finite_measure ?N"
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60585
diff changeset
  1003
  proof (standard, intro exI conjI ballI)
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1004
    show "countable (range (\<lambda>(i, j). A i \<inter> Q j))"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1005
      by auto
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1006
    show "range (\<lambda>(i, j). A i \<inter> Q j) \<subseteq> sets (density M f)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1007
      using A_in_sets by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1008
  next
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1009
    have "\<Union>range (\<lambda>(i, j). A i \<inter> Q j) = (\<Union>i j. A i \<inter> Q j)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1010
      by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1011
    also have "\<dots> = (\<Union>i. A i) \<inter> space M" using Q by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1012
    also have "(\<Union>i. A i) = space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1013
    proof safe
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1014
      fix x assume x: "x \<in> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1015
      show "x \<in> (\<Union>i. A i)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1016
      proof (cases "f x" rule: ennreal_cases)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1017
        case top with x show ?thesis unfolding A_def by (auto intro: exI[of _ 0])
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1018
      next
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
  1019
        case (real r)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1020
        with ennreal_Ex_less_of_nat[of "f x"] obtain n :: nat where "f x < n"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1021
          by auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1022
        also have "n < (Suc n :: ennreal)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1023
          by simp
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1024
        finally show ?thesis
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1025
          using x real by (auto simp: A_def ennreal_of_nat_eq_real_of_nat intro!: exI[of _ "Suc n"])
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1026
      qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1027
    qed (auto simp: A_def)
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1028
    finally show "\<Union>range (\<lambda>(i, j). A i \<inter> Q j) = space ?N" by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1029
  next
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1030
    fix X assume "X \<in> range (\<lambda>(i, j). A i \<inter> Q j)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1031
    then obtain i j where [simp]:"X = A i \<inter> Q j" by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1032
    have "(\<integral>\<^sup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1033
    proof (cases i)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1034
      case 0
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1035
      have "AE x in M. f x * indicator (A i \<inter> Q j) x = 0"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1036
        using AE by (auto simp: A_def \<open>i = 0\<close>)
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1037
      from nn_integral_cong_AE[OF this] show ?thesis by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1038
    next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1039
      case (Suc n)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1040
      then have "(\<integral>\<^sup>+x. f x * indicator (A i \<inter> Q j) x \<partial>M) \<le>
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1041
        (\<integral>\<^sup>+x. (Suc n :: ennreal) * indicator (Q j) x \<partial>M)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1042
        by (auto intro!: nn_integral_mono simp: indicator_def A_def ennreal_of_nat_eq_real_of_nat)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1043
      also have "\<dots> = Suc n * emeasure M (Q j)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1044
        using Q by (auto intro!: nn_integral_cmult_indicator)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41832
diff changeset
  1045
      also have "\<dots> < \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1046
        using Q by (auto simp: ennreal_mult_less_top less_top of_nat_less_top)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1047
      finally show ?thesis by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1048
    qed
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1049
    then show "emeasure ?N X \<noteq> \<infinity>"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1050
      using A_in_sets Q f by (auto simp: emeasure_density)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1051
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1052
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1053
49778
bbbc0f492780 sigma_finite_iff_density_finite does not require a positive density function
hoelzl
parents: 47694
diff changeset
  1054
lemma (in sigma_finite_measure) sigma_finite_iff_density_finite:
bbbc0f492780 sigma_finite_iff_density_finite does not require a positive density function
hoelzl
parents: 47694
diff changeset
  1055
  "f \<in> borel_measurable M \<Longrightarrow> sigma_finite_measure (density M f) \<longleftrightarrow> (AE x in M. f x \<noteq> \<infinity>)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1056
  by (subst sigma_finite_iff_density_finite')
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1057
     (auto simp: max_def intro!: measurable_If)
49778
bbbc0f492780 sigma_finite_iff_density_finite does not require a positive density function
hoelzl
parents: 47694
diff changeset
  1058
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1059
subsection \<open>Radon-Nikodym derivative\<close>
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1060
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1061
definition RN_deriv :: "'a measure \<Rightarrow> 'a measure \<Rightarrow> 'a \<Rightarrow> ennreal" where
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1062
  "RN_deriv M N =
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1063
    (if \<exists>f. f \<in> borel_measurable M \<and> density M f = N
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1064
       then SOME f. f \<in> borel_measurable M \<and> density M f = N
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1065
       else (\<lambda>_. 0))"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1066
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
  1067
lemma RN_derivI:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1068
  assumes "f \<in> borel_measurable M" "density M f = N"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1069
  shows "density M (RN_deriv M N) = N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1070
proof -
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1071
  have "\<exists>f. f \<in> borel_measurable M \<and> density M f = N"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1072
    using assms by auto
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1073
  moreover then have "density M (SOME f. f \<in> borel_measurable M \<and> density M f = N) = N"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1074
    by (rule someI2_ex) auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1075
  ultimately show ?thesis
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1076
    by (auto simp: RN_deriv_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1077
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1078
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1079
lemma borel_measurable_RN_deriv[measurable]: "RN_deriv M N \<in> borel_measurable M"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1080
proof -
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1081
  { assume ex: "\<exists>f. f \<in> borel_measurable M \<and> density M f = N"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1082
    have 1: "(SOME f. f \<in> borel_measurable M \<and> density M f = N) \<in> borel_measurable M"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1083
      using ex by (rule someI2_ex) auto }
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1084
  from this show ?thesis
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1085
    by (auto simp: RN_deriv_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1086
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1087
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1088
lemma density_RN_deriv_density:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1089
  assumes f: "f \<in> borel_measurable M"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1090
  shows "density M (RN_deriv M (density M f)) = density M f"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1091
  by (rule RN_derivI[OF f]) simp
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1092
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1093
lemma (in sigma_finite_measure) density_RN_deriv:
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1094
  "absolutely_continuous M N \<Longrightarrow> sets N = sets M \<Longrightarrow> density M (RN_deriv M N) = N"
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1095
  by (metis RN_derivI Radon_Nikodym)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1096
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1097
lemma (in sigma_finite_measure) RN_deriv_nn_integral:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1098
  assumes N: "absolutely_continuous M N" "sets N = sets M"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1099
    and f: "f \<in> borel_measurable M"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1100
  shows "integral\<^sup>N N f = (\<integral>\<^sup>+x. RN_deriv M N x * f x \<partial>M)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1101
proof -
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1102
  have "integral\<^sup>N N f = integral\<^sup>N (density M (RN_deriv M N)) f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1103
    using N by (simp add: density_RN_deriv)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1104
  also have "\<dots> = (\<integral>\<^sup>+x. RN_deriv M N x * f x \<partial>M)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1105
    using f by (simp add: nn_integral_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1106
  finally show ?thesis by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1107
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1108
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1109
lemma null_setsD_AE: "N \<in> null_sets M \<Longrightarrow> AE x in M. x \<notin> N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1110
  using AE_iff_null_sets[of N M] by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1111
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1112
lemma (in sigma_finite_measure) RN_deriv_unique:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1113
  assumes f: "f \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1114
  and eq: "density M f = N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1115
  shows "AE x in M. f x = RN_deriv M N x"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1116
  unfolding eq[symmetric]
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1117
  by (intro density_unique_iff[THEN iffD1] f borel_measurable_RN_deriv
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1118
            density_RN_deriv_density[symmetric])
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1119
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1120
lemma RN_deriv_unique_sigma_finite:
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1121
  assumes f: "f \<in> borel_measurable M"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1122
  and eq: "density M f = N" and fin: "sigma_finite_measure N"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1123
  shows "AE x in M. f x = RN_deriv M N x"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49778
diff changeset
  1124
  using fin unfolding eq[symmetric]
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1125
  by (intro sigma_finite_density_unique[THEN iffD1] f borel_measurable_RN_deriv
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1126
            density_RN_deriv_density[symmetric])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1127
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1128
lemma (in sigma_finite_measure) RN_deriv_distr:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1129
  fixes T :: "'a \<Rightarrow> 'b"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1130
  assumes T: "T \<in> measurable M M'" and T': "T' \<in> measurable M' M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1131
    and inv: "\<forall>x\<in>space M. T' (T x) = x"
50021
d96a3f468203 add support for function application to measurability prover
hoelzl
parents: 50003
diff changeset
  1132
  and ac[simp]: "absolutely_continuous (distr M M' T) (distr N M' T)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1133
  and N: "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1134
  shows "AE x in M. RN_deriv (distr M M' T) (distr N M' T) (T x) = RN_deriv M N x"
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1135
proof (rule RN_deriv_unique)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1136
  have [simp]: "sets N = sets M" by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1137
  note sets_eq_imp_space_eq[OF N, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1138
  have measurable_N[simp]: "\<And>M'. measurable N M' = measurable M M'" by (auto simp: measurable_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1139
  { fix A assume "A \<in> sets M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
  1140
    with inv T T' sets.sets_into_space[OF this]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1141
    have "T -` T' -` A \<inter> T -` space M' \<inter> space M = A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1142
      by (auto simp: measurable_def) }
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1143
  note eq = this[simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1144
  { fix A assume "A \<in> sets M"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
  1145
    with inv T T' sets.sets_into_space[OF this]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1146
    have "(T' \<circ> T) -` A \<inter> space M = A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1147
      by (auto simp: measurable_def) }
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1148
  note eq2 = this[simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1149
  let ?M' = "distr M M' T" and ?N' = "distr N M' T"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1150
  interpret M': sigma_finite_measure ?M'
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1151
  proof
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1152
    from sigma_finite_countable guess F .. note F = this
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1153
    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>)"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1154
    proof (intro exI conjI ballI)
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1155
      show *: "(\<lambda>A. T' -` A \<inter> space ?M') ` F \<subseteq> sets ?M'"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1156
        using F T' by (auto simp: measurable_def)
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1157
      show "\<Union>((\<lambda>A. T' -` A \<inter> space ?M')`F) = space ?M'"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1158
        using F T'[THEN measurable_space] by (auto simp: set_eq_iff)
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1159
    next
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1160
      fix X assume "X \<in> (\<lambda>A. T' -` A \<inter> space ?M')`F"
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1161
      then obtain A where [simp]: "X = T' -` A \<inter> space ?M'" and "A \<in> F" by auto
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1162
      have "X \<in> sets M'" using F T' \<open>A\<in>F\<close> by auto
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1163
      moreover
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1164
      have Fi: "A \<in> sets M" using F \<open>A\<in>F\<close> by auto
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1165
      ultimately show "emeasure ?M' X \<noteq> \<infinity>"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1166
        using F T T' \<open>A\<in>F\<close> by (simp add: emeasure_distr)
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 56996
diff changeset
  1167
    qed (insert F, auto)
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1168
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1169
  have "(RN_deriv ?M' ?N') \<circ> T \<in> borel_measurable M"
50021
d96a3f468203 add support for function application to measurability prover
hoelzl
parents: 50003
diff changeset
  1170
    using T ac by measurable
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1171
  then show "(\<lambda>x. RN_deriv ?M' ?N' (T x)) \<in> borel_measurable M"
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1172
    by (simp add: comp_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1173
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1174
  have "N = distr N M (T' \<circ> T)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1175
    by (subst measure_of_of_measure[of N, symmetric])
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50021
diff changeset
  1176
       (auto simp add: distr_def sets.sigma_sets_eq intro!: measure_of_eq sets.space_closed)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1177
  also have "\<dots> = distr (distr N M' T) M T'"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1178
    using T T' by (simp add: distr_distr)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1179
  also have "\<dots> = distr (density (distr M M' T) (RN_deriv (distr M M' T) (distr N M' T))) M T'"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1180
    using ac by (simp add: M'.density_RN_deriv)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1181
  also have "\<dots> = density M (RN_deriv (distr M M' T) (distr N M' T) \<circ> T)"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1182
    by (simp add: distr_density_distr[OF T T', OF inv])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1183
  finally show "density M (\<lambda>x. RN_deriv (distr M M' T) (distr N M' T) (T x)) = N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1184
    by (simp add: comp_def)
41832
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1185
qed
27cb9113b1a0 add lemma RN_deriv_vimage
hoelzl
parents: 41705
diff changeset
  1186
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1187
lemma (in sigma_finite_measure) RN_deriv_finite:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1188
  assumes N: "sigma_finite_measure N" and ac: "absolutely_continuous M N" "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1189
  shows "AE x in M. RN_deriv M N x \<noteq> \<infinity>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1190
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1191
  interpret N: sigma_finite_measure N by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1192
  from N show ?thesis
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1193
    using sigma_finite_iff_density_finite[OF borel_measurable_RN_deriv, of N] density_RN_deriv[OF ac]
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1194
    by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1195
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1196
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1197
lemma (in sigma_finite_measure)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1198
  assumes N: "sigma_finite_measure N" and ac: "absolutely_continuous M N" "sets N = sets M"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1199
    and f: "f \<in> borel_measurable M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1200
  shows RN_deriv_integrable: "integrable N f \<longleftrightarrow>
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1201
      integrable M (\<lambda>x. enn2real (RN_deriv M N x) * f x)" (is ?integrable)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1202
    and RN_deriv_integral: "integral\<^sup>L N f = (\<integral>x. enn2real (RN_deriv M N x) * f x \<partial>M)" (is ?integral)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1203
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1204
  note ac(2)[simp] and sets_eq_imp_space_eq[OF ac(2), simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1205
  interpret N: sigma_finite_measure N by fact
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1206
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1207
  have eq: "density M (RN_deriv M N) = density M (\<lambda>x. enn2real (RN_deriv M N x))"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1208
  proof (rule density_cong)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1209
    from RN_deriv_finite[OF assms(1,2,3)]
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1210
    show "AE x in M. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1211
      by eventually_elim (auto simp: less_top)
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1212
  qed (insert ac, auto)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1213
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1214
  show ?integrable
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1215
    apply (subst density_RN_deriv[OF ac, symmetric])
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1216
    unfolding eq
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1217
    apply (intro integrable_real_density f AE_I2 enn2real_nonneg)
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1218
    apply (insert ac, auto)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1219
    done
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1220
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1221
  show ?integral
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1222
    apply (subst density_RN_deriv[OF ac, symmetric])
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1223
    unfolding eq
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1224
    apply (intro integral_real_density f AE_I2 enn2real_nonneg)
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1225
    apply (insert ac, auto)
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56537
diff changeset
  1226
    done
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1227
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39097
diff changeset
  1228
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1229
lemma (in sigma_finite_measure) real_RN_deriv:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1230
  assumes "finite_measure N"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1231
  assumes ac: "absolutely_continuous M N" "sets N = sets M"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1232
  obtains D where "D \<in> borel_measurable M"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1233
    and "AE x in M. RN_deriv M N x = ennreal (D x)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1234
    and "AE x in N. 0 < D x"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1235
    and "\<And>x. 0 \<le> D x"
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1236
proof
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1237
  interpret N: finite_measure N by fact
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61169
diff changeset
  1238
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1239
  note RN = borel_measurable_RN_deriv density_RN_deriv[OF ac]
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1240
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1241
  let ?RN = "\<lambda>t. {x \<in> space M. RN_deriv M N x = t}"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1242
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1243
  show "(\<lambda>x. enn2real (RN_deriv M N x)) \<in> borel_measurable M"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1244
    using RN by auto
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1245
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1246
  have "N (?RN \<infinity>) = (\<integral>\<^sup>+ x. RN_deriv M N x * indicator (?RN \<infinity>) x \<partial>M)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1247
    using RN(1) by (subst RN(2)[symmetric]) (auto simp: emeasure_density)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1248
  also have "\<dots> = (\<integral>\<^sup>+ x. \<infinity> * indicator (?RN \<infinity>) x \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1249
    by (intro nn_integral_cong) (auto simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1250
  also have "\<dots> = \<infinity> * emeasure M (?RN \<infinity>)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1251
    using RN by (intro nn_integral_cmult_indicator) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1252
  finally have eq: "N (?RN \<infinity>) = \<infinity> * emeasure M (?RN \<infinity>)" .
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1253
  moreover
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1254
  have "emeasure M (?RN \<infinity>) = 0"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1255
  proof (rule ccontr)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1256
    assume "emeasure M {x \<in> space M. RN_deriv M N x = \<infinity>} \<noteq> 0"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1257
    then have "0 < emeasure M {x \<in> space M. RN_deriv M N x = \<infinity>}"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1258
      by (auto simp: zero_less_iff_neq_zero)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1259
    with eq have "N (?RN \<infinity>) = \<infinity>" by (simp add: ennreal_mult_eq_top_iff)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1260
    with N.emeasure_finite[of "?RN \<infinity>"] RN show False by auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1261
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1262
  ultimately have "AE x in M. RN_deriv M N x < \<infinity>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1263
    using RN by (intro AE_iff_measurable[THEN iffD2]) (auto simp: less_top[symmetric])
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1264
  then show "AE x in M. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1265
    by auto
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1266
  then have eq: "AE x in N. RN_deriv M N x = ennreal (enn2real (RN_deriv M N x))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1267
    using ac absolutely_continuous_AE by auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1268
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1269
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1270
  have "N (?RN 0) = (\<integral>\<^sup>+ x. RN_deriv M N x * indicator (?RN 0) x \<partial>M)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1271
    by (subst RN(2)[symmetric]) (auto simp: emeasure_density)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1272
  also have "\<dots> = (\<integral>\<^sup>+ x. 0 \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1273
    by (intro nn_integral_cong) (auto simp: indicator_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1274
  finally have "AE x in N. RN_deriv M N x \<noteq> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1275
    using RN by (subst AE_iff_measurable[OF _ refl]) (auto simp: ac cong: sets_eq_imp_space_eq)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1276
  with eq show "AE x in N. 0 < enn2real (RN_deriv M N x)"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1277
    by (auto simp: enn2real_positive_iff less_top[symmetric] zero_less_iff_neq_zero)
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1278
qed (rule enn2real_nonneg)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42866
diff changeset
  1279
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1280
lemma (in sigma_finite_measure) RN_deriv_singleton:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1281
  assumes ac: "absolutely_continuous M N" "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1282
  and x: "{x} \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
  1283
  shows "N {x} = RN_deriv M N x * emeasure M {x}"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1284
proof -
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61610
diff changeset
  1285
  from \<open>{x} \<in> sets M\<close>
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
  1286
  have "density M (RN_deriv M N) {x} = (\<integral>\<^sup>+w. RN_deriv M N x * indicator {x} w \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1287
    by (auto simp: indicator_def emeasure_density intro!: nn_integral_cong)
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62623
diff changeset
  1288
  with x density_RN_deriv[OF ac] show ?thesis
62083
7582b39f51ed add the proof of the central limit theorem
hoelzl
parents: 61969
diff changeset
  1289
    by (auto simp: max_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1290
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1291
d5d342611edb Rewrite the Probability theory.
hoelzl
parents:
diff changeset
  1292
end