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