src/HOL/Probability/Infinite_Product_Measure.thy
author huffman
Sun Apr 01 16:09:58 2012 +0200 (2012-04-01)
changeset 47255 30a1692557b0
parent 46905 6b1c0a80a57a
child 47694 05663f75964c
permissions -rw-r--r--
removed Nat_Numeral.thy, moving all theorems elsewhere
hoelzl@42147
     1
(*  Title:      HOL/Probability/Infinite_Product_Measure.thy
hoelzl@42147
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42147
     3
*)
hoelzl@42147
     4
hoelzl@42147
     5
header {*Infinite Product Measure*}
hoelzl@42147
     6
hoelzl@42147
     7
theory Infinite_Product_Measure
hoelzl@42148
     8
  imports Probability_Measure
hoelzl@42147
     9
begin
hoelzl@42147
    10
hoelzl@42147
    11
lemma restrict_extensional_sub[intro]: "A \<subseteq> B \<Longrightarrow> restrict f A \<in> extensional B"
hoelzl@42147
    12
  unfolding restrict_def extensional_def by auto
hoelzl@42147
    13
hoelzl@42147
    14
lemma restrict_restrict[simp]: "restrict (restrict f A) B = restrict f (A \<inter> B)"
hoelzl@42147
    15
  unfolding restrict_def by (simp add: fun_eq_iff)
hoelzl@42147
    16
hoelzl@42147
    17
lemma split_merge: "P (merge I x J y i) \<longleftrightarrow> (i \<in> I \<longrightarrow> P (x i)) \<and> (i \<in> J - I \<longrightarrow> P (y i)) \<and> (i \<notin> I \<union> J \<longrightarrow> P undefined)"
hoelzl@42147
    18
  unfolding merge_def by auto
hoelzl@42147
    19
hoelzl@42147
    20
lemma extensional_merge_sub: "I \<union> J \<subseteq> K \<Longrightarrow> merge I x J y \<in> extensional K"
hoelzl@42147
    21
  unfolding merge_def extensional_def by auto
hoelzl@42147
    22
hoelzl@42147
    23
lemma injective_vimage_restrict:
hoelzl@42147
    24
  assumes J: "J \<subseteq> I"
hoelzl@42147
    25
  and sets: "A \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" "B \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" and ne: "(\<Pi>\<^isub>E i\<in>I. S i) \<noteq> {}"
hoelzl@42147
    26
  and eq: "(\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i) = (\<lambda>x. restrict x J) -` B \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
hoelzl@42147
    27
  shows "A = B"
hoelzl@42147
    28
proof  (intro set_eqI)
hoelzl@42147
    29
  fix x
hoelzl@42147
    30
  from ne obtain y where y: "\<And>i. i \<in> I \<Longrightarrow> y i \<in> S i" by auto
hoelzl@42147
    31
  have "J \<inter> (I - J) = {}" by auto
hoelzl@42147
    32
  show "x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@42147
    33
  proof cases
hoelzl@42147
    34
    assume x: "x \<in> (\<Pi>\<^isub>E i\<in>J. S i)"
hoelzl@42147
    35
    have "x \<in> A \<longleftrightarrow> merge J x (I - J) y \<in> (\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
hoelzl@42147
    36
      using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub split: split_merge)
hoelzl@42147
    37
    then show "x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@42147
    38
      using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub eq split: split_merge)
hoelzl@42147
    39
  next
hoelzl@42147
    40
    assume "x \<notin> (\<Pi>\<^isub>E i\<in>J. S i)" with sets show "x \<in> A \<longleftrightarrow> x \<in> B" by auto
hoelzl@42147
    41
  qed
hoelzl@42147
    42
qed
hoelzl@42147
    43
hoelzl@42147
    44
lemma (in product_prob_space) measure_preserving_restrict:
hoelzl@42147
    45
  assumes "J \<noteq> {}" "J \<subseteq> K" "finite K"
hoelzl@42147
    46
  shows "(\<lambda>f. restrict f J) \<in> measure_preserving (\<Pi>\<^isub>M i\<in>K. M i) (\<Pi>\<^isub>M i\<in>J. M i)" (is "?R \<in> _")
hoelzl@42147
    47
proof -
hoelzl@45777
    48
  interpret K: finite_product_prob_space M K by default fact
hoelzl@42147
    49
  have J: "J \<noteq> {}" "finite J" using assms by (auto simp add: finite_subset)
hoelzl@42147
    50
  interpret J: finite_product_prob_space M J
hoelzl@42147
    51
    by default (insert J, auto)
hoelzl@42147
    52
  from J.sigma_finite_pairs guess F .. note F = this
hoelzl@42147
    53
  then have [simp,intro]: "\<And>k i. k \<in> J \<Longrightarrow> F k i \<in> sets (M k)"
hoelzl@42147
    54
    by auto
wenzelm@46731
    55
  let ?F = "\<lambda>i. \<Pi>\<^isub>E k\<in>J. F k i"
hoelzl@42147
    56
  let ?J = "product_algebra_generator J M \<lparr> measure := measure (Pi\<^isub>M J M) \<rparr>"
hoelzl@42147
    57
  have "?R \<in> measure_preserving (\<Pi>\<^isub>M i\<in>K. M i) (sigma ?J)"
hoelzl@42147
    58
  proof (rule K.measure_preserving_Int_stable)
hoelzl@42147
    59
    show "Int_stable ?J"
hoelzl@42147
    60
      by (auto simp: Int_stable_def product_algebra_generator_def PiE_Int)
hoelzl@42147
    61
    show "range ?F \<subseteq> sets ?J" "incseq ?F" "(\<Union>i. ?F i) = space ?J"
hoelzl@42147
    62
      using F by auto
hoelzl@42147
    63
    show "\<And>i. measure ?J (?F i) \<noteq> \<infinity>"
hoelzl@42147
    64
      using F by (simp add: J.measure_times setprod_PInf)
hoelzl@42147
    65
    have "measure_space (Pi\<^isub>M J M)" by default
hoelzl@42147
    66
    then show "measure_space (sigma ?J)"
hoelzl@42147
    67
      by (simp add: product_algebra_def sigma_def)
hoelzl@42147
    68
    show "?R \<in> measure_preserving (Pi\<^isub>M K M) ?J"
hoelzl@42147
    69
    proof (simp add: measure_preserving_def measurable_def product_algebra_generator_def del: vimage_Int,
hoelzl@42147
    70
           safe intro!: restrict_extensional)
hoelzl@42147
    71
      fix x k assume "k \<in> J" "x \<in> (\<Pi> i\<in>K. space (M i))"
hoelzl@42147
    72
      then show "x k \<in> space (M k)" using `J \<subseteq> K` by auto
hoelzl@42147
    73
    next
hoelzl@42147
    74
      fix E assume "E \<in> (\<Pi> i\<in>J. sets (M i))"
hoelzl@42147
    75
      then have E: "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets (M j)" by auto
hoelzl@42147
    76
      then have *: "?R -` Pi\<^isub>E J E \<inter> (\<Pi>\<^isub>E i\<in>K. space (M i)) = (\<Pi>\<^isub>E i\<in>K. if i \<in> J then E i else space (M i))"
hoelzl@42147
    77
        (is "?X = Pi\<^isub>E K ?M")
hoelzl@42147
    78
        using `J \<subseteq> K` sets_into_space by (auto simp: Pi_iff split: split_if_asm) blast+
hoelzl@42147
    79
      with E show "?X \<in> sets (Pi\<^isub>M K M)"
hoelzl@42147
    80
        by (auto intro!: product_algebra_generatorI)
hoelzl@42147
    81
      have "measure (Pi\<^isub>M J M) (Pi\<^isub>E J E) = (\<Prod>i\<in>J. measure (M i) (?M i))"
hoelzl@42147
    82
        using E by (simp add: J.measure_times)
hoelzl@42147
    83
      also have "\<dots> = measure (Pi\<^isub>M K M) ?X"
hoelzl@42147
    84
        unfolding * using E `finite K` `J \<subseteq> K`
hoelzl@42147
    85
        by (auto simp: K.measure_times M.measure_space_1
hoelzl@42147
    86
                 cong del: setprod_cong
hoelzl@42147
    87
                 intro!: setprod_mono_one_left)
hoelzl@42147
    88
      finally show "measure (Pi\<^isub>M J M) (Pi\<^isub>E J E) = measure (Pi\<^isub>M K M) ?X" .
hoelzl@42147
    89
    qed
hoelzl@42147
    90
  qed
hoelzl@42147
    91
  then show ?thesis
hoelzl@42147
    92
    by (simp add: product_algebra_def sigma_def)
hoelzl@42147
    93
qed
hoelzl@42147
    94
hoelzl@42147
    95
lemma (in product_prob_space) measurable_restrict:
hoelzl@42147
    96
  assumes *: "J \<noteq> {}" "J \<subseteq> K" "finite K"
hoelzl@42147
    97
  shows "(\<lambda>f. restrict f J) \<in> measurable (\<Pi>\<^isub>M i\<in>K. M i) (\<Pi>\<^isub>M i\<in>J. M i)"
hoelzl@42147
    98
  using measure_preserving_restrict[OF *]
hoelzl@42147
    99
  by (rule measure_preservingD2)
hoelzl@42147
   100
hoelzl@42147
   101
definition (in product_prob_space)
hoelzl@42147
   102
  "emb J K X = (\<lambda>x. restrict x K) -` X \<inter> space (Pi\<^isub>M J M)"
hoelzl@42147
   103
hoelzl@42147
   104
lemma (in product_prob_space) emb_trans[simp]:
hoelzl@42147
   105
  "J \<subseteq> K \<Longrightarrow> K \<subseteq> L \<Longrightarrow> emb L K (emb K J X) = emb L J X"
hoelzl@42147
   106
  by (auto simp add: Int_absorb1 emb_def)
hoelzl@42147
   107
hoelzl@42147
   108
lemma (in product_prob_space) emb_empty[simp]:
hoelzl@42147
   109
  "emb K J {} = {}"
hoelzl@42147
   110
  by (simp add: emb_def)
hoelzl@42147
   111
hoelzl@42147
   112
lemma (in product_prob_space) emb_Pi:
hoelzl@42147
   113
  assumes "X \<in> (\<Pi> j\<in>J. sets (M j))" "J \<subseteq> K"
hoelzl@42147
   114
  shows "emb K J (Pi\<^isub>E J X) = (\<Pi>\<^isub>E i\<in>K. if i \<in> J then X i else space (M i))"
hoelzl@42147
   115
  using assms space_closed
hoelzl@42147
   116
  by (auto simp: emb_def Pi_iff split: split_if_asm) blast+
hoelzl@42147
   117
hoelzl@42147
   118
lemma (in product_prob_space) emb_injective:
hoelzl@42147
   119
  assumes "J \<noteq> {}" "J \<subseteq> L" "finite J" and sets: "X \<in> sets (Pi\<^isub>M J M)" "Y \<in> sets (Pi\<^isub>M J M)"
hoelzl@42147
   120
  assumes "emb L J X = emb L J Y"
hoelzl@42147
   121
  shows "X = Y"
hoelzl@42147
   122
proof -
hoelzl@42147
   123
  interpret J: finite_product_sigma_finite M J by default fact
hoelzl@42147
   124
  show "X = Y"
hoelzl@42147
   125
  proof (rule injective_vimage_restrict)
hoelzl@42147
   126
    show "X \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))" "Y \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
hoelzl@42147
   127
      using J.sets_into_space sets by auto
hoelzl@42147
   128
    have "\<forall>i\<in>L. \<exists>x. x \<in> space (M i)"
hoelzl@42147
   129
      using M.not_empty by auto
hoelzl@42147
   130
    from bchoice[OF this]
hoelzl@42147
   131
    show "(\<Pi>\<^isub>E i\<in>L. space (M i)) \<noteq> {}" by auto
hoelzl@42147
   132
    show "(\<lambda>x. restrict x J) -` X \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i)) = (\<lambda>x. restrict x J) -` Y \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i))"
hoelzl@42147
   133
      using `emb L J X = emb L J Y` by (simp add: emb_def)
hoelzl@42147
   134
  qed fact
hoelzl@42147
   135
qed
hoelzl@42147
   136
hoelzl@42147
   137
lemma (in product_prob_space) emb_id:
hoelzl@42147
   138
  "B \<subseteq> (\<Pi>\<^isub>E i\<in>L. space (M i)) \<Longrightarrow> emb L L B = B"
hoelzl@42147
   139
  by (auto simp: emb_def Pi_iff subset_eq extensional_restrict)
hoelzl@42147
   140
hoelzl@42147
   141
lemma (in product_prob_space) emb_simps:
hoelzl@42147
   142
  shows "emb L K (A \<union> B) = emb L K A \<union> emb L K B"
hoelzl@42147
   143
    and "emb L K (A \<inter> B) = emb L K A \<inter> emb L K B"
hoelzl@42147
   144
    and "emb L K (A - B) = emb L K A - emb L K B"
hoelzl@42147
   145
  by (auto simp: emb_def)
hoelzl@42147
   146
hoelzl@42147
   147
lemma (in product_prob_space) measurable_emb[intro,simp]:
hoelzl@42147
   148
  assumes *: "J \<noteq> {}" "J \<subseteq> L" "finite L" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42147
   149
  shows "emb L J X \<in> sets (Pi\<^isub>M L M)"
hoelzl@42147
   150
  using measurable_restrict[THEN measurable_sets, OF *] by (simp add: emb_def)
hoelzl@42147
   151
hoelzl@42147
   152
lemma (in product_prob_space) measure_emb[intro,simp]:
hoelzl@42147
   153
  assumes *: "J \<noteq> {}" "J \<subseteq> L" "finite L" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42147
   154
  shows "measure (Pi\<^isub>M L M) (emb L J X) = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   155
  using measure_preserving_restrict[THEN measure_preservingD, OF *]
hoelzl@42147
   156
  by (simp add: emb_def)
hoelzl@42147
   157
hoelzl@42147
   158
definition (in product_prob_space) generator :: "('i \<Rightarrow> 'a) measure_space" where
hoelzl@42147
   159
  "generator = \<lparr>
hoelzl@42147
   160
    space = (\<Pi>\<^isub>E i\<in>I. space (M i)),
hoelzl@42147
   161
    sets = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M)),
hoelzl@42147
   162
    measure = undefined
hoelzl@42147
   163
  \<rparr>"
hoelzl@42147
   164
hoelzl@42147
   165
lemma (in product_prob_space) generatorI:
hoelzl@42147
   166
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> A = emb I J X \<Longrightarrow> A \<in> sets generator"
hoelzl@42147
   167
  unfolding generator_def by auto
hoelzl@42147
   168
hoelzl@42147
   169
lemma (in product_prob_space) generatorI':
hoelzl@42147
   170
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> emb I J X \<in> sets generator"
hoelzl@42147
   171
  unfolding generator_def by auto
hoelzl@42147
   172
hoelzl@42147
   173
lemma (in product_sigma_finite)
hoelzl@42147
   174
  assumes "I \<inter> J = {}" "finite I" "finite J" and A: "A \<in> sets (Pi\<^isub>M (I \<union> J) M)"
hoelzl@42147
   175
  shows measure_fold_integral:
hoelzl@42147
   176
    "measure (Pi\<^isub>M (I \<union> J) M) A = (\<integral>\<^isup>+x. measure (Pi\<^isub>M J M) (merge I x J -` A \<inter> space (Pi\<^isub>M J M)) \<partial>Pi\<^isub>M I M)" (is ?I)
hoelzl@42147
   177
    and measure_fold_measurable:
hoelzl@42147
   178
    "(\<lambda>x. measure (Pi\<^isub>M J M) (merge I x J -` A \<inter> space (Pi\<^isub>M J M))) \<in> borel_measurable (Pi\<^isub>M I M)" (is ?B)
hoelzl@42147
   179
proof -
hoelzl@42147
   180
  interpret I: finite_product_sigma_finite M I by default fact
hoelzl@42147
   181
  interpret J: finite_product_sigma_finite M J by default fact
hoelzl@42147
   182
  interpret IJ: pair_sigma_finite I.P J.P ..
hoelzl@42147
   183
  show ?I
hoelzl@42147
   184
    unfolding measure_fold[OF assms]
hoelzl@42147
   185
    apply (subst IJ.pair_measure_alt)
hoelzl@42147
   186
    apply (intro measurable_sets[OF _ A] measurable_merge assms)
hoelzl@42147
   187
    apply (auto simp: vimage_compose[symmetric] comp_def space_pair_measure
hoelzl@42147
   188
      intro!: I.positive_integral_cong)
hoelzl@42147
   189
    done
hoelzl@42147
   190
hoelzl@42147
   191
  have "(\<lambda>(x, y). merge I x J y) -` A \<inter> space (I.P \<Otimes>\<^isub>M J.P) \<in> sets (I.P \<Otimes>\<^isub>M J.P)"
hoelzl@42147
   192
    by (intro measurable_sets[OF _ A] measurable_merge assms)
hoelzl@42147
   193
  from IJ.measure_cut_measurable_fst[OF this]
hoelzl@42147
   194
  show ?B
hoelzl@42147
   195
    apply (auto simp: vimage_compose[symmetric] comp_def space_pair_measure)
hoelzl@42147
   196
    apply (subst (asm) measurable_cong)
hoelzl@42147
   197
    apply auto
hoelzl@42147
   198
    done
hoelzl@42147
   199
qed
hoelzl@42147
   200
hoelzl@42147
   201
definition (in product_prob_space)
hoelzl@42147
   202
  "\<mu>G A =
hoelzl@42147
   203
    (THE x. \<forall>J. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> J \<subseteq> I \<longrightarrow> (\<forall>X\<in>sets (Pi\<^isub>M J M). A = emb I J X \<longrightarrow> x = measure (Pi\<^isub>M J M) X))"
hoelzl@42147
   204
hoelzl@42147
   205
lemma (in product_prob_space) \<mu>G_spec:
hoelzl@42147
   206
  assumes J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42147
   207
  shows "\<mu>G A = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   208
  unfolding \<mu>G_def
hoelzl@42147
   209
proof (intro the_equality allI impI ballI)
hoelzl@42147
   210
  fix K Y assume K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "A = emb I K Y" "Y \<in> sets (Pi\<^isub>M K M)"
hoelzl@42147
   211
  have "measure (Pi\<^isub>M K M) Y = measure (Pi\<^isub>M (K \<union> J) M) (emb (K \<union> J) K Y)"
hoelzl@42147
   212
    using K J by simp
hoelzl@42147
   213
  also have "emb (K \<union> J) K Y = emb (K \<union> J) J X"
hoelzl@42147
   214
    using K J by (simp add: emb_injective[of "K \<union> J" I])
hoelzl@42147
   215
  also have "measure (Pi\<^isub>M (K \<union> J) M) (emb (K \<union> J) J X) = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   216
    using K J by simp
hoelzl@42147
   217
  finally show "measure (Pi\<^isub>M J M) X = measure (Pi\<^isub>M K M) Y" ..
hoelzl@42147
   218
qed (insert J, force)
hoelzl@42147
   219
hoelzl@42147
   220
lemma (in product_prob_space) \<mu>G_eq:
hoelzl@42147
   221
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> \<mu>G (emb I J X) = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   222
  by (intro \<mu>G_spec) auto
hoelzl@42147
   223
hoelzl@42147
   224
lemma (in product_prob_space) generator_Ex:
hoelzl@42147
   225
  assumes *: "A \<in> sets generator"
hoelzl@42147
   226
  shows "\<exists>J X. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I \<and> X \<in> sets (Pi\<^isub>M J M) \<and> A = emb I J X \<and> \<mu>G A = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   227
proof -
hoelzl@42147
   228
  from * obtain J X where J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42147
   229
    unfolding generator_def by auto
hoelzl@42147
   230
  with \<mu>G_spec[OF this] show ?thesis by auto
hoelzl@42147
   231
qed
hoelzl@42147
   232
hoelzl@42147
   233
lemma (in product_prob_space) generatorE:
hoelzl@42147
   234
  assumes A: "A \<in> sets generator"
hoelzl@42147
   235
  obtains J X where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A" "\<mu>G A = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   236
proof -
hoelzl@42147
   237
  from generator_Ex[OF A] obtain X J where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A"
hoelzl@42147
   238
    "\<mu>G A = measure (Pi\<^isub>M J M) X" by auto
hoelzl@42147
   239
  then show thesis by (intro that) auto
hoelzl@42147
   240
qed
hoelzl@42147
   241
hoelzl@42147
   242
lemma (in product_prob_space) merge_sets:
hoelzl@42147
   243
  assumes "finite J" "finite K" "J \<inter> K = {}" and A: "A \<in> sets (Pi\<^isub>M (J \<union> K) M)" and x: "x \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   244
  shows "merge J x K -` A \<inter> space (Pi\<^isub>M K M) \<in> sets (Pi\<^isub>M K M)"
hoelzl@42147
   245
proof -
hoelzl@42147
   246
  interpret J: finite_product_sigma_algebra M J by default fact
hoelzl@42147
   247
  interpret K: finite_product_sigma_algebra M K by default fact
hoelzl@42147
   248
  interpret JK: pair_sigma_algebra J.P K.P ..
hoelzl@42147
   249
hoelzl@42147
   250
  from JK.measurable_cut_fst[OF
hoelzl@42147
   251
    measurable_merge[THEN measurable_sets, OF `J \<inter> K = {}`], OF A, of x] x
hoelzl@42147
   252
  show ?thesis
hoelzl@42147
   253
      by (simp add: space_pair_measure comp_def vimage_compose[symmetric])
hoelzl@42147
   254
qed
hoelzl@42147
   255
hoelzl@42147
   256
lemma (in product_prob_space) merge_emb:
hoelzl@42147
   257
  assumes "K \<subseteq> I" "J \<subseteq> I" and y: "y \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   258
  shows "(merge J y (I - J) -` emb I K X \<inter> space (Pi\<^isub>M I M)) =
hoelzl@42147
   259
    emb I (K - J) (merge J y (K - J) -` emb (J \<union> K) K X \<inter> space (Pi\<^isub>M (K - J) M))"
hoelzl@42147
   260
proof -
hoelzl@42147
   261
  have [simp]: "\<And>x J K L. merge J y K (restrict x L) = merge J y (K \<inter> L) x"
hoelzl@42147
   262
    by (auto simp: restrict_def merge_def)
hoelzl@42147
   263
  have [simp]: "\<And>x J K L. restrict (merge J y K x) L = merge (J \<inter> L) y (K \<inter> L) x"
hoelzl@42147
   264
    by (auto simp: restrict_def merge_def)
hoelzl@42147
   265
  have [simp]: "(I - J) \<inter> K = K - J" using `K \<subseteq> I` `J \<subseteq> I` by auto
hoelzl@42147
   266
  have [simp]: "(K - J) \<inter> (K \<union> J) = K - J" by auto
hoelzl@42147
   267
  have [simp]: "(K - J) \<inter> K = K - J" by auto
hoelzl@42147
   268
  from y `K \<subseteq> I` `J \<subseteq> I` show ?thesis
hoelzl@42147
   269
    by (simp split: split_merge add: emb_def Pi_iff extensional_merge_sub set_eq_iff) auto
hoelzl@42147
   270
qed
hoelzl@42147
   271
hoelzl@42147
   272
definition (in product_prob_space) infprod_algebra :: "('i \<Rightarrow> 'a) measure_space" where
hoelzl@42147
   273
  "infprod_algebra = sigma generator \<lparr> measure :=
hoelzl@42147
   274
    (SOME \<mu>. (\<forall>s\<in>sets generator. \<mu> s = \<mu>G s) \<and>
hoelzl@45777
   275
       prob_space \<lparr>space = space generator, sets = sets (sigma generator), measure = \<mu>\<rparr>)\<rparr>"
hoelzl@42147
   276
hoelzl@42147
   277
syntax
hoelzl@42147
   278
  "_PiP"  :: "[pttrn, 'i set, ('b, 'd) measure_space_scheme] => ('i => 'b, 'd) measure_space_scheme"  ("(3PIP _:_./ _)" 10)
hoelzl@42147
   279
hoelzl@42147
   280
syntax (xsymbols)
hoelzl@42147
   281
  "_PiP" :: "[pttrn, 'i set, ('b, 'd) measure_space_scheme] => ('i => 'b, 'd) measure_space_scheme"  ("(3\<Pi>\<^isub>P _\<in>_./ _)"   10)
hoelzl@42147
   282
hoelzl@42147
   283
syntax (HTML output)
hoelzl@42147
   284
  "_PiP" :: "[pttrn, 'i set, ('b, 'd) measure_space_scheme] => ('i => 'b, 'd) measure_space_scheme"  ("(3\<Pi>\<^isub>P _\<in>_./ _)"   10)
hoelzl@42147
   285
hoelzl@42147
   286
abbreviation
hoelzl@42147
   287
  "Pi\<^isub>P I M \<equiv> product_prob_space.infprod_algebra M I"
hoelzl@42147
   288
hoelzl@42147
   289
translations
hoelzl@42147
   290
  "PIP x:I. M" == "CONST Pi\<^isub>P I (%x. M)"
hoelzl@42147
   291
hoelzl@45777
   292
lemma (in product_prob_space) algebra_generator:
hoelzl@45777
   293
  assumes "I \<noteq> {}" shows "algebra generator"
hoelzl@42147
   294
proof
hoelzl@42147
   295
  let ?G = generator
hoelzl@42147
   296
  show "sets ?G \<subseteq> Pow (space ?G)"
hoelzl@42147
   297
    by (auto simp: generator_def emb_def)
hoelzl@45777
   298
  from `I \<noteq> {}` obtain i where "i \<in> I" by auto
hoelzl@42147
   299
  then show "{} \<in> sets ?G"
hoelzl@42147
   300
    by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\<lambda>i. {}"]
hoelzl@42147
   301
      simp: product_algebra_def sigma_def sigma_sets.Empty generator_def emb_def)
hoelzl@42147
   302
  from `i \<in> I` show "space ?G \<in> sets ?G"
hoelzl@42147
   303
    by (auto intro!: exI[of _ "{i}"] image_eqI[where x="Pi\<^isub>E {i} (\<lambda>i. space (M i))"]
hoelzl@42147
   304
      simp: generator_def emb_def)
hoelzl@42147
   305
  fix A assume "A \<in> sets ?G"
hoelzl@42147
   306
  then obtain JA XA where XA: "JA \<noteq> {}" "finite JA" "JA \<subseteq> I" "XA \<in> sets (Pi\<^isub>M JA M)" and A: "A = emb I JA XA"
hoelzl@42147
   307
    by (auto simp: generator_def)
hoelzl@42147
   308
  fix B assume "B \<in> sets ?G"
hoelzl@42147
   309
  then obtain JB XB where XB: "JB \<noteq> {}" "finite JB" "JB \<subseteq> I" "XB \<in> sets (Pi\<^isub>M JB M)" and B: "B = emb I JB XB"
hoelzl@42147
   310
    by (auto simp: generator_def)
hoelzl@42147
   311
  let ?RA = "emb (JA \<union> JB) JA XA"
hoelzl@42147
   312
  let ?RB = "emb (JA \<union> JB) JB XB"
hoelzl@42147
   313
  interpret JAB: finite_product_sigma_algebra M "JA \<union> JB"
hoelzl@42147
   314
    by default (insert XA XB, auto)
hoelzl@42147
   315
  have *: "A - B = emb I (JA \<union> JB) (?RA - ?RB)" "A \<union> B = emb I (JA \<union> JB) (?RA \<union> ?RB)"
hoelzl@42147
   316
    using XA A XB B by (auto simp: emb_simps)
hoelzl@42147
   317
  then show "A - B \<in> sets ?G" "A \<union> B \<in> sets ?G"
hoelzl@42147
   318
    using XA XB by (auto intro!: generatorI')
hoelzl@42147
   319
qed
hoelzl@42147
   320
hoelzl@45777
   321
lemma (in product_prob_space) positive_\<mu>G: 
hoelzl@45777
   322
  assumes "I \<noteq> {}"
hoelzl@45777
   323
  shows "positive generator \<mu>G"
hoelzl@45777
   324
proof -
hoelzl@45777
   325
  interpret G!: algebra generator by (rule algebra_generator) fact
hoelzl@45777
   326
  show ?thesis
hoelzl@45777
   327
  proof (intro positive_def[THEN iffD2] conjI ballI)
hoelzl@45777
   328
    from generatorE[OF G.empty_sets] guess J X . note this[simp]
hoelzl@45777
   329
    interpret J: finite_product_sigma_finite M J by default fact
hoelzl@45777
   330
    have "X = {}"
hoelzl@45777
   331
      by (rule emb_injective[of J I]) simp_all
hoelzl@45777
   332
    then show "\<mu>G {} = 0" by simp
hoelzl@45777
   333
  next
hoelzl@45777
   334
    fix A assume "A \<in> sets generator"
hoelzl@45777
   335
    from generatorE[OF this] guess J X . note this[simp]
hoelzl@45777
   336
    interpret J: finite_product_sigma_finite M J by default fact
hoelzl@45777
   337
    show "0 \<le> \<mu>G A" by simp
hoelzl@45777
   338
  qed
hoelzl@42147
   339
qed
hoelzl@42147
   340
hoelzl@45777
   341
lemma (in product_prob_space) additive_\<mu>G: 
hoelzl@45777
   342
  assumes "I \<noteq> {}"
hoelzl@45777
   343
  shows "additive generator \<mu>G"
hoelzl@45777
   344
proof -
hoelzl@45777
   345
  interpret G!: algebra generator by (rule algebra_generator) fact
hoelzl@45777
   346
  show ?thesis
hoelzl@45777
   347
  proof (intro additive_def[THEN iffD2] ballI impI)
hoelzl@45777
   348
    fix A assume "A \<in> sets generator" with generatorE guess J X . note J = this
hoelzl@45777
   349
    fix B assume "B \<in> sets generator" with generatorE guess K Y . note K = this
hoelzl@45777
   350
    assume "A \<inter> B = {}"
hoelzl@45777
   351
    have JK: "J \<union> K \<noteq> {}" "J \<union> K \<subseteq> I" "finite (J \<union> K)"
hoelzl@45777
   352
      using J K by auto
hoelzl@45777
   353
    interpret JK: finite_product_sigma_finite M "J \<union> K" by default fact
hoelzl@45777
   354
    have JK_disj: "emb (J \<union> K) J X \<inter> emb (J \<union> K) K Y = {}"
hoelzl@45777
   355
      apply (rule emb_injective[of "J \<union> K" I])
hoelzl@45777
   356
      apply (insert `A \<inter> B = {}` JK J K)
hoelzl@45777
   357
      apply (simp_all add: JK.Int emb_simps)
hoelzl@45777
   358
      done
hoelzl@45777
   359
    have AB: "A = emb I (J \<union> K) (emb (J \<union> K) J X)" "B = emb I (J \<union> K) (emb (J \<union> K) K Y)"
hoelzl@45777
   360
      using J K by simp_all
hoelzl@45777
   361
    then have "\<mu>G (A \<union> B) = \<mu>G (emb I (J \<union> K) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y))"
hoelzl@45777
   362
      by (simp add: emb_simps)
hoelzl@45777
   363
    also have "\<dots> = measure (Pi\<^isub>M (J \<union> K) M) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y)"
hoelzl@45777
   364
      using JK J(1, 4) K(1, 4) by (simp add: \<mu>G_eq JK.Un)
hoelzl@45777
   365
    also have "\<dots> = \<mu>G A + \<mu>G B"
hoelzl@45777
   366
      using J K JK_disj by (simp add: JK.measure_additive[symmetric])
hoelzl@45777
   367
    finally show "\<mu>G (A \<union> B) = \<mu>G A + \<mu>G B" .
hoelzl@45777
   368
  qed
hoelzl@42147
   369
qed
hoelzl@42147
   370
hoelzl@42147
   371
lemma (in product_prob_space) finite_index_eq_finite_product:
hoelzl@42147
   372
  assumes "finite I"
hoelzl@42147
   373
  shows "sets (sigma generator) = sets (Pi\<^isub>M I M)"
hoelzl@42147
   374
proof safe
hoelzl@42147
   375
  interpret I: finite_product_sigma_algebra M I by default fact
hoelzl@45777
   376
  have space_generator[simp]: "space generator = space (Pi\<^isub>M I M)"
hoelzl@42147
   377
    by (simp add: generator_def product_algebra_def)
hoelzl@42147
   378
  { fix A assume "A \<in> sets (sigma generator)"
hoelzl@42147
   379
    then show "A \<in> sets I.P" unfolding sets_sigma
hoelzl@42147
   380
    proof induct
hoelzl@42147
   381
      case (Basic A)
hoelzl@42147
   382
      from generatorE[OF this] guess J X . note J = this
hoelzl@42147
   383
      with `finite I` have "emb I J X \<in> sets I.P" by auto
hoelzl@42147
   384
      with `emb I J X = A` show "A \<in> sets I.P" by simp
hoelzl@42147
   385
    qed auto }
hoelzl@45777
   386
  { fix A assume A: "A \<in> sets I.P"
hoelzl@45777
   387
    show "A \<in> sets (sigma generator)"
hoelzl@45777
   388
    proof cases
hoelzl@45777
   389
      assume "I = {}"
hoelzl@45777
   390
      with I.P_empty[OF this] A
hoelzl@45777
   391
      have "A = space generator \<or> A = {}" 
hoelzl@45777
   392
        unfolding space_generator by auto
hoelzl@45777
   393
      then show ?thesis
hoelzl@45777
   394
        by (auto simp: sets_sigma simp del: space_generator
hoelzl@45777
   395
                 intro: sigma_sets.Empty sigma_sets_top)
hoelzl@45777
   396
    next
hoelzl@45777
   397
      assume "I \<noteq> {}"
hoelzl@45777
   398
      note A this
hoelzl@45777
   399
      moreover with I.sets_into_space have "emb I I A = A" by (intro emb_id) auto
hoelzl@45777
   400
      ultimately show "A \<in> sets (sigma generator)"
hoelzl@45777
   401
        using `finite I` unfolding sets_sigma
hoelzl@45777
   402
        by (intro sigma_sets.Basic generatorI[of I A]) auto
hoelzl@45777
   403
  qed }
hoelzl@42147
   404
qed
hoelzl@42147
   405
hoelzl@42147
   406
lemma (in product_prob_space) extend_\<mu>G:
hoelzl@42147
   407
  "\<exists>\<mu>. (\<forall>s\<in>sets generator. \<mu> s = \<mu>G s) \<and>
hoelzl@45777
   408
       prob_space \<lparr>space = space generator, sets = sets (sigma generator), measure = \<mu>\<rparr>"
hoelzl@42147
   409
proof cases
hoelzl@42147
   410
  assume "finite I"
hoelzl@45777
   411
  interpret I: finite_product_prob_space M I by default fact
hoelzl@42147
   412
  show ?thesis
hoelzl@42147
   413
  proof (intro exI[of _ "measure (Pi\<^isub>M I M)"] ballI conjI)
hoelzl@42147
   414
    fix A assume "A \<in> sets generator"
hoelzl@42147
   415
    from generatorE[OF this] guess J X . note J = this
hoelzl@42147
   416
    from J(1-4) `finite I` show "measure I.P A = \<mu>G A"
hoelzl@42147
   417
      unfolding J(6)
hoelzl@42147
   418
      by (subst J(5)[symmetric]) (simp add: measure_emb)
hoelzl@42147
   419
  next
hoelzl@42147
   420
    have [simp]: "space generator = space (Pi\<^isub>M I M)"
hoelzl@42147
   421
      by (simp add: generator_def product_algebra_def)
hoelzl@42147
   422
    have "\<lparr>space = space generator, sets = sets (sigma generator), measure = measure I.P\<rparr>
hoelzl@42147
   423
      = I.P" (is "?P = _")
hoelzl@42147
   424
      by (auto intro!: measure_space.equality simp: finite_index_eq_finite_product[OF `finite I`])
hoelzl@45777
   425
    show "prob_space ?P"
hoelzl@45777
   426
    proof
hoelzl@45777
   427
      show "measure_space ?P" using `?P = I.P` by simp default
hoelzl@45777
   428
      show "measure ?P (space ?P) = 1"
hoelzl@45777
   429
        using I.measure_space_1 by simp
hoelzl@45777
   430
    qed
hoelzl@42147
   431
  qed
hoelzl@42147
   432
next
hoelzl@42147
   433
  let ?G = generator
hoelzl@42147
   434
  assume "\<not> finite I"
hoelzl@45777
   435
  then have I_not_empty: "I \<noteq> {}" by auto
hoelzl@45777
   436
  interpret G!: algebra generator by (rule algebra_generator) fact
hoelzl@42147
   437
  note \<mu>G_mono =
hoelzl@45777
   438
    G.additive_increasing[OF positive_\<mu>G[OF I_not_empty] additive_\<mu>G[OF I_not_empty], THEN increasingD]
hoelzl@42147
   439
hoelzl@42147
   440
  { fix Z J assume J: "J \<noteq> {}" "finite J" "J \<subseteq> I" and Z: "Z \<in> sets ?G"
hoelzl@42147
   441
hoelzl@42147
   442
    from `infinite I` `finite J` obtain k where k: "k \<in> I" "k \<notin> J"
hoelzl@42147
   443
      by (metis rev_finite_subset subsetI)
hoelzl@42147
   444
    moreover from Z guess K' X' by (rule generatorE)
hoelzl@42147
   445
    moreover def K \<equiv> "insert k K'"
hoelzl@42147
   446
    moreover def X \<equiv> "emb K K' X'"
hoelzl@42147
   447
    ultimately have K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "X \<in> sets (Pi\<^isub>M K M)" "Z = emb I K X"
hoelzl@42147
   448
      "K - J \<noteq> {}" "K - J \<subseteq> I" "\<mu>G Z = measure (Pi\<^isub>M K M) X"
hoelzl@42147
   449
      by (auto simp: subset_insertI)
hoelzl@42147
   450
wenzelm@46731
   451
    let ?M = "\<lambda>y. merge J y (K - J) -` emb (J \<union> K) K X \<inter> space (Pi\<^isub>M (K - J) M)"
hoelzl@42147
   452
    { fix y assume y: "y \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   453
      note * = merge_emb[OF `K \<subseteq> I` `J \<subseteq> I` y, of X]
hoelzl@42147
   454
      moreover
hoelzl@42147
   455
      have **: "?M y \<in> sets (Pi\<^isub>M (K - J) M)"
hoelzl@42147
   456
        using J K y by (intro merge_sets) auto
hoelzl@42147
   457
      ultimately
hoelzl@42147
   458
      have ***: "(merge J y (I - J) -` Z \<inter> space (Pi\<^isub>M I M)) \<in> sets ?G"
hoelzl@42147
   459
        using J K by (intro generatorI) auto
hoelzl@42147
   460
      have "\<mu>G (merge J y (I - J) -` emb I K X \<inter> space (Pi\<^isub>M I M)) = measure (Pi\<^isub>M (K - J) M) (?M y)"
hoelzl@42147
   461
        unfolding * using K J by (subst \<mu>G_eq[OF _ _ _ **]) auto
hoelzl@42147
   462
      note * ** *** this }
hoelzl@42147
   463
    note merge_in_G = this
hoelzl@42147
   464
hoelzl@42147
   465
    have "finite (K - J)" using K by auto
hoelzl@42147
   466
hoelzl@42147
   467
    interpret J: finite_product_prob_space M J by default fact+
hoelzl@42147
   468
    interpret KmJ: finite_product_prob_space M "K - J" by default fact+
hoelzl@42147
   469
hoelzl@42147
   470
    have "\<mu>G Z = measure (Pi\<^isub>M (J \<union> (K - J)) M) (emb (J \<union> (K - J)) K X)"
hoelzl@42147
   471
      using K J by simp
hoelzl@42147
   472
    also have "\<dots> = (\<integral>\<^isup>+ x. measure (Pi\<^isub>M (K - J) M) (?M x) \<partial>Pi\<^isub>M J M)"
hoelzl@42147
   473
      using K J by (subst measure_fold_integral) auto
hoelzl@42147
   474
    also have "\<dots> = (\<integral>\<^isup>+ y. \<mu>G (merge J y (I - J) -` Z \<inter> space (Pi\<^isub>M I M)) \<partial>Pi\<^isub>M J M)"
hoelzl@42147
   475
      (is "_ = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)")
hoelzl@42147
   476
    proof (intro J.positive_integral_cong)
hoelzl@42147
   477
      fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   478
      with K merge_in_G(2)[OF this]
hoelzl@42147
   479
      show "measure (Pi\<^isub>M (K - J) M) (?M x) = \<mu>G (?MZ x)"
hoelzl@42147
   480
        unfolding `Z = emb I K X` merge_in_G(1)[OF x] by (subst \<mu>G_eq) auto
hoelzl@42147
   481
    qed
hoelzl@42147
   482
    finally have fold: "\<mu>G Z = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)" .
hoelzl@42147
   483
hoelzl@42147
   484
    { fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   485
      then have "\<mu>G (?MZ x) \<le> 1"
hoelzl@42147
   486
        unfolding merge_in_G(4)[OF x] `Z = emb I K X`
hoelzl@42147
   487
        by (intro KmJ.measure_le_1 merge_in_G(2)[OF x]) }
hoelzl@42147
   488
    note le_1 = this
hoelzl@42147
   489
wenzelm@46731
   490
    let ?q = "\<lambda>y. \<mu>G (merge J y (I - J) -` Z \<inter> space (Pi\<^isub>M I M))"
hoelzl@42147
   491
    have "?q \<in> borel_measurable (Pi\<^isub>M J M)"
hoelzl@42147
   492
      unfolding `Z = emb I K X` using J K merge_in_G(3)
hoelzl@42147
   493
      by (simp add: merge_in_G  \<mu>G_eq measure_fold_measurable
hoelzl@42147
   494
               del: space_product_algebra cong: measurable_cong)
hoelzl@42147
   495
    note this fold le_1 merge_in_G(3) }
hoelzl@42147
   496
  note fold = this
hoelzl@42147
   497
hoelzl@45777
   498
  have "\<exists>\<mu>. (\<forall>s\<in>sets ?G. \<mu> s = \<mu>G s) \<and>
hoelzl@45777
   499
    measure_space \<lparr>space = space ?G, sets = sets (sigma ?G), measure = \<mu>\<rparr>"
hoelzl@45777
   500
    (is "\<exists>\<mu>. _ \<and> measure_space (?ms \<mu>)")
hoelzl@42147
   501
  proof (rule G.caratheodory_empty_continuous[OF positive_\<mu>G additive_\<mu>G])
hoelzl@42147
   502
    fix A assume "A \<in> sets ?G"
hoelzl@42147
   503
    with generatorE guess J X . note JX = this
hoelzl@42147
   504
    interpret JK: finite_product_prob_space M J by default fact+
wenzelm@46898
   505
    from JX show "\<mu>G A \<noteq> \<infinity>" by simp
hoelzl@42147
   506
  next
hoelzl@42147
   507
    fix A assume A: "range A \<subseteq> sets ?G" "decseq A" "(\<Inter>i. A i) = {}"
hoelzl@42147
   508
    then have "decseq (\<lambda>i. \<mu>G (A i))"
hoelzl@42147
   509
      by (auto intro!: \<mu>G_mono simp: decseq_def)
hoelzl@42147
   510
    moreover
hoelzl@42147
   511
    have "(INF i. \<mu>G (A i)) = 0"
hoelzl@42147
   512
    proof (rule ccontr)
hoelzl@42147
   513
      assume "(INF i. \<mu>G (A i)) \<noteq> 0" (is "?a \<noteq> 0")
hoelzl@42147
   514
      moreover have "0 \<le> ?a"
hoelzl@45777
   515
        using A positive_\<mu>G[OF I_not_empty] by (auto intro!: INF_greatest simp: positive_def)
hoelzl@42147
   516
      ultimately have "0 < ?a" by auto
hoelzl@42147
   517
hoelzl@42147
   518
      have "\<forall>n. \<exists>J X. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I \<and> X \<in> sets (Pi\<^isub>M J M) \<and> A n = emb I J X \<and> \<mu>G (A n) = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   519
        using A by (intro allI generator_Ex) auto
hoelzl@42147
   520
      then obtain J' X' where J': "\<And>n. J' n \<noteq> {}" "\<And>n. finite (J' n)" "\<And>n. J' n \<subseteq> I" "\<And>n. X' n \<in> sets (Pi\<^isub>M (J' n) M)"
hoelzl@42147
   521
        and A': "\<And>n. A n = emb I (J' n) (X' n)"
hoelzl@42147
   522
        unfolding choice_iff by blast
hoelzl@42147
   523
      moreover def J \<equiv> "\<lambda>n. (\<Union>i\<le>n. J' i)"
hoelzl@42147
   524
      moreover def X \<equiv> "\<lambda>n. emb (J n) (J' n) (X' n)"
hoelzl@42147
   525
      ultimately have J: "\<And>n. J n \<noteq> {}" "\<And>n. finite (J n)" "\<And>n. J n \<subseteq> I" "\<And>n. X n \<in> sets (Pi\<^isub>M (J n) M)"
hoelzl@42147
   526
        by auto
hoelzl@42147
   527
      with A' have A_eq: "\<And>n. A n = emb I (J n) (X n)" "\<And>n. A n \<in> sets ?G"
hoelzl@42147
   528
        unfolding J_def X_def by (subst emb_trans) (insert A, auto)
hoelzl@42147
   529
hoelzl@42147
   530
      have J_mono: "\<And>n m. n \<le> m \<Longrightarrow> J n \<subseteq> J m"
hoelzl@42147
   531
        unfolding J_def by force
hoelzl@42147
   532
hoelzl@42147
   533
      interpret J: finite_product_prob_space M "J i" for i by default fact+
hoelzl@42147
   534
hoelzl@42147
   535
      have a_le_1: "?a \<le> 1"
hoelzl@42147
   536
        using \<mu>G_spec[of "J 0" "A 0" "X 0"] J A_eq
hoelzl@44928
   537
        by (auto intro!: INF_lower2[of 0] J.measure_le_1)
hoelzl@42147
   538
wenzelm@46731
   539
      let ?M = "\<lambda>K Z y. merge K y (I - K) -` Z \<inter> space (Pi\<^isub>M I M)"
hoelzl@42147
   540
hoelzl@42147
   541
      { fix Z k assume Z: "range Z \<subseteq> sets ?G" "decseq Z" "\<forall>n. ?a / 2^k \<le> \<mu>G (Z n)"
hoelzl@42147
   542
        then have Z_sets: "\<And>n. Z n \<in> sets ?G" by auto
hoelzl@42147
   543
        fix J' assume J': "J' \<noteq> {}" "finite J'" "J' \<subseteq> I"
hoelzl@42147
   544
        interpret J': finite_product_prob_space M J' by default fact+
hoelzl@42147
   545
wenzelm@46731
   546
        let ?q = "\<lambda>n y. \<mu>G (?M J' (Z n) y)"
wenzelm@46731
   547
        let ?Q = "\<lambda>n. ?q n -` {?a / 2^(k+1) ..} \<inter> space (Pi\<^isub>M J' M)"
hoelzl@42147
   548
        { fix n
hoelzl@42147
   549
          have "?q n \<in> borel_measurable (Pi\<^isub>M J' M)"
hoelzl@42147
   550
            using Z J' by (intro fold(1)) auto
hoelzl@42147
   551
          then have "?Q n \<in> sets (Pi\<^isub>M J' M)"
hoelzl@42147
   552
            by (rule measurable_sets) auto }
hoelzl@42147
   553
        note Q_sets = this
hoelzl@42147
   554
hoelzl@42147
   555
        have "?a / 2^(k+1) \<le> (INF n. measure (Pi\<^isub>M J' M) (?Q n))"
hoelzl@44928
   556
        proof (intro INF_greatest)
hoelzl@42147
   557
          fix n
hoelzl@42147
   558
          have "?a / 2^k \<le> \<mu>G (Z n)" using Z by auto
hoelzl@42147
   559
          also have "\<dots> \<le> (\<integral>\<^isup>+ x. indicator (?Q n) x + ?a / 2^(k+1) \<partial>Pi\<^isub>M J' M)"
hoelzl@42147
   560
            unfolding fold(2)[OF J' `Z n \<in> sets ?G`]
hoelzl@42147
   561
          proof (intro J'.positive_integral_mono)
hoelzl@42147
   562
            fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
hoelzl@42147
   563
            then have "?q n x \<le> 1 + 0"
hoelzl@42147
   564
              using J' Z fold(3) Z_sets by auto
hoelzl@42147
   565
            also have "\<dots> \<le> 1 + ?a / 2^(k+1)"
hoelzl@42147
   566
              using `0 < ?a` by (intro add_mono) auto
hoelzl@42147
   567
            finally have "?q n x \<le> 1 + ?a / 2^(k+1)" .
hoelzl@42147
   568
            with x show "?q n x \<le> indicator (?Q n) x + ?a / 2^(k+1)"
hoelzl@42147
   569
              by (auto split: split_indicator simp del: power_Suc)
hoelzl@42147
   570
          qed
hoelzl@42147
   571
          also have "\<dots> = measure (Pi\<^isub>M J' M) (?Q n) + ?a / 2^(k+1)"
hoelzl@42147
   572
            using `0 \<le> ?a` Q_sets J'.measure_space_1
hoelzl@42147
   573
            by (subst J'.positive_integral_add) auto
hoelzl@42147
   574
          finally show "?a / 2^(k+1) \<le> measure (Pi\<^isub>M J' M) (?Q n)" using `?a \<le> 1`
hoelzl@43920
   575
            by (cases rule: ereal2_cases[of ?a "measure (Pi\<^isub>M J' M) (?Q n)"])
hoelzl@42147
   576
               (auto simp: field_simps)
hoelzl@42147
   577
        qed
hoelzl@42147
   578
        also have "\<dots> = measure (Pi\<^isub>M J' M) (\<Inter>n. ?Q n)"
hoelzl@42147
   579
        proof (intro J'.continuity_from_above)
hoelzl@42147
   580
          show "range ?Q \<subseteq> sets (Pi\<^isub>M J' M)" using Q_sets by auto
hoelzl@42147
   581
          show "decseq ?Q"
hoelzl@42147
   582
            unfolding decseq_def
hoelzl@42147
   583
          proof (safe intro!: vimageI[OF refl])
hoelzl@42147
   584
            fix m n :: nat assume "m \<le> n"
hoelzl@42147
   585
            fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
hoelzl@42147
   586
            assume "?a / 2^(k+1) \<le> ?q n x"
hoelzl@42147
   587
            also have "?q n x \<le> ?q m x"
hoelzl@42147
   588
            proof (rule \<mu>G_mono)
hoelzl@42147
   589
              from fold(4)[OF J', OF Z_sets x]
hoelzl@42147
   590
              show "?M J' (Z n) x \<in> sets ?G" "?M J' (Z m) x \<in> sets ?G" by auto
hoelzl@42147
   591
              show "?M J' (Z n) x \<subseteq> ?M J' (Z m) x"
hoelzl@42147
   592
                using `decseq Z`[THEN decseqD, OF `m \<le> n`] by auto
hoelzl@42147
   593
            qed
hoelzl@42147
   594
            finally show "?a / 2^(k+1) \<le> ?q m x" .
hoelzl@42147
   595
          qed
hoelzl@42147
   596
        qed (intro J'.finite_measure Q_sets)
hoelzl@42147
   597
        finally have "(\<Inter>n. ?Q n) \<noteq> {}"
hoelzl@42147
   598
          using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
hoelzl@42147
   599
        then have "\<exists>w\<in>space (Pi\<^isub>M J' M). \<forall>n. ?a / 2 ^ (k + 1) \<le> ?q n w" by auto }
hoelzl@42147
   600
      note Ex_w = this
hoelzl@42147
   601
wenzelm@46731
   602
      let ?q = "\<lambda>k n y. \<mu>G (?M (J k) (A n) y)"
hoelzl@42147
   603
hoelzl@44928
   604
      have "\<forall>n. ?a / 2 ^ 0 \<le> \<mu>G (A n)" by (auto intro: INF_lower)
hoelzl@42147
   605
      from Ex_w[OF A(1,2) this J(1-3), of 0] guess w0 .. note w0 = this
hoelzl@42147
   606
wenzelm@46731
   607
      let ?P =
wenzelm@46731
   608
        "\<lambda>k wk w. w \<in> space (Pi\<^isub>M (J (Suc k)) M) \<and> restrict w (J k) = wk \<and>
wenzelm@46731
   609
          (\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n w)"
hoelzl@42147
   610
      def w \<equiv> "nat_rec w0 (\<lambda>k wk. Eps (?P k wk))"
hoelzl@42147
   611
hoelzl@42147
   612
      { fix k have w: "w k \<in> space (Pi\<^isub>M (J k) M) \<and>
hoelzl@42147
   613
          (\<forall>n. ?a / 2 ^ (k + 1) \<le> ?q k n (w k)) \<and> (k \<noteq> 0 \<longrightarrow> restrict (w k) (J (k - 1)) = w (k - 1))"
hoelzl@42147
   614
        proof (induct k)
hoelzl@42147
   615
          case 0 with w0 show ?case
hoelzl@42147
   616
            unfolding w_def nat_rec_0 by auto
hoelzl@42147
   617
        next
hoelzl@42147
   618
          case (Suc k)
hoelzl@42147
   619
          then have wk: "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
hoelzl@42147
   620
          have "\<exists>w'. ?P k (w k) w'"
hoelzl@42147
   621
          proof cases
hoelzl@42147
   622
            assume [simp]: "J k = J (Suc k)"
hoelzl@42147
   623
            show ?thesis
hoelzl@42147
   624
            proof (intro exI[of _ "w k"] conjI allI)
hoelzl@42147
   625
              fix n
hoelzl@42147
   626
              have "?a / 2 ^ (Suc k + 1) \<le> ?a / 2 ^ (k + 1)"
hoelzl@42147
   627
                using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: field_simps)
hoelzl@42147
   628
              also have "\<dots> \<le> ?q k n (w k)" using Suc by auto
hoelzl@42147
   629
              finally show "?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n (w k)" by simp
hoelzl@42147
   630
            next
hoelzl@42147
   631
              show "w k \<in> space (Pi\<^isub>M (J (Suc k)) M)"
hoelzl@42147
   632
                using Suc by simp
hoelzl@42147
   633
              then show "restrict (w k) (J k) = w k"
hoelzl@42147
   634
                by (simp add: extensional_restrict)
hoelzl@42147
   635
            qed
hoelzl@42147
   636
          next
hoelzl@42147
   637
            assume "J k \<noteq> J (Suc k)"
hoelzl@42147
   638
            with J_mono[of k "Suc k"] have "J (Suc k) - J k \<noteq> {}" (is "?D \<noteq> {}") by auto
hoelzl@42147
   639
            have "range (\<lambda>n. ?M (J k) (A n) (w k)) \<subseteq> sets ?G"
hoelzl@42147
   640
              "decseq (\<lambda>n. ?M (J k) (A n) (w k))"
hoelzl@42147
   641
              "\<forall>n. ?a / 2 ^ (k + 1) \<le> \<mu>G (?M (J k) (A n) (w k))"
hoelzl@42147
   642
              using `decseq A` fold(4)[OF J(1-3) A_eq(2), of "w k" k] Suc
hoelzl@42147
   643
              by (auto simp: decseq_def)
hoelzl@42147
   644
            from Ex_w[OF this `?D \<noteq> {}`] J[of "Suc k"]
hoelzl@42147
   645
            obtain w' where w': "w' \<in> space (Pi\<^isub>M ?D M)"
hoelzl@42147
   646
              "\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> \<mu>G (?M ?D (?M (J k) (A n) (w k)) w')" by auto
hoelzl@42147
   647
            let ?w = "merge (J k) (w k) ?D w'"
hoelzl@42147
   648
            have [simp]: "\<And>x. merge (J k) (w k) (I - J k) (merge ?D w' (I - ?D) x) =
hoelzl@42147
   649
              merge (J (Suc k)) ?w (I - (J (Suc k))) x"
hoelzl@42147
   650
              using J(3)[of "Suc k"] J(3)[of k] J_mono[of k "Suc k"]
hoelzl@42147
   651
              by (auto intro!: ext split: split_merge)
hoelzl@42147
   652
            have *: "\<And>n. ?M ?D (?M (J k) (A n) (w k)) w' = ?M (J (Suc k)) (A n) ?w"
hoelzl@42147
   653
              using w'(1) J(3)[of "Suc k"]
hoelzl@42147
   654
              by (auto split: split_merge intro!: extensional_merge_sub) force+
hoelzl@42147
   655
            show ?thesis
hoelzl@42147
   656
              apply (rule exI[of _ ?w])
hoelzl@42147
   657
              using w' J_mono[of k "Suc k"] wk unfolding *
hoelzl@42147
   658
              apply (auto split: split_merge intro!: extensional_merge_sub ext)
hoelzl@42147
   659
              apply (force simp: extensional_def)
hoelzl@42147
   660
              done
hoelzl@42147
   661
          qed
hoelzl@42147
   662
          then have "?P k (w k) (w (Suc k))"
hoelzl@42147
   663
            unfolding w_def nat_rec_Suc unfolding w_def[symmetric]
hoelzl@42147
   664
            by (rule someI_ex)
hoelzl@42147
   665
          then show ?case by auto
hoelzl@42147
   666
        qed
hoelzl@42147
   667
        moreover
hoelzl@42147
   668
        then have "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
hoelzl@42147
   669
        moreover
hoelzl@42147
   670
        from w have "?a / 2 ^ (k + 1) \<le> ?q k k (w k)" by auto
hoelzl@42147
   671
        then have "?M (J k) (A k) (w k) \<noteq> {}"
hoelzl@45777
   672
          using positive_\<mu>G[OF I_not_empty, unfolded positive_def] `0 < ?a` `?a \<le> 1`
hoelzl@42147
   673
          by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
hoelzl@42147
   674
        then obtain x where "x \<in> ?M (J k) (A k) (w k)" by auto
hoelzl@42147
   675
        then have "merge (J k) (w k) (I - J k) x \<in> A k" by auto
hoelzl@42147
   676
        then have "\<exists>x\<in>A k. restrict x (J k) = w k"
hoelzl@42147
   677
          using `w k \<in> space (Pi\<^isub>M (J k) M)`
hoelzl@42147
   678
          by (intro rev_bexI) (auto intro!: ext simp: extensional_def)
hoelzl@42147
   679
        ultimately have "w k \<in> space (Pi\<^isub>M (J k) M)"
hoelzl@42147
   680
          "\<exists>x\<in>A k. restrict x (J k) = w k"
hoelzl@42147
   681
          "k \<noteq> 0 \<Longrightarrow> restrict (w k) (J (k - 1)) = w (k - 1)"
hoelzl@42147
   682
          by auto }
hoelzl@42147
   683
      note w = this
hoelzl@42147
   684
hoelzl@42147
   685
      { fix k l i assume "k \<le> l" "i \<in> J k"
hoelzl@42147
   686
        { fix l have "w k i = w (k + l) i"
hoelzl@42147
   687
          proof (induct l)
hoelzl@42147
   688
            case (Suc l)
hoelzl@42147
   689
            from `i \<in> J k` J_mono[of k "k + l"] have "i \<in> J (k + l)" by auto
hoelzl@42147
   690
            with w(3)[of "k + Suc l"]
hoelzl@42147
   691
            have "w (k + l) i = w (k + Suc l) i"
hoelzl@42147
   692
              by (auto simp: restrict_def fun_eq_iff split: split_if_asm)
hoelzl@42147
   693
            with Suc show ?case by simp
hoelzl@42147
   694
          qed simp }
hoelzl@42147
   695
        from this[of "l - k"] `k \<le> l` have "w l i = w k i" by simp }
hoelzl@42147
   696
      note w_mono = this
hoelzl@42147
   697
hoelzl@42147
   698
      def w' \<equiv> "\<lambda>i. if i \<in> (\<Union>k. J k) then w (LEAST k. i \<in> J k) i else if i \<in> I then (SOME x. x \<in> space (M i)) else undefined"
hoelzl@42147
   699
      { fix i k assume k: "i \<in> J k"
hoelzl@42147
   700
        have "w k i = w (LEAST k. i \<in> J k) i"
hoelzl@42147
   701
          by (intro w_mono Least_le k LeastI[of _ k])
hoelzl@42147
   702
        then have "w' i = w k i"
hoelzl@42147
   703
          unfolding w'_def using k by auto }
hoelzl@42147
   704
      note w'_eq = this
hoelzl@42147
   705
      have w'_simps1: "\<And>i. i \<notin> I \<Longrightarrow> w' i = undefined"
hoelzl@42147
   706
        using J by (auto simp: w'_def)
hoelzl@42147
   707
      have w'_simps2: "\<And>i. i \<notin> (\<Union>k. J k) \<Longrightarrow> i \<in> I \<Longrightarrow> w' i \<in> space (M i)"
hoelzl@42147
   708
        using J by (auto simp: w'_def intro!: someI_ex[OF M.not_empty[unfolded ex_in_conv[symmetric]]])
hoelzl@42147
   709
      { fix i assume "i \<in> I" then have "w' i \<in> space (M i)"
hoelzl@42147
   710
          using w(1) by (cases "i \<in> (\<Union>k. J k)") (force simp: w'_simps2 w'_eq)+ }
hoelzl@42147
   711
      note w'_simps[simp] = w'_eq w'_simps1 w'_simps2 this
hoelzl@42147
   712
hoelzl@42147
   713
      have w': "w' \<in> space (Pi\<^isub>M I M)"
hoelzl@42147
   714
        using w(1) by (auto simp add: Pi_iff extensional_def)
hoelzl@42147
   715
hoelzl@42147
   716
      { fix n
hoelzl@42147
   717
        have "restrict w' (J n) = w n" using w(1)
hoelzl@42147
   718
          by (auto simp add: fun_eq_iff restrict_def Pi_iff extensional_def)
hoelzl@42147
   719
        with w[of n] obtain x where "x \<in> A n" "restrict x (J n) = restrict w' (J n)" by auto
hoelzl@42147
   720
        then have "w' \<in> A n" unfolding A_eq using w' by (auto simp: emb_def) }
hoelzl@42147
   721
      then have "w' \<in> (\<Inter>i. A i)" by auto
hoelzl@42147
   722
      with `(\<Inter>i. A i) = {}` show False by auto
hoelzl@42147
   723
    qed
hoelzl@42147
   724
    ultimately show "(\<lambda>i. \<mu>G (A i)) ----> 0"
hoelzl@43920
   725
      using LIMSEQ_ereal_INFI[of "\<lambda>i. \<mu>G (A i)"] by simp
hoelzl@45777
   726
  qed fact+
hoelzl@45777
   727
  then guess \<mu> .. note \<mu> = this
hoelzl@45777
   728
  show ?thesis
hoelzl@45777
   729
  proof (intro exI[of _ \<mu>] conjI)
hoelzl@45777
   730
    show "\<forall>S\<in>sets ?G. \<mu> S = \<mu>G S" using \<mu> by simp
hoelzl@45777
   731
    show "prob_space (?ms \<mu>)"
hoelzl@45777
   732
    proof
hoelzl@45777
   733
      show "measure_space (?ms \<mu>)" using \<mu> by simp
hoelzl@45777
   734
      obtain i where "i \<in> I" using I_not_empty by auto
hoelzl@45777
   735
      interpret i: finite_product_sigma_finite M "{i}" by default auto
hoelzl@45777
   736
      let ?X = "\<Pi>\<^isub>E i\<in>{i}. space (M i)"
hoelzl@45777
   737
      have X: "?X \<in> sets (Pi\<^isub>M {i} M)"
hoelzl@45777
   738
        by auto
hoelzl@45777
   739
      with `i \<in> I` have "emb I {i} ?X \<in> sets generator"
hoelzl@45777
   740
        by (intro generatorI') auto
hoelzl@45777
   741
      with \<mu> have "\<mu> (emb I {i} ?X) = \<mu>G (emb I {i} ?X)" by auto
hoelzl@45777
   742
      with \<mu>G_eq[OF _ _ _ X] `i \<in> I` 
hoelzl@45777
   743
      have "\<mu> (emb I {i} ?X) = measure (M i) (space (M i))"
hoelzl@45777
   744
        by (simp add: i.measure_times)
hoelzl@45777
   745
      also have "emb I {i} ?X = space (Pi\<^isub>P I M)"
hoelzl@45777
   746
        using `i \<in> I` by (auto simp: emb_def infprod_algebra_def generator_def)
hoelzl@45777
   747
      finally show "measure (?ms \<mu>) (space (?ms \<mu>)) = 1"
hoelzl@45777
   748
        using M.measure_space_1 by (simp add: infprod_algebra_def)
hoelzl@45777
   749
    qed
hoelzl@42147
   750
  qed
hoelzl@42147
   751
qed
hoelzl@42147
   752
hoelzl@42147
   753
lemma (in product_prob_space) infprod_spec:
hoelzl@45777
   754
  "(\<forall>s\<in>sets generator. measure (Pi\<^isub>P I M) s = \<mu>G s) \<and> prob_space (Pi\<^isub>P I M)"
hoelzl@45777
   755
  (is "?Q infprod_algebra")
hoelzl@45777
   756
  unfolding infprod_algebra_def
hoelzl@45777
   757
  by (rule someI2_ex[OF extend_\<mu>G])
hoelzl@45777
   758
     (auto simp: sigma_def generator_def)
hoelzl@42147
   759
hoelzl@45777
   760
sublocale product_prob_space \<subseteq> P: prob_space "Pi\<^isub>P I M"
hoelzl@45777
   761
  using infprod_spec by simp
hoelzl@42147
   762
hoelzl@42147
   763
lemma (in product_prob_space) measure_infprod_emb:
hoelzl@42147
   764
  assumes "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42257
   765
  shows "\<mu> (emb I J X) = measure (Pi\<^isub>M J M) X"
hoelzl@42147
   766
proof -
hoelzl@42147
   767
  have "emb I J X \<in> sets generator"
hoelzl@42147
   768
    using assms by (rule generatorI')
hoelzl@42147
   769
  with \<mu>G_eq[OF assms] infprod_spec show ?thesis by auto
hoelzl@42147
   770
qed
hoelzl@42147
   771
hoelzl@42166
   772
lemma (in product_prob_space) measurable_component:
hoelzl@42166
   773
  assumes "i \<in> I"
hoelzl@42166
   774
  shows "(\<lambda>x. x i) \<in> measurable (Pi\<^isub>P I M) (M i)"
hoelzl@42166
   775
proof (unfold measurable_def, safe)
hoelzl@42166
   776
  fix x assume "x \<in> space (Pi\<^isub>P I M)"
hoelzl@42166
   777
  then show "x i \<in> space (M i)"
hoelzl@42166
   778
    using `i \<in> I` by (auto simp: infprod_algebra_def generator_def)
hoelzl@42166
   779
next
hoelzl@42166
   780
  fix A assume "A \<in> sets (M i)"
hoelzl@42166
   781
  with `i \<in> I` have
hoelzl@42166
   782
    "(\<Pi>\<^isub>E x \<in> {i}. A) \<in> sets (Pi\<^isub>M {i} M)"
hoelzl@42166
   783
    "(\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M) = emb I {i} (\<Pi>\<^isub>E x \<in> {i}. A)"
hoelzl@42166
   784
    by (auto simp: infprod_algebra_def generator_def emb_def)
hoelzl@42166
   785
  from generatorI[OF _ _ _ this] `i \<in> I`
hoelzl@42166
   786
  show "(\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M) \<in> sets (Pi\<^isub>P I M)"
hoelzl@42166
   787
    unfolding infprod_algebra_def by auto
hoelzl@42166
   788
qed
hoelzl@42166
   789
hoelzl@42257
   790
lemma (in product_prob_space) emb_in_infprod_algebra[intro]:
hoelzl@42257
   791
  fixes J assumes J: "finite J" "J \<subseteq> I" and X: "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42257
   792
  shows "emb I J X \<in> sets (\<Pi>\<^isub>P i\<in>I. M i)"
hoelzl@42257
   793
proof cases
hoelzl@42257
   794
  assume "J = {}"
hoelzl@42257
   795
  with X have "emb I J X = space (\<Pi>\<^isub>P i\<in>I. M i) \<or> emb I J X = {}"
hoelzl@42257
   796
    by (auto simp: emb_def infprod_algebra_def generator_def
hoelzl@42257
   797
                   product_algebra_def product_algebra_generator_def image_constant sigma_def)
hoelzl@42257
   798
  then show ?thesis by auto
hoelzl@42257
   799
next
hoelzl@42257
   800
  assume "J \<noteq> {}"
hoelzl@42257
   801
  show ?thesis unfolding infprod_algebra_def
hoelzl@42257
   802
    by simp (intro in_sigma generatorI'  `J \<noteq> {}` J X)
hoelzl@42257
   803
qed
hoelzl@42257
   804
hoelzl@42257
   805
lemma (in product_prob_space) finite_measure_infprod_emb:
hoelzl@42257
   806
  assumes "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@42257
   807
  shows "\<mu>' (emb I J X) = finite_measure.\<mu>' (Pi\<^isub>M J M) X"
hoelzl@42257
   808
proof -
hoelzl@42257
   809
  interpret J: finite_product_prob_space M J by default fact+
hoelzl@42257
   810
  from assms have "emb I J X \<in> sets (Pi\<^isub>P I M)" by auto
hoelzl@42257
   811
  with assms show "\<mu>' (emb I J X) = J.\<mu>' X"
hoelzl@42257
   812
    unfolding \<mu>'_def J.\<mu>'_def
hoelzl@42257
   813
    unfolding measure_infprod_emb[OF assms]
hoelzl@42257
   814
    by auto
hoelzl@42257
   815
qed
hoelzl@42257
   816
hoelzl@42257
   817
lemma (in finite_product_prob_space) finite_measure_times:
hoelzl@42257
   818
  assumes "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (M i)"
hoelzl@42257
   819
  shows "\<mu>' (Pi\<^isub>E I A) = (\<Prod>i\<in>I. M.\<mu>' i (A i))"
hoelzl@42257
   820
  using assms
hoelzl@42257
   821
  unfolding \<mu>'_def M.\<mu>'_def
hoelzl@42257
   822
  by (subst measure_times[OF assms])
hoelzl@43920
   823
     (auto simp: finite_measure_eq M.finite_measure_eq setprod_ereal)
hoelzl@42257
   824
hoelzl@42257
   825
lemma (in product_prob_space) finite_measure_infprod_emb_Pi:
hoelzl@42257
   826
  assumes J: "finite J" "J \<subseteq> I" "\<And>j. j \<in> J \<Longrightarrow> X j \<in> sets (M j)"
hoelzl@42257
   827
  shows "\<mu>' (emb I J (Pi\<^isub>E J X)) = (\<Prod>j\<in>J. M.\<mu>' j (X j))"
hoelzl@42257
   828
proof cases
hoelzl@42257
   829
  assume "J = {}"
hoelzl@42257
   830
  then have "emb I J (Pi\<^isub>E J X) = space infprod_algebra"
hoelzl@42257
   831
    by (auto simp: infprod_algebra_def generator_def sigma_def emb_def)
hoelzl@45777
   832
  then show ?thesis using `J = {}` P.prob_space
hoelzl@45777
   833
    by simp
hoelzl@42257
   834
next
hoelzl@42257
   835
  assume "J \<noteq> {}"
hoelzl@42257
   836
  interpret J: finite_product_prob_space M J by default fact+
hoelzl@42257
   837
  have "(\<Prod>i\<in>J. M.\<mu>' i (X i)) = J.\<mu>' (Pi\<^isub>E J X)"
hoelzl@42257
   838
    using J `J \<noteq> {}` by (subst J.finite_measure_times) auto
hoelzl@42257
   839
  also have "\<dots> = \<mu>' (emb I J (Pi\<^isub>E J X))"
hoelzl@42257
   840
    using J `J \<noteq> {}` by (intro finite_measure_infprod_emb[symmetric]) auto
hoelzl@42257
   841
  finally show ?thesis by simp
hoelzl@42257
   842
qed
hoelzl@42257
   843
hoelzl@42257
   844
lemma sigma_sets_mono: assumes "A \<subseteq> sigma_sets X B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@42257
   845
proof
hoelzl@42257
   846
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
hoelzl@42257
   847
    by induct (insert `A \<subseteq> sigma_sets X B`, auto intro: sigma_sets.intros)
hoelzl@42257
   848
qed
hoelzl@42257
   849
hoelzl@42257
   850
lemma sigma_sets_mono': assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@42257
   851
proof
hoelzl@42257
   852
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
hoelzl@42257
   853
    by induct (insert `A \<subseteq> B`, auto intro: sigma_sets.intros)
hoelzl@42257
   854
qed
hoelzl@42257
   855
hoelzl@43679
   856
lemma sigma_sets_superset_generator: "A \<subseteq> sigma_sets X A"
hoelzl@42257
   857
  by (auto intro: sigma_sets.Basic)
hoelzl@42257
   858
hoelzl@42257
   859
lemma (in product_prob_space) infprod_algebra_alt:
hoelzl@42257
   860
  "Pi\<^isub>P I M = sigma \<lparr> space = space (Pi\<^isub>P I M),
hoelzl@42257
   861
    sets = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` Pi\<^isub>E J ` (\<Pi> i \<in> J. sets (M i))),
hoelzl@42257
   862
    measure = measure (Pi\<^isub>P I M) \<rparr>"
hoelzl@42257
   863
  (is "_ = sigma \<lparr> space = ?O, sets = ?M, measure = ?m \<rparr>")
hoelzl@42257
   864
proof (rule measure_space.equality)
hoelzl@42257
   865
  let ?G = "\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M)"
hoelzl@42257
   866
  have "sigma_sets ?O ?M = sigma_sets ?O ?G"
hoelzl@42257
   867
  proof (intro equalityI sigma_sets_mono UN_least)
hoelzl@42257
   868
    fix J assume J: "J \<in> {J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}"
hoelzl@42257
   869
    have "emb I J ` Pi\<^isub>E J ` (\<Pi> i\<in>J. sets (M i)) \<subseteq> emb I J ` sets (Pi\<^isub>M J M)" by auto
hoelzl@42257
   870
    also have "\<dots> \<subseteq> ?G" using J by (rule UN_upper)
hoelzl@43679
   871
    also have "\<dots> \<subseteq> sigma_sets ?O ?G" by (rule sigma_sets_superset_generator)
hoelzl@42257
   872
    finally show "emb I J ` Pi\<^isub>E J ` (\<Pi> i\<in>J. sets (M i)) \<subseteq> sigma_sets ?O ?G" .
hoelzl@42257
   873
    have "emb I J ` sets (Pi\<^isub>M J M) = emb I J ` sigma_sets (space (Pi\<^isub>M J M)) (Pi\<^isub>E J ` (\<Pi> i \<in> J. sets (M i)))"
hoelzl@42257
   874
      by (simp add: sets_sigma product_algebra_generator_def product_algebra_def)
hoelzl@42257
   875
    also have "\<dots> = sigma_sets (space (Pi\<^isub>M I M)) (emb I J ` Pi\<^isub>E J ` (\<Pi> i \<in> J. sets (M i)))"
hoelzl@42257
   876
      using J M.sets_into_space
wenzelm@46905
   877
      by (auto simp: emb_def [abs_def] intro!: sigma_sets_vimage[symmetric]) blast
hoelzl@42257
   878
    also have "\<dots> \<subseteq> sigma_sets (space (Pi\<^isub>M I M)) ?M"
hoelzl@42257
   879
      using J by (intro sigma_sets_mono') auto
hoelzl@42257
   880
    finally show "emb I J ` sets (Pi\<^isub>M J M) \<subseteq> sigma_sets ?O ?M"
hoelzl@42257
   881
      by (simp add: infprod_algebra_def generator_def)
hoelzl@42257
   882
  qed
hoelzl@42257
   883
  then show "sets (Pi\<^isub>P I M) = sets (sigma \<lparr> space = ?O, sets = ?M, measure = ?m \<rparr>)"
hoelzl@42257
   884
    by (simp_all add: infprod_algebra_def generator_def sets_sigma)
hoelzl@42257
   885
qed simp_all
hoelzl@42257
   886
hoelzl@42257
   887
lemma (in product_prob_space) infprod_algebra_alt2:
hoelzl@42257
   888
  "Pi\<^isub>P I M = sigma \<lparr> space = space (Pi\<^isub>P I M),
hoelzl@42257
   889
    sets = (\<Union>i\<in>I. (\<lambda>A. (\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M)) ` sets (M i)),
hoelzl@42257
   890
    measure = measure (Pi\<^isub>P I M) \<rparr>"
hoelzl@42257
   891
  (is "_ = ?S")
hoelzl@42257
   892
proof (rule measure_space.equality)
hoelzl@42257
   893
  let "sigma \<lparr> space = ?O, sets = ?A, \<dots> = _ \<rparr>" = ?S
hoelzl@42257
   894
  let ?G = "(\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` Pi\<^isub>E J ` (\<Pi> i \<in> J. sets (M i)))"
hoelzl@42257
   895
  have "sets (Pi\<^isub>P I M) = sigma_sets ?O ?G"
hoelzl@42257
   896
    by (subst infprod_algebra_alt) (simp add: sets_sigma)
hoelzl@42257
   897
  also have "\<dots> = sigma_sets ?O ?A"
hoelzl@42257
   898
  proof (intro equalityI sigma_sets_mono subsetI)
hoelzl@42257
   899
    interpret A: sigma_algebra ?S
hoelzl@42257
   900
      by (rule sigma_algebra_sigma) auto
hoelzl@42257
   901
    fix A assume "A \<in> ?G"
hoelzl@42257
   902
    then obtain J B where "finite J" "J \<noteq> {}" "J \<subseteq> I" "A = emb I J (Pi\<^isub>E J B)"
hoelzl@42257
   903
        and B: "\<And>i. i \<in> J \<Longrightarrow> B i \<in> sets (M i)"
hoelzl@42257
   904
      by auto
hoelzl@42257
   905
    then have A: "A = (\<Inter>j\<in>J. (\<lambda>x. x j) -` (B j) \<inter> space (Pi\<^isub>P I M))"
hoelzl@42257
   906
      by (auto simp: emb_def infprod_algebra_def generator_def Pi_iff)
hoelzl@42257
   907
    { fix j assume "j\<in>J"
hoelzl@42257
   908
      with `J \<subseteq> I` have "j \<in> I" by auto
hoelzl@42257
   909
      with `j \<in> J` B have "(\<lambda>x. x j) -` (B j) \<inter> space (Pi\<^isub>P I M) \<in> sets ?S"
hoelzl@42257
   910
        by (auto simp: sets_sigma intro: sigma_sets.Basic) }
hoelzl@42257
   911
    with `finite J` `J \<noteq> {}` have "A \<in> sets ?S"
hoelzl@42257
   912
      unfolding A by (intro A.finite_INT) auto
hoelzl@42257
   913
    then show "A \<in> sigma_sets ?O ?A" by (simp add: sets_sigma)
hoelzl@42257
   914
  next
hoelzl@42257
   915
    fix A assume "A \<in> ?A"
hoelzl@42257
   916
    then obtain i B where i: "i \<in> I" "B \<in> sets (M i)"
hoelzl@42257
   917
        and "A = (\<lambda>x. x i) -` B \<inter> space (Pi\<^isub>P I M)"
hoelzl@42257
   918
      by auto
hoelzl@42257
   919
    then have "A = emb I {i} (Pi\<^isub>E {i} (\<lambda>_. B))"
hoelzl@42257
   920
      by (auto simp: emb_def infprod_algebra_def generator_def Pi_iff)
hoelzl@42257
   921
    with i show "A \<in> sigma_sets ?O ?G"
hoelzl@42257
   922
      by (intro sigma_sets.Basic UN_I[where a="{i}"]) auto
hoelzl@42257
   923
  qed
hoelzl@42866
   924
  also have "\<dots> = sets ?S"
hoelzl@42257
   925
    by (simp add: sets_sigma)
hoelzl@42866
   926
  finally show "sets (Pi\<^isub>P I M) = sets ?S" .
hoelzl@42257
   927
qed simp_all
hoelzl@42257
   928
hoelzl@42257
   929
lemma (in product_prob_space) measurable_into_infprod_algebra:
hoelzl@42257
   930
  assumes "sigma_algebra N"
hoelzl@42257
   931
  assumes f: "\<And>i. i \<in> I \<Longrightarrow> (\<lambda>x. f x i) \<in> measurable N (M i)"
hoelzl@42257
   932
  assumes ext: "\<And>x. x \<in> space N \<Longrightarrow> f x \<in> extensional I"
hoelzl@42257
   933
  shows "f \<in> measurable N (Pi\<^isub>P I M)"
hoelzl@42257
   934
proof -
hoelzl@42257
   935
  interpret N: sigma_algebra N by fact
hoelzl@42257
   936
  have f_in: "\<And>i. i \<in> I \<Longrightarrow> (\<lambda>x. f x i) \<in> space N \<rightarrow> space (M i)"
hoelzl@42257
   937
    using f by (auto simp: measurable_def)
hoelzl@42257
   938
  { fix i A assume i: "i \<in> I" "A \<in> sets (M i)"
hoelzl@42257
   939
    then have "f -` (\<lambda>x. x i) -` A \<inter> f -` space infprod_algebra \<inter> space N = (\<lambda>x. f x i) -` A \<inter> space N"
hoelzl@42257
   940
      using f_in ext by (auto simp: infprod_algebra_def generator_def)
hoelzl@42257
   941
    also have "\<dots> \<in> sets N"
hoelzl@42257
   942
      by (rule measurable_sets f i)+
hoelzl@42257
   943
    finally have "f -` (\<lambda>x. x i) -` A \<inter> f -` space infprod_algebra \<inter> space N \<in> sets N" . }
hoelzl@42257
   944
  with f_in ext show ?thesis
hoelzl@42257
   945
    by (subst infprod_algebra_alt2)
hoelzl@42257
   946
       (auto intro!: N.measurable_sigma simp: Pi_iff infprod_algebra_def generator_def)
hoelzl@42257
   947
qed
hoelzl@42257
   948
hoelzl@42865
   949
lemma (in product_prob_space) measurable_singleton_infprod:
hoelzl@42865
   950
  assumes "i \<in> I"
hoelzl@42865
   951
  shows "(\<lambda>x. x i) \<in> measurable (Pi\<^isub>P I M) (M i)"
hoelzl@42865
   952
proof (unfold measurable_def, intro CollectI conjI ballI)
hoelzl@42865
   953
  show "(\<lambda>x. x i) \<in> space (Pi\<^isub>P I M) \<rightarrow> space (M i)"
hoelzl@42865
   954
    using M.sets_into_space `i \<in> I`
hoelzl@42865
   955
    by (auto simp: infprod_algebra_def generator_def)
hoelzl@42865
   956
  fix A assume "A \<in> sets (M i)"
hoelzl@42865
   957
  have "(\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M) = emb I {i} (\<Pi>\<^isub>E _\<in>{i}. A)"
hoelzl@42865
   958
    by (auto simp: infprod_algebra_def generator_def emb_def)
hoelzl@42865
   959
  also have "\<dots> \<in> sets (Pi\<^isub>P I M)"
hoelzl@42865
   960
    using `i \<in> I` `A \<in> sets (M i)`
hoelzl@42865
   961
    by (intro emb_in_infprod_algebra product_algebraI) auto
hoelzl@42865
   962
  finally show "(\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M) \<in> sets (Pi\<^isub>P I M)" .
hoelzl@42865
   963
qed
hoelzl@42865
   964
hoelzl@42865
   965
lemma (in product_prob_space) sigma_product_algebra_sigma_eq:
hoelzl@42865
   966
  assumes M: "\<And>i. i \<in> I \<Longrightarrow> M i = sigma (E i)"
hoelzl@42865
   967
  shows "sets (Pi\<^isub>P I M) = sigma_sets (space (Pi\<^isub>P I M)) (\<Union>i\<in>I. (\<lambda>A. (\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M)) ` sets (E i))"
hoelzl@42865
   968
proof -
hoelzl@42865
   969
  let ?E = "(\<Union>i\<in>I. (\<lambda>A. (\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M)) ` sets (E i))"
hoelzl@42865
   970
  let ?M = "(\<Union>i\<in>I. (\<lambda>A. (\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M)) ` sets (M i))"
hoelzl@42865
   971
  { fix i A assume "i\<in>I" "A \<in> sets (E i)"
hoelzl@42865
   972
    then have "A \<in> sets (M i)" using M by auto
hoelzl@42865
   973
    then have "A \<in> Pow (space (M i))" using M.sets_into_space by auto
hoelzl@42865
   974
    then have "A \<in> Pow (space (E i))" using M[OF `i \<in> I`] by auto }
hoelzl@42865
   975
  moreover
hoelzl@42865
   976
  have "\<And>i. i \<in> I \<Longrightarrow> (\<lambda>x. x i) \<in> space infprod_algebra \<rightarrow> space (E i)"
hoelzl@42865
   977
    by (auto simp: M infprod_algebra_def generator_def Pi_iff)
hoelzl@42865
   978
  ultimately have "sigma_sets (space (Pi\<^isub>P I M)) ?M \<subseteq> sigma_sets (space (Pi\<^isub>P I M)) ?E"
hoelzl@42865
   979
    apply (intro sigma_sets_mono UN_least)
hoelzl@42865
   980
    apply (simp add: sets_sigma M)
hoelzl@42865
   981
    apply (subst sigma_sets_vimage[symmetric])
hoelzl@42865
   982
    apply (auto intro!: sigma_sets_mono')
hoelzl@42865
   983
    done
hoelzl@42865
   984
  moreover have "sigma_sets (space (Pi\<^isub>P I M)) ?E \<subseteq> sigma_sets (space (Pi\<^isub>P I M)) ?M"
hoelzl@42865
   985
    by (intro sigma_sets_mono') (auto simp: M)
hoelzl@42865
   986
  ultimately show ?thesis
hoelzl@42865
   987
    by (subst infprod_algebra_alt2) (auto simp: sets_sigma)
hoelzl@42865
   988
qed
hoelzl@42865
   989
hoelzl@42865
   990
lemma (in product_prob_space) Int_proj_eq_emb:
hoelzl@42865
   991
  assumes "J \<noteq> {}" "J \<subseteq> I"
hoelzl@42865
   992
  shows "(\<Inter>i\<in>J. (\<lambda>x. x i) -` A i \<inter> space (Pi\<^isub>P I M)) = emb I J (Pi\<^isub>E J A)"
hoelzl@42865
   993
  using assms by (auto simp: infprod_algebra_def generator_def emb_def Pi_iff)
hoelzl@42865
   994
hoelzl@42865
   995
lemma (in product_prob_space) emb_insert:
hoelzl@42865
   996
  "i \<notin> J \<Longrightarrow> emb I J (Pi\<^isub>E J f) \<inter> ((\<lambda>x. x i) -` A \<inter> space (Pi\<^isub>P I M)) =
hoelzl@42865
   997
    emb I (insert i J) (Pi\<^isub>E (insert i J) (f(i := A)))"
hoelzl@42865
   998
  by (auto simp: emb_def Pi_iff infprod_algebra_def generator_def split: split_if_asm)
hoelzl@42865
   999
hoelzl@42257
  1000
subsection {* Sequence space *}
hoelzl@42257
  1001
hoelzl@42257
  1002
locale sequence_space = product_prob_space M "UNIV :: nat set" for M
hoelzl@42257
  1003
hoelzl@42257
  1004
lemma (in sequence_space) infprod_in_sets[intro]:
hoelzl@42257
  1005
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets (M i)"
hoelzl@42257
  1006
  shows "Pi UNIV E \<in> sets (Pi\<^isub>P UNIV M)"
hoelzl@42257
  1007
proof -
hoelzl@42257
  1008
  have "Pi UNIV E = (\<Inter>i. emb UNIV {..i} (\<Pi>\<^isub>E j\<in>{..i}. E j))"
hoelzl@42257
  1009
    using E E[THEN M.sets_into_space]
hoelzl@42257
  1010
    by (auto simp: emb_def Pi_iff extensional_def) blast
hoelzl@42257
  1011
  with E show ?thesis
hoelzl@42257
  1012
    by (auto intro: emb_in_infprod_algebra)
hoelzl@42257
  1013
qed
hoelzl@42257
  1014
hoelzl@42257
  1015
lemma (in sequence_space) measure_infprod:
hoelzl@42257
  1016
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets (M i)"
hoelzl@42257
  1017
  shows "(\<lambda>n. \<Prod>i\<le>n. M.\<mu>' i (E i)) ----> \<mu>' (Pi UNIV E)"
hoelzl@42257
  1018
proof -
wenzelm@46731
  1019
  let ?E = "\<lambda>n. emb UNIV {..n} (Pi\<^isub>E {.. n} E)"
hoelzl@42257
  1020
  { fix n :: nat
hoelzl@42257
  1021
    interpret n: finite_product_prob_space M "{..n}" by default auto
hoelzl@42257
  1022
    have "(\<Prod>i\<le>n. M.\<mu>' i (E i)) = n.\<mu>' (Pi\<^isub>E {.. n} E)"
hoelzl@42257
  1023
      using E by (subst n.finite_measure_times) auto
hoelzl@42257
  1024
    also have "\<dots> = \<mu>' (?E n)"
hoelzl@42257
  1025
      using E by (intro finite_measure_infprod_emb[symmetric]) auto
hoelzl@42257
  1026
    finally have "(\<Prod>i\<le>n. M.\<mu>' i (E i)) = \<mu>' (?E n)" . }
hoelzl@42257
  1027
  moreover have "Pi UNIV E = (\<Inter>n. ?E n)"
hoelzl@42257
  1028
    using E E[THEN M.sets_into_space]
hoelzl@42257
  1029
    by (auto simp: emb_def extensional_def Pi_iff) blast
hoelzl@42257
  1030
  moreover have "range ?E \<subseteq> sets (Pi\<^isub>P UNIV M)"
hoelzl@42257
  1031
    using E by auto
hoelzl@42257
  1032
  moreover have "decseq ?E"
hoelzl@42257
  1033
    by (auto simp: emb_def Pi_iff decseq_def)
hoelzl@42257
  1034
  ultimately show ?thesis
hoelzl@42257
  1035
    by (simp add: finite_continuity_from_above)
hoelzl@42257
  1036
qed
hoelzl@42257
  1037
hoelzl@42147
  1038
end