author hoelzl
Thu May 26 14:11:57 2011 +0200 (2011-05-26)
changeset 42981 fe7f5a26e4c6
parent 42861 16375b493b64
child 42982 fa0ac7bee9ac
permissions -rw-r--r--
add lemma indep_sets_collect_sigma
     1 (*  Title:      HOL/Probability/Independent_Family.thy
     2     Author:     Johannes Hölzl, TU München
     3 *)
     5 header {* Independent families of events, event sets, and random variables *}
     7 theory Independent_Family
     8   imports Probability_Measure
     9 begin
    11 definition (in prob_space)
    12   "indep_events A I \<longleftrightarrow> (A`I \<subseteq> sets M) \<and>
    13     (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j)))"
    15 definition (in prob_space)
    16   "indep_event A B \<longleftrightarrow> indep_events (bool_case A B) UNIV"
    18 definition (in prob_space)
    19   "indep_sets F I \<longleftrightarrow> (\<forall>i\<in>I. F i \<subseteq> sets M) \<and>
    20     (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> (\<forall>A\<in>Pi J F. prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))))"
    22 definition (in prob_space)
    23   "indep_set A B \<longleftrightarrow> indep_sets (bool_case A B) UNIV"
    25 definition (in prob_space)
    26   "indep_rv M' X I \<longleftrightarrow>
    27     (\<forall>i\<in>I. random_variable (M' i) (X i)) \<and>
    28     indep_sets (\<lambda>i. sigma_sets (space M) { X i -` A \<inter> space M | A. A \<in> sets (M' i)}) I"
    30 lemma (in prob_space) indep_sets_cong:
    31   "I = J \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> F i = G i) \<Longrightarrow> indep_sets F I \<longleftrightarrow> indep_sets G J"
    32   by (simp add: indep_sets_def, intro conj_cong all_cong imp_cong ball_cong) blast+
    34 lemma (in prob_space) indep_events_finite_index_events:
    35   "indep_events F I \<longleftrightarrow> (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_events F J)"
    36   by (auto simp: indep_events_def)
    38 lemma (in prob_space) indep_sets_finite_index_sets:
    39   "indep_sets F I \<longleftrightarrow> (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_sets F J)"
    40 proof (intro iffI allI impI)
    41   assume *: "\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_sets F J"
    42   show "indep_sets F I" unfolding indep_sets_def
    43   proof (intro conjI ballI allI impI)
    44     fix i assume "i \<in> I"
    45     with *[THEN spec, of "{i}"] show "F i \<subseteq> events"
    46       by (auto simp: indep_sets_def)
    47   qed (insert *, auto simp: indep_sets_def)
    48 qed (auto simp: indep_sets_def)
    50 lemma (in prob_space) indep_sets_mono_index:
    51   "J \<subseteq> I \<Longrightarrow> indep_sets F I \<Longrightarrow> indep_sets F J"
    52   unfolding indep_sets_def by auto
    54 lemma (in prob_space) indep_sets_mono_sets:
    55   assumes indep: "indep_sets F I"
    56   assumes mono: "\<And>i. i\<in>I \<Longrightarrow> G i \<subseteq> F i"
    57   shows "indep_sets G I"
    58 proof -
    59   have "(\<forall>i\<in>I. F i \<subseteq> events) \<Longrightarrow> (\<forall>i\<in>I. G i \<subseteq> events)"
    60     using mono by auto
    61   moreover have "\<And>A J. J \<subseteq> I \<Longrightarrow> A \<in> (\<Pi> j\<in>J. G j) \<Longrightarrow> A \<in> (\<Pi> j\<in>J. F j)"
    62     using mono by (auto simp: Pi_iff)
    63   ultimately show ?thesis
    64     using indep by (auto simp: indep_sets_def)
    65 qed
    67 lemma (in prob_space) indep_setsI:
    68   assumes "\<And>i. i \<in> I \<Longrightarrow> F i \<subseteq> events"
    69     and "\<And>A J. J \<noteq> {} \<Longrightarrow> J \<subseteq> I \<Longrightarrow> finite J \<Longrightarrow> (\<forall>j\<in>J. A j \<in> F j) \<Longrightarrow> prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
    70   shows "indep_sets F I"
    71   using assms unfolding indep_sets_def by (auto simp: Pi_iff)
    73 lemma (in prob_space) indep_setsD:
    74   assumes "indep_sets F I" and "J \<subseteq> I" "J \<noteq> {}" "finite J" "\<forall>j\<in>J. A j \<in> F j"
    75   shows "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
    76   using assms unfolding indep_sets_def by auto
    78 lemma dynkin_systemI':
    79   assumes 1: "\<And> A. A \<in> sets M \<Longrightarrow> A \<subseteq> space M"
    80   assumes empty: "{} \<in> sets M"
    81   assumes Diff: "\<And> A. A \<in> sets M \<Longrightarrow> space M - A \<in> sets M"
    82   assumes 2: "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> sets M
    83           \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
    84   shows "dynkin_system M"
    85 proof -
    86   from Diff[OF empty] have "space M \<in> sets M" by auto
    87   from 1 this Diff 2 show ?thesis
    88     by (intro dynkin_systemI) auto
    89 qed
    91 lemma (in prob_space) indep_sets_dynkin:
    92   assumes indep: "indep_sets F I"
    93   shows "indep_sets (\<lambda>i. sets (dynkin \<lparr> space = space M, sets = F i \<rparr>)) I"
    94     (is "indep_sets ?F I")
    95 proof (subst indep_sets_finite_index_sets, intro allI impI ballI)
    96   fix J assume "finite J" "J \<subseteq> I" "J \<noteq> {}"
    97   with indep have "indep_sets F J"
    98     by (subst (asm) indep_sets_finite_index_sets) auto
    99   { fix J K assume "indep_sets F K"
   100     let "?G S i" = "if i \<in> S then ?F i else F i"
   101     assume "finite J" "J \<subseteq> K"
   102     then have "indep_sets (?G J) K"
   103     proof induct
   104       case (insert j J)
   105       moreover def G \<equiv> "?G J"
   106       ultimately have G: "indep_sets G K" "\<And>i. i \<in> K \<Longrightarrow> G i \<subseteq> events" and "j \<in> K"
   107         by (auto simp: indep_sets_def)
   108       let ?D = "{E\<in>events. indep_sets (G(j := {E})) K }"
   109       { fix X assume X: "X \<in> events"
   110         assume indep: "\<And>J A. J \<noteq> {} \<Longrightarrow> J \<subseteq> K \<Longrightarrow> finite J \<Longrightarrow> j \<notin> J \<Longrightarrow> (\<forall>i\<in>J. A i \<in> G i)
   111           \<Longrightarrow> prob ((\<Inter>i\<in>J. A i) \<inter> X) = prob X * (\<Prod>i\<in>J. prob (A i))"
   112         have "indep_sets (G(j := {X})) K"
   113         proof (rule indep_setsI)
   114           fix i assume "i \<in> K" then show "(G(j:={X})) i \<subseteq> events"
   115             using G X by auto
   116         next
   117           fix A J assume J: "J \<noteq> {}" "J \<subseteq> K" "finite J" "\<forall>i\<in>J. A i \<in> (G(j := {X})) i"
   118           show "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
   119           proof cases
   120             assume "j \<in> J"
   121             with J have "A j = X" by auto
   122             show ?thesis
   123             proof cases
   124               assume "J = {j}" then show ?thesis by simp
   125             next
   126               assume "J \<noteq> {j}"
   127               have "prob (\<Inter>i\<in>J. A i) = prob ((\<Inter>i\<in>J-{j}. A i) \<inter> X)"
   128                 using `j \<in> J` `A j = X` by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
   129               also have "\<dots> = prob X * (\<Prod>i\<in>J-{j}. prob (A i))"
   130               proof (rule indep)
   131                 show "J - {j} \<noteq> {}" "J - {j} \<subseteq> K" "finite (J - {j})" "j \<notin> J - {j}"
   132                   using J `J \<noteq> {j}` `j \<in> J` by auto
   133                 show "\<forall>i\<in>J - {j}. A i \<in> G i"
   134                   using J by auto
   135               qed
   136               also have "\<dots> = prob (A j) * (\<Prod>i\<in>J-{j}. prob (A i))"
   137                 using `A j = X` by simp
   138               also have "\<dots> = (\<Prod>i\<in>J. prob (A i))"
   139                 unfolding setprod.insert_remove[OF `finite J`, symmetric, of "\<lambda>i. prob  (A i)"]
   140                 using `j \<in> J` by (simp add: insert_absorb)
   141               finally show ?thesis .
   142             qed
   143           next
   144             assume "j \<notin> J"
   145             with J have "\<forall>i\<in>J. A i \<in> G i" by (auto split: split_if_asm)
   146             with J show ?thesis
   147               by (intro indep_setsD[OF G(1)]) auto
   148           qed
   149         qed }
   150       note indep_sets_insert = this
   151       have "dynkin_system \<lparr> space = space M, sets = ?D \<rparr>"
   152       proof (rule dynkin_systemI', simp_all, safe)
   153         show "indep_sets (G(j := {{}})) K"
   154           by (rule indep_sets_insert) auto
   155       next
   156         fix X assume X: "X \<in> events" and G': "indep_sets (G(j := {X})) K"
   157         show "indep_sets (G(j := {space M - X})) K"
   158         proof (rule indep_sets_insert)
   159           fix J A assume J: "J \<noteq> {}" "J \<subseteq> K" "finite J" "j \<notin> J" and A: "\<forall>i\<in>J. A i \<in> G i"
   160           then have A_sets: "\<And>i. i\<in>J \<Longrightarrow> A i \<in> events"
   161             using G by auto
   162           have "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) =
   163               prob ((\<Inter>j\<in>J. A j) - (\<Inter>i\<in>insert j J. (A(j := X)) i))"
   164             using A_sets sets_into_space X `J \<noteq> {}`
   165             by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
   166           also have "\<dots> = prob (\<Inter>j\<in>J. A j) - prob (\<Inter>i\<in>insert j J. (A(j := X)) i)"
   167             using J `J \<noteq> {}` `j \<notin> J` A_sets X sets_into_space
   168             by (auto intro!: finite_measure_Diff finite_INT split: split_if_asm)
   169           finally have "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) =
   170               prob (\<Inter>j\<in>J. A j) - prob (\<Inter>i\<in>insert j J. (A(j := X)) i)" .
   171           moreover {
   172             have "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
   173               using J A `finite J` by (intro indep_setsD[OF G(1)]) auto
   174             then have "prob (\<Inter>j\<in>J. A j) = prob (space M) * (\<Prod>i\<in>J. prob (A i))"
   175               using prob_space by simp }
   176           moreover {
   177             have "prob (\<Inter>i\<in>insert j J. (A(j := X)) i) = (\<Prod>i\<in>insert j J. prob ((A(j := X)) i))"
   178               using J A `j \<in> K` by (intro indep_setsD[OF G']) auto
   179             then have "prob (\<Inter>i\<in>insert j J. (A(j := X)) i) = prob X * (\<Prod>i\<in>J. prob (A i))"
   180               using `finite J` `j \<notin> J` by (auto intro!: setprod_cong) }
   181           ultimately have "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) = (prob (space M) - prob X) * (\<Prod>i\<in>J. prob (A i))"
   182             by (simp add: field_simps)
   183           also have "\<dots> = prob (space M - X) * (\<Prod>i\<in>J. prob (A i))"
   184             using X A by (simp add: finite_measure_compl)
   185           finally show "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) = prob (space M - X) * (\<Prod>i\<in>J. prob (A i))" .
   186         qed (insert X, auto)
   187       next
   188         fix F :: "nat \<Rightarrow> 'a set" assume disj: "disjoint_family F" and "range F \<subseteq> ?D"
   189         then have F: "\<And>i. F i \<in> events" "\<And>i. indep_sets (G(j:={F i})) K" by auto
   190         show "indep_sets (G(j := {\<Union>k. F k})) K"
   191         proof (rule indep_sets_insert)
   192           fix J A assume J: "j \<notin> J" "J \<noteq> {}" "J \<subseteq> K" "finite J" and A: "\<forall>i\<in>J. A i \<in> G i"
   193           then have A_sets: "\<And>i. i\<in>J \<Longrightarrow> A i \<in> events"
   194             using G by auto
   195           have "prob ((\<Inter>j\<in>J. A j) \<inter> (\<Union>k. F k)) = prob (\<Union>k. (\<Inter>i\<in>insert j J. (A(j := F k)) i))"
   196             using `J \<noteq> {}` `j \<notin> J` `j \<in> K` by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
   197           moreover have "(\<lambda>k. prob (\<Inter>i\<in>insert j J. (A(j := F k)) i)) sums prob (\<Union>k. (\<Inter>i\<in>insert j J. (A(j := F k)) i))"
   198           proof (rule finite_measure_UNION)
   199             show "disjoint_family (\<lambda>k. \<Inter>i\<in>insert j J. (A(j := F k)) i)"
   200               using disj by (rule disjoint_family_on_bisimulation) auto
   201             show "range (\<lambda>k. \<Inter>i\<in>insert j J. (A(j := F k)) i) \<subseteq> events"
   202               using A_sets F `finite J` `J \<noteq> {}` `j \<notin> J` by (auto intro!: Int)
   203           qed
   204           moreover { fix k
   205             from J A `j \<in> K` have "prob (\<Inter>i\<in>insert j J. (A(j := F k)) i) = prob (F k) * (\<Prod>i\<in>J. prob (A i))"
   206               by (subst indep_setsD[OF F(2)]) (auto intro!: setprod_cong split: split_if_asm)
   207             also have "\<dots> = prob (F k) * prob (\<Inter>i\<in>J. A i)"
   208               using J A `j \<in> K` by (subst indep_setsD[OF G(1)]) auto
   209             finally have "prob (\<Inter>i\<in>insert j J. (A(j := F k)) i) = prob (F k) * prob (\<Inter>i\<in>J. A i)" . }
   210           ultimately have "(\<lambda>k. prob (F k) * prob (\<Inter>i\<in>J. A i)) sums (prob ((\<Inter>j\<in>J. A j) \<inter> (\<Union>k. F k)))"
   211             by simp
   212           moreover
   213           have "(\<lambda>k. prob (F k) * prob (\<Inter>i\<in>J. A i)) sums (prob (\<Union>k. F k) * prob (\<Inter>i\<in>J. A i))"
   214             using disj F(1) by (intro finite_measure_UNION sums_mult2) auto
   215           then have "(\<lambda>k. prob (F k) * prob (\<Inter>i\<in>J. A i)) sums (prob (\<Union>k. F k) * (\<Prod>i\<in>J. prob (A i)))"
   216             using J A `j \<in> K` by (subst indep_setsD[OF G(1), symmetric]) auto
   217           ultimately
   218           show "prob ((\<Inter>j\<in>J. A j) \<inter> (\<Union>k. F k)) = prob (\<Union>k. F k) * (\<Prod>j\<in>J. prob (A j))"
   219             by (auto dest!: sums_unique)
   220         qed (insert F, auto)
   221       qed (insert sets_into_space, auto)
   222       then have mono: "sets (dynkin \<lparr>space = space M, sets = G j\<rparr>) \<subseteq>
   223         sets \<lparr>space = space M, sets = {E \<in> events. indep_sets (G(j := {E})) K}\<rparr>"
   224       proof (rule dynkin_system.dynkin_subset, simp_all, safe)
   225         fix X assume "X \<in> G j"
   226         then show "X \<in> events" using G `j \<in> K` by auto
   227         from `indep_sets G K`
   228         show "indep_sets (G(j := {X})) K"
   229           by (rule indep_sets_mono_sets) (insert `X \<in> G j`, auto)
   230       qed
   231       have "indep_sets (G(j:=?D)) K"
   232       proof (rule indep_setsI)
   233         fix i assume "i \<in> K" then show "(G(j := ?D)) i \<subseteq> events"
   234           using G(2) by auto
   235       next
   236         fix A J assume J: "J\<noteq>{}" "J \<subseteq> K" "finite J" and A: "\<forall>i\<in>J. A i \<in> (G(j := ?D)) i"
   237         show "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
   238         proof cases
   239           assume "j \<in> J"
   240           with A have indep: "indep_sets (G(j := {A j})) K" by auto
   241           from J A show ?thesis
   242             by (intro indep_setsD[OF indep]) auto
   243         next
   244           assume "j \<notin> J"
   245           with J A have "\<forall>i\<in>J. A i \<in> G i" by (auto split: split_if_asm)
   246           with J show ?thesis
   247             by (intro indep_setsD[OF G(1)]) auto
   248         qed
   249       qed
   250       then have "indep_sets (G(j:=sets (dynkin \<lparr>space = space M, sets = G j\<rparr>))) K"
   251         by (rule indep_sets_mono_sets) (insert mono, auto)
   252       then show ?case
   253         by (rule indep_sets_mono_sets) (insert `j \<in> K` `j \<notin> J`, auto simp: G_def)
   254     qed (insert `indep_sets F K`, simp) }
   255   from this[OF `indep_sets F J` `finite J` subset_refl]
   256   show "indep_sets (\<lambda>i. sets (dynkin \<lparr> space = space M, sets = F i \<rparr>)) J"
   257     by (rule indep_sets_mono_sets) auto
   258 qed
   260 lemma (in prob_space) indep_sets_sigma:
   261   assumes indep: "indep_sets F I"
   262   assumes stable: "\<And>i. i \<in> I \<Longrightarrow> Int_stable \<lparr> space = space M, sets = F i \<rparr>"
   263   shows "indep_sets (\<lambda>i. sets (sigma \<lparr> space = space M, sets = F i \<rparr>)) I"
   264 proof -
   265   from indep_sets_dynkin[OF indep]
   266   show ?thesis
   267   proof (rule indep_sets_mono_sets, subst sigma_eq_dynkin, simp_all add: stable)
   268     fix i assume "i \<in> I"
   269     with indep have "F i \<subseteq> events" by (auto simp: indep_sets_def)
   270     with sets_into_space show "F i \<subseteq> Pow (space M)" by auto
   271   qed
   272 qed
   274 lemma (in prob_space) indep_sets_sigma_sets:
   275   assumes "indep_sets F I"
   276   assumes "\<And>i. i \<in> I \<Longrightarrow> Int_stable \<lparr> space = space M, sets = F i \<rparr>"
   277   shows "indep_sets (\<lambda>i. sigma_sets (space M) (F i)) I"
   278   using indep_sets_sigma[OF assms] by (simp add: sets_sigma)
   280 lemma (in prob_space) indep_sets2_eq:
   281   "indep_set A B \<longleftrightarrow> A \<subseteq> events \<and> B \<subseteq> events \<and> (\<forall>a\<in>A. \<forall>b\<in>B. prob (a \<inter> b) = prob a * prob b)"
   282   unfolding indep_set_def
   283 proof (intro iffI ballI conjI)
   284   assume indep: "indep_sets (bool_case A B) UNIV"
   285   { fix a b assume "a \<in> A" "b \<in> B"
   286     with indep_setsD[OF indep, of UNIV "bool_case a b"]
   287     show "prob (a \<inter> b) = prob a * prob b"
   288       unfolding UNIV_bool by (simp add: ac_simps) }
   289   from indep show "A \<subseteq> events" "B \<subseteq> events"
   290     unfolding indep_sets_def UNIV_bool by auto
   291 next
   292   assume *: "A \<subseteq> events \<and> B \<subseteq> events \<and> (\<forall>a\<in>A. \<forall>b\<in>B. prob (a \<inter> b) = prob a * prob b)"
   293   show "indep_sets (bool_case A B) UNIV"
   294   proof (rule indep_setsI)
   295     fix i show "(case i of True \<Rightarrow> A | False \<Rightarrow> B) \<subseteq> events"
   296       using * by (auto split: bool.split)
   297   next
   298     fix J X assume "J \<noteq> {}" "J \<subseteq> UNIV" and X: "\<forall>j\<in>J. X j \<in> (case j of True \<Rightarrow> A | False \<Rightarrow> B)"
   299     then have "J = {True} \<or> J = {False} \<or> J = {True,False}"
   300       by (auto simp: UNIV_bool)
   301     then show "prob (\<Inter>j\<in>J. X j) = (\<Prod>j\<in>J. prob (X j))"
   302       using X * by auto
   303   qed
   304 qed
   306 lemma (in prob_space) indep_set_sigma_sets:
   307   assumes "indep_set A B"
   308   assumes A: "Int_stable \<lparr> space = space M, sets = A \<rparr>"
   309   assumes B: "Int_stable \<lparr> space = space M, sets = B \<rparr>"
   310   shows "indep_set (sigma_sets (space M) A) (sigma_sets (space M) B)"
   311 proof -
   312   have "indep_sets (\<lambda>i. sigma_sets (space M) (case i of True \<Rightarrow> A | False \<Rightarrow> B)) UNIV"
   313   proof (rule indep_sets_sigma_sets)
   314     show "indep_sets (bool_case A B) UNIV"
   315       by (rule `indep_set A B`[unfolded indep_set_def])
   316     fix i show "Int_stable \<lparr>space = space M, sets = case i of True \<Rightarrow> A | False \<Rightarrow> B\<rparr>"
   317       using A B by (cases i) auto
   318   qed
   319   then show ?thesis
   320     unfolding indep_set_def
   321     by (rule indep_sets_mono_sets) (auto split: bool.split)
   322 qed
   324 lemma (in prob_space) indep_sets_collect_sigma:
   325   fixes I :: "'j \<Rightarrow> 'i set" and J :: "'j set" and E :: "'i \<Rightarrow> 'a set set"
   326   assumes indep: "indep_sets E (\<Union>j\<in>J. I j)"
   327   assumes Int_stable: "\<And>i j. j \<in> J \<Longrightarrow> i \<in> I j \<Longrightarrow> Int_stable \<lparr>space = space M, sets = E i\<rparr>"
   328   assumes disjoint: "disjoint_family_on I J"
   329   shows "indep_sets (\<lambda>j. sigma_sets (space M) (\<Union>i\<in>I j. E i)) J"
   330 proof -
   331   let "?E j" = "{\<Inter>k\<in>K. E' k| E' K. finite K \<and> K \<noteq> {} \<and> K \<subseteq> I j \<and> (\<forall>k\<in>K. E' k \<in> E k) }"
   333   from indep have E: "\<And>j i. j \<in> J \<Longrightarrow> i \<in> I j \<Longrightarrow> E i \<subseteq> sets M"
   334     unfolding indep_sets_def by auto
   335   { fix j
   336     let ?S = "sigma \<lparr> space = space M, sets = (\<Union>i\<in>I j. E i) \<rparr>"
   337     assume "j \<in> J"
   338     from E[OF this] interpret S: sigma_algebra ?S
   339       using sets_into_space by (intro sigma_algebra_sigma) auto
   341     have "sigma_sets (space M) (\<Union>i\<in>I j. E i) = sigma_sets (space M) (?E j)"
   342     proof (rule sigma_sets_eqI)
   343       fix A assume "A \<in> (\<Union>i\<in>I j. E i)"
   344       then guess i ..
   345       then show "A \<in> sigma_sets (space M) (?E j)"
   346         by (auto intro!: sigma_sets.intros exI[of _ "{i}"] exI[of _ "\<lambda>i. A"])
   347     next
   348       fix A assume "A \<in> ?E j"
   349       then obtain E' K where "finite K" "K \<noteq> {}" "K \<subseteq> I j" "\<And>k. k \<in> K \<Longrightarrow> E' k \<in> E k"
   350         and A: "A = (\<Inter>k\<in>K. E' k)"
   351         by auto
   352       then have "A \<in> sets ?S" unfolding A
   353         by (safe intro!: S.finite_INT)
   354            (auto simp: sets_sigma intro!: sigma_sets.Basic)
   355       then show "A \<in> sigma_sets (space M) (\<Union>i\<in>I j. E i)"
   356         by (simp add: sets_sigma)
   357     qed }
   358   moreover have "indep_sets (\<lambda>j. sigma_sets (space M) (?E j)) J"
   359   proof (rule indep_sets_sigma_sets)
   360     show "indep_sets ?E J"
   361     proof (intro indep_setsI)
   362       fix j assume "j \<in> J" with E show "?E j \<subseteq> events" by (force  intro!: finite_INT)
   363     next
   364       fix K A assume K: "K \<noteq> {}" "K \<subseteq> J" "finite K"
   365         and "\<forall>j\<in>K. A j \<in> ?E j"
   366       then have "\<forall>j\<in>K. \<exists>E' L. A j = (\<Inter>l\<in>L. E' l) \<and> finite L \<and> L \<noteq> {} \<and> L \<subseteq> I j \<and> (\<forall>l\<in>L. E' l \<in> E l)"
   367         by simp
   368       from bchoice[OF this] guess E' ..
   369       from bchoice[OF this] obtain L
   370         where A: "\<And>j. j\<in>K \<Longrightarrow> A j = (\<Inter>l\<in>L j. E' j l)"
   371         and L: "\<And>j. j\<in>K \<Longrightarrow> finite (L j)" "\<And>j. j\<in>K \<Longrightarrow> L j \<noteq> {}" "\<And>j. j\<in>K \<Longrightarrow> L j \<subseteq> I j"
   372         and E': "\<And>j l. j\<in>K \<Longrightarrow> l \<in> L j \<Longrightarrow> E' j l \<in> E l"
   373         by auto
   375       { fix k l j assume "k \<in> K" "j \<in> K" "l \<in> L j" "l \<in> L k"
   376         have "k = j"
   377         proof (rule ccontr)
   378           assume "k \<noteq> j"
   379           with disjoint `K \<subseteq> J` `k \<in> K` `j \<in> K` have "I k \<inter> I j = {}"
   380             unfolding disjoint_family_on_def by auto
   381           with L(2,3)[OF `j \<in> K`] L(2,3)[OF `k \<in> K`]
   382           show False using `l \<in> L k` `l \<in> L j` by auto
   383         qed }
   384       note L_inj = this
   386       def k \<equiv> "\<lambda>l. (SOME k. k \<in> K \<and> l \<in> L k)"
   387       { fix x j l assume *: "j \<in> K" "l \<in> L j"
   388         have "k l = j" unfolding k_def
   389         proof (rule some_equality)
   390           fix k assume "k \<in> K \<and> l \<in> L k"
   391           with * L_inj show "k = j" by auto
   392         qed (insert *, simp) }
   393       note k_simp[simp] = this
   394       let "?E' l" = "E' (k l) l"
   395       have "prob (\<Inter>j\<in>K. A j) = prob (\<Inter>l\<in>(\<Union>k\<in>K. L k). ?E' l)"
   396         by (auto simp: A intro!: arg_cong[where f=prob])
   397       also have "\<dots> = (\<Prod>l\<in>(\<Union>k\<in>K. L k). prob (?E' l))"
   398         using L K E' by (intro indep_setsD[OF indep]) (simp_all add: UN_mono)
   399       also have "\<dots> = (\<Prod>j\<in>K. \<Prod>l\<in>L j. prob (E' j l))"
   400         using K L L_inj by (subst setprod_UN_disjoint) auto
   401       also have "\<dots> = (\<Prod>j\<in>K. prob (A j))"
   402         using K L E' by (auto simp add: A intro!: setprod_cong indep_setsD[OF indep, symmetric]) blast
   403       finally show "prob (\<Inter>j\<in>K. A j) = (\<Prod>j\<in>K. prob (A j))" .
   404     qed
   405   next
   406     fix j assume "j \<in> J"
   407     show "Int_stable \<lparr> space = space M, sets = ?E j \<rparr>"
   408     proof (rule Int_stableI)
   409       fix a assume "a \<in> ?E j" then obtain Ka Ea
   410         where a: "a = (\<Inter>k\<in>Ka. Ea k)" "finite Ka" "Ka \<noteq> {}" "Ka \<subseteq> I j" "\<And>k. k\<in>Ka \<Longrightarrow> Ea k \<in> E k" by auto
   411       fix b assume "b \<in> ?E j" then obtain Kb Eb
   412         where b: "b = (\<Inter>k\<in>Kb. Eb k)" "finite Kb" "Kb \<noteq> {}" "Kb \<subseteq> I j" "\<And>k. k\<in>Kb \<Longrightarrow> Eb k \<in> E k" by auto
   413       let ?A = "\<lambda>k. (if k \<in> Ka \<inter> Kb then Ea k \<inter> Eb k else if k \<in> Kb then Eb k else if k \<in> Ka then Ea k else {})"
   414       have "a \<inter> b = INTER (Ka \<union> Kb) ?A"
   415         by (simp add: a b set_eq_iff) auto
   416       with a b `j \<in> J` Int_stableD[OF Int_stable] show "a \<inter> b \<in> ?E j"
   417         by (intro CollectI exI[of _ "Ka \<union> Kb"] exI[of _ ?A]) auto
   418     qed
   419   qed
   420   ultimately show ?thesis
   421     by (simp cong: indep_sets_cong)
   422 qed
   424 end