src/HOL/Probability/Infinite_Product_Measure.thy
author hoelzl
Fri Feb 19 13:40:50 2016 +0100 (2016-02-19)
changeset 62378 85ed00c1fe7c
parent 62343 24106dc44def
child 62390 842917225d56
permissions -rw-r--r--
generalize more theorems to support enat and ennreal
hoelzl@42147
     1
(*  Title:      HOL/Probability/Infinite_Product_Measure.thy
hoelzl@42147
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42147
     3
*)
hoelzl@42147
     4
wenzelm@61808
     5
section \<open>Infinite Product Measure\<close>
hoelzl@42147
     6
hoelzl@42147
     7
theory Infinite_Product_Measure
immler@50039
     8
  imports Probability_Measure Caratheodory Projective_Family
hoelzl@42147
     9
begin
hoelzl@42147
    10
hoelzl@61359
    11
lemma (in product_prob_space) distr_PiM_restrict_finite:
hoelzl@61359
    12
  assumes "finite J" "J \<subseteq> I"
hoelzl@61359
    13
  shows "distr (PiM I M) (PiM J M) (\<lambda>x. restrict x J) = PiM J M"
hoelzl@61359
    14
proof (rule PiM_eqI)
hoelzl@61359
    15
  fix X assume X: "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
hoelzl@61359
    16
  { fix J X assume J: "J \<noteq> {} \<or> I = {}" "finite J" "J \<subseteq> I" and X: "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
hoelzl@61359
    17
    have "emeasure (PiM I M) (emb I J (PiE J X)) = (\<Prod>i\<in>J. M i (X i))"
hoelzl@61359
    18
    proof (subst emeasure_extend_measure_Pair[OF PiM_def, where \<mu>'=lim], goal_cases)
hoelzl@61359
    19
      case 1 then show ?case
hoelzl@61359
    20
        by (simp add: M.emeasure_space_1 emeasure_PiM Pi_iff sets_PiM_I_finite emeasure_lim_emb)
hoelzl@61359
    21
    next
hoelzl@61359
    22
      case (2 J X)
hoelzl@61359
    23
      then have "emb I J (Pi\<^sub>E J X) \<in> sets (PiM I M)"
hoelzl@61359
    24
        by (intro measurable_prod_emb sets_PiM_I_finite) auto
hoelzl@61359
    25
      from this[THEN sets.sets_into_space] show ?case
hoelzl@61359
    26
        by (simp add: space_PiM)
hoelzl@61359
    27
    qed (insert assms J X, simp_all del: sets_lim
hoelzl@61359
    28
      add: M.emeasure_space_1 sets_lim[symmetric] emeasure_countably_additive emeasure_positive) }
hoelzl@61359
    29
  note * = this
hoelzl@42147
    30
hoelzl@61359
    31
  have "emeasure (PiM I M) (emb I J (PiE J X)) = (\<Prod>i\<in>J. M i (X i))"
hoelzl@61359
    32
  proof cases
hoelzl@61359
    33
    assume "\<not> (J \<noteq> {} \<or> I = {})"
hoelzl@61359
    34
    then obtain i where "J = {}" "i \<in> I" by auto
hoelzl@61359
    35
    moreover then have "emb I {} {\<lambda>x. undefined} = emb I {i} (\<Pi>\<^sub>E i\<in>{i}. space (M i))"
hoelzl@61359
    36
      by (auto simp: space_PiM prod_emb_def)
hoelzl@61359
    37
    ultimately show ?thesis
hoelzl@61359
    38
      by (simp add: * M.emeasure_space_1)
hoelzl@61359
    39
  qed (simp add: *[OF _ assms X])
hoelzl@61359
    40
  with assms show "emeasure (distr (Pi\<^sub>M I M) (Pi\<^sub>M J M) (\<lambda>x. restrict x J)) (Pi\<^sub>E J X) = (\<Prod>i\<in>J. emeasure (M i) (X i))"
hoelzl@61359
    41
    by (subst emeasure_distr_restrict[OF _ refl]) (auto intro!: sets_PiM_I_finite X)
hoelzl@61359
    42
qed (insert assms, auto)
hoelzl@42147
    43
hoelzl@61359
    44
lemma (in product_prob_space) emeasure_PiM_emb':
hoelzl@61359
    45
  "J \<subseteq> I \<Longrightarrow> finite J \<Longrightarrow> X \<in> sets (PiM J M) \<Longrightarrow> emeasure (Pi\<^sub>M I M) (emb I J X) = PiM J M X"
hoelzl@61359
    46
  by (subst distr_PiM_restrict_finite[symmetric, of J])
hoelzl@61359
    47
     (auto intro!: emeasure_distr_restrict[symmetric])
hoelzl@42147
    48
hoelzl@61359
    49
lemma (in product_prob_space) emeasure_PiM_emb:
hoelzl@61359
    50
  "J \<subseteq> I \<Longrightarrow> finite J \<Longrightarrow> (\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)) \<Longrightarrow> 
hoelzl@61359
    51
    emeasure (Pi\<^sub>M I M) (emb I J (Pi\<^sub>E J X)) = (\<Prod> i\<in>J. emeasure (M i) (X i))"
hoelzl@61359
    52
  by (subst emeasure_PiM_emb') (auto intro!: emeasure_PiM)
hoelzl@42147
    53
ballarin@61565
    54
sublocale product_prob_space \<subseteq> P?: prob_space "Pi\<^sub>M I M"
hoelzl@42257
    55
proof
hoelzl@61359
    56
  have *: "emb I {} {\<lambda>x. undefined} = space (PiM I M)"
hoelzl@61359
    57
    by (auto simp: prod_emb_def space_PiM)
wenzelm@53015
    58
  show "emeasure (Pi\<^sub>M I M) (space (Pi\<^sub>M I M)) = 1"
hoelzl@61359
    59
    using emeasure_PiM_emb[of "{}" "\<lambda>_. {}"] by (simp add: *)
hoelzl@42257
    60
qed
hoelzl@42257
    61
hoelzl@50000
    62
lemma (in product_prob_space) emeasure_PiM_Collect:
hoelzl@50000
    63
  assumes X: "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
wenzelm@53015
    64
  shows "emeasure (Pi\<^sub>M I M) {x\<in>space (Pi\<^sub>M I M). \<forall>i\<in>J. x i \<in> X i} = (\<Prod> i\<in>J. emeasure (M i) (X i))"
hoelzl@50000
    65
proof -
wenzelm@53015
    66
  have "{x\<in>space (Pi\<^sub>M I M). \<forall>i\<in>J. x i \<in> X i} = emb I J (Pi\<^sub>E J X)"
hoelzl@50000
    67
    unfolding prod_emb_def using assms by (auto simp: space_PiM Pi_iff)
hoelzl@50000
    68
  with emeasure_PiM_emb[OF assms] show ?thesis by simp
hoelzl@50000
    69
qed
hoelzl@50000
    70
hoelzl@50000
    71
lemma (in product_prob_space) emeasure_PiM_Collect_single:
hoelzl@50000
    72
  assumes X: "i \<in> I" "A \<in> sets (M i)"
wenzelm@53015
    73
  shows "emeasure (Pi\<^sub>M I M) {x\<in>space (Pi\<^sub>M I M). x i \<in> A} = emeasure (M i) A"
hoelzl@50000
    74
  using emeasure_PiM_Collect[of "{i}" "\<lambda>i. A"] assms
hoelzl@50000
    75
  by simp
hoelzl@50000
    76
hoelzl@47694
    77
lemma (in product_prob_space) measure_PiM_emb:
hoelzl@47694
    78
  assumes "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
wenzelm@53015
    79
  shows "measure (PiM I M) (emb I J (Pi\<^sub>E J X)) = (\<Prod> i\<in>J. measure (M i) (X i))"
hoelzl@47694
    80
  using emeasure_PiM_emb[OF assms]
hoelzl@47694
    81
  unfolding emeasure_eq_measure M.emeasure_eq_measure by (simp add: setprod_ereal)
hoelzl@42865
    82
hoelzl@50000
    83
lemma sets_Collect_single':
hoelzl@50000
    84
  "i \<in> I \<Longrightarrow> {x\<in>space (M i). P x} \<in> sets (M i) \<Longrightarrow> {x\<in>space (PiM I M). P (x i)} \<in> sets (PiM I M)"
hoelzl@50000
    85
  using sets_Collect_single[of i I "{x\<in>space (M i). P x}" M]
hoelzl@50123
    86
  by (simp add: space_PiM PiE_iff cong: conj_cong)
hoelzl@50000
    87
hoelzl@47694
    88
lemma (in finite_product_prob_space) finite_measure_PiM_emb:
wenzelm@53015
    89
  "(\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets (M i)) \<Longrightarrow> measure (PiM I M) (Pi\<^sub>E I A) = (\<Prod>i\<in>I. measure (M i) (A i))"
immler@50244
    90
  using measure_PiM_emb[of I A] finite_index prod_emb_PiE_same_index[OF sets.sets_into_space, of I A M]
hoelzl@47694
    91
  by auto
hoelzl@42865
    92
hoelzl@50000
    93
lemma (in product_prob_space) PiM_component:
hoelzl@50000
    94
  assumes "i \<in> I"
hoelzl@50000
    95
  shows "distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i) = M i"
hoelzl@50000
    96
proof (rule measure_eqI[symmetric])
hoelzl@50000
    97
  fix A assume "A \<in> sets (M i)"
hoelzl@50000
    98
  moreover have "((\<lambda>\<omega>. \<omega> i) -` A \<inter> space (PiM I M)) = {x\<in>space (PiM I M). x i \<in> A}"
hoelzl@50000
    99
    by auto
hoelzl@50000
   100
  ultimately show "emeasure (M i) A = emeasure (distr (PiM I M) (M i) (\<lambda>\<omega>. \<omega> i)) A"
wenzelm@61808
   101
    by (auto simp: \<open>i\<in>I\<close> emeasure_distr measurable_component_singleton emeasure_PiM_Collect_single)
hoelzl@50000
   102
qed simp
hoelzl@50000
   103
hoelzl@50000
   104
lemma (in product_prob_space) PiM_eq:
hoelzl@61362
   105
  assumes M': "sets M' = sets (PiM I M)"
hoelzl@50000
   106
  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>
wenzelm@53015
   107
    emeasure M' (prod_emb I M J (\<Pi>\<^sub>E j\<in>J. F j)) = (\<Prod>j\<in>J. emeasure (M j) (F j))"
hoelzl@50000
   108
  shows "M' = (PiM I M)"
hoelzl@61362
   109
proof (rule measure_eqI_PiM_infinite[symmetric, OF refl M'])
hoelzl@61362
   110
  show "finite_measure (Pi\<^sub>M I M)"
hoelzl@61362
   111
    by standard (simp add: P.emeasure_space_1)
hoelzl@61362
   112
qed (simp add: eq emeasure_PiM_emb)
hoelzl@50000
   113
hoelzl@59000
   114
lemma (in product_prob_space) AE_component: "i \<in> I \<Longrightarrow> AE x in M i. P x \<Longrightarrow> AE x in PiM I M. P (x i)"
hoelzl@59000
   115
  apply (rule AE_distrD[of "\<lambda>\<omega>. \<omega> i" "PiM I M" "M i" P])
hoelzl@59000
   116
  apply simp
hoelzl@59000
   117
  apply (subst PiM_component)
hoelzl@59000
   118
  apply simp_all
hoelzl@59000
   119
  done
hoelzl@59000
   120
wenzelm@61808
   121
subsection \<open>Sequence space\<close>
hoelzl@42257
   122
hoelzl@50000
   123
definition comb_seq :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> 'a)" where
hoelzl@50000
   124
  "comb_seq i \<omega> \<omega>' j = (if j < i then \<omega> j else \<omega>' (j - i))"
hoelzl@50000
   125
hoelzl@50000
   126
lemma split_comb_seq: "P (comb_seq i \<omega> \<omega>' j) \<longleftrightarrow> (j < i \<longrightarrow> P (\<omega> j)) \<and> (\<forall>k. j = i + k \<longrightarrow> P (\<omega>' k))"
hoelzl@50000
   127
  by (auto simp: comb_seq_def not_less)
hoelzl@50000
   128
hoelzl@50000
   129
lemma split_comb_seq_asm: "P (comb_seq i \<omega> \<omega>' j) \<longleftrightarrow> \<not> ((j < i \<and> \<not> P (\<omega> j)) \<or> (\<exists>k. j = i + k \<and> \<not> P (\<omega>' k)))"
hoelzl@50000
   130
  by (auto simp: comb_seq_def)
hoelzl@42257
   131
hoelzl@50099
   132
lemma measurable_comb_seq:
wenzelm@53015
   133
  "(\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') \<in> measurable ((\<Pi>\<^sub>M i\<in>UNIV. M) \<Otimes>\<^sub>M (\<Pi>\<^sub>M i\<in>UNIV. M)) (\<Pi>\<^sub>M i\<in>UNIV. M)"
hoelzl@50000
   134
proof (rule measurable_PiM_single)
wenzelm@53015
   135
  show "(\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') \<in> space ((\<Pi>\<^sub>M i\<in>UNIV. M) \<Otimes>\<^sub>M (\<Pi>\<^sub>M i\<in>UNIV. M)) \<rightarrow> (UNIV \<rightarrow>\<^sub>E space M)"
hoelzl@50123
   136
    by (auto simp: space_pair_measure space_PiM PiE_iff split: split_comb_seq)
hoelzl@50000
   137
  fix j :: nat and A assume A: "A \<in> sets M"
blanchet@55414
   138
  then have *: "{\<omega> \<in> space ((\<Pi>\<^sub>M i\<in>UNIV. M) \<Otimes>\<^sub>M (\<Pi>\<^sub>M i\<in>UNIV. M)). case_prod (comb_seq i) \<omega> j \<in> A} =
wenzelm@53015
   139
    (if j < i then {\<omega> \<in> space (\<Pi>\<^sub>M i\<in>UNIV. M). \<omega> j \<in> A} \<times> space (\<Pi>\<^sub>M i\<in>UNIV. M)
wenzelm@53015
   140
              else space (\<Pi>\<^sub>M i\<in>UNIV. M) \<times> {\<omega> \<in> space (\<Pi>\<^sub>M i\<in>UNIV. M). \<omega> (j - i) \<in> A})"
immler@50244
   141
    by (auto simp: space_PiM space_pair_measure comb_seq_def dest: sets.sets_into_space)
blanchet@55414
   142
  show "{\<omega> \<in> space ((\<Pi>\<^sub>M i\<in>UNIV. M) \<Otimes>\<^sub>M (\<Pi>\<^sub>M i\<in>UNIV. M)). case_prod (comb_seq i) \<omega> j \<in> A} \<in> sets ((\<Pi>\<^sub>M i\<in>UNIV. M) \<Otimes>\<^sub>M (\<Pi>\<^sub>M i\<in>UNIV. M))"
hoelzl@50000
   143
    unfolding * by (auto simp: A intro!: sets_Collect_single)
hoelzl@50000
   144
qed
hoelzl@50000
   145
hoelzl@50099
   146
lemma measurable_comb_seq'[measurable (raw)]:
wenzelm@53015
   147
  assumes f: "f \<in> measurable N (\<Pi>\<^sub>M i\<in>UNIV. M)" and g: "g \<in> measurable N (\<Pi>\<^sub>M i\<in>UNIV. M)"
wenzelm@53015
   148
  shows "(\<lambda>x. comb_seq i (f x) (g x)) \<in> measurable N (\<Pi>\<^sub>M i\<in>UNIV. M)"
hoelzl@50000
   149
  using measurable_compose[OF measurable_Pair[OF f g] measurable_comb_seq] by simp
hoelzl@50000
   150
hoelzl@50099
   151
lemma comb_seq_0: "comb_seq 0 \<omega> \<omega>' = \<omega>'"
hoelzl@50099
   152
  by (auto simp add: comb_seq_def)
hoelzl@50099
   153
blanchet@55415
   154
lemma comb_seq_Suc: "comb_seq (Suc n) \<omega> \<omega>' = comb_seq n \<omega> (case_nat (\<omega> n) \<omega>')"
hoelzl@50099
   155
  by (auto simp add: comb_seq_def not_less less_Suc_eq le_imp_diff_is_add intro!: ext split: nat.split)
hoelzl@50099
   156
blanchet@55415
   157
lemma comb_seq_Suc_0[simp]: "comb_seq (Suc 0) \<omega> = case_nat (\<omega> 0)"
hoelzl@50099
   158
  by (intro ext) (simp add: comb_seq_Suc comb_seq_0)
hoelzl@50099
   159
hoelzl@50099
   160
lemma comb_seq_less: "i < n \<Longrightarrow> comb_seq n \<omega> \<omega>' i = \<omega> i"
hoelzl@50099
   161
  by (auto split: split_comb_seq)
hoelzl@50099
   162
hoelzl@50099
   163
lemma comb_seq_add: "comb_seq n \<omega> \<omega>' (i + n) = \<omega>' i"
hoelzl@50099
   164
  by (auto split: nat.split split_comb_seq)
hoelzl@50099
   165
blanchet@55415
   166
lemma case_nat_comb_seq: "case_nat s' (comb_seq n \<omega> \<omega>') (i + n) = case_nat (case_nat s' \<omega> n) \<omega>' i"
hoelzl@50099
   167
  by (auto split: nat.split split_comb_seq)
hoelzl@50099
   168
blanchet@55415
   169
lemma case_nat_comb_seq':
blanchet@55415
   170
  "case_nat s (comb_seq i \<omega> \<omega>') = comb_seq (Suc i) (case_nat s \<omega>) \<omega>'"
hoelzl@50099
   171
  by (auto split: split_comb_seq nat.split)
hoelzl@50099
   172
hoelzl@50000
   173
locale sequence_space = product_prob_space "\<lambda>i. M" "UNIV :: nat set" for M
hoelzl@50000
   174
begin
hoelzl@50000
   175
wenzelm@53015
   176
abbreviation "S \<equiv> \<Pi>\<^sub>M i\<in>UNIV::nat set. M"
hoelzl@50000
   177
hoelzl@50000
   178
lemma infprod_in_sets[intro]:
hoelzl@50000
   179
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
hoelzl@50000
   180
  shows "Pi UNIV E \<in> sets S"
hoelzl@42257
   181
proof -
wenzelm@53015
   182
  have "Pi UNIV E = (\<Inter>i. emb UNIV {..i} (\<Pi>\<^sub>E j\<in>{..i}. E j))"
immler@50244
   183
    using E E[THEN sets.sets_into_space]
haftmann@62343
   184
    by (auto simp: prod_emb_def Pi_iff extensional_def)
hoelzl@47694
   185
  with E show ?thesis by auto
hoelzl@42257
   186
qed
hoelzl@42257
   187
hoelzl@50000
   188
lemma measure_PiM_countable:
hoelzl@50000
   189
  fixes E :: "nat \<Rightarrow> 'a set" assumes E: "\<And>i. E i \<in> sets M"
wenzelm@61969
   190
  shows "(\<lambda>n. \<Prod>i\<le>n. measure M (E i)) \<longlonglongrightarrow> measure S (Pi UNIV E)"
hoelzl@42257
   191
proof -
wenzelm@53015
   192
  let ?E = "\<lambda>n. emb UNIV {..n} (Pi\<^sub>E {.. n} E)"
hoelzl@50000
   193
  have "\<And>n. (\<Prod>i\<le>n. measure M (E i)) = measure S (?E n)"
hoelzl@47694
   194
    using E by (simp add: measure_PiM_emb)
hoelzl@42257
   195
  moreover have "Pi UNIV E = (\<Inter>n. ?E n)"
immler@50244
   196
    using E E[THEN sets.sets_into_space]
haftmann@62343
   197
    by (auto simp: prod_emb_def extensional_def Pi_iff)
hoelzl@50000
   198
  moreover have "range ?E \<subseteq> sets S"
hoelzl@42257
   199
    using E by auto
hoelzl@42257
   200
  moreover have "decseq ?E"
hoelzl@47694
   201
    by (auto simp: prod_emb_def Pi_iff decseq_def)
hoelzl@42257
   202
  ultimately show ?thesis
hoelzl@47694
   203
    by (simp add: finite_Lim_measure_decseq)
hoelzl@42257
   204
qed
hoelzl@42257
   205
hoelzl@50000
   206
lemma nat_eq_diff_eq: 
hoelzl@50000
   207
  fixes a b c :: nat
hoelzl@50000
   208
  shows "c \<le> b \<Longrightarrow> a = b - c \<longleftrightarrow> a + c = b"
hoelzl@50000
   209
  by auto
hoelzl@50000
   210
hoelzl@50000
   211
lemma PiM_comb_seq:
wenzelm@53015
   212
  "distr (S \<Otimes>\<^sub>M S) S (\<lambda>(\<omega>, \<omega>'). comb_seq i \<omega> \<omega>') = S" (is "?D = _")
hoelzl@50000
   213
proof (rule PiM_eq)
hoelzl@50000
   214
  let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
hoelzl@50000
   215
  let "distr _ _ ?f" = "?D"
hoelzl@50000
   216
hoelzl@50000
   217
  fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
wenzelm@53015
   218
  let ?X = "prod_emb ?I ?M J (\<Pi>\<^sub>E j\<in>J. E j)"
hoelzl@50000
   219
  have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
immler@50244
   220
    using J(3)[THEN sets.sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
wenzelm@53015
   221
  with J have "?f -` ?X \<inter> space (S \<Otimes>\<^sub>M S) =
hoelzl@50000
   222
    (prod_emb ?I ?M (J \<inter> {..<i}) (PIE j:J \<inter> {..<i}. E j)) \<times>
hoelzl@50000
   223
    (prod_emb ?I ?M ((op + i) -` J) (PIE j:(op + i) -` J. E (i + j)))" (is "_ = ?E \<times> ?F")
hoelzl@50123
   224
   by (auto simp: space_pair_measure space_PiM prod_emb_def all_conj_distrib PiE_iff
hoelzl@50000
   225
               split: split_comb_seq split_comb_seq_asm)
wenzelm@53015
   226
  then have "emeasure ?D ?X = emeasure (S \<Otimes>\<^sub>M S) (?E \<times> ?F)"
hoelzl@50000
   227
    by (subst emeasure_distr[OF measurable_comb_seq])
hoelzl@50000
   228
       (auto intro!: sets_PiM_I simp: split_beta' J)
hoelzl@50000
   229
  also have "\<dots> = emeasure S ?E * emeasure S ?F"
hoelzl@50000
   230
    using J by (intro P.emeasure_pair_measure_Times)  (auto intro!: sets_PiM_I finite_vimageI simp: inj_on_def)
hoelzl@50000
   231
  also have "emeasure S ?F = (\<Prod>j\<in>(op + i) -` J. emeasure M (E (i + j)))"
hoelzl@50000
   232
    using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI inj_on_def)
hoelzl@50000
   233
  also have "\<dots> = (\<Prod>j\<in>J - (J \<inter> {..<i}). emeasure M (E j))"
haftmann@57418
   234
    by (rule setprod.reindex_cong [of "\<lambda>x. x - i"])
hoelzl@50000
   235
       (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
hoelzl@50000
   236
  also have "emeasure S ?E = (\<Prod>j\<in>J \<inter> {..<i}. emeasure M (E j))"
hoelzl@50000
   237
    using J by (intro emeasure_PiM_emb) simp_all
hoelzl@50000
   238
  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))"
haftmann@57512
   239
    by (subst mult.commute) (auto simp: J setprod.subset_diff[symmetric])
hoelzl@50000
   240
  finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
hoelzl@50000
   241
qed simp_all
hoelzl@50000
   242
hoelzl@50000
   243
lemma PiM_iter:
blanchet@55415
   244
  "distr (M \<Otimes>\<^sub>M S) S (\<lambda>(s, \<omega>). case_nat s \<omega>) = S" (is "?D = _")
hoelzl@50000
   245
proof (rule PiM_eq)
hoelzl@50000
   246
  let ?I = "UNIV::nat set" and ?M = "\<lambda>n. M"
hoelzl@50000
   247
  let "distr _ _ ?f" = "?D"
hoelzl@50000
   248
hoelzl@50000
   249
  fix J E assume J: "finite J" "J \<subseteq> ?I" "\<And>j. j \<in> J \<Longrightarrow> E j \<in> sets M"
hoelzl@50000
   250
  let ?X = "prod_emb ?I ?M J (PIE j:J. E j)"
hoelzl@50000
   251
  have "\<And>j x. j \<in> J \<Longrightarrow> x \<in> E j \<Longrightarrow> x \<in> space M"
immler@50244
   252
    using J(3)[THEN sets.sets_into_space] by (auto simp: space_PiM Pi_iff subset_eq)
wenzelm@53015
   253
  with J have "?f -` ?X \<inter> space (M \<Otimes>\<^sub>M S) = (if 0 \<in> J then E 0 else space M) \<times>
hoelzl@50000
   254
    (prod_emb ?I ?M (Suc -` J) (PIE j:Suc -` J. E (Suc j)))" (is "_ = ?E \<times> ?F")
hoelzl@50123
   255
   by (auto simp: space_pair_measure space_PiM PiE_iff prod_emb_def all_conj_distrib
hoelzl@50000
   256
      split: nat.split nat.split_asm)
wenzelm@53015
   257
  then have "emeasure ?D ?X = emeasure (M \<Otimes>\<^sub>M S) (?E \<times> ?F)"
hoelzl@50099
   258
    by (subst emeasure_distr)
hoelzl@50000
   259
       (auto intro!: sets_PiM_I simp: split_beta' J)
hoelzl@50000
   260
  also have "\<dots> = emeasure M ?E * emeasure S ?F"
hoelzl@50000
   261
    using J by (intro P.emeasure_pair_measure_Times) (auto intro!: sets_PiM_I finite_vimageI)
hoelzl@50000
   262
  also have "emeasure S ?F = (\<Prod>j\<in>Suc -` J. emeasure M (E (Suc j)))"
hoelzl@50000
   263
    using J by (intro emeasure_PiM_emb) (simp_all add: finite_vimageI)
hoelzl@50000
   264
  also have "\<dots> = (\<Prod>j\<in>J - {0}. emeasure M (E j))"
haftmann@57418
   265
    by (rule setprod.reindex_cong [of "\<lambda>x. x - 1"])
hoelzl@50000
   266
       (auto simp: image_iff Bex_def not_less nat_eq_diff_eq ac_simps cong: conj_cong intro!: inj_onI)
hoelzl@50000
   267
  also have "emeasure M ?E * (\<Prod>j\<in>J - {0}. emeasure M (E j)) = (\<Prod>j\<in>J. emeasure M (E j))"
hoelzl@50000
   268
    by (auto simp: M.emeasure_space_1 setprod.remove J)
hoelzl@50000
   269
  finally show "emeasure ?D ?X = (\<Prod>j\<in>J. emeasure M (E j))" .
hoelzl@50000
   270
qed simp_all
hoelzl@50000
   271
hoelzl@50000
   272
end
hoelzl@50000
   273
hoelzl@42147
   274
end