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