src/HOL/Probability/Infinite_Product_Measure.thy
 author hoelzl Fri Nov 02 14:00:39 2012 +0100 (2012-11-02) changeset 50000 cfe8ee8a1371 parent 49804 ace9b5a83e60 child 50003 8c213922ed49 permissions -rw-r--r--
infinite product measure is invariant under adding prefixes
```     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
```
```     9 begin
```
```    10
```
```    11 lemma extensional_UNIV[simp]: "extensional UNIV = UNIV"
```
```    12   by (auto simp: extensional_def)
```
```    13
```
```    14 lemma restrict_extensional_sub[intro]: "A \<subseteq> B \<Longrightarrow> restrict f A \<in> extensional B"
```
```    15   unfolding restrict_def extensional_def by auto
```
```    16
```
```    17 lemma restrict_restrict[simp]: "restrict (restrict f A) B = restrict f (A \<inter> B)"
```
```    18   unfolding restrict_def by (simp add: fun_eq_iff)
```
```    19
```
```    20 lemma split_merge: "P (merge I J (x,y) i) \<longleftrightarrow> (i \<in> I \<longrightarrow> P (x i)) \<and> (i \<in> J - I \<longrightarrow> P (y i)) \<and> (i \<notin> I \<union> J \<longrightarrow> P undefined)"
```
```    21   unfolding merge_def by auto
```
```    22
```
```    23 lemma extensional_merge_sub: "I \<union> J \<subseteq> K \<Longrightarrow> merge I J (x, y) \<in> extensional K"
```
```    24   unfolding merge_def extensional_def by auto
```
```    25
```
```    26 lemma injective_vimage_restrict:
```
```    27   assumes J: "J \<subseteq> I"
```
```    28   and sets: "A \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" "B \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" and ne: "(\<Pi>\<^isub>E i\<in>I. S i) \<noteq> {}"
```
```    29   and eq: "(\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i) = (\<lambda>x. restrict x J) -` B \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
```
```    30   shows "A = B"
```
```    31 proof  (intro set_eqI)
```
```    32   fix x
```
```    33   from ne obtain y where y: "\<And>i. i \<in> I \<Longrightarrow> y i \<in> S i" by auto
```
```    34   have "J \<inter> (I - J) = {}" by auto
```
```    35   show "x \<in> A \<longleftrightarrow> x \<in> B"
```
```    36   proof cases
```
```    37     assume x: "x \<in> (\<Pi>\<^isub>E i\<in>J. S i)"
```
```    38     have "x \<in> A \<longleftrightarrow> merge J (I - J) (x,y) \<in> (\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
```
```    39       using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub split: split_merge)
```
```    40     then show "x \<in> A \<longleftrightarrow> x \<in> B"
```
```    41       using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub eq split: split_merge)
```
```    42   next
```
```    43     assume "x \<notin> (\<Pi>\<^isub>E i\<in>J. S i)" with sets show "x \<in> A \<longleftrightarrow> x \<in> B" by auto
```
```    44   qed
```
```    45 qed
```
```    46
```
```    47 lemma prod_algebraI_finite:
```
```    48   "finite I \<Longrightarrow> (\<forall>i\<in>I. E i \<in> sets (M i)) \<Longrightarrow> (Pi\<^isub>E I E) \<in> prod_algebra I M"
```
```    49   using prod_algebraI[of I I E M] prod_emb_PiE_same_index[of I E M, OF sets_into_space] by simp
```
```    50
```
```    51 lemma Int_stable_PiE: "Int_stable {Pi\<^isub>E J E | E. \<forall>i\<in>I. E i \<in> sets (M i)}"
```
```    52 proof (safe intro!: Int_stableI)
```
```    53   fix E F assume "\<forall>i\<in>I. E i \<in> sets (M i)" "\<forall>i\<in>I. F i \<in> sets (M i)"
```
```    54   then show "\<exists>G. Pi\<^isub>E J E \<inter> Pi\<^isub>E J F = Pi\<^isub>E J G \<and> (\<forall>i\<in>I. G i \<in> sets (M i))"
```
```    55     by (auto intro!: exI[of _ "\<lambda>i. E i \<inter> F i"])
```
```    56 qed
```
```    57
```
```    58 lemma prod_emb_trans[simp]:
```
```    59   "J \<subseteq> K \<Longrightarrow> K \<subseteq> L \<Longrightarrow> prod_emb L M K (prod_emb K M J X) = prod_emb L M J X"
```
```    60   by (auto simp add: Int_absorb1 prod_emb_def)
```
```    61
```
```    62 lemma prod_emb_Pi:
```
```    63   assumes "X \<in> (\<Pi> j\<in>J. sets (M j))" "J \<subseteq> K"
```
```    64   shows "prod_emb K M J (Pi\<^isub>E J X) = (\<Pi>\<^isub>E i\<in>K. if i \<in> J then X i else space (M i))"
```
```    65   using assms space_closed
```
```    66   by (auto simp: prod_emb_def Pi_iff split: split_if_asm) blast+
```
```    67
```
```    68 lemma prod_emb_id:
```
```    69   "B \<subseteq> (\<Pi>\<^isub>E i\<in>L. space (M i)) \<Longrightarrow> prod_emb L M L B = B"
```
```    70   by (auto simp: prod_emb_def Pi_iff subset_eq extensional_restrict)
```
```    71
```
```    72 lemma measurable_prod_emb[intro, simp]:
```
```    73   "J \<subseteq> L \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> prod_emb L M J X \<in> sets (Pi\<^isub>M L M)"
```
```    74   unfolding prod_emb_def space_PiM[symmetric]
```
```    75   by (auto intro!: measurable_sets measurable_restrict measurable_component_singleton)
```
```    76
```
```    77 lemma measurable_restrict_subset: "J \<subseteq> L \<Longrightarrow> (\<lambda>f. restrict f J) \<in> measurable (Pi\<^isub>M L M) (Pi\<^isub>M J M)"
```
```    78   by (intro measurable_restrict measurable_component_singleton) auto
```
```    79
```
```    80 lemma (in product_prob_space) distr_restrict:
```
```    81   assumes "J \<noteq> {}" "J \<subseteq> K" "finite K"
```
```    82   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")
```
```    83 proof (rule measure_eqI_generator_eq)
```
```    84   have "finite J" using `J \<subseteq> K` `finite K` by (auto simp add: finite_subset)
```
```    85   interpret J: finite_product_prob_space M J proof qed fact
```
```    86   interpret K: finite_product_prob_space M K proof qed fact
```
```    87
```
```    88   let ?J = "{Pi\<^isub>E J E | E. \<forall>i\<in>J. E i \<in> sets (M i)}"
```
```    89   let ?F = "\<lambda>i. \<Pi>\<^isub>E k\<in>J. space (M k)"
```
```    90   let ?\<Omega> = "(\<Pi>\<^isub>E k\<in>J. space (M k))"
```
```    91   show "Int_stable ?J"
```
```    92     by (rule Int_stable_PiE)
```
```    93   show "range ?F \<subseteq> ?J" "(\<Union>i. ?F i) = ?\<Omega>"
```
```    94     using `finite J` by (auto intro!: prod_algebraI_finite)
```
```    95   { fix i show "emeasure ?P (?F i) \<noteq> \<infinity>" by simp }
```
```    96   show "?J \<subseteq> Pow ?\<Omega>" by (auto simp: Pi_iff dest: sets_into_space)
```
```    97   show "sets (\<Pi>\<^isub>M i\<in>J. M i) = sigma_sets ?\<Omega> ?J" "sets ?D = sigma_sets ?\<Omega> ?J"
```
```    98     using `finite J` by (simp_all add: sets_PiM prod_algebra_eq_finite Pi_iff)
```
```    99
```
```   100   fix X assume "X \<in> ?J"
```
```   101   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
```
```   102   with `finite J` have X: "X \<in> sets (Pi\<^isub>M J M)" by auto
```
```   103
```
```   104   have "emeasure ?P X = (\<Prod> i\<in>J. emeasure (M i) (E i))"
```
```   105     using E by (simp add: J.measure_times)
```
```   106   also have "\<dots> = (\<Prod> i\<in>J. emeasure (M i) (if i \<in> J then E i else space (M i)))"
```
```   107     by simp
```
```   108   also have "\<dots> = (\<Prod> i\<in>K. emeasure (M i) (if i \<in> J then E i else space (M i)))"
```
```   109     using `finite K` `J \<subseteq> K`
```
```   110     by (intro setprod_mono_one_left) (auto simp: M.emeasure_space_1)
```
```   111   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))"
```
```   112     using E by (simp add: K.measure_times)
```
```   113   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))"
```
```   114     using `J \<subseteq> K` sets_into_space E by (force simp:  Pi_iff split: split_if_asm)
```
```   115   finally show "emeasure (Pi\<^isub>M J M) X = emeasure ?D X"
```
```   116     using X `J \<subseteq> K` apply (subst emeasure_distr)
```
```   117     by (auto intro!: measurable_restrict_subset simp: space_PiM)
```
```   118 qed
```
```   119
```
```   120 abbreviation (in product_prob_space)
```
```   121   "emb L K X \<equiv> prod_emb L M K X"
```
```   122
```
```   123 lemma (in product_prob_space) emeasure_prod_emb[simp]:
```
```   124   assumes L: "J \<noteq> {}" "J \<subseteq> L" "finite L" and X: "X \<in> sets (Pi\<^isub>M J M)"
```
```   125   shows "emeasure (Pi\<^isub>M L M) (emb L J X) = emeasure (Pi\<^isub>M J M) X"
```
```   126   by (subst distr_restrict[OF L])
```
```   127      (simp add: prod_emb_def space_PiM emeasure_distr measurable_restrict_subset L X)
```
```   128
```
```   129 lemma (in product_prob_space) prod_emb_injective:
```
```   130   assumes "J \<noteq> {}" "J \<subseteq> L" "finite J" and sets: "X \<in> sets (Pi\<^isub>M J M)" "Y \<in> sets (Pi\<^isub>M J M)"
```
```   131   assumes "prod_emb L M J X = prod_emb L M J Y"
```
```   132   shows "X = Y"
```
```   133 proof (rule injective_vimage_restrict)
```
```   134   show "X \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))" "Y \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
```
```   135     using sets[THEN sets_into_space] by (auto simp: space_PiM)
```
```   136   have "\<forall>i\<in>L. \<exists>x. x \<in> space (M i)"
```
```   137       using M.not_empty by auto
```
```   138   from bchoice[OF this]
```
```   139   show "(\<Pi>\<^isub>E i\<in>L. space (M i)) \<noteq> {}" by auto
```
```   140   show "(\<lambda>x. restrict x J) -` X \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i)) = (\<lambda>x. restrict x J) -` Y \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i))"
```
```   141     using `prod_emb L M J X = prod_emb L M J Y` by (simp add: prod_emb_def)
```
```   142 qed fact
```
```   143
```
```   144 definition (in product_prob_space) generator :: "('i \<Rightarrow> 'a) set set" where
```
```   145   "generator = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M))"
```
```   146
```
```   147 lemma (in product_prob_space) generatorI':
```
```   148   "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> emb I J X \<in> generator"
```
```   149   unfolding generator_def by auto
```
```   150
```
```   151 lemma (in product_prob_space) algebra_generator:
```
```   152   assumes "I \<noteq> {}" shows "algebra (\<Pi>\<^isub>E i\<in>I. space (M i)) generator" (is "algebra ?\<Omega> ?G")
```
```   153   unfolding algebra_def algebra_axioms_def ring_of_sets_iff
```
```   154 proof (intro conjI ballI)
```
```   155   let ?G = generator
```
```   156   show "?G \<subseteq> Pow ?\<Omega>"
```
```   157     by (auto simp: generator_def prod_emb_def)
```
```   158   from `I \<noteq> {}` obtain i where "i \<in> I" by auto
```
```   159   then show "{} \<in> ?G"
```
```   160     by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\<lambda>i. {}"]
```
```   161              simp: sigma_sets.Empty generator_def prod_emb_def)
```
```   162   from `i \<in> I` show "?\<Omega> \<in> ?G"
```
```   163     by (auto intro!: exI[of _ "{i}"] image_eqI[where x="Pi\<^isub>E {i} (\<lambda>i. space (M i))"]
```
```   164              simp: generator_def prod_emb_def)
```
```   165   fix A assume "A \<in> ?G"
```
```   166   then obtain JA XA where XA: "JA \<noteq> {}" "finite JA" "JA \<subseteq> I" "XA \<in> sets (Pi\<^isub>M JA M)" and A: "A = emb I JA XA"
```
```   167     by (auto simp: generator_def)
```
```   168   fix B assume "B \<in> ?G"
```
```   169   then obtain JB XB where XB: "JB \<noteq> {}" "finite JB" "JB \<subseteq> I" "XB \<in> sets (Pi\<^isub>M JB M)" and B: "B = emb I JB XB"
```
```   170     by (auto simp: generator_def)
```
```   171   let ?RA = "emb (JA \<union> JB) JA XA"
```
```   172   let ?RB = "emb (JA \<union> JB) JB XB"
```
```   173   have *: "A - B = emb I (JA \<union> JB) (?RA - ?RB)" "A \<union> B = emb I (JA \<union> JB) (?RA \<union> ?RB)"
```
```   174     using XA A XB B by auto
```
```   175   show "A - B \<in> ?G" "A \<union> B \<in> ?G"
```
```   176     unfolding * using XA XB by (safe intro!: generatorI') auto
```
```   177 qed
```
```   178
```
```   179 lemma (in product_prob_space) sets_PiM_generator:
```
```   180   "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
```
```   181 proof cases
```
```   182   assume "I = {}" then show ?thesis
```
```   183     unfolding generator_def
```
```   184     by (auto simp: sets_PiM_empty sigma_sets_empty_eq cong: conj_cong)
```
```   185 next
```
```   186   assume "I \<noteq> {}"
```
```   187   show ?thesis
```
```   188   proof
```
```   189     show "sets (Pi\<^isub>M I M) \<subseteq> sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
```
```   190       unfolding sets_PiM
```
```   191     proof (safe intro!: sigma_sets_subseteq)
```
```   192       fix A assume "A \<in> prod_algebra I M" with `I \<noteq> {}` show "A \<in> generator"
```
```   193         by (auto intro!: generatorI' elim!: prod_algebraE)
```
```   194     qed
```
```   195   qed (auto simp: generator_def space_PiM[symmetric] intro!: sigma_sets_subset)
```
```   196 qed
```
```   197
```
```   198
```
```   199 lemma (in product_prob_space) generatorI:
```
```   200   "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> A = emb I J X \<Longrightarrow> A \<in> generator"
```
```   201   unfolding generator_def by auto
```
```   202
```
```   203 definition (in product_prob_space)
```
```   204   "\<mu>G A =
```
```   205     (THE x. \<forall>J. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> J \<subseteq> I \<longrightarrow> (\<forall>X\<in>sets (Pi\<^isub>M J M). A = emb I J X \<longrightarrow> x = emeasure (Pi\<^isub>M J M) X))"
```
```   206
```
```   207 lemma (in product_prob_space) \<mu>G_spec:
```
```   208   assumes J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
```
```   209   shows "\<mu>G A = emeasure (Pi\<^isub>M J M) X"
```
```   210   unfolding \<mu>G_def
```
```   211 proof (intro the_equality allI impI ballI)
```
```   212   fix K Y assume K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "A = emb I K Y" "Y \<in> sets (Pi\<^isub>M K M)"
```
```   213   have "emeasure (Pi\<^isub>M K M) Y = emeasure (Pi\<^isub>M (K \<union> J) M) (emb (K \<union> J) K Y)"
```
```   214     using K J by simp
```
```   215   also have "emb (K \<union> J) K Y = emb (K \<union> J) J X"
```
```   216     using K J by (simp add: prod_emb_injective[of "K \<union> J" I])
```
```   217   also have "emeasure (Pi\<^isub>M (K \<union> J) M) (emb (K \<union> J) J X) = emeasure (Pi\<^isub>M J M) X"
```
```   218     using K J by simp
```
```   219   finally show "emeasure (Pi\<^isub>M J M) X = emeasure (Pi\<^isub>M K M) Y" ..
```
```   220 qed (insert J, force)
```
```   221
```
```   222 lemma (in product_prob_space) \<mu>G_eq:
```
```   223   "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> \<mu>G (emb I J X) = emeasure (Pi\<^isub>M J M) X"
```
```   224   by (intro \<mu>G_spec) auto
```
```   225
```
```   226 lemma (in product_prob_space) generator_Ex:
```
```   227   assumes *: "A \<in> generator"
```
```   228   shows "\<exists>J X. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I \<and> X \<in> sets (Pi\<^isub>M J M) \<and> A = emb I J X \<and> \<mu>G A = emeasure (Pi\<^isub>M J M) X"
```
```   229 proof -
```
```   230   from * obtain J X where J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
```
```   231     unfolding generator_def by auto
```
```   232   with \<mu>G_spec[OF this] show ?thesis by auto
```
```   233 qed
```
```   234
```
```   235 lemma (in product_prob_space) generatorE:
```
```   236   assumes A: "A \<in> generator"
```
```   237   obtains J X where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A" "\<mu>G A = emeasure (Pi\<^isub>M J M) X"
```
```   238 proof -
```
```   239   from generator_Ex[OF A] obtain X J where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A"
```
```   240     "\<mu>G A = emeasure (Pi\<^isub>M J M) X" by auto
```
```   241   then show thesis by (intro that) auto
```
```   242 qed
```
```   243
```
```   244 lemma (in product_prob_space) merge_sets:
```
```   245   assumes "J \<inter> K = {}" and A: "A \<in> sets (Pi\<^isub>M (J \<union> K) M)" and x: "x \<in> space (Pi\<^isub>M J M)"
```
```   246   shows "(\<lambda>y. merge J K (x,y)) -` A \<inter> space (Pi\<^isub>M K M) \<in> sets (Pi\<^isub>M K M)"
```
```   247   by (rule measurable_sets[OF _ A] measurable_compose[OF measurable_Pair measurable_merge]
```
```   248            measurable_const x measurable_ident)+
```
```   249
```
```   250 lemma (in product_prob_space) merge_emb:
```
```   251   assumes "K \<subseteq> I" "J \<subseteq> I" and y: "y \<in> space (Pi\<^isub>M J M)"
```
```   252   shows "((\<lambda>x. merge J (I - J) (y, x)) -` emb I K X \<inter> space (Pi\<^isub>M I M)) =
```
```   253     emb I (K - J) ((\<lambda>x. merge J (K - J) (y, x)) -` emb (J \<union> K) K X \<inter> space (Pi\<^isub>M (K - J) M))"
```
```   254 proof -
```
```   255   have [simp]: "\<And>x J K L. merge J K (y, restrict x L) = merge J (K \<inter> L) (y, x)"
```
```   256     by (auto simp: restrict_def merge_def)
```
```   257   have [simp]: "\<And>x J K L. restrict (merge J K (y, x)) L = merge (J \<inter> L) (K \<inter> L) (y, x)"
```
```   258     by (auto simp: restrict_def merge_def)
```
```   259   have [simp]: "(I - J) \<inter> K = K - J" using `K \<subseteq> I` `J \<subseteq> I` by auto
```
```   260   have [simp]: "(K - J) \<inter> (K \<union> J) = K - J" by auto
```
```   261   have [simp]: "(K - J) \<inter> K = K - J" by auto
```
```   262   from y `K \<subseteq> I` `J \<subseteq> I` show ?thesis
```
```   263     by (simp split: split_merge add: prod_emb_def Pi_iff extensional_merge_sub set_eq_iff space_PiM)
```
```   264        auto
```
```   265 qed
```
```   266
```
```   267 lemma (in product_prob_space) positive_\<mu>G:
```
```   268   assumes "I \<noteq> {}"
```
```   269   shows "positive generator \<mu>G"
```
```   270 proof -
```
```   271   interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
```
```   272   show ?thesis
```
```   273   proof (intro positive_def[THEN iffD2] conjI ballI)
```
```   274     from generatorE[OF G.empty_sets] guess J X . note this[simp]
```
```   275     interpret J: finite_product_sigma_finite M J by default fact
```
```   276     have "X = {}"
```
```   277       by (rule prod_emb_injective[of J I]) simp_all
```
```   278     then show "\<mu>G {} = 0" by simp
```
```   279   next
```
```   280     fix A assume "A \<in> generator"
```
```   281     from generatorE[OF this] guess J X . note this[simp]
```
```   282     interpret J: finite_product_sigma_finite M J by default fact
```
```   283     show "0 \<le> \<mu>G A" by (simp add: emeasure_nonneg)
```
```   284   qed
```
```   285 qed
```
```   286
```
```   287 lemma (in product_prob_space) additive_\<mu>G:
```
```   288   assumes "I \<noteq> {}"
```
```   289   shows "additive generator \<mu>G"
```
```   290 proof -
```
```   291   interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
```
```   292   show ?thesis
```
```   293   proof (intro additive_def[THEN iffD2] ballI impI)
```
```   294     fix A assume "A \<in> generator" with generatorE guess J X . note J = this
```
```   295     fix B assume "B \<in> generator" with generatorE guess K Y . note K = this
```
```   296     assume "A \<inter> B = {}"
```
```   297     have JK: "J \<union> K \<noteq> {}" "J \<union> K \<subseteq> I" "finite (J \<union> K)"
```
```   298       using J K by auto
```
```   299     interpret JK: finite_product_sigma_finite M "J \<union> K" by default fact
```
```   300     have JK_disj: "emb (J \<union> K) J X \<inter> emb (J \<union> K) K Y = {}"
```
```   301       apply (rule prod_emb_injective[of "J \<union> K" I])
```
```   302       apply (insert `A \<inter> B = {}` JK J K)
```
```   303       apply (simp_all add: Int prod_emb_Int)
```
```   304       done
```
```   305     have AB: "A = emb I (J \<union> K) (emb (J \<union> K) J X)" "B = emb I (J \<union> K) (emb (J \<union> K) K Y)"
```
```   306       using J K by simp_all
```
```   307     then have "\<mu>G (A \<union> B) = \<mu>G (emb I (J \<union> K) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y))"
```
```   308       by simp
```
```   309     also have "\<dots> = emeasure (Pi\<^isub>M (J \<union> K) M) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y)"
```
```   310       using JK J(1, 4) K(1, 4) by (simp add: \<mu>G_eq Un del: prod_emb_Un)
```
```   311     also have "\<dots> = \<mu>G A + \<mu>G B"
```
```   312       using J K JK_disj by (simp add: plus_emeasure[symmetric])
```
```   313     finally show "\<mu>G (A \<union> B) = \<mu>G A + \<mu>G B" .
```
```   314   qed
```
```   315 qed
```
```   316
```
```   317 lemma (in product_prob_space) emeasure_PiM_emb_not_empty:
```
```   318   assumes X: "J \<noteq> {}" "J \<subseteq> I" "finite J" "\<forall>i\<in>J. X i \<in> sets (M i)"
```
```   319   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)"
```
```   320 proof cases
```
```   321   assume "finite I" with X show ?thesis by simp
```
```   322 next
```
```   323   let ?\<Omega> = "\<Pi>\<^isub>E i\<in>I. space (M i)"
```
```   324   let ?G = generator
```
```   325   assume "\<not> finite I"
```
```   326   then have I_not_empty: "I \<noteq> {}" by auto
```
```   327   interpret G!: algebra ?\<Omega> generator by (rule algebra_generator) fact
```
```   328   note \<mu>G_mono =
```
```   329     G.additive_increasing[OF positive_\<mu>G[OF I_not_empty] additive_\<mu>G[OF I_not_empty], THEN increasingD]
```
```   330
```
```   331   { fix Z J assume J: "J \<noteq> {}" "finite J" "J \<subseteq> I" and Z: "Z \<in> ?G"
```
```   332
```
```   333     from `infinite I` `finite J` obtain k where k: "k \<in> I" "k \<notin> J"
```
```   334       by (metis rev_finite_subset subsetI)
```
```   335     moreover from Z guess K' X' by (rule generatorE)
```
```   336     moreover def K \<equiv> "insert k K'"
```
```   337     moreover def X \<equiv> "emb K K' X'"
```
```   338     ultimately have K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "X \<in> sets (Pi\<^isub>M K M)" "Z = emb I K X"
```
```   339       "K - J \<noteq> {}" "K - J \<subseteq> I" "\<mu>G Z = emeasure (Pi\<^isub>M K M) X"
```
```   340       by (auto simp: subset_insertI)
```
```   341
```
```   342     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)"
```
```   343     { fix y assume y: "y \<in> space (Pi\<^isub>M J M)"
```
```   344       note * = merge_emb[OF `K \<subseteq> I` `J \<subseteq> I` y, of X]
```
```   345       moreover
```
```   346       have **: "?M y \<in> sets (Pi\<^isub>M (K - J) M)"
```
```   347         using J K y by (intro merge_sets) auto
```
```   348       ultimately
```
```   349       have ***: "((\<lambda>x. merge J (I - J) (y, x)) -` Z \<inter> space (Pi\<^isub>M I M)) \<in> ?G"
```
```   350         using J K by (intro generatorI) auto
```
```   351       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)"
```
```   352         unfolding * using K J by (subst \<mu>G_eq[OF _ _ _ **]) auto
```
```   353       note * ** *** this }
```
```   354     note merge_in_G = this
```
```   355
```
```   356     have "finite (K - J)" using K by auto
```
```   357
```
```   358     interpret J: finite_product_prob_space M J by default fact+
```
```   359     interpret KmJ: finite_product_prob_space M "K - J" by default fact+
```
```   360
```
```   361     have "\<mu>G Z = emeasure (Pi\<^isub>M (J \<union> (K - J)) M) (emb (J \<union> (K - J)) K X)"
```
```   362       using K J by simp
```
```   363     also have "\<dots> = (\<integral>\<^isup>+ x. emeasure (Pi\<^isub>M (K - J) M) (?M x) \<partial>Pi\<^isub>M J M)"
```
```   364       using K J by (subst emeasure_fold_integral) auto
```
```   365     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)"
```
```   366       (is "_ = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)")
```
```   367     proof (intro positive_integral_cong)
```
```   368       fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
```
```   369       with K merge_in_G(2)[OF this]
```
```   370       show "emeasure (Pi\<^isub>M (K - J) M) (?M x) = \<mu>G (?MZ x)"
```
```   371         unfolding `Z = emb I K X` merge_in_G(1)[OF x] by (subst \<mu>G_eq) auto
```
```   372     qed
```
```   373     finally have fold: "\<mu>G Z = (\<integral>\<^isup>+x. \<mu>G (?MZ x) \<partial>Pi\<^isub>M J M)" .
```
```   374
```
```   375     { fix x assume x: "x \<in> space (Pi\<^isub>M J M)"
```
```   376       then have "\<mu>G (?MZ x) \<le> 1"
```
```   377         unfolding merge_in_G(4)[OF x] `Z = emb I K X`
```
```   378         by (intro KmJ.measure_le_1 merge_in_G(2)[OF x]) }
```
```   379     note le_1 = this
```
```   380
```
```   381     let ?q = "\<lambda>y. \<mu>G ((\<lambda>x. merge J (I - J) (y,x)) -` Z \<inter> space (Pi\<^isub>M I M))"
```
```   382     have "?q \<in> borel_measurable (Pi\<^isub>M J M)"
```
```   383       unfolding `Z = emb I K X` using J K merge_in_G(3)
```
```   384       by (simp add: merge_in_G  \<mu>G_eq emeasure_fold_measurable cong: measurable_cong)
```
```   385     note this fold le_1 merge_in_G(3) }
```
```   386   note fold = this
```
```   387
```
```   388   have "\<exists>\<mu>. (\<forall>s\<in>?G. \<mu> s = \<mu>G s) \<and> measure_space ?\<Omega> (sigma_sets ?\<Omega> ?G) \<mu>"
```
```   389   proof (rule G.caratheodory_empty_continuous[OF positive_\<mu>G additive_\<mu>G])
```
```   390     fix A assume "A \<in> ?G"
```
```   391     with generatorE guess J X . note JX = this
```
```   392     interpret JK: finite_product_prob_space M J by default fact+
```
```   393     from JX show "\<mu>G A \<noteq> \<infinity>" by simp
```
```   394   next
```
```   395     fix A assume A: "range A \<subseteq> ?G" "decseq A" "(\<Inter>i. A i) = {}"
```
```   396     then have "decseq (\<lambda>i. \<mu>G (A i))"
```
```   397       by (auto intro!: \<mu>G_mono simp: decseq_def)
```
```   398     moreover
```
```   399     have "(INF i. \<mu>G (A i)) = 0"
```
```   400     proof (rule ccontr)
```
```   401       assume "(INF i. \<mu>G (A i)) \<noteq> 0" (is "?a \<noteq> 0")
```
```   402       moreover have "0 \<le> ?a"
```
```   403         using A positive_\<mu>G[OF I_not_empty] by (auto intro!: INF_greatest simp: positive_def)
```
```   404       ultimately have "0 < ?a" by auto
```
```   405
```
```   406       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 (Pi\<^isub>M J M) X"
```
```   407         using A by (intro allI generator_Ex) auto
```
```   408       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)"
```
```   409         and A': "\<And>n. A n = emb I (J' n) (X' n)"
```
```   410         unfolding choice_iff by blast
```
```   411       moreover def J \<equiv> "\<lambda>n. (\<Union>i\<le>n. J' i)"
```
```   412       moreover def X \<equiv> "\<lambda>n. emb (J n) (J' n) (X' n)"
```
```   413       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)"
```
```   414         by auto
```
```   415       with A' have A_eq: "\<And>n. A n = emb I (J n) (X n)" "\<And>n. A n \<in> ?G"
```
```   416         unfolding J_def X_def by (subst prod_emb_trans) (insert A, auto)
```
```   417
```
```   418       have J_mono: "\<And>n m. n \<le> m \<Longrightarrow> J n \<subseteq> J m"
```
```   419         unfolding J_def by force
```
```   420
```
```   421       interpret J: finite_product_prob_space M "J i" for i by default fact+
```
```   422
```
```   423       have a_le_1: "?a \<le> 1"
```
```   424         using \<mu>G_spec[of "J 0" "A 0" "X 0"] J A_eq
```
```   425         by (auto intro!: INF_lower2[of 0] J.measure_le_1)
```
```   426
```
```   427       let ?M = "\<lambda>K Z y. (\<lambda>x. merge K (I - K) (y, x)) -` Z \<inter> space (Pi\<^isub>M I M)"
```
```   428
```
```   429       { fix Z k assume Z: "range Z \<subseteq> ?G" "decseq Z" "\<forall>n. ?a / 2^k \<le> \<mu>G (Z n)"
```
```   430         then have Z_sets: "\<And>n. Z n \<in> ?G" by auto
```
```   431         fix J' assume J': "J' \<noteq> {}" "finite J'" "J' \<subseteq> I"
```
```   432         interpret J': finite_product_prob_space M J' by default fact+
```
```   433
```
```   434         let ?q = "\<lambda>n y. \<mu>G (?M J' (Z n) y)"
```
```   435         let ?Q = "\<lambda>n. ?q n -` {?a / 2^(k+1) ..} \<inter> space (Pi\<^isub>M J' M)"
```
```   436         { fix n
```
```   437           have "?q n \<in> borel_measurable (Pi\<^isub>M J' M)"
```
```   438             using Z J' by (intro fold(1)) auto
```
```   439           then have "?Q n \<in> sets (Pi\<^isub>M J' M)"
```
```   440             by (rule measurable_sets) auto }
```
```   441         note Q_sets = this
```
```   442
```
```   443         have "?a / 2^(k+1) \<le> (INF n. emeasure (Pi\<^isub>M J' M) (?Q n))"
```
```   444         proof (intro INF_greatest)
```
```   445           fix n
```
```   446           have "?a / 2^k \<le> \<mu>G (Z n)" using Z by auto
```
```   447           also have "\<dots> \<le> (\<integral>\<^isup>+ x. indicator (?Q n) x + ?a / 2^(k+1) \<partial>Pi\<^isub>M J' M)"
```
```   448             unfolding fold(2)[OF J' `Z n \<in> ?G`]
```
```   449           proof (intro positive_integral_mono)
```
```   450             fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
```
```   451             then have "?q n x \<le> 1 + 0"
```
```   452               using J' Z fold(3) Z_sets by auto
```
```   453             also have "\<dots> \<le> 1 + ?a / 2^(k+1)"
```
```   454               using `0 < ?a` by (intro add_mono) auto
```
```   455             finally have "?q n x \<le> 1 + ?a / 2^(k+1)" .
```
```   456             with x show "?q n x \<le> indicator (?Q n) x + ?a / 2^(k+1)"
```
```   457               by (auto split: split_indicator simp del: power_Suc)
```
```   458           qed
```
```   459           also have "\<dots> = emeasure (Pi\<^isub>M J' M) (?Q n) + ?a / 2^(k+1)"
```
```   460             using `0 \<le> ?a` Q_sets J'.emeasure_space_1
```
```   461             by (subst positive_integral_add) auto
```
```   462           finally show "?a / 2^(k+1) \<le> emeasure (Pi\<^isub>M J' M) (?Q n)" using `?a \<le> 1`
```
```   463             by (cases rule: ereal2_cases[of ?a "emeasure (Pi\<^isub>M J' M) (?Q n)"])
```
```   464                (auto simp: field_simps)
```
```   465         qed
```
```   466         also have "\<dots> = emeasure (Pi\<^isub>M J' M) (\<Inter>n. ?Q n)"
```
```   467         proof (intro INF_emeasure_decseq)
```
```   468           show "range ?Q \<subseteq> sets (Pi\<^isub>M J' M)" using Q_sets by auto
```
```   469           show "decseq ?Q"
```
```   470             unfolding decseq_def
```
```   471           proof (safe intro!: vimageI[OF refl])
```
```   472             fix m n :: nat assume "m \<le> n"
```
```   473             fix x assume x: "x \<in> space (Pi\<^isub>M J' M)"
```
```   474             assume "?a / 2^(k+1) \<le> ?q n x"
```
```   475             also have "?q n x \<le> ?q m x"
```
```   476             proof (rule \<mu>G_mono)
```
```   477               from fold(4)[OF J', OF Z_sets x]
```
```   478               show "?M J' (Z n) x \<in> ?G" "?M J' (Z m) x \<in> ?G" by auto
```
```   479               show "?M J' (Z n) x \<subseteq> ?M J' (Z m) x"
```
```   480                 using `decseq Z`[THEN decseqD, OF `m \<le> n`] by auto
```
```   481             qed
```
```   482             finally show "?a / 2^(k+1) \<le> ?q m x" .
```
```   483           qed
```
```   484         qed simp
```
```   485         finally have "(\<Inter>n. ?Q n) \<noteq> {}"
```
```   486           using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
```
```   487         then have "\<exists>w\<in>space (Pi\<^isub>M J' M). \<forall>n. ?a / 2 ^ (k + 1) \<le> ?q n w" by auto }
```
```   488       note Ex_w = this
```
```   489
```
```   490       let ?q = "\<lambda>k n y. \<mu>G (?M (J k) (A n) y)"
```
```   491
```
```   492       have "\<forall>n. ?a / 2 ^ 0 \<le> \<mu>G (A n)" by (auto intro: INF_lower)
```
```   493       from Ex_w[OF A(1,2) this J(1-3), of 0] guess w0 .. note w0 = this
```
```   494
```
```   495       let ?P =
```
```   496         "\<lambda>k wk w. w \<in> space (Pi\<^isub>M (J (Suc k)) M) \<and> restrict w (J k) = wk \<and>
```
```   497           (\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n w)"
```
```   498       def w \<equiv> "nat_rec w0 (\<lambda>k wk. Eps (?P k wk))"
```
```   499
```
```   500       { fix k have w: "w k \<in> space (Pi\<^isub>M (J k) M) \<and>
```
```   501           (\<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))"
```
```   502         proof (induct k)
```
```   503           case 0 with w0 show ?case
```
```   504             unfolding w_def nat_rec_0 by auto
```
```   505         next
```
```   506           case (Suc k)
```
```   507           then have wk: "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
```
```   508           have "\<exists>w'. ?P k (w k) w'"
```
```   509           proof cases
```
```   510             assume [simp]: "J k = J (Suc k)"
```
```   511             show ?thesis
```
```   512             proof (intro exI[of _ "w k"] conjI allI)
```
```   513               fix n
```
```   514               have "?a / 2 ^ (Suc k + 1) \<le> ?a / 2 ^ (k + 1)"
```
```   515                 using `0 < ?a` `?a \<le> 1` by (cases ?a) (auto simp: field_simps)
```
```   516               also have "\<dots> \<le> ?q k n (w k)" using Suc by auto
```
```   517               finally show "?a / 2 ^ (Suc k + 1) \<le> ?q (Suc k) n (w k)" by simp
```
```   518             next
```
```   519               show "w k \<in> space (Pi\<^isub>M (J (Suc k)) M)"
```
```   520                 using Suc by simp
```
```   521               then show "restrict (w k) (J k) = w k"
```
```   522                 by (simp add: extensional_restrict space_PiM)
```
```   523             qed
```
```   524           next
```
```   525             assume "J k \<noteq> J (Suc k)"
```
```   526             with J_mono[of k "Suc k"] have "J (Suc k) - J k \<noteq> {}" (is "?D \<noteq> {}") by auto
```
```   527             have "range (\<lambda>n. ?M (J k) (A n) (w k)) \<subseteq> ?G"
```
```   528               "decseq (\<lambda>n. ?M (J k) (A n) (w k))"
```
```   529               "\<forall>n. ?a / 2 ^ (k + 1) \<le> \<mu>G (?M (J k) (A n) (w k))"
```
```   530               using `decseq A` fold(4)[OF J(1-3) A_eq(2), of "w k" k] Suc
```
```   531               by (auto simp: decseq_def)
```
```   532             from Ex_w[OF this `?D \<noteq> {}`] J[of "Suc k"]
```
```   533             obtain w' where w': "w' \<in> space (Pi\<^isub>M ?D M)"
```
```   534               "\<forall>n. ?a / 2 ^ (Suc k + 1) \<le> \<mu>G (?M ?D (?M (J k) (A n) (w k)) w')" by auto
```
```   535             let ?w = "merge (J k) ?D (w k, w')"
```
```   536             have [simp]: "\<And>x. merge (J k) (I - J k) (w k, merge ?D (I - ?D) (w', x)) =
```
```   537               merge (J (Suc k)) (I - (J (Suc k))) (?w, x)"
```
```   538               using J(3)[of "Suc k"] J(3)[of k] J_mono[of k "Suc k"]
```
```   539               by (auto intro!: ext split: split_merge)
```
```   540             have *: "\<And>n. ?M ?D (?M (J k) (A n) (w k)) w' = ?M (J (Suc k)) (A n) ?w"
```
```   541               using w'(1) J(3)[of "Suc k"]
```
```   542               by (auto simp: space_PiM split: split_merge intro!: extensional_merge_sub) force+
```
```   543             show ?thesis
```
```   544               apply (rule exI[of _ ?w])
```
```   545               using w' J_mono[of k "Suc k"] wk unfolding *
```
```   546               apply (auto split: split_merge intro!: extensional_merge_sub ext simp: space_PiM)
```
```   547               apply (force simp: extensional_def)
```
```   548               done
```
```   549           qed
```
```   550           then have "?P k (w k) (w (Suc k))"
```
```   551             unfolding w_def nat_rec_Suc unfolding w_def[symmetric]
```
```   552             by (rule someI_ex)
```
```   553           then show ?case by auto
```
```   554         qed
```
```   555         moreover
```
```   556         then have "w k \<in> space (Pi\<^isub>M (J k) M)" by auto
```
```   557         moreover
```
```   558         from w have "?a / 2 ^ (k + 1) \<le> ?q k k (w k)" by auto
```
```   559         then have "?M (J k) (A k) (w k) \<noteq> {}"
```
```   560           using positive_\<mu>G[OF I_not_empty, unfolded positive_def] `0 < ?a` `?a \<le> 1`
```
```   561           by (cases ?a) (auto simp: divide_le_0_iff power_le_zero_eq)
```
```   562         then obtain x where "x \<in> ?M (J k) (A k) (w k)" by auto
```
```   563         then have "merge (J k) (I - J k) (w k, x) \<in> A k" by auto
```
```   564         then have "\<exists>x\<in>A k. restrict x (J k) = w k"
```
```   565           using `w k \<in> space (Pi\<^isub>M (J k) M)`
```
```   566           by (intro rev_bexI) (auto intro!: ext simp: extensional_def space_PiM)
```
```   567         ultimately have "w k \<in> space (Pi\<^isub>M (J k) M)"
```
```   568           "\<exists>x\<in>A k. restrict x (J k) = w k"
```
```   569           "k \<noteq> 0 \<Longrightarrow> restrict (w k) (J (k - 1)) = w (k - 1)"
```
```   570           by auto }
```
```   571       note w = this
```
```   572
```
```   573       { fix k l i assume "k \<le> l" "i \<in> J k"
```
```   574         { fix l have "w k i = w (k + l) i"
```
```   575           proof (induct l)
```
```   576             case (Suc l)
```
```   577             from `i \<in> J k` J_mono[of k "k + l"] have "i \<in> J (k + l)" by auto
```
```   578             with w(3)[of "k + Suc l"]
```
```   579             have "w (k + l) i = w (k + Suc l) i"
```
```   580               by (auto simp: restrict_def fun_eq_iff split: split_if_asm)
```
```   581             with Suc show ?case by simp
```
```   582           qed simp }
```
```   583         from this[of "l - k"] `k \<le> l` have "w l i = w k i" by simp }
```
```   584       note w_mono = this
```
```   585
```
```   586       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"
```
```   587       { fix i k assume k: "i \<in> J k"
```
```   588         have "w k i = w (LEAST k. i \<in> J k) i"
```
```   589           by (intro w_mono Least_le k LeastI[of _ k])
```
```   590         then have "w' i = w k i"
```
```   591           unfolding w'_def using k by auto }
```
```   592       note w'_eq = this
```
```   593       have w'_simps1: "\<And>i. i \<notin> I \<Longrightarrow> w' i = undefined"
```
```   594         using J by (auto simp: w'_def)
```
```   595       have w'_simps2: "\<And>i. i \<notin> (\<Union>k. J k) \<Longrightarrow> i \<in> I \<Longrightarrow> w' i \<in> space (M i)"
```
```   596         using J by (auto simp: w'_def intro!: someI_ex[OF M.not_empty[unfolded ex_in_conv[symmetric]]])
```
```   597       { fix i assume "i \<in> I" then have "w' i \<in> space (M i)"
```
```   598           using w(1) by (cases "i \<in> (\<Union>k. J k)") (force simp: w'_simps2 w'_eq space_PiM)+ }
```
```   599       note w'_simps[simp] = w'_eq w'_simps1 w'_simps2 this
```
```   600
```
```   601       have w': "w' \<in> space (Pi\<^isub>M I M)"
```
```   602         using w(1) by (auto simp add: Pi_iff extensional_def space_PiM)
```
```   603
```
```   604       { fix n
```
```   605         have "restrict w' (J n) = w n" using w(1)
```
```   606           by (auto simp add: fun_eq_iff restrict_def Pi_iff extensional_def space_PiM)
```
```   607         with w[of n] obtain x where "x \<in> A n" "restrict x (J n) = restrict w' (J n)" by auto
```
```   608         then have "w' \<in> A n" unfolding A_eq using w' by (auto simp: prod_emb_def space_PiM) }
```
```   609       then have "w' \<in> (\<Inter>i. A i)" by auto
```
```   610       with `(\<Inter>i. A i) = {}` show False by auto
```
```   611     qed
```
```   612     ultimately show "(\<lambda>i. \<mu>G (A i)) ----> 0"
```
```   613       using LIMSEQ_ereal_INFI[of "\<lambda>i. \<mu>G (A i)"] by simp
```
```   614   qed fact+
```
```   615   then guess \<mu> .. note \<mu> = this
```
```   616   show ?thesis
```
```   617   proof (subst emeasure_extend_measure_Pair[OF PiM_def, of I M \<mu> J X])
```
```   618     from assms show "(J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))"
```
```   619       by (simp add: Pi_iff)
```
```   620   next
```
```   621     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))"
```
```   622     then show "emb I J (Pi\<^isub>E J X) \<in> Pow (\<Pi>\<^isub>E i\<in>I. space (M i))"
```
```   623       by (auto simp: Pi_iff prod_emb_def dest: sets_into_space)
```
```   624     have "emb I J (Pi\<^isub>E J X) \<in> generator"
```
```   625       using J `I \<noteq> {}` by (intro generatorI') auto
```
```   626     then have "\<mu> (emb I J (Pi\<^isub>E J X)) = \<mu>G (emb I J (Pi\<^isub>E J X))"
```
```   627       using \<mu> by simp
```
```   628     also have "\<dots> = (\<Prod> j\<in>J. if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j)))"
```
```   629       using J  `I \<noteq> {}` by (subst \<mu>G_spec[OF _ _ _ refl]) (auto simp: emeasure_PiM Pi_iff)
```
```   630     also have "\<dots> = (\<Prod>j\<in>J \<union> {i \<in> I. emeasure (M i) (space (M i)) \<noteq> 1}.
```
```   631       if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j)))"
```
```   632       using J `I \<noteq> {}` by (intro setprod_mono_one_right) (auto simp: M.emeasure_space_1)
```
```   633     finally show "\<mu> (emb I J (Pi\<^isub>E J X)) = \<dots>" .
```
```   634   next
```
```   635     let ?F = "\<lambda>j. if j \<in> J then emeasure (M j) (X j) else emeasure (M j) (space (M j))"
```
```   636     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)"
```
```   637       using X `I \<noteq> {}` by (intro setprod_mono_one_right) (auto simp: M.emeasure_space_1)
```
```   638     then show "(\<Prod>j\<in>J \<union> {i \<in> I. emeasure (M i) (space (M i)) \<noteq> 1}. ?F j) =
```
```   639       emeasure (Pi\<^isub>M J M) (Pi\<^isub>E J X)"
```
```   640       using X by (auto simp add: emeasure_PiM)
```
```   641   next
```
```   642     show "positive (sets (Pi\<^isub>M I M)) \<mu>" "countably_additive (sets (Pi\<^isub>M I M)) \<mu>"
```
```   643       using \<mu> unfolding sets_PiM_generator by (auto simp: measure_space_def)
```
```   644   qed
```
```   645 qed
```
```   646
```
```   647 sublocale product_prob_space \<subseteq> P: prob_space "Pi\<^isub>M I M"
```
```   648 proof
```
```   649   show "emeasure (Pi\<^isub>M I M) (space (Pi\<^isub>M I M)) = 1"
```
```   650   proof cases
```
```   651     assume "I = {}" then show ?thesis by (simp add: space_PiM_empty)
```
```   652   next
```
```   653     assume "I \<noteq> {}"
```
```   654     then obtain i where "i \<in> I" by auto
```
```   655     moreover then have "emb I {i} (\<Pi>\<^isub>E i\<in>{i}. space (M i)) = (space (Pi\<^isub>M I M))"
```
```   656       by (auto simp: prod_emb_def space_PiM)
```
```   657     ultimately show ?thesis
```
```   658       using emeasure_PiM_emb_not_empty[of "{i}" "\<lambda>i. space (M i)"]
```
```   659       by (simp add: emeasure_PiM emeasure_space_1)
```
```   660   qed
```
```   661 qed
```
```   662
```
```   663 lemma (in product_prob_space) emeasure_PiM_emb:
```
```   664   assumes X: "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
```
```   665   shows "emeasure (Pi\<^isub>M I M) (emb I J (Pi\<^isub>E J X)) = (\<Prod> i\<in>J. emeasure (M i) (X i))"
```
```   666 proof cases
```
```   667   assume "J = {}"
```
```   668   moreover have "emb I {} {\<lambda>x. undefined} = space (Pi\<^isub>M I M)"
```
```   669     by (auto simp: space_PiM prod_emb_def)
```
```   670   ultimately show ?thesis
```
```   671     by (simp add: space_PiM_empty P.emeasure_space_1)
```
```   672 next
```
```   673   assume "J \<noteq> {}" with X show ?thesis
```
```   674     by (subst emeasure_PiM_emb_not_empty) (auto simp: emeasure_PiM)
```
```   675 qed
```
```   676
```
```   677 lemma (in product_prob_space) emeasure_PiM_Collect:
```
```   678   assumes X: "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
```
```   679   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))"
```
```   680 proof -
```
```   681   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)"
```
```   682     unfolding prod_emb_def using assms by (auto simp: space_PiM Pi_iff)
```
```   683   with emeasure_PiM_emb[OF assms] show ?thesis by simp
```
```   684 qed
```
```   685
```
```   686 lemma (in product_prob_space) emeasure_PiM_Collect_single:
```
```   687   assumes X: "i \<in> I" "A \<in> sets (M i)"
```
```   688   shows "emeasure (Pi\<^isub>M I M) {x\<in>space (Pi\<^isub>M I M). x i \<in> A} = emeasure (M i) A"
```
```   689   using emeasure_PiM_Collect[of "{i}" "\<lambda>i. A"] assms
```
```   690   by simp
```
```   691
```
```   692 lemma (in product_prob_space) measure_PiM_emb:
```
```   693   assumes "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
```
```   694   shows "measure (PiM I M) (emb I J (Pi\<^isub>E J X)) = (\<Prod> i\<in>J. measure (M i) (X i))"
```
```   695   using emeasure_PiM_emb[OF assms]
```
```   696   unfolding emeasure_eq_measure M.emeasure_eq_measure by (simp add: setprod_ereal)
```
```   697
```
```   698 lemma sets_Collect_single':
```
```   699   "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)"
```
```   700   using sets_Collect_single[of i I "{x\<in>space (M i). P x}" M]
```
```   701   by (simp add: space_PiM Pi_iff cong: conj_cong)
```
```   702
```
```   703 lemma (in finite_product_prob_space) finite_measure_PiM_emb:
```
```   704   "(\<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))"
```
```   705   using measure_PiM_emb[of I A] finite_index prod_emb_PiE_same_index[OF sets_into_space, of I A M]
```
```   706   by auto
```
```   707
```
```   708 lemma (in product_prob_space) PiM_component:
```
```   709   assumes "i \<in> I"
```
```   710   shows "distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i) = M i"
```
```   711 proof (rule measure_eqI[symmetric])
```
```   712   fix A assume "A \<in> sets (M i)"
```
```   713   moreover have "((\<lambda>\<omega>. \<omega> i) -` A \<inter> space (PiM I M)) = {x\<in>space (PiM I M). x i \<in> A}"
```
```   714     by auto
```
```   715   ultimately show "emeasure (M i) A = emeasure (distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i)) A"
```
```   716     by (auto simp: `i\<in>I` emeasure_distr measurable_component_singleton emeasure_PiM_Collect_single)
```
```   717 qed simp
```
```   718
```
```   719 lemma (in product_prob_space) PiM_eq:
```
```   720   assumes "I \<noteq> {}"
```
```   721   assumes "sets M' = sets (PiM I M)"
```
```   722   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>
```
```   723     emeasure M' (prod_emb I M J (\<Pi>\<^isub>E j\<in>J. F j)) = (\<Prod>j\<in>J. emeasure (M j) (F j))"
```
```   724   shows "M' = (PiM I M)"
```
```   725 proof (rule measure_eqI_generator_eq[symmetric, OF Int_stable_prod_algebra prod_algebra_sets_into_space])
```
```   726   show "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) (prod_algebra I M)"
```
```   727     by (rule sets_PiM)
```
```   728   then show "sets M' = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) (prod_algebra I M)"
```
```   729     unfolding `sets M' = sets (PiM I M)` by simp
```
```   730
```
```   731   def i \<equiv> "SOME i. i \<in> I"
```
```   732   with `I \<noteq> {}` have i: "i \<in> I"
```
```   733     by (auto intro: someI_ex)
```
```   734
```
```   735   def A \<equiv> "\<lambda>n::nat. prod_emb I M {i} (\<Pi>\<^isub>E j\<in>{i}. space (M i))"
```
```   736   then show "range A \<subseteq> prod_algebra I M"
```
```   737     by (auto intro!: prod_algebraI i)
```
```   738
```
```   739   have A_eq: "\<And>i. A i = space (PiM I M)"
```
```   740     by (auto simp: prod_emb_def space_PiM Pi_iff A_def i)
```
```   741   show "(\<Union>i. A i) = (\<Pi>\<^isub>E i\<in>I. space (M i))"
```
```   742     unfolding A_eq by (auto simp: space_PiM)
```
```   743   show "\<And>i. emeasure (PiM I M) (A i) \<noteq> \<infinity>"
```
```   744     unfolding A_eq P.emeasure_space_1 by simp
```
```   745 next
```
```   746   fix X assume X: "X \<in> prod_algebra I M"
```
```   747   then obtain J E where X: "X = prod_emb I M J (PIE j:J. E j)"
```
```   748     and J: "finite J" "J \<subseteq> I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets (M j)"
```
```   749     by (force elim!: prod_algebraE)
```
```   750   from eq[OF J] have "emeasure M' X = (\<Prod>j\<in>J. emeasure (M j) (E j))"
```
```   751     by (simp add: X)
```
```   752   also have "\<dots> = emeasure (PiM I M) X"
```
```   753     unfolding X using J by (intro emeasure_PiM_emb[symmetric]) auto
```
```   754   finally show "emeasure (PiM I M) X = emeasure M' X" ..
```
```   755 qed
```
```   756
```
```   757 subsection {* Sequence space *}
```
```   758
```
```   759 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)"
```
```   760 proof (rule measurable_PiM_single)
```
```   761   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)"
```
```   762     by (auto simp: space_pair_measure space_PiM Pi_iff split: nat.split)
```
```   763   fix i :: nat and A assume A: "A \<in> sets M"
```
```   764   then have *: "{\<omega> \<in> space (M \<Otimes>\<^isub>M (\<Pi>\<^isub>M i\<in>UNIV. M)). prod_case nat_case \<omega> i \<in> A} =
```
```   765     (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})"
```
```   766     by (auto simp: space_PiM space_pair_measure split: nat.split dest: sets_into_space)
```
```   767   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))"
```
```   768     unfolding * by (auto simp: A split: nat.split intro!: sets_Collect_single)
```
```   769 qed
```
```   770
```
```   771 lemma measurable_nat_case':
```
```   772   assumes f: "f \<in> measurable N M" and g: "g \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
```
```   773   shows "(\<lambda>x. nat_case (f x) (g x)) \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
```
```   774   using measurable_compose[OF measurable_Pair[OF f g] measurable_nat_case] by simp
```
```   775
```
```   776 definition comb_seq :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a)" where
```
```   777   "comb_seq i \<omega> \<omega>' j = (if j < i then \<omega> j else \<omega>' (j - i))"
```
```   778
```
```   779 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))"
```
```   780   by (auto simp: comb_seq_def not_less)
```
```   781
```
```   782 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)))"
```
```   783   by (auto simp: comb_seq_def)
```
```   784
```
```   785 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)"
```
```   786 proof (rule measurable_PiM_single)
```
```   787   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)"
```
```   788     by (auto simp: space_pair_measure space_PiM Pi_iff split: split_comb_seq)
```
```   789   fix j :: nat and A assume A: "A \<in> sets M"
```
```   790   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} =
```
```   791     (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)
```
```   792               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})"
```
```   793     by (auto simp: space_PiM space_pair_measure comb_seq_def dest: sets_into_space)
```
```   794   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))"
```
```   795     unfolding * by (auto simp: A intro!: sets_Collect_single)
```
```   796 qed
```
```   797
```
```   798 lemma measurable_comb_seq':
```
```   799   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)"
```
```   800   shows "(\<lambda>x. comb_seq i (f x) (g x)) \<in> measurable N (\<Pi>\<^isub>M i\<in>UNIV. M)"
```
```   801   using measurable_compose[OF measurable_Pair[OF f g] measurable_comb_seq] by simp
```
```   802
```
```   803 locale sequence_space = product_prob_space "\<lambda>i. M" "UNIV :: nat set" for M
```
```   804 begin
```
```   805
```
```   806 abbreviation "S \<equiv> \<Pi>\<^isub>M i\<in>UNIV::nat set. M"
```
```   807
```
```   808 lemma infprod_in_sets[intro]:
```
```   809   fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
```
```   810   shows "Pi UNIV E \<in> sets S"
```
```   811 proof -
```
```   812   have "Pi UNIV E = (\<Inter>i. emb UNIV {..i} (\<Pi>\<^isub>E j\<in>{..i}. E j))"
```
```   813     using E E[THEN sets_into_space]
```
```   814     by (auto simp: prod_emb_def Pi_iff extensional_def) blast
```
```   815   with E show ?thesis by auto
```
```   816 qed
```
```   817
```
```   818 lemma measure_PiM_countable:
```
```   819   fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
```
```   820   shows "(\<lambda>n. \<Prod>i\<le>n. measure M (E i)) ----> measure S (Pi UNIV E)"
```
```   821 proof -
```
```   822   let ?E = "\<lambda>n. emb UNIV {..n} (Pi\<^isub>E {.. n} E)"
```
```   823   have "\<And>n. (\<Prod>i\<le>n. measure M (E i)) = measure S (?E n)"
```
```   824     using E by (simp add: measure_PiM_emb)
```
```   825   moreover have "Pi UNIV E = (\<Inter>n. ?E n)"
```
```   826     using E E[THEN sets_into_space]
```
```   827     by (auto simp: prod_emb_def extensional_def Pi_iff) blast
```
```   828   moreover have "range ?E \<subseteq> sets S"
```
```   829     using E by auto
```
```   830   moreover have "decseq ?E"
```
```   831     by (auto simp: prod_emb_def Pi_iff decseq_def)
```
```   832   ultimately show ?thesis
```
```   833     by (simp add: finite_Lim_measure_decseq)
```
```   834 qed
```
```   835
```
```   836 lemma nat_eq_diff_eq:
```
```   837   fixes a b c :: nat
```
```   838   shows "c \<le> b \<Longrightarrow> a = b - c \<longleftrightarrow> a + c = b"
```
```   839   by auto
```
```   840
```
```   841 lemma PiM_comb_seq:
```
```   842   "distr (S \<Otimes>\<^isub>M S) S (\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') = S" (is "?D = _")
```
```   843 proof (rule PiM_eq)
```
```   844   let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
```
```   845   let "distr _ _ ?f" = "?D"
```
```   846
```
```   847   fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
```
```   848   let ?X = "prod_emb ?I ?M J (\<Pi>\<^isub>E j\<in>J. E j)"
```
```   849   have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
```
```   850     using J(3)[THEN sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
```
```   851   with J have "?f -` ?X \<inter> space (S \<Otimes>\<^isub>M S) =
```
```   852     (prod_emb ?I ?M (J \<inter> {..<i}) (PIE j:J \<inter> {..<i}. E j)) \<times>
```
```   853     (prod_emb ?I ?M ((op + i) -` J) (PIE j:(op + i) -` J. E (i + j)))" (is "_ = ?E \<times> ?F")
```
```   854    by (auto simp: space_pair_measure space_PiM prod_emb_def all_conj_distrib Pi_iff
```
```   855                split: split_comb_seq split_comb_seq_asm)
```
```   856   then have "emeasure ?D ?X = emeasure (S \<Otimes>\<^isub>M S) (?E \<times> ?F)"
```
```   857     by (subst emeasure_distr[OF measurable_comb_seq])
```
```   858        (auto intro!: sets_PiM_I simp: split_beta' J)
```
```   859   also have "\<dots> = emeasure S ?E * emeasure S ?F"
```
```   860     using J by (intro P.emeasure_pair_measure_Times)  (auto intro!: sets_PiM_I finite_vimageI simp: inj_on_def)
```
```   861   also have "emeasure S ?F = (\<Prod>j\<in>(op + i) -` J. emeasure M (E (i + j)))"
```
```   862     using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI inj_on_def)
```
```   863   also have "\<dots> = (\<Prod>j\<in>J - (J \<inter> {..<i}). emeasure M (E j))"
```
```   864     by (rule strong_setprod_reindex_cong[where f="\<lambda>x. x - i"])
```
```   865        (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
```
```   866   also have "emeasure S ?E = (\<Prod>j\<in>J \<inter> {..<i}. emeasure M (E j))"
```
```   867     using J by (intro emeasure_PiM_emb) simp_all
```
```   868   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))"
```
```   869     by (subst mult_commute) (auto simp: J setprod_subset_diff[symmetric])
```
```   870   finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
```
```   871 qed simp_all
```
```   872
```
```   873 lemma PiM_iter:
```
```   874   "distr (M \<Otimes>\<^isub>M S) S (\<lambda>(s, \<omega>). nat_case s \<omega>) = S" (is "?D = _")
```
```   875 proof (rule PiM_eq)
```
```   876   let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
```
```   877   let "distr _ _ ?f" = "?D"
```
```   878
```
```   879   fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
```
```   880   let ?X = "prod_emb ?I ?M J (PIE j:J. E j)"
```
```   881   have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
```
```   882     using J(3)[THEN sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
```
```   883   with J have "?f -` ?X \<inter> space (M \<Otimes>\<^isub>M S) = (if 0 \<in> J then E 0 else space M) \<times>
```
```   884     (prod_emb ?I ?M (Suc -` J) (PIE j:Suc -` J. E (Suc j)))" (is "_ = ?E \<times> ?F")
```
```   885    by (auto simp: space_pair_measure space_PiM Pi_iff prod_emb_def all_conj_distrib
```
```   886       split: nat.split nat.split_asm)
```
```   887   then have "emeasure ?D ?X = emeasure (M \<Otimes>\<^isub>M S) (?E \<times> ?F)"
```
```   888     by (subst emeasure_distr[OF measurable_nat_case])
```
```   889        (auto intro!: sets_PiM_I simp: split_beta' J)
```
```   890   also have "\<dots> = emeasure M ?E * emeasure S ?F"
```
```   891     using J by (intro P.emeasure_pair_measure_Times) (auto intro!: sets_PiM_I finite_vimageI)
```
```   892   also have "emeasure S ?F = (\<Prod>j\<in>Suc -` J. emeasure M (E (Suc j)))"
```
```   893     using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI)
```
```   894   also have "\<dots> = (\<Prod>j\<in>J - {0}. emeasure M (E j))"
```
```   895     by (rule strong_setprod_reindex_cong[where f="\<lambda>x. x - 1"])
```
```   896        (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
```
```   897   also have "emeasure M ?E * (\<Prod>j\<in>J - {0}. emeasure M (E j)) = (\<Prod>j\<in>J. emeasure M (E j))"
```
```   898     by (auto simp: M.emeasure_space_1 setprod.remove J)
```
```   899   finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
```
```   900 qed simp_all
```
```   901
```
```   902 end
```
```   903
```
`   904 end`