src/HOL/Probability/Infinite_Product_Measure.thy
author immler@in.tum.de
Fri Nov 09 14:31:26 2012 +0100 (2012-11-09)
changeset 50042 6fe18351e9dd
parent 50041 afe886a04198
child 50087 635d73673b5e
permissions -rw-r--r--
moved lemmas into projective_family; added header for theory Projective_Family
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
immler@50039
     8
  imports Probability_Measure Caratheodory Projective_Family
hoelzl@42147
     9
begin
hoelzl@42147
    10
hoelzl@47694
    11
lemma (in product_prob_space) distr_restrict:
hoelzl@42147
    12
  assumes "J \<noteq> {}" "J \<subseteq> K" "finite K"
hoelzl@47694
    13
  shows "(\<Pi>\<^isub>M i\<in>J. M i) = distr (\<Pi>\<^isub>M i\<in>K. M i) (\<Pi>\<^isub>M i\<in>J. M i) (\<lambda>f. restrict f J)" (is "?P = ?D")
hoelzl@47694
    14
proof (rule measure_eqI_generator_eq)
hoelzl@47694
    15
  have "finite J" using `J \<subseteq> K` `finite K` by (auto simp add: finite_subset)
hoelzl@47694
    16
  interpret J: finite_product_prob_space M J proof qed fact
hoelzl@47694
    17
  interpret K: finite_product_prob_space M K proof qed fact
hoelzl@47694
    18
hoelzl@47694
    19
  let ?J = "{Pi\<^isub>E J E | E. \<forall>i\<in>J. E i \<in> sets (M i)}"
hoelzl@47694
    20
  let ?F = "\<lambda>i. \<Pi>\<^isub>E k\<in>J. space (M k)"
hoelzl@47694
    21
  let ?\<Omega> = "(\<Pi>\<^isub>E k\<in>J. space (M k))"
hoelzl@47694
    22
  show "Int_stable ?J"
hoelzl@47694
    23
    by (rule Int_stable_PiE)
hoelzl@49784
    24
  show "range ?F \<subseteq> ?J" "(\<Union>i. ?F i) = ?\<Omega>"
hoelzl@47694
    25
    using `finite J` by (auto intro!: prod_algebraI_finite)
hoelzl@47694
    26
  { fix i show "emeasure ?P (?F i) \<noteq> \<infinity>" by simp }
hoelzl@47694
    27
  show "?J \<subseteq> Pow ?\<Omega>" by (auto simp: Pi_iff dest: sets_into_space)
hoelzl@47694
    28
  show "sets (\<Pi>\<^isub>M i\<in>J. M i) = sigma_sets ?\<Omega> ?J" "sets ?D = sigma_sets ?\<Omega> ?J"
hoelzl@47694
    29
    using `finite J` by (simp_all add: sets_PiM prod_algebra_eq_finite Pi_iff)
hoelzl@47694
    30
  
hoelzl@47694
    31
  fix X assume "X \<in> ?J"
hoelzl@47694
    32
  then obtain E where [simp]: "X = Pi\<^isub>E J E" and E: "\<forall>i\<in>J. E i \<in> sets (M i)" by auto
hoelzl@50003
    33
  with `finite J` have X: "X \<in> sets (Pi\<^isub>M J M)"
hoelzl@50003
    34
    by simp
hoelzl@47694
    35
hoelzl@47694
    36
  have "emeasure ?P X = (\<Prod> i\<in>J. emeasure (M i) (E i))"
hoelzl@47694
    37
    using E by (simp add: J.measure_times)
hoelzl@47694
    38
  also have "\<dots> = (\<Prod> i\<in>J. emeasure (M i) (if i \<in> J then E i else space (M i)))"
hoelzl@47694
    39
    by simp
hoelzl@47694
    40
  also have "\<dots> = (\<Prod> i\<in>K. emeasure (M i) (if i \<in> J then E i else space (M i)))"
hoelzl@47694
    41
    using `finite K` `J \<subseteq> K`
hoelzl@47694
    42
    by (intro setprod_mono_one_left) (auto simp: M.emeasure_space_1)
hoelzl@47694
    43
  also have "\<dots> = emeasure (Pi\<^isub>M K M) (\<Pi>\<^isub>E i\<in>K. if i \<in> J then E i else space (M i))"
hoelzl@47694
    44
    using E by (simp add: K.measure_times)
hoelzl@47694
    45
  also have "(\<Pi>\<^isub>E i\<in>K. if i \<in> J then E i else space (M i)) = (\<lambda>f. restrict f J) -` Pi\<^isub>E J E \<inter> (\<Pi>\<^isub>E i\<in>K. space (M i))"
hoelzl@47694
    46
    using `J \<subseteq> K` sets_into_space E by (force simp:  Pi_iff split: split_if_asm)
hoelzl@47694
    47
  finally show "emeasure (Pi\<^isub>M J M) X = emeasure ?D X"
hoelzl@47694
    48
    using X `J \<subseteq> K` apply (subst emeasure_distr)
hoelzl@47694
    49
    by (auto intro!: measurable_restrict_subset simp: space_PiM)
hoelzl@42147
    50
qed
hoelzl@42147
    51
hoelzl@47694
    52
lemma (in product_prob_space) emeasure_prod_emb[simp]:
hoelzl@47694
    53
  assumes L: "J \<noteq> {}" "J \<subseteq> L" "finite L" and X: "X \<in> sets (Pi\<^isub>M J M)"
immler@50039
    54
  shows "emeasure (Pi\<^isub>M L M) (prod_emb L M J X) = emeasure (Pi\<^isub>M J M) X"
hoelzl@47694
    55
  by (subst distr_restrict[OF L])
hoelzl@47694
    56
     (simp add: prod_emb_def space_PiM emeasure_distr measurable_restrict_subset L X)
hoelzl@42147
    57
immler@50039
    58
sublocale product_prob_space \<subseteq> projective_family I "\<lambda>J. PiM J M" M
immler@50039
    59
proof
immler@50039
    60
  fix J::"'i set" assume "finite J"
immler@50039
    61
  interpret f: finite_product_prob_space M J proof qed fact
immler@50039
    62
  show "emeasure (Pi\<^isub>M J M) (space (Pi\<^isub>M J M)) \<noteq> \<infinity>" by simp
immler@50040
    63
  show "\<exists>A. range A \<subseteq> sets (Pi\<^isub>M J M) \<and>
immler@50040
    64
            (\<Union>i. A i) = space (Pi\<^isub>M J M) \<and>
immler@50040
    65
            (\<forall>i. emeasure (Pi\<^isub>M J M) (A i) \<noteq> \<infinity>)" using sigma_finite[OF `finite J`]
immler@50040
    66
    by (auto simp add: sigma_finite_measure_def)
immler@50040
    67
  show "emeasure (Pi\<^isub>M J M) (space (Pi\<^isub>M J M)) = 1" by (rule f.emeasure_space_1)
immler@50039
    68
qed simp_all
immler@50039
    69
immler@50039
    70
lemma (in product_prob_space) PiP_PiM_finite[simp]:
immler@50039
    71
  assumes "J \<noteq> {}" "finite J" "J \<subseteq> I" shows "PiP J M (\<lambda>J. PiM J M) = PiM J M"
immler@50039
    72
  using assms by (simp add: PiP_finite)
immler@50039
    73
hoelzl@47694
    74
lemma (in product_prob_space) emeasure_PiM_emb_not_empty:
hoelzl@47694
    75
  assumes X: "J \<noteq> {}" "J \<subseteq> I" "finite J" "\<forall>i\<in>J. X i \<in> sets (M i)"
hoelzl@47694
    76
  shows "emeasure (Pi\<^isub>M I M) (emb I J (Pi\<^isub>E J X)) = emeasure (Pi\<^isub>M J M) (Pi\<^isub>E J X)"
hoelzl@42147
    77
proof cases
hoelzl@47694
    78
  assume "finite I" with X show ?thesis by simp
hoelzl@42147
    79
next
hoelzl@47694
    80
  let ?\<Omega> = "\<Pi>\<^isub>E i\<in>I. space (M i)"
hoelzl@42147
    81
  let ?G = generator
hoelzl@42147
    82
  assume "\<not> finite I"
hoelzl@45777
    83
  then have I_not_empty: "I \<noteq> {}" by auto
hoelzl@47694
    84
  interpret G!: algebra ?\<Omega> generator by (rule algebra_generator) fact
hoelzl@42147
    85
  note \<mu>G_mono =
hoelzl@45777
    86
    G.additive_increasing[OF positive_\<mu>G[OF I_not_empty] additive_\<mu>G[OF I_not_empty], THEN increasingD]
hoelzl@42147
    87
hoelzl@47694
    88
  { fix Z J assume J: "J \<noteq> {}" "finite J" "J \<subseteq> I" and Z: "Z \<in> ?G"
hoelzl@42147
    89
hoelzl@42147
    90
    from `infinite I` `finite J` obtain k where k: "k \<in> I" "k \<notin> J"
hoelzl@42147
    91
      by (metis rev_finite_subset subsetI)
hoelzl@42147
    92
    moreover from Z guess K' X' by (rule generatorE)
hoelzl@42147
    93
    moreover def K \<equiv> "insert k K'"
hoelzl@42147
    94
    moreover def X \<equiv> "emb K K' X'"
hoelzl@42147
    95
    ultimately have K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "X \<in> sets (Pi\<^isub>M K M)" "Z = emb I K X"
hoelzl@47694
    96
      "K - J \<noteq> {}" "K - J \<subseteq> I" "\<mu>G Z = emeasure (Pi\<^isub>M K M) X"
hoelzl@42147
    97
      by (auto simp: subset_insertI)
hoelzl@49780
    98
    let ?M = "\<lambda>y. (\<lambda>x. merge J (K - J) (y, x)) -` emb (J \<union> K) K X \<inter> space (Pi\<^isub>M (K - J) M)"
hoelzl@42147
    99
    { fix y assume y: "y \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   100
      note * = merge_emb[OF `K \<subseteq> I` `J \<subseteq> I` y, of X]
hoelzl@42147
   101
      moreover
hoelzl@42147
   102
      have **: "?M y \<in> sets (Pi\<^isub>M (K - J) M)"
hoelzl@42147
   103
        using J K y by (intro merge_sets) auto
hoelzl@42147
   104
      ultimately
hoelzl@49780
   105
      have ***: "((\<lambda>x. merge J (I - J) (y, x)) -` Z \<inter> space (Pi\<^isub>M I M)) \<in> ?G"
hoelzl@42147
   106
        using J K by (intro generatorI) auto
hoelzl@49780
   107
      have "\<mu>G ((\<lambda>x. merge J (I - J) (y, x)) -` emb I K X \<inter> space (Pi\<^isub>M I M)) = emeasure (Pi\<^isub>M (K - J) M) (?M y)"
hoelzl@42147
   108
        unfolding * using K J by (subst \<mu>G_eq[OF _ _ _ **]) auto
hoelzl@42147
   109
      note * ** *** this }
hoelzl@42147
   110
    note merge_in_G = this
hoelzl@42147
   111
hoelzl@42147
   112
    have "finite (K - J)" using K by auto
hoelzl@42147
   113
hoelzl@42147
   114
    interpret J: finite_product_prob_space M J by default fact+
hoelzl@42147
   115
    interpret KmJ: finite_product_prob_space M "K - J" by default fact+
hoelzl@42147
   116
hoelzl@47694
   117
    have "\<mu>G Z = emeasure (Pi\<^isub>M (J \<union> (K - J)) M) (emb (J \<union> (K - J)) K X)"
hoelzl@42147
   118
      using K J by simp
hoelzl@47694
   119
    also have "\<dots> = (\<integral>\<^isup>+ x. emeasure (Pi\<^isub>M (K - J) M) (?M x) \<partial>Pi\<^isub>M J M)"
hoelzl@47694
   120
      using K J by (subst emeasure_fold_integral) auto
hoelzl@49780
   121
    also have "\<dots> = (\<integral>\<^isup>+ y. \<mu>G ((\<lambda>x. merge J (I - J) (y, x)) -` Z \<inter> space (Pi\<^isub>M I M)) \<partial>Pi\<^isub>M J M)"
hoelzl@42147
   122
      (is "_ = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)")
hoelzl@47694
   123
    proof (intro positive_integral_cong)
hoelzl@42147
   124
      fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   125
      with K merge_in_G(2)[OF this]
hoelzl@47694
   126
      show "emeasure (Pi\<^isub>M (K - J) M) (?M x) = \<mu>G (?MZ x)"
hoelzl@42147
   127
        unfolding `Z = emb I K X` merge_in_G(1)[OF x] by (subst \<mu>G_eq) auto
hoelzl@42147
   128
    qed
hoelzl@42147
   129
    finally have fold: "\<mu>G Z = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)" .
hoelzl@42147
   130
hoelzl@42147
   131
    { fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
hoelzl@42147
   132
      then have "\<mu>G (?MZ x) \<le> 1"
hoelzl@42147
   133
        unfolding merge_in_G(4)[OF x] `Z = emb I K X`
hoelzl@42147
   134
        by (intro KmJ.measure_le_1 merge_in_G(2)[OF x]) }
hoelzl@42147
   135
    note le_1 = this
hoelzl@42147
   136
hoelzl@49780
   137
    let ?q = "\<lambda>y. \<mu>G ((\<lambda>x. merge J (I - J) (y,x)) -` Z \<inter> space (Pi\<^isub>M I M))"
hoelzl@42147
   138
    have "?q \<in> borel_measurable (Pi\<^isub>M J M)"
hoelzl@42147
   139
      unfolding `Z = emb I K X` using J K merge_in_G(3)
hoelzl@47694
   140
      by (simp add: merge_in_G  \<mu>G_eq emeasure_fold_measurable cong: measurable_cong)
hoelzl@42147
   141
    note this fold le_1 merge_in_G(3) }
hoelzl@42147
   142
  note fold = this
hoelzl@42147
   143
hoelzl@47694
   144
  have "\<exists>\<mu>. (\<forall>s\<in>?G. \<mu> s = \<mu>G s) \<and> measure_space ?\<Omega> (sigma_sets ?\<Omega> ?G) \<mu>"
hoelzl@42147
   145
  proof (rule G.caratheodory_empty_continuous[OF positive_\<mu>G additive_\<mu>G])
hoelzl@47694
   146
    fix A assume "A \<in> ?G"
hoelzl@42147
   147
    with generatorE guess J X . note JX = this
hoelzl@50000
   148
    interpret JK: finite_product_prob_space M J by default fact+ 
wenzelm@46898
   149
    from JX show "\<mu>G A \<noteq> \<infinity>" by simp
hoelzl@42147
   150
  next
hoelzl@47694
   151
    fix A assume A: "range A \<subseteq> ?G" "decseq A" "(\<Inter>i. A i) = {}"
hoelzl@42147
   152
    then have "decseq (\<lambda>i. \<mu>G (A i))"
hoelzl@42147
   153
      by (auto intro!: \<mu>G_mono simp: decseq_def)
hoelzl@42147
   154
    moreover
hoelzl@42147
   155
    have "(INF i. \<mu>G (A i)) = 0"
hoelzl@42147
   156
    proof (rule ccontr)
hoelzl@42147
   157
      assume "(INF i. \<mu>G (A i)) \<noteq> 0" (is "?a \<noteq> 0")
hoelzl@42147
   158
      moreover have "0 \<le> ?a"
hoelzl@45777
   159
        using A positive_\<mu>G[OF I_not_empty] by (auto intro!: INF_greatest simp: positive_def)
hoelzl@42147
   160
      ultimately have "0 < ?a" by auto
hoelzl@42147
   161
immler@50039
   162
      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) = emeasure (PiP J M (\<lambda>J. (Pi\<^isub>M J M))) X"
hoelzl@42147
   163
        using A by (intro allI generator_Ex) auto
hoelzl@42147
   164
      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
   165
        and A': "\<And>n. A n = emb I (J' n) (X' n)"
hoelzl@42147
   166
        unfolding choice_iff by blast
hoelzl@42147
   167
      moreover def J \<equiv> "\<lambda>n. (\<Union>i\<le>n. J' i)"
hoelzl@42147
   168
      moreover def X \<equiv> "\<lambda>n. emb (J n) (J' n) (X' n)"
hoelzl@42147
   169
      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
   170
        by auto
hoelzl@47694
   171
      with A' have A_eq: "\<And>n. A n = emb I (J n) (X n)" "\<And>n. A n \<in> ?G"
hoelzl@47694
   172
        unfolding J_def X_def by (subst prod_emb_trans) (insert A, auto)
hoelzl@42147
   173
hoelzl@42147
   174
      have J_mono: "\<And>n m. n \<le> m \<Longrightarrow> J n \<subseteq> J m"
hoelzl@42147
   175
        unfolding J_def by force
hoelzl@42147
   176
hoelzl@42147
   177
      interpret J: finite_product_prob_space M "J i" for i by default fact+
hoelzl@42147
   178
hoelzl@42147
   179
      have a_le_1: "?a \<le> 1"
hoelzl@42147
   180
        using \<mu>G_spec[of "J 0" "A 0" "X 0"] J A_eq
hoelzl@44928
   181
        by (auto intro!: INF_lower2[of 0] J.measure_le_1)
hoelzl@42147
   182
hoelzl@49780
   183
      let ?M = "\<lambda>K Z y. (\<lambda>x. merge K (I - K) (y, x)) -` Z \<inter> space (Pi\<^isub>M I M)"
hoelzl@42147
   184
hoelzl@47694
   185
      { fix Z k assume Z: "range Z \<subseteq> ?G" "decseq Z" "\<forall>n. ?a / 2^k \<le> \<mu>G (Z n)"
hoelzl@47694
   186
        then have Z_sets: "\<And>n. Z n \<in> ?G" by auto
hoelzl@42147
   187
        fix J' assume J': "J' \<noteq> {}" "finite J'" "J' \<subseteq> I"
hoelzl@42147
   188
        interpret J': finite_product_prob_space M J' by default fact+
hoelzl@42147
   189
wenzelm@46731
   190
        let ?q = "\<lambda>n y. \<mu>G (?M J' (Z n) y)"
wenzelm@46731
   191
        let ?Q = "\<lambda>n. ?q n -` {?a / 2^(k+1) ..} \<inter> space (Pi\<^isub>M J' M)"
hoelzl@42147
   192
        { fix n
hoelzl@42147
   193
          have "?q n \<in> borel_measurable (Pi\<^isub>M J' M)"
hoelzl@42147
   194
            using Z J' by (intro fold(1)) auto
hoelzl@42147
   195
          then have "?Q n \<in> sets (Pi\<^isub>M J' M)"
hoelzl@42147
   196
            by (rule measurable_sets) auto }
hoelzl@42147
   197
        note Q_sets = this
hoelzl@42147
   198
hoelzl@47694
   199
        have "?a / 2^(k+1) \<le> (INF n. emeasure (Pi\<^isub>M J' M) (?Q n))"
hoelzl@44928
   200
        proof (intro INF_greatest)
hoelzl@42147
   201
          fix n
hoelzl@42147
   202
          have "?a / 2^k \<le> \<mu>G (Z n)" using Z by auto
hoelzl@42147
   203
          also have "\<dots> \<le> (\<integral>\<^isup>+ x. indicator (?Q n) x + ?a / 2^(k+1) \<partial>Pi\<^isub>M J' M)"
hoelzl@47694
   204
            unfolding fold(2)[OF J' `Z n \<in> ?G`]
hoelzl@47694
   205
          proof (intro positive_integral_mono)
hoelzl@42147
   206
            fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
hoelzl@42147
   207
            then have "?q n x \<le> 1 + 0"
hoelzl@42147
   208
              using J' Z fold(3) Z_sets by auto
hoelzl@42147
   209
            also have "\<dots> \<le> 1 + ?a / 2^(k+1)"
hoelzl@42147
   210
              using `0 < ?a` by (intro add_mono) auto
hoelzl@42147
   211
            finally have "?q n x \<le> 1 + ?a / 2^(k+1)" .
hoelzl@42147
   212
            with x show "?q n x \<le> indicator (?Q n) x + ?a / 2^(k+1)"
hoelzl@42147
   213
              by (auto split: split_indicator simp del: power_Suc)
hoelzl@42147
   214
          qed
hoelzl@47694
   215
          also have "\<dots> = emeasure (Pi\<^isub>M J' M) (?Q n) + ?a / 2^(k+1)"
hoelzl@47694
   216
            using `0 \<le> ?a` Q_sets J'.emeasure_space_1
hoelzl@47694
   217
            by (subst positive_integral_add) auto
hoelzl@47694
   218
          finally show "?a / 2^(k+1) \<le> emeasure (Pi\<^isub>M J' M) (?Q n)" using `?a \<le> 1`
hoelzl@47694
   219
            by (cases rule: ereal2_cases[of ?a "emeasure (Pi\<^isub>M J' M) (?Q n)"])
hoelzl@42147
   220
               (auto simp: field_simps)
hoelzl@42147
   221
        qed
hoelzl@47694
   222
        also have "\<dots> = emeasure (Pi\<^isub>M J' M) (\<Inter>n. ?Q n)"
hoelzl@47694
   223
        proof (intro INF_emeasure_decseq)
hoelzl@42147
   224
          show "range ?Q \<subseteq> sets (Pi\<^isub>M J' M)" using Q_sets by auto
hoelzl@42147
   225
          show "decseq ?Q"
hoelzl@42147
   226
            unfolding decseq_def
hoelzl@42147
   227
          proof (safe intro!: vimageI[OF refl])
hoelzl@42147
   228
            fix m n :: nat assume "m \<le> n"
hoelzl@42147
   229
            fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
hoelzl@42147
   230
            assume "?a / 2^(k+1) \<le> ?q n x"
hoelzl@42147
   231
            also have "?q n x \<le> ?q m x"
hoelzl@42147
   232
            proof (rule \<mu>G_mono)
hoelzl@42147
   233
              from fold(4)[OF J', OF Z_sets x]
hoelzl@47694
   234
              show "?M J' (Z n) x \<in> ?G" "?M J' (Z m) x \<in> ?G" by auto
hoelzl@42147
   235
              show "?M J' (Z n) x \<subseteq> ?M J' (Z m) x"
hoelzl@42147
   236
                using `decseq Z`[THEN decseqD, OF `m \<le> n`] by auto
hoelzl@42147
   237
            qed
hoelzl@42147
   238
            finally show "?a / 2^(k+1) \<le> ?q m x" .
hoelzl@42147
   239
          qed
hoelzl@47694
   240
        qed simp
hoelzl@42147
   241
        finally have "(\<Inter>n. ?Q n) \<noteq> {}"
hoelzl@42147
   242
          using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
hoelzl@42147
   243
        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
   244
      note Ex_w = this
hoelzl@42147
   245
wenzelm@46731
   246
      let ?q = "\<lambda>k n y. \<mu>G (?M (J k) (A n) y)"
hoelzl@42147
   247
hoelzl@44928
   248
      have "\<forall>n. ?a / 2 ^ 0 \<le> \<mu>G (A n)" by (auto intro: INF_lower)
hoelzl@42147
   249
      from Ex_w[OF A(1,2) this J(1-3), of 0] guess w0 .. note w0 = this
hoelzl@42147
   250
wenzelm@46731
   251
      let ?P =
wenzelm@46731
   252
        "\<lambda>k wk w. w \<in> space (Pi\<^isub>M (J (Suc k)) M) \<and> restrict w (J k) = wk \<and>
wenzelm@46731
   253
          (\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n w)"
hoelzl@42147
   254
      def w \<equiv> "nat_rec w0 (\<lambda>k wk. Eps (?P k wk))"
hoelzl@42147
   255
hoelzl@42147
   256
      { fix k have w: "w k \<in> space (Pi\<^isub>M (J k) M) \<and>
hoelzl@42147
   257
          (\<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
   258
        proof (induct k)
hoelzl@42147
   259
          case 0 with w0 show ?case
hoelzl@42147
   260
            unfolding w_def nat_rec_0 by auto
hoelzl@42147
   261
        next
hoelzl@42147
   262
          case (Suc k)
hoelzl@42147
   263
          then have wk: "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
hoelzl@42147
   264
          have "\<exists>w'. ?P k (w k) w'"
hoelzl@42147
   265
          proof cases
hoelzl@42147
   266
            assume [simp]: "J k = J (Suc k)"
hoelzl@42147
   267
            show ?thesis
hoelzl@42147
   268
            proof (intro exI[of _ "w k"] conjI allI)
hoelzl@42147
   269
              fix n
hoelzl@42147
   270
              have "?a / 2 ^ (Suc k + 1) \<le> ?a / 2 ^ (k + 1)"
hoelzl@42147
   271
                using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: field_simps)
hoelzl@42147
   272
              also have "\<dots> \<le> ?q k n (w k)" using Suc by auto
hoelzl@42147
   273
              finally show "?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n (w k)" by simp
hoelzl@42147
   274
            next
hoelzl@42147
   275
              show "w k \<in> space (Pi\<^isub>M (J (Suc k)) M)"
hoelzl@42147
   276
                using Suc by simp
hoelzl@42147
   277
              then show "restrict (w k) (J k) = w k"
hoelzl@47694
   278
                by (simp add: extensional_restrict space_PiM)
hoelzl@42147
   279
            qed
hoelzl@42147
   280
          next
hoelzl@42147
   281
            assume "J k \<noteq> J (Suc k)"
hoelzl@42147
   282
            with J_mono[of k "Suc k"] have "J (Suc k) - J k \<noteq> {}" (is "?D \<noteq> {}") by auto
hoelzl@47694
   283
            have "range (\<lambda>n. ?M (J k) (A n) (w k)) \<subseteq> ?G"
hoelzl@42147
   284
              "decseq (\<lambda>n. ?M (J k) (A n) (w k))"
hoelzl@42147
   285
              "\<forall>n. ?a / 2 ^ (k + 1) \<le> \<mu>G (?M (J k) (A n) (w k))"
hoelzl@42147
   286
              using `decseq A` fold(4)[OF J(1-3) A_eq(2), of "w k" k] Suc
hoelzl@42147
   287
              by (auto simp: decseq_def)
hoelzl@42147
   288
            from Ex_w[OF this `?D \<noteq> {}`] J[of "Suc k"]
hoelzl@42147
   289
            obtain w' where w': "w' \<in> space (Pi\<^isub>M ?D M)"
hoelzl@42147
   290
              "\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> \<mu>G (?M ?D (?M (J k) (A n) (w k)) w')" by auto
hoelzl@49780
   291
            let ?w = "merge (J k) ?D (w k, w')"
hoelzl@49780
   292
            have [simp]: "\<And>x. merge (J k) (I - J k) (w k, merge ?D (I - ?D) (w', x)) =
hoelzl@49780
   293
              merge (J (Suc k)) (I - (J (Suc k))) (?w, x)"
hoelzl@42147
   294
              using J(3)[of "Suc k"] J(3)[of k] J_mono[of k "Suc k"]
hoelzl@42147
   295
              by (auto intro!: ext split: split_merge)
hoelzl@42147
   296
            have *: "\<And>n. ?M ?D (?M (J k) (A n) (w k)) w' = ?M (J (Suc k)) (A n) ?w"
hoelzl@42147
   297
              using w'(1) J(3)[of "Suc k"]
hoelzl@47694
   298
              by (auto simp: space_PiM split: split_merge intro!: extensional_merge_sub) force+
hoelzl@42147
   299
            show ?thesis
hoelzl@42147
   300
              apply (rule exI[of _ ?w])
hoelzl@42147
   301
              using w' J_mono[of k "Suc k"] wk unfolding *
hoelzl@47694
   302
              apply (auto split: split_merge intro!: extensional_merge_sub ext simp: space_PiM)
hoelzl@42147
   303
              apply (force simp: extensional_def)
hoelzl@42147
   304
              done
hoelzl@42147
   305
          qed
hoelzl@42147
   306
          then have "?P k (w k) (w (Suc k))"
hoelzl@42147
   307
            unfolding w_def nat_rec_Suc unfolding w_def[symmetric]
hoelzl@42147
   308
            by (rule someI_ex)
hoelzl@42147
   309
          then show ?case by auto
hoelzl@42147
   310
        qed
hoelzl@42147
   311
        moreover
hoelzl@42147
   312
        then have "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
hoelzl@42147
   313
        moreover
hoelzl@42147
   314
        from w have "?a / 2 ^ (k + 1) \<le> ?q k k (w k)" by auto
hoelzl@42147
   315
        then have "?M (J k) (A k) (w k) \<noteq> {}"
hoelzl@45777
   316
          using positive_\<mu>G[OF I_not_empty, unfolded positive_def] `0 < ?a` `?a \<le> 1`
hoelzl@42147
   317
          by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
hoelzl@42147
   318
        then obtain x where "x \<in> ?M (J k) (A k) (w k)" by auto
hoelzl@49780
   319
        then have "merge (J k) (I - J k) (w k, x) \<in> A k" by auto
hoelzl@42147
   320
        then have "\<exists>x\<in>A k. restrict x (J k) = w k"
hoelzl@42147
   321
          using `w k \<in> space (Pi\<^isub>M (J k) M)`
hoelzl@47694
   322
          by (intro rev_bexI) (auto intro!: ext simp: extensional_def space_PiM)
hoelzl@42147
   323
        ultimately have "w k \<in> space (Pi\<^isub>M (J k) M)"
hoelzl@42147
   324
          "\<exists>x\<in>A k. restrict x (J k) = w k"
hoelzl@42147
   325
          "k \<noteq> 0 \<Longrightarrow> restrict (w k) (J (k - 1)) = w (k - 1)"
hoelzl@42147
   326
          by auto }
hoelzl@42147
   327
      note w = this
hoelzl@42147
   328
hoelzl@42147
   329
      { fix k l i assume "k \<le> l" "i \<in> J k"
hoelzl@42147
   330
        { fix l have "w k i = w (k + l) i"
hoelzl@42147
   331
          proof (induct l)
hoelzl@42147
   332
            case (Suc l)
hoelzl@42147
   333
            from `i \<in> J k` J_mono[of k "k + l"] have "i \<in> J (k + l)" by auto
hoelzl@42147
   334
            with w(3)[of "k + Suc l"]
hoelzl@42147
   335
            have "w (k + l) i = w (k + Suc l) i"
hoelzl@42147
   336
              by (auto simp: restrict_def fun_eq_iff split: split_if_asm)
hoelzl@42147
   337
            with Suc show ?case by simp
hoelzl@42147
   338
          qed simp }
hoelzl@42147
   339
        from this[of "l - k"] `k \<le> l` have "w l i = w k i" by simp }
hoelzl@42147
   340
      note w_mono = this
hoelzl@42147
   341
hoelzl@42147
   342
      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
   343
      { fix i k assume k: "i \<in> J k"
hoelzl@42147
   344
        have "w k i = w (LEAST k. i \<in> J k) i"
hoelzl@42147
   345
          by (intro w_mono Least_le k LeastI[of _ k])
hoelzl@42147
   346
        then have "w' i = w k i"
hoelzl@42147
   347
          unfolding w'_def using k by auto }
hoelzl@42147
   348
      note w'_eq = this
hoelzl@42147
   349
      have w'_simps1: "\<And>i. i \<notin> I \<Longrightarrow> w' i = undefined"
hoelzl@42147
   350
        using J by (auto simp: w'_def)
hoelzl@42147
   351
      have w'_simps2: "\<And>i. i \<notin> (\<Union>k. J k) \<Longrightarrow> i \<in> I \<Longrightarrow> w' i \<in> space (M i)"
hoelzl@42147
   352
        using J by (auto simp: w'_def intro!: someI_ex[OF M.not_empty[unfolded ex_in_conv[symmetric]]])
hoelzl@42147
   353
      { fix i assume "i \<in> I" then have "w' i \<in> space (M i)"
hoelzl@47694
   354
          using w(1) by (cases "i \<in> (\<Union>k. J k)") (force simp: w'_simps2 w'_eq space_PiM)+ }
hoelzl@42147
   355
      note w'_simps[simp] = w'_eq w'_simps1 w'_simps2 this
hoelzl@42147
   356
hoelzl@42147
   357
      have w': "w' \<in> space (Pi\<^isub>M I M)"
hoelzl@47694
   358
        using w(1) by (auto simp add: Pi_iff extensional_def space_PiM)
hoelzl@42147
   359
hoelzl@42147
   360
      { fix n
hoelzl@42147
   361
        have "restrict w' (J n) = w n" using w(1)
hoelzl@47694
   362
          by (auto simp add: fun_eq_iff restrict_def Pi_iff extensional_def space_PiM)
hoelzl@42147
   363
        with w[of n] obtain x where "x \<in> A n" "restrict x (J n) = restrict w' (J n)" by auto
hoelzl@47694
   364
        then have "w' \<in> A n" unfolding A_eq using w' by (auto simp: prod_emb_def space_PiM) }
hoelzl@42147
   365
      then have "w' \<in> (\<Inter>i. A i)" by auto
hoelzl@42147
   366
      with `(\<Inter>i. A i) = {}` show False by auto
hoelzl@42147
   367
    qed
hoelzl@42147
   368
    ultimately show "(\<lambda>i. \<mu>G (A i)) ----> 0"
hoelzl@43920
   369
      using LIMSEQ_ereal_INFI[of "\<lambda>i. \<mu>G (A i)"] by simp
hoelzl@45777
   370
  qed fact+
hoelzl@45777
   371
  then guess \<mu> .. note \<mu> = this
hoelzl@45777
   372
  show ?thesis
hoelzl@47694
   373
  proof (subst emeasure_extend_measure_Pair[OF PiM_def, of I M \<mu> J X])
hoelzl@47694
   374
    from assms show "(J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))"
hoelzl@47694
   375
      by (simp add: Pi_iff)
hoelzl@47694
   376
  next
hoelzl@47694
   377
    fix J X assume J: "(J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))"
hoelzl@47694
   378
    then show "emb I J (Pi\<^isub>E J X) \<in> Pow (\<Pi>\<^isub>E i\<in>I. space (M i))"
hoelzl@47694
   379
      by (auto simp: Pi_iff prod_emb_def dest: sets_into_space)
hoelzl@47694
   380
    have "emb I J (Pi\<^isub>E J X) \<in> generator"
hoelzl@50003
   381
      using J `I \<noteq> {}` by (intro generatorI') (auto simp: Pi_iff)
hoelzl@47694
   382
    then have "\<mu> (emb I J (Pi\<^isub>E J X)) = \<mu>G (emb I J (Pi\<^isub>E J X))"
hoelzl@47694
   383
      using \<mu> by simp
hoelzl@47694
   384
    also have "\<dots> = (\<Prod> j\<in>J. if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j)))"
hoelzl@47694
   385
      using J  `I \<noteq> {}` by (subst \<mu>G_spec[OF _ _ _ refl]) (auto simp: emeasure_PiM Pi_iff)
hoelzl@47694
   386
    also have "\<dots> = (\<Prod>j\<in>J \<union> {i \<in> I. emeasure (M i) (space (M i)) \<noteq> 1}.
hoelzl@47694
   387
      if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j)))"
hoelzl@47694
   388
      using J `I \<noteq> {}` by (intro setprod_mono_one_right) (auto simp: M.emeasure_space_1)
hoelzl@47694
   389
    finally show "\<mu> (emb I J (Pi\<^isub>E J X)) = \<dots>" .
hoelzl@47694
   390
  next
hoelzl@47694
   391
    let ?F = "\<lambda>j. if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j))"
hoelzl@47694
   392
    have "(\<Prod>j\<in>J \<union> {i \<in> I. emeasure (M i) (space (M i)) \<noteq> 1}. ?F j) = (\<Prod>j\<in>J. ?F j)"
hoelzl@47694
   393
      using X `I \<noteq> {}` by (intro setprod_mono_one_right) (auto simp: M.emeasure_space_1)
hoelzl@47694
   394
    then show "(\<Prod>j\<in>J \<union> {i \<in> I. emeasure (M i) (space (M i)) \<noteq> 1}. ?F j) =
hoelzl@47694
   395
      emeasure (Pi\<^isub>M J M) (Pi\<^isub>E J X)"
hoelzl@47694
   396
      using X by (auto simp add: emeasure_PiM) 
hoelzl@47694
   397
  next
hoelzl@47694
   398
    show "positive (sets (Pi\<^isub>M I M)) \<mu>" "countably_additive (sets (Pi\<^isub>M I M)) \<mu>"
hoelzl@49804
   399
      using \<mu> unfolding sets_PiM_generator by (auto simp: measure_space_def)
hoelzl@42147
   400
  qed
hoelzl@42147
   401
qed
hoelzl@42147
   402
hoelzl@47694
   403
sublocale product_prob_space \<subseteq> P: prob_space "Pi\<^isub>M I M"
hoelzl@42257
   404
proof
hoelzl@47694
   405
  show "emeasure (Pi\<^isub>M I M) (space (Pi\<^isub>M I M)) = 1"
hoelzl@47694
   406
  proof cases
hoelzl@47694
   407
    assume "I = {}" then show ?thesis by (simp add: space_PiM_empty)
hoelzl@47694
   408
  next
hoelzl@47694
   409
    assume "I \<noteq> {}"
hoelzl@47694
   410
    then obtain i where "i \<in> I" by auto
hoelzl@47694
   411
    moreover then have "emb I {i} (\<Pi>\<^isub>E i\<in>{i}. space (M i)) = (space (Pi\<^isub>M I M))"
hoelzl@47694
   412
      by (auto simp: prod_emb_def space_PiM)
hoelzl@47694
   413
    ultimately show ?thesis
hoelzl@47694
   414
      using emeasure_PiM_emb_not_empty[of "{i}" "\<lambda>i. space (M i)"]
hoelzl@47694
   415
      by (simp add: emeasure_PiM emeasure_space_1)
hoelzl@47694
   416
  qed
hoelzl@42257
   417
qed
hoelzl@42257
   418
hoelzl@47694
   419
lemma (in product_prob_space) emeasure_PiM_emb:
hoelzl@47694
   420
  assumes X: "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
hoelzl@47694
   421
  shows "emeasure (Pi\<^isub>M I M) (emb I J (Pi\<^isub>E J X)) = (\<Prod> i\<in>J. emeasure (M i) (X i))"
hoelzl@47694
   422
proof cases
hoelzl@47694
   423
  assume "J = {}"
hoelzl@47694
   424
  moreover have "emb I {} {\<lambda>x. undefined} = space (Pi\<^isub>M I M)"
hoelzl@47694
   425
    by (auto simp: space_PiM prod_emb_def)
hoelzl@47694
   426
  ultimately show ?thesis
hoelzl@47694
   427
    by (simp add: space_PiM_empty P.emeasure_space_1)
hoelzl@47694
   428
next
hoelzl@47694
   429
  assume "J \<noteq> {}" with X show ?thesis
hoelzl@47694
   430
    by (subst emeasure_PiM_emb_not_empty) (auto simp: emeasure_PiM)
hoelzl@42257
   431
qed
hoelzl@42257
   432
hoelzl@50000
   433
lemma (in product_prob_space) emeasure_PiM_Collect:
hoelzl@50000
   434
  assumes X: "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
hoelzl@50000
   435
  shows "emeasure (Pi\<^isub>M I M) {x\<in>space (Pi\<^isub>M I M). \<forall>i\<in>J. x i \<in> X i} = (\<Prod> i\<in>J. emeasure (M i) (X i))"
hoelzl@50000
   436
proof -
hoelzl@50000
   437
  have "{x\<in>space (Pi\<^isub>M I M). \<forall>i\<in>J. x i \<in> X i} = emb I J (Pi\<^isub>E J X)"
hoelzl@50000
   438
    unfolding prod_emb_def using assms by (auto simp: space_PiM Pi_iff)
hoelzl@50000
   439
  with emeasure_PiM_emb[OF assms] show ?thesis by simp
hoelzl@50000
   440
qed
hoelzl@50000
   441
hoelzl@50000
   442
lemma (in product_prob_space) emeasure_PiM_Collect_single:
hoelzl@50000
   443
  assumes X: "i \<in> I" "A \<in> sets (M i)"
hoelzl@50000
   444
  shows "emeasure (Pi\<^isub>M I M) {x\<in>space (Pi\<^isub>M I M). x i \<in> A} = emeasure (M i) A"
hoelzl@50000
   445
  using emeasure_PiM_Collect[of "{i}" "\<lambda>i. A"] assms
hoelzl@50000
   446
  by simp
hoelzl@50000
   447
hoelzl@47694
   448
lemma (in product_prob_space) measure_PiM_emb:
hoelzl@47694
   449
  assumes "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
hoelzl@47694
   450
  shows "measure (PiM I M) (emb I J (Pi\<^isub>E J X)) = (\<Prod> i\<in>J. measure (M i) (X i))"
hoelzl@47694
   451
  using emeasure_PiM_emb[OF assms]
hoelzl@47694
   452
  unfolding emeasure_eq_measure M.emeasure_eq_measure by (simp add: setprod_ereal)
hoelzl@42865
   453
hoelzl@50000
   454
lemma sets_Collect_single':
hoelzl@50000
   455
  "i \<in> I \<Longrightarrow> {x\<in>space (M i). P x} \<in> sets (M i) \<Longrightarrow> {x\<in>space (PiM I M). P (x i)} \<in> sets (PiM I M)"
hoelzl@50000
   456
  using sets_Collect_single[of i I "{x\<in>space (M i). P x}" M]
hoelzl@50000
   457
  by (simp add: space_PiM Pi_iff cong: conj_cong)
hoelzl@50000
   458
hoelzl@47694
   459
lemma (in finite_product_prob_space) finite_measure_PiM_emb:
hoelzl@47694
   460
  "(\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (M i)) \<Longrightarrow> measure (PiM I M) (Pi\<^isub>E I A) = (\<Prod>i\<in>I. measure (M i) (A i))"
hoelzl@47694
   461
  using measure_PiM_emb[of I A] finite_index prod_emb_PiE_same_index[OF sets_into_space, of I A M]
hoelzl@47694
   462
  by auto
hoelzl@42865
   463
hoelzl@50000
   464
lemma (in product_prob_space) PiM_component:
hoelzl@50000
   465
  assumes "i \<in> I"
hoelzl@50000
   466
  shows "distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i) = M i"
hoelzl@50000
   467
proof (rule measure_eqI[symmetric])
hoelzl@50000
   468
  fix A assume "A \<in> sets (M i)"
hoelzl@50000
   469
  moreover have "((\<lambda>\<omega>. \<omega> i) -` A \<inter> space (PiM I M)) = {x\<in>space (PiM I M). x i \<in> A}"
hoelzl@50000
   470
    by auto
hoelzl@50000
   471
  ultimately show "emeasure (M i) A = emeasure (distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i)) A"
hoelzl@50000
   472
    by (auto simp: `i\<in>I` emeasure_distr measurable_component_singleton emeasure_PiM_Collect_single)
hoelzl@50000
   473
qed simp
hoelzl@50000
   474
hoelzl@50000
   475
lemma (in product_prob_space) PiM_eq:
hoelzl@50000
   476
  assumes "I \<noteq> {}"
hoelzl@50000
   477
  assumes "sets M' = sets (PiM I M)"
hoelzl@50000
   478
  assumes eq: "\<And>J F. finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> (\<And>j. j \<in> J \<Longrightarrow> F j \<in> sets (M j)) \<Longrightarrow>
hoelzl@50000
   479
    emeasure M' (prod_emb I M J (\<Pi>\<^isub>E j\<in>J. F j)) = (\<Prod>j\<in>J. emeasure (M j) (F j))"
hoelzl@50000
   480
  shows "M' = (PiM I M)"
hoelzl@50000
   481
proof (rule measure_eqI_generator_eq[symmetric, OF Int_stable_prod_algebra prod_algebra_sets_into_space])
hoelzl@50000
   482
  show "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) (prod_algebra I M)"
hoelzl@50000
   483
    by (rule sets_PiM)
hoelzl@50000
   484
  then show "sets M' = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) (prod_algebra I M)"
hoelzl@50000
   485
    unfolding `sets M' = sets (PiM I M)` by simp
hoelzl@50000
   486
hoelzl@50000
   487
  def i \<equiv> "SOME i. i \<in> I"
hoelzl@50000
   488
  with `I \<noteq> {}` have i: "i \<in> I"
hoelzl@50000
   489
    by (auto intro: someI_ex)
hoelzl@50000
   490
hoelzl@50000
   491
  def A \<equiv> "\<lambda>n::nat. prod_emb I M {i} (\<Pi>\<^isub>E j\<in>{i}. space (M i))"
hoelzl@50000
   492
  then show "range A \<subseteq> prod_algebra I M"
hoelzl@50000
   493
    by (auto intro!: prod_algebraI i)
hoelzl@50000
   494
hoelzl@50000
   495
  have A_eq: "\<And>i. A i = space (PiM I M)"
hoelzl@50000
   496
    by (auto simp: prod_emb_def space_PiM Pi_iff A_def i)
hoelzl@50000
   497
  show "(\<Union>i. A i) = (\<Pi>\<^isub>E i\<in>I. space (M i))"
hoelzl@50000
   498
    unfolding A_eq by (auto simp: space_PiM)
hoelzl@50000
   499
  show "\<And>i. emeasure (PiM I M) (A i) \<noteq> \<infinity>"
hoelzl@50000
   500
    unfolding A_eq P.emeasure_space_1 by simp
hoelzl@50000
   501
next
hoelzl@50000
   502
  fix X assume X: "X \<in> prod_algebra I M"
hoelzl@50000
   503
  then obtain J E where X: "X = prod_emb I M J (PIE j:J. E j)"
hoelzl@50000
   504
    and J: "finite J" "J \<subseteq> I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets (M j)"
hoelzl@50000
   505
    by (force elim!: prod_algebraE)
hoelzl@50000
   506
  from eq[OF J] have "emeasure M' X = (\<Prod>j\<in>J. emeasure (M j) (E j))"
hoelzl@50000
   507
    by (simp add: X)
hoelzl@50000
   508
  also have "\<dots> = emeasure (PiM I M) X"
hoelzl@50000
   509
    unfolding X using J by (intro emeasure_PiM_emb[symmetric]) auto
hoelzl@50000
   510
  finally show "emeasure (PiM I M) X = emeasure M' X" ..
hoelzl@50000
   511
qed
hoelzl@50000
   512
hoelzl@42257
   513
subsection {* Sequence space *}
hoelzl@42257
   514
hoelzl@50000
   515
lemma measurable_nat_case: "(\<lambda>(x, \<omega>). nat_case x \<omega>) \<in> measurable (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)) (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   516
proof (rule measurable_PiM_single)
hoelzl@50000
   517
  show "(\<lambda>(x, \<omega>). nat_case x \<omega>) \<in> space (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)) \<rightarrow> (UNIV \<rightarrow>\<^isub>E space M)"
hoelzl@50000
   518
    by (auto simp: space_pair_measure space_PiM Pi_iff split: nat.split)
hoelzl@50000
   519
  fix i :: nat and A assume A: "A \<in> sets M"
hoelzl@50000
   520
  then have *: "{\<omega> \<in> space (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)). prod_case nat_case \<omega> i \<in> A} =
hoelzl@50000
   521
    (case i of 0 \<Rightarrow> A \<times> space (\<Pi>\<^isub>M i\<in>UNIV. M) | Suc n \<Rightarrow> space M \<times> {\<omega>\<in>space (\<Pi>\<^isub>M i\<in>UNIV. M). \<omega> n \<in> A})"
hoelzl@50000
   522
    by (auto simp: space_PiM space_pair_measure split: nat.split dest: sets_into_space)
hoelzl@50000
   523
  show "{\<omega> \<in> space (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)). prod_case nat_case \<omega> i \<in> A} \<in> sets (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M))"
hoelzl@50000
   524
    unfolding * by (auto simp: A split: nat.split intro!: sets_Collect_single)
hoelzl@50000
   525
qed
hoelzl@50000
   526
hoelzl@50000
   527
lemma measurable_nat_case':
hoelzl@50000
   528
  assumes f: "f \<in> measurable N M" and g: "g \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   529
  shows "(\<lambda>x. nat_case (f x) (g x)) \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   530
  using measurable_compose[OF measurable_Pair[OF f g] measurable_nat_case] by simp
hoelzl@50000
   531
hoelzl@50000
   532
definition comb_seq :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a)" where
hoelzl@50000
   533
  "comb_seq i \<omega> \<omega>' j = (if j < i then \<omega> j else \<omega>' (j - i))"
hoelzl@50000
   534
hoelzl@50000
   535
lemma split_comb_seq: "P (comb_seq i \<omega> \<omega>' j) \<longleftrightarrow> (j < i \<longrightarrow> P (\<omega> j)) \<and> (\<forall>k. j = i + k \<longrightarrow> P (\<omega>' k))"
hoelzl@50000
   536
  by (auto simp: comb_seq_def not_less)
hoelzl@50000
   537
hoelzl@50000
   538
lemma split_comb_seq_asm: "P (comb_seq i \<omega> \<omega>' j) \<longleftrightarrow> \<not> ((j < i \<and> \<not> P (\<omega> j)) \<or> (\<exists>k. j = i + k \<and> \<not> P (\<omega>' k)))"
hoelzl@50000
   539
  by (auto simp: comb_seq_def)
hoelzl@42257
   540
hoelzl@50000
   541
lemma measurable_comb_seq: "(\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') \<in> measurable ((\<Pi>\<^isub>M i\<in>UNIV. M) \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)) (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   542
proof (rule measurable_PiM_single)
hoelzl@50000
   543
  show "(\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') \<in> space ((\<Pi>\<^isub>M i\<in>UNIV. M) \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)) \<rightarrow> (UNIV \<rightarrow>\<^isub>E space M)"
hoelzl@50000
   544
    by (auto simp: space_pair_measure space_PiM Pi_iff split: split_comb_seq)
hoelzl@50000
   545
  fix j :: nat and A assume A: "A \<in> sets M"
hoelzl@50000
   546
  then have *: "{\<omega> \<in> space ((\<Pi>\<^isub>M i\<in>UNIV. M) \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)). prod_case (comb_seq i) \<omega> j \<in> A} =
hoelzl@50000
   547
    (if j < i then {\<omega> \<in> space (\<Pi>\<^isub>M i\<in>UNIV. M). \<omega> j \<in> A} \<times> space (\<Pi>\<^isub>M i\<in>UNIV. M)
hoelzl@50000
   548
              else space (\<Pi>\<^isub>M i\<in>UNIV. M) \<times> {\<omega> \<in> space (\<Pi>\<^isub>M i\<in>UNIV. M). \<omega> (j - i) \<in> A})"
hoelzl@50000
   549
    by (auto simp: space_PiM space_pair_measure comb_seq_def dest: sets_into_space)
hoelzl@50000
   550
  show "{\<omega> \<in> space ((\<Pi>\<^isub>M i\<in>UNIV. M) \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)). prod_case (comb_seq i) \<omega> j \<in> A} \<in> sets ((\<Pi>\<^isub>M i\<in>UNIV. M) \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M))"
hoelzl@50000
   551
    unfolding * by (auto simp: A intro!: sets_Collect_single)
hoelzl@50000
   552
qed
hoelzl@50000
   553
hoelzl@50000
   554
lemma measurable_comb_seq':
hoelzl@50000
   555
  assumes f: "f \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)" and g: "g \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   556
  shows "(\<lambda>x. comb_seq i (f x) (g x)) \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
hoelzl@50000
   557
  using measurable_compose[OF measurable_Pair[OF f g] measurable_comb_seq] by simp
hoelzl@50000
   558
hoelzl@50000
   559
locale sequence_space = product_prob_space "\<lambda>i. M" "UNIV :: nat set" for M
hoelzl@50000
   560
begin
hoelzl@50000
   561
hoelzl@50000
   562
abbreviation "S \<equiv> \<Pi>\<^isub>M i\<in>UNIV::nat set. M"
hoelzl@50000
   563
hoelzl@50000
   564
lemma infprod_in_sets[intro]:
hoelzl@50000
   565
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
hoelzl@50000
   566
  shows "Pi UNIV E \<in> sets S"
hoelzl@42257
   567
proof -
hoelzl@42257
   568
  have "Pi UNIV E = (\<Inter>i. emb UNIV {..i} (\<Pi>\<^isub>E j\<in>{..i}. E j))"
hoelzl@47694
   569
    using E E[THEN sets_into_space]
hoelzl@47694
   570
    by (auto simp: prod_emb_def Pi_iff extensional_def) blast
hoelzl@47694
   571
  with E show ?thesis by auto
hoelzl@42257
   572
qed
hoelzl@42257
   573
hoelzl@50000
   574
lemma measure_PiM_countable:
hoelzl@50000
   575
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
hoelzl@50000
   576
  shows "(\<lambda>n. \<Prod>i\<le>n. measure M (E i)) ----> measure S (Pi UNIV E)"
hoelzl@42257
   577
proof -
wenzelm@46731
   578
  let ?E = "\<lambda>n. emb UNIV {..n} (Pi\<^isub>E {.. n} E)"
hoelzl@50000
   579
  have "\<And>n. (\<Prod>i\<le>n. measure M (E i)) = measure S (?E n)"
hoelzl@47694
   580
    using E by (simp add: measure_PiM_emb)
hoelzl@42257
   581
  moreover have "Pi UNIV E = (\<Inter>n. ?E n)"
hoelzl@47694
   582
    using E E[THEN sets_into_space]
hoelzl@47694
   583
    by (auto simp: prod_emb_def extensional_def Pi_iff) blast
hoelzl@50000
   584
  moreover have "range ?E \<subseteq> sets S"
hoelzl@42257
   585
    using E by auto
hoelzl@42257
   586
  moreover have "decseq ?E"
hoelzl@47694
   587
    by (auto simp: prod_emb_def Pi_iff decseq_def)
hoelzl@42257
   588
  ultimately show ?thesis
hoelzl@47694
   589
    by (simp add: finite_Lim_measure_decseq)
hoelzl@42257
   590
qed
hoelzl@42257
   591
hoelzl@50000
   592
lemma nat_eq_diff_eq: 
hoelzl@50000
   593
  fixes a b c :: nat
hoelzl@50000
   594
  shows "c \<le> b \<Longrightarrow> a = b - c \<longleftrightarrow> a + c = b"
hoelzl@50000
   595
  by auto
hoelzl@50000
   596
hoelzl@50000
   597
lemma PiM_comb_seq:
hoelzl@50000
   598
  "distr (S \<Otimes>\<^isub>M S) S (\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') = S" (is "?D = _")
hoelzl@50000
   599
proof (rule PiM_eq)
hoelzl@50000
   600
  let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
hoelzl@50000
   601
  let "distr _ _ ?f" = "?D"
hoelzl@50000
   602
hoelzl@50000
   603
  fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
hoelzl@50000
   604
  let ?X = "prod_emb ?I ?M J (\<Pi>\<^isub>E j\<in>J. E j)"
hoelzl@50000
   605
  have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
hoelzl@50000
   606
    using J(3)[THEN sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
hoelzl@50000
   607
  with J have "?f -` ?X \<inter> space (S \<Otimes>\<^isub>M S) =
hoelzl@50000
   608
    (prod_emb ?I ?M (J \<inter> {..<i}) (PIE j:J \<inter> {..<i}. E j)) \<times>
hoelzl@50000
   609
    (prod_emb ?I ?M ((op + i) -` J) (PIE j:(op + i) -` J. E (i + j)))" (is "_ = ?E \<times> ?F")
hoelzl@50000
   610
   by (auto simp: space_pair_measure space_PiM prod_emb_def all_conj_distrib Pi_iff
hoelzl@50000
   611
               split: split_comb_seq split_comb_seq_asm)
hoelzl@50000
   612
  then have "emeasure ?D ?X = emeasure (S \<Otimes>\<^isub>M S) (?E \<times> ?F)"
hoelzl@50000
   613
    by (subst emeasure_distr[OF measurable_comb_seq])
hoelzl@50000
   614
       (auto intro!: sets_PiM_I simp: split_beta' J)
hoelzl@50000
   615
  also have "\<dots> = emeasure S ?E * emeasure S ?F"
hoelzl@50000
   616
    using J by (intro P.emeasure_pair_measure_Times)  (auto intro!: sets_PiM_I finite_vimageI simp: inj_on_def)
hoelzl@50000
   617
  also have "emeasure S ?F = (\<Prod>j\<in>(op + i) -` J. emeasure M (E (i + j)))"
hoelzl@50000
   618
    using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI inj_on_def)
hoelzl@50000
   619
  also have "\<dots> = (\<Prod>j\<in>J - (J \<inter> {..<i}). emeasure M (E j))"
hoelzl@50000
   620
    by (rule strong_setprod_reindex_cong[where f="\<lambda>x. x - i"])
hoelzl@50000
   621
       (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
hoelzl@50000
   622
  also have "emeasure S ?E = (\<Prod>j\<in>J \<inter> {..<i}. emeasure M (E j))"
hoelzl@50000
   623
    using J by (intro emeasure_PiM_emb) simp_all
hoelzl@50000
   624
  also have "(\<Prod>j\<in>J \<inter> {..<i}. emeasure M (E j)) * (\<Prod>j\<in>J - (J \<inter> {..<i}). emeasure M (E j)) = (\<Prod>j\<in>J. emeasure M (E j))"
hoelzl@50000
   625
    by (subst mult_commute) (auto simp: J setprod_subset_diff[symmetric])
hoelzl@50000
   626
  finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
hoelzl@50000
   627
qed simp_all
hoelzl@50000
   628
hoelzl@50000
   629
lemma PiM_iter:
hoelzl@50000
   630
  "distr (M \<Otimes>\<^isub>M S) S (\<lambda>(s, \<omega>). nat_case s \<omega>) = S" (is "?D = _")
hoelzl@50000
   631
proof (rule PiM_eq)
hoelzl@50000
   632
  let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
hoelzl@50000
   633
  let "distr _ _ ?f" = "?D"
hoelzl@50000
   634
hoelzl@50000
   635
  fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
hoelzl@50000
   636
  let ?X = "prod_emb ?I ?M J (PIE j:J. E j)"
hoelzl@50000
   637
  have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
hoelzl@50000
   638
    using J(3)[THEN sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
hoelzl@50000
   639
  with J have "?f -` ?X \<inter> space (M \<Otimes>\<^isub>M S) = (if 0 \<in> J then E 0 else space M) \<times>
hoelzl@50000
   640
    (prod_emb ?I ?M (Suc -` J) (PIE j:Suc -` J. E (Suc j)))" (is "_ = ?E \<times> ?F")
hoelzl@50000
   641
   by (auto simp: space_pair_measure space_PiM Pi_iff prod_emb_def all_conj_distrib
hoelzl@50000
   642
      split: nat.split nat.split_asm)
hoelzl@50000
   643
  then have "emeasure ?D ?X = emeasure (M \<Otimes>\<^isub>M S) (?E \<times> ?F)"
hoelzl@50000
   644
    by (subst emeasure_distr[OF measurable_nat_case])
hoelzl@50000
   645
       (auto intro!: sets_PiM_I simp: split_beta' J)
hoelzl@50000
   646
  also have "\<dots> = emeasure M ?E * emeasure S ?F"
hoelzl@50000
   647
    using J by (intro P.emeasure_pair_measure_Times) (auto intro!: sets_PiM_I finite_vimageI)
hoelzl@50000
   648
  also have "emeasure S ?F = (\<Prod>j\<in>Suc -` J. emeasure M (E (Suc j)))"
hoelzl@50000
   649
    using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI)
hoelzl@50000
   650
  also have "\<dots> = (\<Prod>j\<in>J - {0}. emeasure M (E j))"
hoelzl@50000
   651
    by (rule strong_setprod_reindex_cong[where f="\<lambda>x. x - 1"])
hoelzl@50000
   652
       (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
hoelzl@50000
   653
  also have "emeasure M ?E * (\<Prod>j\<in>J - {0}. emeasure M (E j)) = (\<Prod>j\<in>J. emeasure M (E j))"
hoelzl@50000
   654
    by (auto simp: M.emeasure_space_1 setprod.remove J)
hoelzl@50000
   655
  finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
hoelzl@50000
   656
qed simp_all
hoelzl@50000
   657
hoelzl@50000
   658
end
hoelzl@50000
   659
hoelzl@42147
   660
end