src/HOL/Analysis/Embed_Measure.thy
author nipkow
Wed Jan 10 15:25:09 2018 +0100 (18 months ago)
changeset 67399 eab6ce8368fa
parent 67241 73635a5bfa5c
child 69180 922833cc6839
permissions -rw-r--r--
ran isabelle update_op on all sources
hoelzl@63627
     1
(*  Title:      HOL/Analysis/Embed_Measure.thy
hoelzl@59092
     2
    Author:     Manuel Eberl, TU M√ľnchen
hoelzl@59092
     3
hoelzl@62975
     4
    Defines measure embeddings with injective functions, i.e. lifting a measure on some values
hoelzl@62975
     5
    to a measure on "tagged" values (e.g. embed_measure M Inl lifts a measure on values 'a to a
hoelzl@59092
     6
    measure on the left part of the sum type 'a + 'b)
hoelzl@59092
     7
*)
hoelzl@59092
     8
wenzelm@61808
     9
section \<open>Embed Measure Spaces with a Function\<close>
hoelzl@59092
    10
hoelzl@59092
    11
theory Embed_Measure
hoelzl@59092
    12
imports Binary_Product_Measure
hoelzl@59092
    13
begin
hoelzl@59092
    14
hoelzl@59092
    15
definition embed_measure :: "'a measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
hoelzl@62975
    16
  "embed_measure M f = measure_of (f ` space M) {f ` A |A. A \<in> sets M}
hoelzl@59092
    17
                           (\<lambda>A. emeasure M (f -` A \<inter> space M))"
hoelzl@59092
    18
hoelzl@59092
    19
lemma space_embed_measure: "space (embed_measure M f) = f ` space M"
hoelzl@62975
    20
  unfolding embed_measure_def
hoelzl@59092
    21
  by (subst space_measure_of) (auto dest: sets.sets_into_space)
hoelzl@59092
    22
hoelzl@59092
    23
lemma sets_embed_measure':
hoelzl@62975
    24
  assumes inj: "inj_on f (space M)"
hoelzl@59092
    25
  shows "sets (embed_measure M f) = {f ` A |A. A \<in> sets M}"
hoelzl@59092
    26
  unfolding embed_measure_def
hoelzl@59092
    27
proof (intro sigma_algebra.sets_measure_of_eq sigma_algebra_iff2[THEN iffD2] conjI allI ballI impI)
hoelzl@59092
    28
  fix s assume "s \<in> {f ` A |A. A \<in> sets M}"
hoelzl@59092
    29
  then obtain s' where s'_props: "s = f ` s'" "s' \<in> sets M" by auto
hoelzl@59092
    30
  hence "f ` space M - s = f ` (space M - s')" using inj
hoelzl@59092
    31
    by (auto dest: inj_onD sets.sets_into_space)
hoelzl@59092
    32
  also have "... \<in> {f ` A |A. A \<in> sets M}" using s'_props by auto
hoelzl@59092
    33
  finally show "f ` space M - s \<in> {f ` A |A. A \<in> sets M}" .
hoelzl@59092
    34
next
hoelzl@59092
    35
  fix A :: "nat \<Rightarrow> _" assume "range A \<subseteq> {f ` A |A. A \<in> sets M}"
wenzelm@63539
    36
  then obtain A' where A': "\<And>i. A i = f ` A' i" "\<And>i. A' i \<in> sets M"
hoelzl@59092
    37
    by (auto simp: subset_eq choice_iff)
wenzelm@63539
    38
  then have "(\<Union>x. f ` A' x) = f ` (\<Union>x. A' x)" by blast
wenzelm@63539
    39
  with A' show "(\<Union>i. A i) \<in> {f ` A |A. A \<in> sets M}"
haftmann@62343
    40
    by simp blast
hoelzl@59092
    41
qed (auto dest: sets.sets_into_space)
hoelzl@59092
    42
hoelzl@59092
    43
lemma the_inv_into_vimage:
hoelzl@59092
    44
  "inj_on f X \<Longrightarrow> A \<subseteq> X \<Longrightarrow> the_inv_into X f -` A \<inter> (f`X) = f ` A"
hoelzl@59092
    45
  by (auto simp: the_inv_into_f_f)
hoelzl@59092
    46
hoelzl@59092
    47
lemma sets_embed_eq_vimage_algebra:
hoelzl@59092
    48
  assumes "inj_on f (space M)"
hoelzl@59092
    49
  shows "sets (embed_measure M f) = sets (vimage_algebra (f`space M) (the_inv_into (space M) f) M)"
hoelzl@63886
    50
  by (auto simp: sets_embed_measure'[OF assms] Pi_iff the_inv_into_f_f assms sets_vimage_algebra2 Setcompr_eq_image
hoelzl@59092
    51
           dest: sets.sets_into_space
hoelzl@59092
    52
           intro!: image_cong the_inv_into_vimage[symmetric])
hoelzl@59092
    53
hoelzl@59092
    54
lemma sets_embed_measure:
hoelzl@62975
    55
  assumes inj: "inj f"
hoelzl@59092
    56
  shows "sets (embed_measure M f) = {f ` A |A. A \<in> sets M}"
hoelzl@59092
    57
  using assms by (subst sets_embed_measure') (auto intro!: inj_onI dest: injD)
hoelzl@59092
    58
hoelzl@59092
    59
lemma in_sets_embed_measure: "A \<in> sets M \<Longrightarrow> f ` A \<in> sets (embed_measure M f)"
hoelzl@59092
    60
  unfolding embed_measure_def
hoelzl@59092
    61
  by (intro in_measure_of) (auto dest: sets.sets_into_space)
hoelzl@59092
    62
hoelzl@59092
    63
lemma measurable_embed_measure1:
hoelzl@62975
    64
  assumes g: "(\<lambda>x. g (f x)) \<in> measurable M N"
hoelzl@59092
    65
  shows "g \<in> measurable (embed_measure M f) N"
hoelzl@59092
    66
  unfolding measurable_def
hoelzl@59092
    67
proof safe
hoelzl@59092
    68
  fix A assume "A \<in> sets N"
hoelzl@59092
    69
  with g have "(\<lambda>x. g (f x)) -` A \<inter> space M \<in> sets M"
hoelzl@59092
    70
    by (rule measurable_sets)
hoelzl@59092
    71
  then have "f ` ((\<lambda>x. g (f x)) -` A \<inter> space M) \<in> sets (embed_measure M f)"
hoelzl@59092
    72
    by (rule in_sets_embed_measure)
hoelzl@59092
    73
  also have "f ` ((\<lambda>x. g (f x)) -` A \<inter> space M) = g -` A \<inter> space (embed_measure M f)"
hoelzl@59092
    74
    by (auto simp: space_embed_measure)
hoelzl@59092
    75
  finally show "g -` A \<inter> space (embed_measure M f) \<in> sets (embed_measure M f)" .
hoelzl@59092
    76
qed (insert measurable_space[OF assms], auto simp: space_embed_measure)
hoelzl@59092
    77
hoelzl@59092
    78
lemma measurable_embed_measure2':
hoelzl@62975
    79
  assumes "inj_on f (space M)"
hoelzl@59092
    80
  shows "f \<in> measurable M (embed_measure M f)"
hoelzl@59092
    81
proof-
hoelzl@59092
    82
  {
hoelzl@59092
    83
    fix A assume A: "A \<in> sets M"
wenzelm@63539
    84
    also from A have "A = A \<inter> space M" by auto
hoelzl@59092
    85
    also have "... = f -` f ` A \<inter> space M" using A assms
hoelzl@59092
    86
      by (auto dest: inj_onD sets.sets_into_space)
hoelzl@59092
    87
    finally have "f -` f ` A \<inter> space M \<in> sets M" .
hoelzl@59092
    88
  }
hoelzl@59092
    89
  thus ?thesis using assms unfolding embed_measure_def
hoelzl@59092
    90
    by (intro measurable_measure_of) (auto dest: sets.sets_into_space)
hoelzl@59092
    91
qed
hoelzl@59092
    92
hoelzl@59092
    93
lemma measurable_embed_measure2:
hoelzl@59092
    94
  assumes [simp]: "inj f" shows "f \<in> measurable M (embed_measure M f)"
hoelzl@59092
    95
  by (auto simp: inj_vimage_image_eq embed_measure_def
hoelzl@59092
    96
           intro!: measurable_measure_of dest: sets.sets_into_space)
hoelzl@59092
    97
hoelzl@59092
    98
lemma embed_measure_eq_distr':
hoelzl@59092
    99
  assumes "inj_on f (space M)"
hoelzl@59092
   100
  shows "embed_measure M f = distr M (embed_measure M f) f"
hoelzl@59092
   101
proof-
hoelzl@62975
   102
  have "distr M (embed_measure M f) f =
hoelzl@59092
   103
            measure_of (f ` space M) {f ` A |A. A \<in> sets M}
hoelzl@59092
   104
                       (\<lambda>A. emeasure M (f -` A \<inter> space M))" unfolding distr_def
hoelzl@59092
   105
      by (simp add: space_embed_measure sets_embed_measure'[OF assms])
hoelzl@59092
   106
  also have "... = embed_measure M f" unfolding embed_measure_def ..
hoelzl@59092
   107
  finally show ?thesis ..
hoelzl@59092
   108
qed
hoelzl@59092
   109
hoelzl@59092
   110
lemma embed_measure_eq_distr:
hoelzl@59092
   111
    "inj f \<Longrightarrow> embed_measure M f = distr M (embed_measure M f) f"
hoelzl@59092
   112
  by (rule embed_measure_eq_distr') (auto intro!: inj_onI dest: injD)
hoelzl@59092
   113
Andreas@60065
   114
lemma nn_integral_embed_measure':
Andreas@60065
   115
  "inj_on f (space M) \<Longrightarrow> g \<in> borel_measurable (embed_measure M f) \<Longrightarrow>
Andreas@60065
   116
  nn_integral (embed_measure M f) g = nn_integral M (\<lambda>x. g (f x))"
Andreas@60065
   117
  apply (subst embed_measure_eq_distr', simp)
Andreas@60065
   118
  apply (subst nn_integral_distr)
Andreas@60065
   119
  apply (simp_all add: measurable_embed_measure2')
Andreas@60065
   120
  done
Andreas@60065
   121
hoelzl@59092
   122
lemma nn_integral_embed_measure:
hoelzl@59092
   123
  "inj f \<Longrightarrow> g \<in> borel_measurable (embed_measure M f) \<Longrightarrow>
hoelzl@59092
   124
  nn_integral (embed_measure M f) g = nn_integral M (\<lambda>x. g (f x))"
Andreas@60065
   125
  by(erule nn_integral_embed_measure'[OF subset_inj_on]) simp
hoelzl@59092
   126
hoelzl@59092
   127
lemma emeasure_embed_measure':
hoelzl@59092
   128
    assumes "inj_on f (space M)" "A \<in> sets (embed_measure M f)"
hoelzl@59092
   129
    shows "emeasure (embed_measure M f) A = emeasure M (f -` A \<inter> space M)"
hoelzl@59092
   130
  by (subst embed_measure_eq_distr'[OF assms(1)])
hoelzl@59092
   131
     (simp add: emeasure_distr[OF measurable_embed_measure2'[OF assms(1)] assms(2)])
hoelzl@59092
   132
hoelzl@59092
   133
lemma emeasure_embed_measure:
hoelzl@59092
   134
    assumes "inj f" "A \<in> sets (embed_measure M f)"
hoelzl@59092
   135
    shows "emeasure (embed_measure M f) A = emeasure M (f -` A \<inter> space M)"
hoelzl@59092
   136
 using assms by (intro emeasure_embed_measure') (auto intro!: inj_onI dest: injD)
hoelzl@59092
   137
hoelzl@62975
   138
lemma embed_measure_comp:
hoelzl@59092
   139
  assumes [simp]: "inj f" "inj g"
hoelzl@59092
   140
  shows "embed_measure (embed_measure M f) g = embed_measure M (g \<circ> f)"
hoelzl@59092
   141
proof-
hoelzl@59092
   142
  have [simp]: "inj (\<lambda>x. g (f x))" by (subst o_def[symmetric]) (auto intro: inj_comp)
hoelzl@59092
   143
  note measurable_embed_measure2[measurable]
hoelzl@62975
   144
  have "embed_measure (embed_measure M f) g =
hoelzl@59092
   145
            distr M (embed_measure (embed_measure M f) g) (g \<circ> f)"
hoelzl@62975
   146
      by (subst (1 2) embed_measure_eq_distr)
hoelzl@59092
   147
         (simp_all add: distr_distr sets_embed_measure cong: distr_cong)
hoelzl@59092
   148
  also have "... = embed_measure M (g \<circ> f)"
hoelzl@59092
   149
      by (subst (3) embed_measure_eq_distr, simp add: o_def, rule distr_cong)
hoelzl@62975
   150
         (auto simp: sets_embed_measure o_def image_image[symmetric]
hoelzl@59092
   151
               intro: inj_comp cong: distr_cong)
hoelzl@59092
   152
  finally show ?thesis .
hoelzl@59092
   153
qed
hoelzl@59092
   154
hoelzl@59092
   155
lemma sigma_finite_embed_measure:
hoelzl@59092
   156
  assumes "sigma_finite_measure M" and inj: "inj f"
hoelzl@59092
   157
  shows "sigma_finite_measure (embed_measure M f)"
wenzelm@60580
   158
proof -
hoelzl@59092
   159
  from assms(1) interpret sigma_finite_measure M .
hoelzl@59092
   160
  from sigma_finite_countable obtain A where
hoelzl@59092
   161
      A_props: "countable A" "A \<subseteq> sets M" "\<Union>A = space M" "\<And>X. X\<in>A \<Longrightarrow> emeasure M X \<noteq> \<infinity>" by blast
nipkow@67399
   162
  from A_props have "countable ((`) f`A)" by auto
wenzelm@60580
   163
  moreover
nipkow@67399
   164
  from inj and A_props have "(`) f`A \<subseteq> sets (embed_measure M f)"
wenzelm@60580
   165
    by (auto simp: sets_embed_measure)
wenzelm@60580
   166
  moreover
nipkow@67399
   167
  from A_props and inj have "\<Union>((`) f`A) = space (embed_measure M f)"
wenzelm@60580
   168
    by (auto simp: space_embed_measure intro!: imageI)
wenzelm@60580
   169
  moreover
nipkow@67399
   170
  from A_props and inj have "\<forall>a\<in>(`) f ` A. emeasure (embed_measure M f) a \<noteq> \<infinity>"
wenzelm@60580
   171
    by (intro ballI, subst emeasure_embed_measure)
wenzelm@60580
   172
       (auto simp: inj_vimage_image_eq intro: in_sets_embed_measure)
wenzelm@61169
   173
  ultimately show ?thesis by - (standard, blast)
hoelzl@59092
   174
qed
hoelzl@59092
   175
Andreas@60065
   176
lemma embed_measure_count_space':
Andreas@60065
   177
    "inj_on f A \<Longrightarrow> embed_measure (count_space A) f = count_space (f`A)"
hoelzl@59092
   178
  apply (subst distr_bij_count_space[of f A "f`A", symmetric])
hoelzl@59092
   179
  apply (simp add: inj_on_def bij_betw_def)
Andreas@60065
   180
  apply (subst embed_measure_eq_distr')
hoelzl@59092
   181
  apply simp
Andreas@60065
   182
  apply(auto 4 3 intro!: measure_eqI imageI simp add: sets_embed_measure' subset_image_iff)
hoelzl@59092
   183
  apply (subst (1 2) emeasure_distr)
Andreas@60065
   184
  apply (auto simp: space_embed_measure sets_embed_measure')
hoelzl@59092
   185
  done
hoelzl@59092
   186
hoelzl@62975
   187
lemma embed_measure_count_space:
Andreas@60065
   188
    "inj f \<Longrightarrow> embed_measure (count_space A) f = count_space (f`A)"
Andreas@60065
   189
  by(rule embed_measure_count_space')(erule subset_inj_on, simp)
Andreas@60065
   190
hoelzl@59092
   191
lemma sets_embed_measure_alt:
nipkow@67399
   192
    "inj f \<Longrightarrow> sets (embed_measure M f) = ((`) f) ` sets M"
hoelzl@59092
   193
  by (auto simp: sets_embed_measure)
hoelzl@59092
   194
hoelzl@59092
   195
lemma emeasure_embed_measure_image':
hoelzl@59092
   196
  assumes "inj_on f (space M)" "X \<in> sets M"
hoelzl@59092
   197
  shows "emeasure (embed_measure M f) (f`X) = emeasure M X"
hoelzl@59092
   198
proof-
hoelzl@59092
   199
  from assms have "emeasure (embed_measure M f) (f`X) = emeasure M (f -` f ` X \<inter> space M)"
hoelzl@59092
   200
    by (subst emeasure_embed_measure') (auto simp: sets_embed_measure')
hoelzl@59092
   201
  also from assms have "f -` f ` X \<inter> space M = X" by (auto dest: inj_onD sets.sets_into_space)
hoelzl@59092
   202
  finally show ?thesis .
hoelzl@59092
   203
qed
hoelzl@59092
   204
hoelzl@59092
   205
lemma emeasure_embed_measure_image:
hoelzl@59092
   206
    "inj f \<Longrightarrow> X \<in> sets M \<Longrightarrow> emeasure (embed_measure M f) (f`X) = emeasure M X"
hoelzl@59092
   207
  by (simp_all add: emeasure_embed_measure in_sets_embed_measure inj_vimage_image_eq)
hoelzl@59092
   208
hoelzl@59092
   209
lemma embed_measure_eq_iff:
hoelzl@59092
   210
  assumes "inj f"
hoelzl@59092
   211
  shows "embed_measure A f = embed_measure B f \<longleftrightarrow> A = B" (is "?M = ?N \<longleftrightarrow> _")
hoelzl@59092
   212
proof
nipkow@67399
   213
  from assms have I: "inj ((`) f)" by (auto intro: injI dest: injD)
hoelzl@59092
   214
  assume asm: "?M = ?N"
hoelzl@59092
   215
  hence "sets (embed_measure A f) = sets (embed_measure B f)" by simp
hoelzl@59092
   216
  with assms have "sets A = sets B" by (simp only: I inj_image_eq_iff sets_embed_measure_alt)
hoelzl@59092
   217
  moreover {
hoelzl@59092
   218
    fix X assume "X \<in> sets A"
hoelzl@59092
   219
    from asm have "emeasure ?M (f`X) = emeasure ?N (f`X)" by simp
hoelzl@62975
   220
    with \<open>X \<in> sets A\<close> and \<open>sets A = sets B\<close> and assms
hoelzl@59092
   221
        have "emeasure A X = emeasure B X" by (simp add: emeasure_embed_measure_image)
hoelzl@59092
   222
  }
hoelzl@59092
   223
  ultimately show "A = B" by (rule measure_eqI)
hoelzl@59092
   224
qed simp
hoelzl@59092
   225
hoelzl@59092
   226
lemma the_inv_into_in_Pi: "inj_on f A \<Longrightarrow> the_inv_into A f \<in> f ` A \<rightarrow> A"
hoelzl@59092
   227
  by (auto simp: the_inv_into_f_f)
hoelzl@59092
   228
hoelzl@59092
   229
lemma map_prod_image: "map_prod f g ` (A \<times> B) = (f`A) \<times> (g`B)"
hoelzl@59092
   230
  using map_prod_surj_on[OF refl refl] .
hoelzl@59092
   231
hoelzl@59092
   232
lemma map_prod_vimage: "map_prod f g -` (A \<times> B) = (f-`A) \<times> (g-`B)"
hoelzl@59092
   233
  by auto
hoelzl@59092
   234
hoelzl@59092
   235
lemma embed_measure_prod:
hoelzl@59092
   236
  assumes f: "inj f" and g: "inj g" and [simp]: "sigma_finite_measure M" "sigma_finite_measure N"
hoelzl@59092
   237
  shows "embed_measure M f \<Otimes>\<^sub>M embed_measure N g = embed_measure (M \<Otimes>\<^sub>M N) (\<lambda>(x, y). (f x, g y))"
hoelzl@59092
   238
    (is "?L = _")
hoelzl@59092
   239
  unfolding map_prod_def[symmetric]
hoelzl@59092
   240
proof (rule pair_measure_eqI)
hoelzl@59092
   241
  have fg[simp]: "\<And>A. inj_on (map_prod f g) A" "\<And>A. inj_on f A" "\<And>A. inj_on g A"
hoelzl@59092
   242
    using f g by (auto simp: inj_on_def)
hoelzl@62975
   243
hoelzl@63333
   244
  note complete_lattice_class.Sup_insert[simp del] ccSup_insert[simp del] SUP_insert[simp del]
hoelzl@63333
   245
     ccSUP_insert[simp del]
hoelzl@59092
   246
  show sets: "sets ?L = sets (embed_measure (M \<Otimes>\<^sub>M N) (map_prod f g))"
hoelzl@59092
   247
    unfolding map_prod_def[symmetric]
hoelzl@59092
   248
    apply (simp add: sets_pair_eq_sets_fst_snd sets_embed_eq_vimage_algebra
hoelzl@59092
   249
      cong: vimage_algebra_cong)
hoelzl@63333
   250
    apply (subst sets_vimage_Sup_eq[where Y="space (M \<Otimes>\<^sub>M N)"])
hoelzl@59092
   251
    apply (simp_all add: space_pair_measure[symmetric])
hoelzl@59092
   252
    apply (auto simp add: the_inv_into_f_f
hoelzl@59092
   253
                simp del: map_prod_simp
hoelzl@59092
   254
                del: prod_fun_imageE) []
hoelzl@63333
   255
    apply auto []
hoelzl@63333
   256
    apply (subst image_insert)
hoelzl@63333
   257
    apply simp
hoelzl@59092
   258
    apply (subst (1 2 3 4 ) vimage_algebra_vimage_algebra_eq)
hoelzl@59092
   259
    apply (simp_all add: the_inv_into_in_Pi Pi_iff[of snd] Pi_iff[of fst] space_pair_measure)
hoelzl@59092
   260
    apply (simp_all add: Pi_iff[of snd] Pi_iff[of fst] the_inv_into_in_Pi vimage_algebra_vimage_algebra_eq
hoelzl@59092
   261
       space_pair_measure[symmetric] map_prod_image[symmetric])
hoelzl@63333
   262
    apply (intro arg_cong[where f=sets] arg_cong[where f=Sup] arg_cong2[where f=insert] vimage_algebra_cong)
hoelzl@59092
   263
    apply (auto simp: map_prod_image the_inv_into_f_f
hoelzl@59092
   264
                simp del: map_prod_simp del: prod_fun_imageE)
hoelzl@59092
   265
    apply (simp_all add: the_inv_into_f_f space_pair_measure)
hoelzl@59092
   266
    done
hoelzl@59092
   267
hoelzl@59092
   268
  note measurable_embed_measure2[measurable]
hoelzl@59092
   269
  fix A B assume AB: "A \<in> sets (embed_measure M f)" "B \<in> sets (embed_measure N g)"
hoelzl@59092
   270
  moreover have "f -` A \<times> g -` B \<inter> space (M \<Otimes>\<^sub>M N) = (f -` A \<inter> space M) \<times> (g -` B \<inter> space N)"
hoelzl@59092
   271
    by (auto simp: space_pair_measure)
hoelzl@59092
   272
  ultimately show "emeasure (embed_measure M f) A * emeasure (embed_measure N g) B =
hoelzl@59092
   273
                     emeasure (embed_measure (M \<Otimes>\<^sub>M N) (map_prod f g)) (A \<times> B)"
hoelzl@59092
   274
    by (simp add: map_prod_vimage sets[symmetric] emeasure_embed_measure
hoelzl@59092
   275
                  sigma_finite_measure.emeasure_pair_measure_Times)
hoelzl@59092
   276
qed (insert assms, simp_all add: sigma_finite_embed_measure)
hoelzl@59092
   277
hoelzl@63333
   278
lemma mono_embed_measure:
hoelzl@63333
   279
  "space M = space M' \<Longrightarrow> sets M \<subseteq> sets M' \<Longrightarrow> sets (embed_measure M f) \<subseteq> sets (embed_measure M' f)"
hoelzl@63333
   280
  unfolding embed_measure_def
hoelzl@63333
   281
  apply (subst (1 2) sets_measure_of)
hoelzl@63333
   282
  apply (blast dest: sets.sets_into_space)
hoelzl@63333
   283
  apply (blast dest: sets.sets_into_space)
hoelzl@63333
   284
  apply simp
hoelzl@63333
   285
  apply (intro sigma_sets_mono')
hoelzl@63333
   286
  apply safe
hoelzl@63333
   287
  apply (simp add: subset_eq)
hoelzl@63333
   288
  apply metis
hoelzl@63333
   289
  done
hoelzl@63333
   290
hoelzl@59092
   291
lemma density_embed_measure:
hoelzl@59092
   292
  assumes inj: "inj f" and Mg[measurable]: "g \<in> borel_measurable (embed_measure M f)"
hoelzl@59092
   293
  shows "density (embed_measure M f) g = embed_measure (density M (g \<circ> f)) f" (is "?M1 = ?M2")
hoelzl@59092
   294
proof (rule measure_eqI)
hoelzl@59092
   295
  fix X assume X: "X \<in> sets ?M1"
hoelzl@62975
   296
  from inj have Mf[measurable]: "f \<in> measurable M (embed_measure M f)"
hoelzl@59092
   297
    by (rule measurable_embed_measure2)
hoelzl@62975
   298
  from Mg and X have "emeasure ?M1 X = \<integral>\<^sup>+ x. g x * indicator X x \<partial>embed_measure M f"
hoelzl@59092
   299
    by (subst emeasure_density) simp_all
hoelzl@59092
   300
  also from X have "... = \<integral>\<^sup>+ x. g (f x) * indicator X (f x) \<partial>M"
hoelzl@62975
   301
    by (subst embed_measure_eq_distr[OF inj], subst nn_integral_distr) auto
hoelzl@59092
   302
  also have "... = \<integral>\<^sup>+ x. g (f x) * indicator (f -` X \<inter> space M) x \<partial>M"
hoelzl@59092
   303
    by (intro nn_integral_cong) (auto split: split_indicator)
hoelzl@59092
   304
  also from X have "... = emeasure (density M (g \<circ> f)) (f -` X \<inter> space M)"
hoelzl@59092
   305
    by (subst emeasure_density) (simp_all add: measurable_comp[OF Mf Mg] measurable_sets[OF Mf])
hoelzl@62975
   306
  also from X and inj have "... = emeasure ?M2 X"
hoelzl@59092
   307
    by (subst emeasure_embed_measure) (simp_all add: sets_embed_measure)
hoelzl@59092
   308
  finally show "emeasure ?M1 X = emeasure ?M2 X" .
hoelzl@59092
   309
qed (simp_all add: sets_embed_measure inj)
hoelzl@59092
   310
hoelzl@59092
   311
lemma density_embed_measure':
hoelzl@59092
   312
  assumes inj: "inj f" and inv: "\<And>x. f' (f x) = x" and Mg[measurable]: "g \<in> borel_measurable M"
hoelzl@59092
   313
  shows "density (embed_measure M f) (g \<circ> f') = embed_measure (density M g) f"
hoelzl@59092
   314
proof-
hoelzl@59092
   315
  have "density (embed_measure M f) (g \<circ> f') = embed_measure (density M (g \<circ> f' \<circ> f)) f"
hoelzl@59092
   316
    by (rule density_embed_measure[OF inj])
hoelzl@62975
   317
       (rule measurable_comp, rule measurable_embed_measure1, subst measurable_cong,
hoelzl@59092
   318
        rule inv, rule measurable_ident_sets, simp, rule Mg)
hoelzl@59092
   319
  also have "density M (g \<circ> f' \<circ> f) = density M g"
hoelzl@59092
   320
    by (intro density_cong) (subst measurable_cong, simp add: o_def inv, simp_all add: Mg inv)
hoelzl@59092
   321
  finally show ?thesis .
hoelzl@59092
   322
qed
hoelzl@59092
   323
hoelzl@59092
   324
lemma inj_on_image_subset_iff:
hoelzl@59092
   325
  assumes "inj_on f C" "A \<subseteq> C"  "B \<subseteq> C"
hoelzl@59092
   326
  shows "f ` A \<subseteq> f ` B \<longleftrightarrow> A \<subseteq> B"
hoelzl@59092
   327
proof (intro iffI subsetI)
hoelzl@59092
   328
  fix x assume A: "f ` A \<subseteq> f ` B" and B: "x \<in> A"
hoelzl@59092
   329
  from B have "f x \<in> f ` A" by blast
hoelzl@59092
   330
  with A have "f x \<in> f ` B" by blast
hoelzl@59092
   331
  then obtain y where "f x = f y" and "y \<in> B" by blast
hoelzl@59092
   332
  with assms and B have "x = y" by (auto dest: inj_onD)
wenzelm@61808
   333
  with \<open>y \<in> B\<close> show "x \<in> B" by simp
hoelzl@59092
   334
qed auto
hoelzl@62975
   335
hoelzl@59092
   336
hoelzl@59092
   337
lemma AE_embed_measure':
hoelzl@59092
   338
  assumes inj: "inj_on f (space M)"
hoelzl@59092
   339
  shows "(AE x in embed_measure M f. P x) \<longleftrightarrow> (AE x in M. P (f x))"
hoelzl@59092
   340
proof
hoelzl@59092
   341
  let ?M = "embed_measure M f"
hoelzl@59092
   342
  assume "AE x in ?M. P x"
hoelzl@59092
   343
  then obtain A where A_props: "A \<in> sets ?M" "emeasure ?M A = 0" "{x\<in>space ?M. \<not>P x} \<subseteq> A"
hoelzl@59092
   344
    by (force elim: AE_E)
hoelzl@59092
   345
  then obtain A' where A'_props: "A = f ` A'" "A' \<in> sets M" by (auto simp: sets_embed_measure' inj)
hoelzl@62975
   346
  moreover have B: "{x\<in>space ?M. \<not>P x} = f ` {x\<in>space M. \<not>P (f x)}"
hoelzl@59092
   347
    by (auto simp: inj space_embed_measure)
hoelzl@59092
   348
  from A_props(3) have "{x\<in>space M. \<not>P (f x)} \<subseteq> A'"
hoelzl@59092
   349
    by (subst (asm) B, subst (asm) A'_props, subst (asm) inj_on_image_subset_iff[OF inj])
hoelzl@59092
   350
       (insert A'_props, auto dest: sets.sets_into_space)
hoelzl@59092
   351
  moreover from A_props A'_props have "emeasure M A' = 0"
hoelzl@59092
   352
    by (simp add: emeasure_embed_measure_image' inj)
hoelzl@59092
   353
  ultimately show "AE x in M. P (f x)" by (intro AE_I)
hoelzl@59092
   354
next
hoelzl@59092
   355
  let ?M = "embed_measure M f"
hoelzl@59092
   356
  assume "AE x in M. P (f x)"
hoelzl@59092
   357
  then obtain A where A_props: "A \<in> sets M" "emeasure M A = 0" "{x\<in>space M. \<not>P (f x)} \<subseteq> A"
hoelzl@59092
   358
    by (force elim: AE_E)
hoelzl@59092
   359
  hence "f`A \<in> sets ?M" "emeasure ?M (f`A) = 0" "{x\<in>space ?M. \<not>P x} \<subseteq> f`A"
hoelzl@59092
   360
    by (auto simp: space_embed_measure emeasure_embed_measure_image' sets_embed_measure' inj)
hoelzl@59092
   361
  thus "AE x in ?M. P x" by (intro AE_I)
hoelzl@59092
   362
qed
hoelzl@59092
   363
hoelzl@59092
   364
lemma AE_embed_measure:
hoelzl@59092
   365
  assumes inj: "inj f"
hoelzl@59092
   366
  shows "(AE x in embed_measure M f. P x) \<longleftrightarrow> (AE x in M. P (f x))"
hoelzl@59092
   367
  using assms by (intro AE_embed_measure') (auto intro!: inj_onI dest: injD)
hoelzl@59092
   368
Andreas@60065
   369
lemma nn_integral_monotone_convergence_SUP_countable:
hoelzl@62975
   370
  fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> ennreal"
Andreas@60065
   371
  assumes nonempty: "Y \<noteq> {}"
nipkow@67399
   372
  and chain: "Complete_Partial_Order.chain (\<le>) (f ` Y)"
Andreas@60065
   373
  and countable: "countable B"
Andreas@60065
   374
  shows "(\<integral>\<^sup>+ x. (SUP i:Y. f i x) \<partial>count_space B) = (SUP i:Y. (\<integral>\<^sup>+ x. f i x \<partial>count_space B))"
Andreas@60065
   375
  (is "?lhs = ?rhs")
Andreas@60065
   376
proof -
Andreas@60065
   377
  let ?f = "(\<lambda>i x. f i (from_nat_into B x) * indicator (to_nat_on B ` B) x)"
Andreas@60065
   378
  have "?lhs = \<integral>\<^sup>+ x. (SUP i:Y. f i (from_nat_into B (to_nat_on B x))) \<partial>count_space B"
Andreas@60065
   379
    by(rule nn_integral_cong)(simp add: countable)
Andreas@60065
   380
  also have "\<dots> = \<integral>\<^sup>+ x. (SUP i:Y. f i (from_nat_into B x)) \<partial>count_space (to_nat_on B ` B)"
Andreas@60065
   381
    by(simp add: embed_measure_count_space'[symmetric] inj_on_to_nat_on countable nn_integral_embed_measure' measurable_embed_measure1)
Andreas@60065
   382
  also have "\<dots> = \<integral>\<^sup>+ x. (SUP i:Y. ?f i x) \<partial>count_space UNIV"
hoelzl@62975
   383
    by(simp add: nn_integral_count_space_indicator ennreal_indicator[symmetric] SUP_mult_right_ennreal nonempty)
hoelzl@62975
   384
  also have "\<dots> = (SUP i:Y. \<integral>\<^sup>+ x. ?f i x \<partial>count_space UNIV)"
Andreas@60065
   385
  proof(rule nn_integral_monotone_convergence_SUP_nat)
nipkow@67399
   386
    show "Complete_Partial_Order.chain (\<le>) (?f ` Y)"
Andreas@60065
   387
      by(rule chain_imageI[OF chain, unfolded image_image])(auto intro!: le_funI split: split_indicator dest: le_funD)
hoelzl@62975
   388
  qed fact
Andreas@60065
   389
  also have "\<dots> = (SUP i:Y. \<integral>\<^sup>+ x. f i (from_nat_into B x) \<partial>count_space (to_nat_on B ` B))"
Andreas@60065
   390
    by(simp add: nn_integral_count_space_indicator)
Andreas@60065
   391
  also have "\<dots> = (SUP i:Y. \<integral>\<^sup>+ x. f i (from_nat_into B (to_nat_on B x)) \<partial>count_space B)"
Andreas@60065
   392
    by(simp add: embed_measure_count_space'[symmetric] inj_on_to_nat_on countable nn_integral_embed_measure' measurable_embed_measure1)
hoelzl@62975
   393
  also have "\<dots> = ?rhs"
Andreas@60065
   394
    by(intro arg_cong2[where f="SUPREMUM"] ext nn_integral_cong_AE)(simp_all add: AE_count_space countable)
Andreas@60065
   395
  finally show ?thesis .
Andreas@60065
   396
qed
Andreas@60065
   397
hoelzl@59092
   398
end