src/HOL/Probability/Independent_Family.thy
 author hoelzl Thu May 26 14:12:02 2011 +0200 (2011-05-26) changeset 42985 1fb670792708 parent 42983 685df9c0626d child 42987 73e2d802ea41 permissions -rw-r--r--
```     1 (*  Title:      HOL/Probability/Independent_Family.thy
```
```     2     Author:     Johannes Hölzl, TU München
```
```     3 *)
```
```     4
```
```     5 header {* Independent families of events, event sets, and random variables *}
```
```     6
```
```     7 theory Independent_Family
```
```     8   imports Probability_Measure
```
```     9 begin
```
```    10
```
```    11 lemma INT_decseq_offset:
```
```    12   assumes "decseq F"
```
```    13   shows "(\<Inter>i. F i) = (\<Inter>i\<in>{n..}. F i)"
```
```    14 proof safe
```
```    15   fix x i assume x: "x \<in> (\<Inter>i\<in>{n..}. F i)"
```
```    16   show "x \<in> F i"
```
```    17   proof cases
```
```    18     from x have "x \<in> F n" by auto
```
```    19     also assume "i \<le> n" with `decseq F` have "F n \<subseteq> F i"
```
```    20       unfolding decseq_def by simp
```
```    21     finally show ?thesis .
```
```    22   qed (insert x, simp)
```
```    23 qed auto
```
```    24
```
```    25 definition (in prob_space)
```
```    26   "indep_events A I \<longleftrightarrow> (A`I \<subseteq> events) \<and>
```
```    27     (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j)))"
```
```    28
```
```    29 definition (in prob_space)
```
```    30   "indep_event A B \<longleftrightarrow> indep_events (bool_case A B) UNIV"
```
```    31
```
```    32 definition (in prob_space)
```
```    33   "indep_sets F I \<longleftrightarrow> (\<forall>i\<in>I. F i \<subseteq> events) \<and>
```
```    34     (\<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))))"
```
```    35
```
```    36 definition (in prob_space)
```
```    37   "indep_set A B \<longleftrightarrow> indep_sets (bool_case A B) UNIV"
```
```    38
```
```    39 definition (in prob_space)
```
```    40   "indep_rv M' X I \<longleftrightarrow>
```
```    41     (\<forall>i\<in>I. random_variable (M' i) (X i)) \<and>
```
```    42     indep_sets (\<lambda>i. sigma_sets (space M) { X i -` A \<inter> space M | A. A \<in> sets (M' i)}) I"
```
```    43
```
```    44 lemma (in prob_space) indep_sets_cong:
```
```    45   "I = J \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> F i = G i) \<Longrightarrow> indep_sets F I \<longleftrightarrow> indep_sets G J"
```
```    46   by (simp add: indep_sets_def, intro conj_cong all_cong imp_cong ball_cong) blast+
```
```    47
```
```    48 lemma (in prob_space) indep_sets_singleton_iff_indep_events:
```
```    49   "indep_sets (\<lambda>i. {F i}) I \<longleftrightarrow> indep_events F I"
```
```    50   unfolding indep_sets_def indep_events_def
```
```    51   by (simp, intro conj_cong ball_cong all_cong imp_cong) (auto simp: Pi_iff)
```
```    52
```
```    53 lemma (in prob_space) indep_events_finite_index_events:
```
```    54   "indep_events F I \<longleftrightarrow> (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_events F J)"
```
```    55   by (auto simp: indep_events_def)
```
```    56
```
```    57 lemma (in prob_space) indep_sets_finite_index_sets:
```
```    58   "indep_sets F I \<longleftrightarrow> (\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_sets F J)"
```
```    59 proof (intro iffI allI impI)
```
```    60   assume *: "\<forall>J\<subseteq>I. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> indep_sets F J"
```
```    61   show "indep_sets F I" unfolding indep_sets_def
```
```    62   proof (intro conjI ballI allI impI)
```
```    63     fix i assume "i \<in> I"
```
```    64     with *[THEN spec, of "{i}"] show "F i \<subseteq> events"
```
```    65       by (auto simp: indep_sets_def)
```
```    66   qed (insert *, auto simp: indep_sets_def)
```
```    67 qed (auto simp: indep_sets_def)
```
```    68
```
```    69 lemma (in prob_space) indep_sets_mono_index:
```
```    70   "J \<subseteq> I \<Longrightarrow> indep_sets F I \<Longrightarrow> indep_sets F J"
```
```    71   unfolding indep_sets_def by auto
```
```    72
```
```    73 lemma (in prob_space) indep_sets_mono_sets:
```
```    74   assumes indep: "indep_sets F I"
```
```    75   assumes mono: "\<And>i. i\<in>I \<Longrightarrow> G i \<subseteq> F i"
```
```    76   shows "indep_sets G I"
```
```    77 proof -
```
```    78   have "(\<forall>i\<in>I. F i \<subseteq> events) \<Longrightarrow> (\<forall>i\<in>I. G i \<subseteq> events)"
```
```    79     using mono by auto
```
```    80   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)"
```
```    81     using mono by (auto simp: Pi_iff)
```
```    82   ultimately show ?thesis
```
```    83     using indep by (auto simp: indep_sets_def)
```
```    84 qed
```
```    85
```
```    86 lemma (in prob_space) indep_setsI:
```
```    87   assumes "\<And>i. i \<in> I \<Longrightarrow> F i \<subseteq> events"
```
```    88     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))"
```
```    89   shows "indep_sets F I"
```
```    90   using assms unfolding indep_sets_def by (auto simp: Pi_iff)
```
```    91
```
```    92 lemma (in prob_space) indep_setsD:
```
```    93   assumes "indep_sets F I" and "J \<subseteq> I" "J \<noteq> {}" "finite J" "\<forall>j\<in>J. A j \<in> F j"
```
```    94   shows "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
```
```    95   using assms unfolding indep_sets_def by auto
```
```    96
```
```    97 lemma (in prob_space) indep_setI:
```
```    98   assumes ev: "A \<subseteq> events" "B \<subseteq> events"
```
```    99     and indep: "\<And>a b. a \<in> A \<Longrightarrow> b \<in> B \<Longrightarrow> prob (a \<inter> b) = prob a * prob b"
```
```   100   shows "indep_set A B"
```
```   101   unfolding indep_set_def
```
```   102 proof (rule indep_setsI)
```
```   103   fix F J assume "J \<noteq> {}" "J \<subseteq> UNIV"
```
```   104     and F: "\<forall>j\<in>J. F j \<in> (case j of True \<Rightarrow> A | False \<Rightarrow> B)"
```
```   105   have "J \<in> Pow UNIV" by auto
```
```   106   with F `J \<noteq> {}` indep[of "F True" "F False"]
```
```   107   show "prob (\<Inter>j\<in>J. F j) = (\<Prod>j\<in>J. prob (F j))"
```
```   108     unfolding UNIV_bool Pow_insert by (auto simp: ac_simps)
```
```   109 qed (auto split: bool.split simp: ev)
```
```   110
```
```   111 lemma (in prob_space) indep_setD:
```
```   112   assumes indep: "indep_set A B" and ev: "a \<in> A" "b \<in> B"
```
```   113   shows "prob (a \<inter> b) = prob a * prob b"
```
```   114   using indep[unfolded indep_set_def, THEN indep_setsD, of UNIV "bool_case a b"] ev
```
```   115   by (simp add: ac_simps UNIV_bool)
```
```   116
```
```   117 lemma (in prob_space)
```
```   118   assumes indep: "indep_set A B"
```
```   119   shows indep_setD_ev1: "A \<subseteq> events"
```
```   120     and indep_setD_ev2: "B \<subseteq> events"
```
```   121   using indep unfolding indep_set_def indep_sets_def UNIV_bool by auto
```
```   122
```
```   123 lemma dynkin_systemI':
```
```   124   assumes 1: "\<And> A. A \<in> sets M \<Longrightarrow> A \<subseteq> space M"
```
```   125   assumes empty: "{} \<in> sets M"
```
```   126   assumes Diff: "\<And> A. A \<in> sets M \<Longrightarrow> space M - A \<in> sets M"
```
```   127   assumes 2: "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> sets M
```
```   128           \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```   129   shows "dynkin_system M"
```
```   130 proof -
```
```   131   from Diff[OF empty] have "space M \<in> sets M" by auto
```
```   132   from 1 this Diff 2 show ?thesis
```
```   133     by (intro dynkin_systemI) auto
```
```   134 qed
```
```   135
```
```   136 lemma (in prob_space) indep_sets_dynkin:
```
```   137   assumes indep: "indep_sets F I"
```
```   138   shows "indep_sets (\<lambda>i. sets (dynkin \<lparr> space = space M, sets = F i \<rparr>)) I"
```
```   139     (is "indep_sets ?F I")
```
```   140 proof (subst indep_sets_finite_index_sets, intro allI impI ballI)
```
```   141   fix J assume "finite J" "J \<subseteq> I" "J \<noteq> {}"
```
```   142   with indep have "indep_sets F J"
```
```   143     by (subst (asm) indep_sets_finite_index_sets) auto
```
```   144   { fix J K assume "indep_sets F K"
```
```   145     let "?G S i" = "if i \<in> S then ?F i else F i"
```
```   146     assume "finite J" "J \<subseteq> K"
```
```   147     then have "indep_sets (?G J) K"
```
```   148     proof induct
```
```   149       case (insert j J)
```
```   150       moreover def G \<equiv> "?G J"
```
```   151       ultimately have G: "indep_sets G K" "\<And>i. i \<in> K \<Longrightarrow> G i \<subseteq> events" and "j \<in> K"
```
```   152         by (auto simp: indep_sets_def)
```
```   153       let ?D = "{E\<in>events. indep_sets (G(j := {E})) K }"
```
```   154       { fix X assume X: "X \<in> events"
```
```   155         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)
```
```   156           \<Longrightarrow> prob ((\<Inter>i\<in>J. A i) \<inter> X) = prob X * (\<Prod>i\<in>J. prob (A i))"
```
```   157         have "indep_sets (G(j := {X})) K"
```
```   158         proof (rule indep_setsI)
```
```   159           fix i assume "i \<in> K" then show "(G(j:={X})) i \<subseteq> events"
```
```   160             using G X by auto
```
```   161         next
```
```   162           fix A J assume J: "J \<noteq> {}" "J \<subseteq> K" "finite J" "\<forall>i\<in>J. A i \<in> (G(j := {X})) i"
```
```   163           show "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
```
```   164           proof cases
```
```   165             assume "j \<in> J"
```
```   166             with J have "A j = X" by auto
```
```   167             show ?thesis
```
```   168             proof cases
```
```   169               assume "J = {j}" then show ?thesis by simp
```
```   170             next
```
```   171               assume "J \<noteq> {j}"
```
```   172               have "prob (\<Inter>i\<in>J. A i) = prob ((\<Inter>i\<in>J-{j}. A i) \<inter> X)"
```
```   173                 using `j \<in> J` `A j = X` by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
```
```   174               also have "\<dots> = prob X * (\<Prod>i\<in>J-{j}. prob (A i))"
```
```   175               proof (rule indep)
```
```   176                 show "J - {j} \<noteq> {}" "J - {j} \<subseteq> K" "finite (J - {j})" "j \<notin> J - {j}"
```
```   177                   using J `J \<noteq> {j}` `j \<in> J` by auto
```
```   178                 show "\<forall>i\<in>J - {j}. A i \<in> G i"
```
```   179                   using J by auto
```
```   180               qed
```
```   181               also have "\<dots> = prob (A j) * (\<Prod>i\<in>J-{j}. prob (A i))"
```
```   182                 using `A j = X` by simp
```
```   183               also have "\<dots> = (\<Prod>i\<in>J. prob (A i))"
```
```   184                 unfolding setprod.insert_remove[OF `finite J`, symmetric, of "\<lambda>i. prob  (A i)"]
```
```   185                 using `j \<in> J` by (simp add: insert_absorb)
```
```   186               finally show ?thesis .
```
```   187             qed
```
```   188           next
```
```   189             assume "j \<notin> J"
```
```   190             with J have "\<forall>i\<in>J. A i \<in> G i" by (auto split: split_if_asm)
```
```   191             with J show ?thesis
```
```   192               by (intro indep_setsD[OF G(1)]) auto
```
```   193           qed
```
```   194         qed }
```
```   195       note indep_sets_insert = this
```
```   196       have "dynkin_system \<lparr> space = space M, sets = ?D \<rparr>"
```
```   197       proof (rule dynkin_systemI', simp_all, safe)
```
```   198         show "indep_sets (G(j := {{}})) K"
```
```   199           by (rule indep_sets_insert) auto
```
```   200       next
```
```   201         fix X assume X: "X \<in> events" and G': "indep_sets (G(j := {X})) K"
```
```   202         show "indep_sets (G(j := {space M - X})) K"
```
```   203         proof (rule indep_sets_insert)
```
```   204           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"
```
```   205           then have A_sets: "\<And>i. i\<in>J \<Longrightarrow> A i \<in> events"
```
```   206             using G by auto
```
```   207           have "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) =
```
```   208               prob ((\<Inter>j\<in>J. A j) - (\<Inter>i\<in>insert j J. (A(j := X)) i))"
```
```   209             using A_sets sets_into_space X `J \<noteq> {}`
```
```   210             by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
```
```   211           also have "\<dots> = prob (\<Inter>j\<in>J. A j) - prob (\<Inter>i\<in>insert j J. (A(j := X)) i)"
```
```   212             using J `J \<noteq> {}` `j \<notin> J` A_sets X sets_into_space
```
```   213             by (auto intro!: finite_measure_Diff finite_INT split: split_if_asm)
```
```   214           finally have "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) =
```
```   215               prob (\<Inter>j\<in>J. A j) - prob (\<Inter>i\<in>insert j J. (A(j := X)) i)" .
```
```   216           moreover {
```
```   217             have "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
```
```   218               using J A `finite J` by (intro indep_setsD[OF G(1)]) auto
```
```   219             then have "prob (\<Inter>j\<in>J. A j) = prob (space M) * (\<Prod>i\<in>J. prob (A i))"
```
```   220               using prob_space by simp }
```
```   221           moreover {
```
```   222             have "prob (\<Inter>i\<in>insert j J. (A(j := X)) i) = (\<Prod>i\<in>insert j J. prob ((A(j := X)) i))"
```
```   223               using J A `j \<in> K` by (intro indep_setsD[OF G']) auto
```
```   224             then have "prob (\<Inter>i\<in>insert j J. (A(j := X)) i) = prob X * (\<Prod>i\<in>J. prob (A i))"
```
```   225               using `finite J` `j \<notin> J` by (auto intro!: setprod_cong) }
```
```   226           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))"
```
```   227             by (simp add: field_simps)
```
```   228           also have "\<dots> = prob (space M - X) * (\<Prod>i\<in>J. prob (A i))"
```
```   229             using X A by (simp add: finite_measure_compl)
```
```   230           finally show "prob ((\<Inter>j\<in>J. A j) \<inter> (space M - X)) = prob (space M - X) * (\<Prod>i\<in>J. prob (A i))" .
```
```   231         qed (insert X, auto)
```
```   232       next
```
```   233         fix F :: "nat \<Rightarrow> 'a set" assume disj: "disjoint_family F" and "range F \<subseteq> ?D"
```
```   234         then have F: "\<And>i. F i \<in> events" "\<And>i. indep_sets (G(j:={F i})) K" by auto
```
```   235         show "indep_sets (G(j := {\<Union>k. F k})) K"
```
```   236         proof (rule indep_sets_insert)
```
```   237           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"
```
```   238           then have A_sets: "\<And>i. i\<in>J \<Longrightarrow> A i \<in> events"
```
```   239             using G by auto
```
```   240           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))"
```
```   241             using `J \<noteq> {}` `j \<notin> J` `j \<in> K` by (auto intro!: arg_cong[where f=prob] split: split_if_asm)
```
```   242           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))"
```
```   243           proof (rule finite_measure_UNION)
```
```   244             show "disjoint_family (\<lambda>k. \<Inter>i\<in>insert j J. (A(j := F k)) i)"
```
```   245               using disj by (rule disjoint_family_on_bisimulation) auto
```
```   246             show "range (\<lambda>k. \<Inter>i\<in>insert j J. (A(j := F k)) i) \<subseteq> events"
```
```   247               using A_sets F `finite J` `J \<noteq> {}` `j \<notin> J` by (auto intro!: Int)
```
```   248           qed
```
```   249           moreover { fix k
```
```   250             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))"
```
```   251               by (subst indep_setsD[OF F(2)]) (auto intro!: setprod_cong split: split_if_asm)
```
```   252             also have "\<dots> = prob (F k) * prob (\<Inter>i\<in>J. A i)"
```
```   253               using J A `j \<in> K` by (subst indep_setsD[OF G(1)]) auto
```
```   254             finally have "prob (\<Inter>i\<in>insert j J. (A(j := F k)) i) = prob (F k) * prob (\<Inter>i\<in>J. A i)" . }
```
```   255           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)))"
```
```   256             by simp
```
```   257           moreover
```
```   258           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))"
```
```   259             using disj F(1) by (intro finite_measure_UNION sums_mult2) auto
```
```   260           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)))"
```
```   261             using J A `j \<in> K` by (subst indep_setsD[OF G(1), symmetric]) auto
```
```   262           ultimately
```
```   263           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))"
```
```   264             by (auto dest!: sums_unique)
```
```   265         qed (insert F, auto)
```
```   266       qed (insert sets_into_space, auto)
```
```   267       then have mono: "sets (dynkin \<lparr>space = space M, sets = G j\<rparr>) \<subseteq>
```
```   268         sets \<lparr>space = space M, sets = {E \<in> events. indep_sets (G(j := {E})) K}\<rparr>"
```
```   269       proof (rule dynkin_system.dynkin_subset, simp_all, safe)
```
```   270         fix X assume "X \<in> G j"
```
```   271         then show "X \<in> events" using G `j \<in> K` by auto
```
```   272         from `indep_sets G K`
```
```   273         show "indep_sets (G(j := {X})) K"
```
```   274           by (rule indep_sets_mono_sets) (insert `X \<in> G j`, auto)
```
```   275       qed
```
```   276       have "indep_sets (G(j:=?D)) K"
```
```   277       proof (rule indep_setsI)
```
```   278         fix i assume "i \<in> K" then show "(G(j := ?D)) i \<subseteq> events"
```
```   279           using G(2) by auto
```
```   280       next
```
```   281         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"
```
```   282         show "prob (\<Inter>j\<in>J. A j) = (\<Prod>j\<in>J. prob (A j))"
```
```   283         proof cases
```
```   284           assume "j \<in> J"
```
```   285           with A have indep: "indep_sets (G(j := {A j})) K" by auto
```
```   286           from J A show ?thesis
```
```   287             by (intro indep_setsD[OF indep]) auto
```
```   288         next
```
```   289           assume "j \<notin> J"
```
```   290           with J A have "\<forall>i\<in>J. A i \<in> G i" by (auto split: split_if_asm)
```
```   291           with J show ?thesis
```
```   292             by (intro indep_setsD[OF G(1)]) auto
```
```   293         qed
```
```   294       qed
```
```   295       then have "indep_sets (G(j:=sets (dynkin \<lparr>space = space M, sets = G j\<rparr>))) K"
```
```   296         by (rule indep_sets_mono_sets) (insert mono, auto)
```
```   297       then show ?case
```
```   298         by (rule indep_sets_mono_sets) (insert `j \<in> K` `j \<notin> J`, auto simp: G_def)
```
```   299     qed (insert `indep_sets F K`, simp) }
```
```   300   from this[OF `indep_sets F J` `finite J` subset_refl]
```
```   301   show "indep_sets (\<lambda>i. sets (dynkin \<lparr> space = space M, sets = F i \<rparr>)) J"
```
```   302     by (rule indep_sets_mono_sets) auto
```
```   303 qed
```
```   304
```
```   305 lemma (in prob_space) indep_sets_sigma:
```
```   306   assumes indep: "indep_sets F I"
```
```   307   assumes stable: "\<And>i. i \<in> I \<Longrightarrow> Int_stable \<lparr> space = space M, sets = F i \<rparr>"
```
```   308   shows "indep_sets (\<lambda>i. sets (sigma \<lparr> space = space M, sets = F i \<rparr>)) I"
```
```   309 proof -
```
```   310   from indep_sets_dynkin[OF indep]
```
```   311   show ?thesis
```
```   312   proof (rule indep_sets_mono_sets, subst sigma_eq_dynkin, simp_all add: stable)
```
```   313     fix i assume "i \<in> I"
```
```   314     with indep have "F i \<subseteq> events" by (auto simp: indep_sets_def)
```
```   315     with sets_into_space show "F i \<subseteq> Pow (space M)" by auto
```
```   316   qed
```
```   317 qed
```
```   318
```
```   319 lemma (in prob_space) indep_sets_sigma_sets:
```
```   320   assumes "indep_sets F I"
```
```   321   assumes "\<And>i. i \<in> I \<Longrightarrow> Int_stable \<lparr> space = space M, sets = F i \<rparr>"
```
```   322   shows "indep_sets (\<lambda>i. sigma_sets (space M) (F i)) I"
```
```   323   using indep_sets_sigma[OF assms] by (simp add: sets_sigma)
```
```   324
```
```   325 lemma (in prob_space) indep_sets2_eq:
```
```   326   "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)"
```
```   327   unfolding indep_set_def
```
```   328 proof (intro iffI ballI conjI)
```
```   329   assume indep: "indep_sets (bool_case A B) UNIV"
```
```   330   { fix a b assume "a \<in> A" "b \<in> B"
```
```   331     with indep_setsD[OF indep, of UNIV "bool_case a b"]
```
```   332     show "prob (a \<inter> b) = prob a * prob b"
```
```   333       unfolding UNIV_bool by (simp add: ac_simps) }
```
```   334   from indep show "A \<subseteq> events" "B \<subseteq> events"
```
```   335     unfolding indep_sets_def UNIV_bool by auto
```
```   336 next
```
```   337   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)"
```
```   338   show "indep_sets (bool_case A B) UNIV"
```
```   339   proof (rule indep_setsI)
```
```   340     fix i show "(case i of True \<Rightarrow> A | False \<Rightarrow> B) \<subseteq> events"
```
```   341       using * by (auto split: bool.split)
```
```   342   next
```
```   343     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)"
```
```   344     then have "J = {True} \<or> J = {False} \<or> J = {True,False}"
```
```   345       by (auto simp: UNIV_bool)
```
```   346     then show "prob (\<Inter>j\<in>J. X j) = (\<Prod>j\<in>J. prob (X j))"
```
```   347       using X * by auto
```
```   348   qed
```
```   349 qed
```
```   350
```
```   351 lemma (in prob_space) indep_set_sigma_sets:
```
```   352   assumes "indep_set A B"
```
```   353   assumes A: "Int_stable \<lparr> space = space M, sets = A \<rparr>"
```
```   354   assumes B: "Int_stable \<lparr> space = space M, sets = B \<rparr>"
```
```   355   shows "indep_set (sigma_sets (space M) A) (sigma_sets (space M) B)"
```
```   356 proof -
```
```   357   have "indep_sets (\<lambda>i. sigma_sets (space M) (case i of True \<Rightarrow> A | False \<Rightarrow> B)) UNIV"
```
```   358   proof (rule indep_sets_sigma_sets)
```
```   359     show "indep_sets (bool_case A B) UNIV"
```
```   360       by (rule `indep_set A B`[unfolded indep_set_def])
```
```   361     fix i show "Int_stable \<lparr>space = space M, sets = case i of True \<Rightarrow> A | False \<Rightarrow> B\<rparr>"
```
```   362       using A B by (cases i) auto
```
```   363   qed
```
```   364   then show ?thesis
```
```   365     unfolding indep_set_def
```
```   366     by (rule indep_sets_mono_sets) (auto split: bool.split)
```
```   367 qed
```
```   368
```
```   369 lemma (in prob_space) indep_sets_collect_sigma:
```
```   370   fixes I :: "'j \<Rightarrow> 'i set" and J :: "'j set" and E :: "'i \<Rightarrow> 'a set set"
```
```   371   assumes indep: "indep_sets E (\<Union>j\<in>J. I j)"
```
```   372   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>"
```
```   373   assumes disjoint: "disjoint_family_on I J"
```
```   374   shows "indep_sets (\<lambda>j. sigma_sets (space M) (\<Union>i\<in>I j. E i)) J"
```
```   375 proof -
```
```   376   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) }"
```
```   377
```
```   378   from indep have E: "\<And>j i. j \<in> J \<Longrightarrow> i \<in> I j \<Longrightarrow> E i \<subseteq> events"
```
```   379     unfolding indep_sets_def by auto
```
```   380   { fix j
```
```   381     let ?S = "sigma \<lparr> space = space M, sets = (\<Union>i\<in>I j. E i) \<rparr>"
```
```   382     assume "j \<in> J"
```
```   383     from E[OF this] interpret S: sigma_algebra ?S
```
```   384       using sets_into_space by (intro sigma_algebra_sigma) auto
```
```   385
```
```   386     have "sigma_sets (space M) (\<Union>i\<in>I j. E i) = sigma_sets (space M) (?E j)"
```
```   387     proof (rule sigma_sets_eqI)
```
```   388       fix A assume "A \<in> (\<Union>i\<in>I j. E i)"
```
```   389       then guess i ..
```
```   390       then show "A \<in> sigma_sets (space M) (?E j)"
```
```   391         by (auto intro!: sigma_sets.intros exI[of _ "{i}"] exI[of _ "\<lambda>i. A"])
```
```   392     next
```
```   393       fix A assume "A \<in> ?E j"
```
```   394       then obtain E' K where "finite K" "K \<noteq> {}" "K \<subseteq> I j" "\<And>k. k \<in> K \<Longrightarrow> E' k \<in> E k"
```
```   395         and A: "A = (\<Inter>k\<in>K. E' k)"
```
```   396         by auto
```
```   397       then have "A \<in> sets ?S" unfolding A
```
```   398         by (safe intro!: S.finite_INT)
```
```   399            (auto simp: sets_sigma intro!: sigma_sets.Basic)
```
```   400       then show "A \<in> sigma_sets (space M) (\<Union>i\<in>I j. E i)"
```
```   401         by (simp add: sets_sigma)
```
```   402     qed }
```
```   403   moreover have "indep_sets (\<lambda>j. sigma_sets (space M) (?E j)) J"
```
```   404   proof (rule indep_sets_sigma_sets)
```
```   405     show "indep_sets ?E J"
```
```   406     proof (intro indep_setsI)
```
```   407       fix j assume "j \<in> J" with E show "?E j \<subseteq> events" by (force  intro!: finite_INT)
```
```   408     next
```
```   409       fix K A assume K: "K \<noteq> {}" "K \<subseteq> J" "finite K"
```
```   410         and "\<forall>j\<in>K. A j \<in> ?E j"
```
```   411       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)"
```
```   412         by simp
```
```   413       from bchoice[OF this] guess E' ..
```
```   414       from bchoice[OF this] obtain L
```
```   415         where A: "\<And>j. j\<in>K \<Longrightarrow> A j = (\<Inter>l\<in>L j. E' j l)"
```
```   416         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"
```
```   417         and E': "\<And>j l. j\<in>K \<Longrightarrow> l \<in> L j \<Longrightarrow> E' j l \<in> E l"
```
```   418         by auto
```
```   419
```
```   420       { fix k l j assume "k \<in> K" "j \<in> K" "l \<in> L j" "l \<in> L k"
```
```   421         have "k = j"
```
```   422         proof (rule ccontr)
```
```   423           assume "k \<noteq> j"
```
```   424           with disjoint `K \<subseteq> J` `k \<in> K` `j \<in> K` have "I k \<inter> I j = {}"
```
```   425             unfolding disjoint_family_on_def by auto
```
```   426           with L(2,3)[OF `j \<in> K`] L(2,3)[OF `k \<in> K`]
```
```   427           show False using `l \<in> L k` `l \<in> L j` by auto
```
```   428         qed }
```
```   429       note L_inj = this
```
```   430
```
```   431       def k \<equiv> "\<lambda>l. (SOME k. k \<in> K \<and> l \<in> L k)"
```
```   432       { fix x j l assume *: "j \<in> K" "l \<in> L j"
```
```   433         have "k l = j" unfolding k_def
```
```   434         proof (rule some_equality)
```
```   435           fix k assume "k \<in> K \<and> l \<in> L k"
```
```   436           with * L_inj show "k = j" by auto
```
```   437         qed (insert *, simp) }
```
```   438       note k_simp[simp] = this
```
```   439       let "?E' l" = "E' (k l) l"
```
```   440       have "prob (\<Inter>j\<in>K. A j) = prob (\<Inter>l\<in>(\<Union>k\<in>K. L k). ?E' l)"
```
```   441         by (auto simp: A intro!: arg_cong[where f=prob])
```
```   442       also have "\<dots> = (\<Prod>l\<in>(\<Union>k\<in>K. L k). prob (?E' l))"
```
```   443         using L K E' by (intro indep_setsD[OF indep]) (simp_all add: UN_mono)
```
```   444       also have "\<dots> = (\<Prod>j\<in>K. \<Prod>l\<in>L j. prob (E' j l))"
```
```   445         using K L L_inj by (subst setprod_UN_disjoint) auto
```
```   446       also have "\<dots> = (\<Prod>j\<in>K. prob (A j))"
```
```   447         using K L E' by (auto simp add: A intro!: setprod_cong indep_setsD[OF indep, symmetric]) blast
```
```   448       finally show "prob (\<Inter>j\<in>K. A j) = (\<Prod>j\<in>K. prob (A j))" .
```
```   449     qed
```
```   450   next
```
```   451     fix j assume "j \<in> J"
```
```   452     show "Int_stable \<lparr> space = space M, sets = ?E j \<rparr>"
```
```   453     proof (rule Int_stableI)
```
```   454       fix a assume "a \<in> ?E j" then obtain Ka Ea
```
```   455         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
```
```   456       fix b assume "b \<in> ?E j" then obtain Kb Eb
```
```   457         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
```
```   458       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 {})"
```
```   459       have "a \<inter> b = INTER (Ka \<union> Kb) ?A"
```
```   460         by (simp add: a b set_eq_iff) auto
```
```   461       with a b `j \<in> J` Int_stableD[OF Int_stable] show "a \<inter> b \<in> ?E j"
```
```   462         by (intro CollectI exI[of _ "Ka \<union> Kb"] exI[of _ ?A]) auto
```
```   463     qed
```
```   464   qed
```
```   465   ultimately show ?thesis
```
```   466     by (simp cong: indep_sets_cong)
```
```   467 qed
```
```   468
```
```   469 definition (in prob_space) terminal_events where
```
```   470   "terminal_events A = (\<Inter>n. sigma_sets (space M) (UNION {n..} A))"
```
```   471
```
```   472 lemma (in prob_space) terminal_events_sets:
```
```   473   assumes A: "\<And>i. A i \<subseteq> events"
```
```   474   assumes "\<And>i::nat. sigma_algebra \<lparr>space = space M, sets = A i\<rparr>"
```
```   475   assumes X: "X \<in> terminal_events A"
```
```   476   shows "X \<in> events"
```
```   477 proof -
```
```   478   let ?A = "(\<Inter>n. sigma_sets (space M) (UNION {n..} A))"
```
```   479   interpret A: sigma_algebra "\<lparr>space = space M, sets = A i\<rparr>" for i by fact
```
```   480   from X have "\<And>n. X \<in> sigma_sets (space M) (UNION {n..} A)" by (auto simp: terminal_events_def)
```
```   481   from this[of 0] have "X \<in> sigma_sets (space M) (UNION UNIV A)" by simp
```
```   482   then show "X \<in> events"
```
```   483     by induct (insert A, auto)
```
```   484 qed
```
```   485
```
```   486 lemma (in prob_space) sigma_algebra_terminal_events:
```
```   487   assumes "\<And>i::nat. sigma_algebra \<lparr>space = space M, sets = A i\<rparr>"
```
```   488   shows "sigma_algebra \<lparr> space = space M, sets = terminal_events A \<rparr>"
```
```   489   unfolding terminal_events_def
```
```   490 proof (simp add: sigma_algebra_iff2, safe)
```
```   491   let ?A = "(\<Inter>n. sigma_sets (space M) (UNION {n..} A))"
```
```   492   interpret A: sigma_algebra "\<lparr>space = space M, sets = A i\<rparr>" for i by fact
```
```   493   { fix X x assume "X \<in> ?A" "x \<in> X"
```
```   494     then have "\<And>n. X \<in> sigma_sets (space M) (UNION {n..} A)" by auto
```
```   495     from this[of 0] have "X \<in> sigma_sets (space M) (UNION UNIV A)" by simp
```
```   496     then have "X \<subseteq> space M"
```
```   497       by induct (insert A.sets_into_space, auto)
```
```   498     with `x \<in> X` show "x \<in> space M" by auto }
```
```   499   { fix F :: "nat \<Rightarrow> 'a set" and n assume "range F \<subseteq> ?A"
```
```   500     then show "(UNION UNIV F) \<in> sigma_sets (space M) (UNION {n..} A)"
```
```   501       by (intro sigma_sets.Union) auto }
```
```   502 qed (auto intro!: sigma_sets.Compl sigma_sets.Empty)
```
```   503
```
```   504 lemma (in prob_space) kolmogorov_0_1_law:
```
```   505   fixes A :: "nat \<Rightarrow> 'a set set"
```
```   506   assumes A: "\<And>i. A i \<subseteq> events"
```
```   507   assumes "\<And>i::nat. sigma_algebra \<lparr>space = space M, sets = A i\<rparr>"
```
```   508   assumes indep: "indep_sets A UNIV"
```
```   509   and X: "X \<in> terminal_events A"
```
```   510   shows "prob X = 0 \<or> prob X = 1"
```
```   511 proof -
```
```   512   let ?D = "\<lparr> space = space M, sets = {D \<in> events. prob (X \<inter> D) = prob X * prob D} \<rparr>"
```
```   513   interpret A: sigma_algebra "\<lparr>space = space M, sets = A i\<rparr>" for i by fact
```
```   514   interpret T: sigma_algebra "\<lparr> space = space M, sets = terminal_events A \<rparr>"
```
```   515     by (rule sigma_algebra_terminal_events) fact
```
```   516   have "X \<subseteq> space M" using T.space_closed X by auto
```
```   517
```
```   518   have X_in: "X \<in> events"
```
```   519     by (rule terminal_events_sets) fact+
```
```   520
```
```   521   interpret D: dynkin_system ?D
```
```   522   proof (rule dynkin_systemI)
```
```   523     fix D assume "D \<in> sets ?D" then show "D \<subseteq> space ?D"
```
```   524       using sets_into_space by auto
```
```   525   next
```
```   526     show "space ?D \<in> sets ?D"
```
```   527       using prob_space `X \<subseteq> space M` by (simp add: Int_absorb2)
```
```   528   next
```
```   529     fix A assume A: "A \<in> sets ?D"
```
```   530     have "prob (X \<inter> (space M - A)) = prob (X - (X \<inter> A))"
```
```   531       using `X \<subseteq> space M` by (auto intro!: arg_cong[where f=prob])
```
```   532     also have "\<dots> = prob X - prob (X \<inter> A)"
```
```   533       using X_in A by (intro finite_measure_Diff) auto
```
```   534     also have "\<dots> = prob X * prob (space M) - prob X * prob A"
```
```   535       using A prob_space by auto
```
```   536     also have "\<dots> = prob X * prob (space M - A)"
```
```   537       using X_in A sets_into_space
```
```   538       by (subst finite_measure_Diff) (auto simp: field_simps)
```
```   539     finally show "space ?D - A \<in> sets ?D"
```
```   540       using A `X \<subseteq> space M` by auto
```
```   541   next
```
```   542     fix F :: "nat \<Rightarrow> 'a set" assume dis: "disjoint_family F" and "range F \<subseteq> sets ?D"
```
```   543     then have F: "range F \<subseteq> events" "\<And>i. prob (X \<inter> F i) = prob X * prob (F i)"
```
```   544       by auto
```
```   545     have "(\<lambda>i. prob (X \<inter> F i)) sums prob (\<Union>i. X \<inter> F i)"
```
```   546     proof (rule finite_measure_UNION)
```
```   547       show "range (\<lambda>i. X \<inter> F i) \<subseteq> events"
```
```   548         using F X_in by auto
```
```   549       show "disjoint_family (\<lambda>i. X \<inter> F i)"
```
```   550         using dis by (rule disjoint_family_on_bisimulation) auto
```
```   551     qed
```
```   552     with F have "(\<lambda>i. prob X * prob (F i)) sums prob (X \<inter> (\<Union>i. F i))"
```
```   553       by simp
```
```   554     moreover have "(\<lambda>i. prob X * prob (F i)) sums (prob X * prob (\<Union>i. F i))"
```
```   555       by (intro mult_right.sums finite_measure_UNION F dis)
```
```   556     ultimately have "prob (X \<inter> (\<Union>i. F i)) = prob X * prob (\<Union>i. F i)"
```
```   557       by (auto dest!: sums_unique)
```
```   558     with F show "(\<Union>i. F i) \<in> sets ?D"
```
```   559       by auto
```
```   560   qed
```
```   561
```
```   562   { fix n
```
```   563     have "indep_sets (\<lambda>b. sigma_sets (space M) (\<Union>m\<in>bool_case {..n} {Suc n..} b. A m)) UNIV"
```
```   564     proof (rule indep_sets_collect_sigma)
```
```   565       have *: "(\<Union>b. case b of True \<Rightarrow> {..n} | False \<Rightarrow> {Suc n..}) = UNIV" (is "?U = _")
```
```   566         by (simp split: bool.split add: set_eq_iff) (metis not_less_eq_eq)
```
```   567       with indep show "indep_sets A ?U" by simp
```
```   568       show "disjoint_family (bool_case {..n} {Suc n..})"
```
```   569         unfolding disjoint_family_on_def by (auto split: bool.split)
```
```   570       fix m
```
```   571       show "Int_stable \<lparr>space = space M, sets = A m\<rparr>"
```
```   572         unfolding Int_stable_def using A.Int by auto
```
```   573     qed
```
```   574     also have "(\<lambda>b. sigma_sets (space M) (\<Union>m\<in>bool_case {..n} {Suc n..} b. A m)) =
```
```   575       bool_case (sigma_sets (space M) (\<Union>m\<in>{..n}. A m)) (sigma_sets (space M) (\<Union>m\<in>{Suc n..}. A m))"
```
```   576       by (auto intro!: ext split: bool.split)
```
```   577     finally have indep: "indep_set (sigma_sets (space M) (\<Union>m\<in>{..n}. A m)) (sigma_sets (space M) (\<Union>m\<in>{Suc n..}. A m))"
```
```   578       unfolding indep_set_def by simp
```
```   579
```
```   580     have "sigma_sets (space M) (\<Union>m\<in>{..n}. A m) \<subseteq> sets ?D"
```
```   581     proof (simp add: subset_eq, rule)
```
```   582       fix D assume D: "D \<in> sigma_sets (space M) (\<Union>m\<in>{..n}. A m)"
```
```   583       have "X \<in> sigma_sets (space M) (\<Union>m\<in>{Suc n..}. A m)"
```
```   584         using X unfolding terminal_events_def by simp
```
```   585       from indep_setD[OF indep D this] indep_setD_ev1[OF indep] D
```
```   586       show "D \<in> events \<and> prob (X \<inter> D) = prob X * prob D"
```
```   587         by (auto simp add: ac_simps)
```
```   588     qed }
```
```   589   then have "(\<Union>n. sigma_sets (space M) (\<Union>m\<in>{..n}. A m)) \<subseteq> sets ?D" (is "?A \<subseteq> _")
```
```   590     by auto
```
```   591
```
```   592   have "sigma \<lparr> space = space M, sets = ?A \<rparr> =
```
```   593     dynkin \<lparr> space = space M, sets = ?A \<rparr>" (is "sigma ?UA = dynkin ?UA")
```
```   594   proof (rule sigma_eq_dynkin)
```
```   595     { fix B n assume "B \<in> sigma_sets (space M) (\<Union>m\<in>{..n}. A m)"
```
```   596       then have "B \<subseteq> space M"
```
```   597         by induct (insert A sets_into_space, auto) }
```
```   598     then show "sets ?UA \<subseteq> Pow (space ?UA)" by auto
```
```   599     show "Int_stable ?UA"
```
```   600     proof (rule Int_stableI)
```
```   601       fix a assume "a \<in> ?A" then guess n .. note a = this
```
```   602       fix b assume "b \<in> ?A" then guess m .. note b = this
```
```   603       interpret Amn: sigma_algebra "sigma \<lparr>space = space M, sets = (\<Union>i\<in>{..max m n}. A i)\<rparr>"
```
```   604         using A sets_into_space by (intro sigma_algebra_sigma) auto
```
```   605       have "sigma_sets (space M) (\<Union>i\<in>{..n}. A i) \<subseteq> sigma_sets (space M) (\<Union>i\<in>{..max m n}. A i)"
```
```   606         by (intro sigma_sets_subseteq UN_mono) auto
```
```   607       with a have "a \<in> sigma_sets (space M) (\<Union>i\<in>{..max m n}. A i)" by auto
```
```   608       moreover
```
```   609       have "sigma_sets (space M) (\<Union>i\<in>{..m}. A i) \<subseteq> sigma_sets (space M) (\<Union>i\<in>{..max m n}. A i)"
```
```   610         by (intro sigma_sets_subseteq UN_mono) auto
```
```   611       with b have "b \<in> sigma_sets (space M) (\<Union>i\<in>{..max m n}. A i)" by auto
```
```   612       ultimately have "a \<inter> b \<in> sigma_sets (space M) (\<Union>i\<in>{..max m n}. A i)"
```
```   613         using Amn.Int[of a b] by (simp add: sets_sigma)
```
```   614       then show "a \<inter> b \<in> (\<Union>n. sigma_sets (space M) (\<Union>i\<in>{..n}. A i))" by auto
```
```   615     qed
```
```   616   qed
```
```   617   moreover have "sets (dynkin ?UA) \<subseteq> sets ?D"
```
```   618   proof (rule D.dynkin_subset)
```
```   619     show "sets ?UA \<subseteq> sets ?D" using `?A \<subseteq> sets ?D` by auto
```
```   620   qed simp
```
```   621   ultimately have "sets (sigma ?UA) \<subseteq> sets ?D" by simp
```
```   622   moreover
```
```   623   have "\<And>n. sigma_sets (space M) (\<Union>i\<in>{n..}. A i) \<subseteq> sigma_sets (space M) ?A"
```
```   624     by (intro sigma_sets_subseteq UN_mono) (auto intro: sigma_sets.Basic)
```
```   625   then have "terminal_events A \<subseteq> sets (sigma ?UA)"
```
```   626     unfolding sets_sigma terminal_events_def by auto
```
```   627   moreover note `X \<in> terminal_events A`
```
```   628   ultimately have "X \<in> sets ?D" by auto
```
```   629   then show ?thesis by auto
```
```   630 qed
```
```   631
```
```   632 lemma (in prob_space) borel_0_1_law:
```
```   633   fixes F :: "nat \<Rightarrow> 'a set"
```
```   634   assumes F: "range F \<subseteq> events" "indep_events F UNIV"
```
```   635   shows "prob (\<Inter>n. \<Union>m\<in>{n..}. F m) = 0 \<or> prob (\<Inter>n. \<Union>m\<in>{n..}. F m) = 1"
```
```   636 proof (rule kolmogorov_0_1_law[of "\<lambda>i. sigma_sets (space M) { F i }"])
```
```   637   show "\<And>i. sigma_sets (space M) {F i} \<subseteq> events"
```
```   638     using F(1) sets_into_space
```
```   639     by (subst sigma_sets_singleton) auto
```
```   640   { fix i show "sigma_algebra \<lparr>space = space M, sets = sigma_sets (space M) {F i}\<rparr>"
```
```   641       using sigma_algebra_sigma[of "\<lparr>space = space M, sets = {F i}\<rparr>"] F sets_into_space
```
```   642       by (auto simp add: sigma_def) }
```
```   643   show "indep_sets (\<lambda>i. sigma_sets (space M) {F i}) UNIV"
```
```   644   proof (rule indep_sets_sigma_sets)
```
```   645     show "indep_sets (\<lambda>i. {F i}) UNIV"
```
```   646       unfolding indep_sets_singleton_iff_indep_events by fact
```
```   647     fix i show "Int_stable \<lparr>space = space M, sets = {F i}\<rparr>"
```
```   648       unfolding Int_stable_def by simp
```
```   649   qed
```
```   650   let "?Q n" = "\<Union>i\<in>{n..}. F i"
```
```   651   show "(\<Inter>n. \<Union>m\<in>{n..}. F m) \<in> terminal_events (\<lambda>i. sigma_sets (space M) {F i})"
```
```   652     unfolding terminal_events_def
```
```   653   proof
```
```   654     fix j
```
```   655     interpret S: sigma_algebra "sigma \<lparr> space = space M, sets = (\<Union>i\<in>{j..}. sigma_sets (space M) {F i})\<rparr>"
```
```   656       using order_trans[OF F(1) space_closed]
```
```   657       by (intro sigma_algebra_sigma) (simp add: sigma_sets_singleton subset_eq)
```
```   658     have "(\<Inter>n. ?Q n) = (\<Inter>n\<in>{j..}. ?Q n)"
```
```   659       by (intro decseq_SucI INT_decseq_offset UN_mono) auto
```
```   660     also have "\<dots> \<in> sets (sigma \<lparr> space = space M, sets = (\<Union>i\<in>{j..}. sigma_sets (space M) {F i})\<rparr>)"
```
```   661       using order_trans[OF F(1) space_closed]
```
```   662       by (safe intro!: S.countable_INT S.countable_UN)
```
```   663          (auto simp: sets_sigma sigma_sets_singleton intro!: sigma_sets.Basic bexI)
```
```   664     finally show "(\<Inter>n. ?Q n) \<in> sigma_sets (space M) (\<Union>i\<in>{j..}. sigma_sets (space M) {F i})"
```
```   665       by (simp add: sets_sigma)
```
```   666   qed
```
```   667 qed
```
```   668
```
```   669 end
```