src/HOL/Probability/Projective_Family.thy
author immler
Thu Nov 15 10:49:58 2012 +0100 (2012-11-15)
changeset 50087 635d73673b5e
parent 50042 6fe18351e9dd
child 50095 94d7dfa9f404
permissions -rw-r--r--
regularity of measures, therefore:
characterization of closure with infimum distance;
characterize of compact sets as totally bounded;
added Diagonal_Subsequence to Library;
introduced (enumerable) topological basis;
rational boxes as basis of ordered euclidean space;
moved some lemmas upwards
immler@50042
     1
(*  Title:      HOL/Probability/Projective_Family.thy
immler@50042
     2
    Author:     Fabian Immler, TU München
immler@50042
     3
    Author:     Johannes Hölzl, TU München
immler@50042
     4
*)
immler@50042
     5
immler@50042
     6
header {*Projective Family*}
immler@50042
     7
immler@50039
     8
theory Projective_Family
immler@50039
     9
imports Finite_Product_Measure Probability_Measure
immler@50039
    10
begin
immler@50039
    11
immler@50087
    12
lemma (in product_prob_space) distr_restrict:
immler@50087
    13
  assumes "J \<noteq> {}" "J \<subseteq> K" "finite K"
immler@50087
    14
  shows "(\<Pi>\<^isub>M i\<in>J. M i) = distr (\<Pi>\<^isub>M i\<in>K. M i) (\<Pi>\<^isub>M i\<in>J. M i) (\<lambda>f. restrict f J)" (is "?P = ?D")
immler@50087
    15
proof (rule measure_eqI_generator_eq)
immler@50087
    16
  have "finite J" using `J \<subseteq> K` `finite K` by (auto simp add: finite_subset)
immler@50087
    17
  interpret J: finite_product_prob_space M J proof qed fact
immler@50087
    18
  interpret K: finite_product_prob_space M K proof qed fact
immler@50087
    19
immler@50087
    20
  let ?J = "{Pi\<^isub>E J E | E. \<forall>i\<in>J. E i \<in> sets (M i)}"
immler@50087
    21
  let ?F = "\<lambda>i. \<Pi>\<^isub>E k\<in>J. space (M k)"
immler@50087
    22
  let ?\<Omega> = "(\<Pi>\<^isub>E k\<in>J. space (M k))"
immler@50087
    23
  show "Int_stable ?J"
immler@50087
    24
    by (rule Int_stable_PiE)
immler@50087
    25
  show "range ?F \<subseteq> ?J" "(\<Union>i. ?F i) = ?\<Omega>"
immler@50087
    26
    using `finite J` by (auto intro!: prod_algebraI_finite)
immler@50087
    27
  { fix i show "emeasure ?P (?F i) \<noteq> \<infinity>" by simp }
immler@50087
    28
  show "?J \<subseteq> Pow ?\<Omega>" by (auto simp: Pi_iff dest: sets_into_space)
immler@50087
    29
  show "sets (\<Pi>\<^isub>M i\<in>J. M i) = sigma_sets ?\<Omega> ?J" "sets ?D = sigma_sets ?\<Omega> ?J"
immler@50087
    30
    using `finite J` by (simp_all add: sets_PiM prod_algebra_eq_finite Pi_iff)
immler@50087
    31
immler@50087
    32
  fix X assume "X \<in> ?J"
immler@50087
    33
  then obtain E where [simp]: "X = Pi\<^isub>E J E" and E: "\<forall>i\<in>J. E i \<in> sets (M i)" by auto
immler@50087
    34
  with `finite J` have X: "X \<in> sets (Pi\<^isub>M J M)"
immler@50087
    35
    by simp
immler@50087
    36
immler@50087
    37
  have "emeasure ?P X = (\<Prod> i\<in>J. emeasure (M i) (E i))"
immler@50087
    38
    using E by (simp add: J.measure_times)
immler@50087
    39
  also have "\<dots> = (\<Prod> i\<in>J. emeasure (M i) (if i \<in> J then E i else space (M i)))"
immler@50087
    40
    by simp
immler@50087
    41
  also have "\<dots> = (\<Prod> i\<in>K. emeasure (M i) (if i \<in> J then E i else space (M i)))"
immler@50087
    42
    using `finite K` `J \<subseteq> K`
immler@50087
    43
    by (intro setprod_mono_one_left) (auto simp: M.emeasure_space_1)
immler@50087
    44
  also have "\<dots> = emeasure (Pi\<^isub>M K M) (\<Pi>\<^isub>E i\<in>K. if i \<in> J then E i else space (M i))"
immler@50087
    45
    using E by (simp add: K.measure_times)
immler@50087
    46
  also have "(\<Pi>\<^isub>E i\<in>K. if i \<in> J then E i else space (M i)) = (\<lambda>f. restrict f J) -` Pi\<^isub>E J E \<inter> (\<Pi>\<^isub>E i\<in>K. space (M i))"
immler@50087
    47
    using `J \<subseteq> K` sets_into_space E by (force simp:  Pi_iff split: split_if_asm)
immler@50087
    48
  finally show "emeasure (Pi\<^isub>M J M) X = emeasure ?D X"
immler@50087
    49
    using X `J \<subseteq> K` apply (subst emeasure_distr)
immler@50087
    50
    by (auto intro!: measurable_restrict_subset simp: space_PiM)
immler@50087
    51
qed
immler@50087
    52
immler@50087
    53
lemma (in product_prob_space) emeasure_prod_emb[simp]:
immler@50087
    54
  assumes L: "J \<noteq> {}" "J \<subseteq> L" "finite L" and X: "X \<in> sets (Pi\<^isub>M J M)"
immler@50087
    55
  shows "emeasure (Pi\<^isub>M L M) (prod_emb L M J X) = emeasure (Pi\<^isub>M J M) X"
immler@50087
    56
  by (subst distr_restrict[OF L])
immler@50087
    57
     (simp add: prod_emb_def space_PiM emeasure_distr measurable_restrict_subset L X)
immler@50087
    58
immler@50039
    59
definition
immler@50039
    60
  PiP :: "'i set \<Rightarrow> ('i \<Rightarrow> 'a measure) \<Rightarrow> ('i set \<Rightarrow> ('i \<Rightarrow> 'a) measure) \<Rightarrow> ('i \<Rightarrow> 'a) measure" where
immler@50039
    61
  "PiP I M P = extend_measure (\<Pi>\<^isub>E i\<in>I. space (M i))
immler@50039
    62
    {(J, X). (J \<noteq> {} \<or> I = {}) \<and> finite J \<and> J \<subseteq> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}
immler@50039
    63
    (\<lambda>(J, X). prod_emb I M J (\<Pi>\<^isub>E j\<in>J. X j))
immler@50039
    64
    (\<lambda>(J, X). emeasure (P J) (Pi\<^isub>E J X))"
immler@50039
    65
immler@50039
    66
lemma space_PiP[simp]: "space (PiP I M P) = space (PiM I M)"
immler@50039
    67
  by (auto simp add: PiP_def space_PiM prod_emb_def intro!: space_extend_measure)
immler@50039
    68
immler@50039
    69
lemma sets_PiP[simp]: "sets (PiP I M P) = sets (PiM I M)"
immler@50039
    70
  by (auto simp add: PiP_def sets_PiM prod_algebra_def prod_emb_def intro!: sets_extend_measure)
immler@50039
    71
immler@50039
    72
lemma measurable_PiP1[simp]: "measurable (PiP I M P) M' = measurable (\<Pi>\<^isub>M i\<in>I. M i) M'"
immler@50039
    73
  unfolding measurable_def by auto
immler@50039
    74
immler@50039
    75
lemma measurable_PiP2[simp]: "measurable M' (PiP I M P) = measurable M' (\<Pi>\<^isub>M i\<in>I. M i)"
immler@50039
    76
  unfolding measurable_def by auto
immler@50039
    77
immler@50039
    78
locale projective_family =
immler@50039
    79
  fixes I::"'i set" and P::"'i set \<Rightarrow> ('i \<Rightarrow> 'a) measure" and M::"('i \<Rightarrow> 'a measure)"
immler@50039
    80
  assumes projective: "\<And>J H X. J \<noteq> {} \<Longrightarrow> J \<subseteq> H \<Longrightarrow> H \<subseteq> I \<Longrightarrow> finite H \<Longrightarrow> X \<in> sets (PiM J M) \<Longrightarrow>
immler@50039
    81
     (P H) (prod_emb H M J X) = (P J) X"
immler@50040
    82
  assumes prob_space: "\<And>J. finite J \<Longrightarrow> prob_space (P J)"
immler@50039
    83
  assumes proj_space: "\<And>J. finite J \<Longrightarrow> space (P J) = space (PiM J M)"
immler@50039
    84
  assumes proj_sets: "\<And>J. finite J \<Longrightarrow> sets (P J) = sets (PiM J M)"
immler@50039
    85
begin
immler@50039
    86
immler@50039
    87
lemma emeasure_PiP:
immler@50039
    88
  assumes "finite J"
immler@50039
    89
  assumes "J \<subseteq> I"
immler@50039
    90
  assumes A: "\<And>i. i\<in>J \<Longrightarrow> A i \<in> sets (M i)"
immler@50039
    91
  shows "emeasure (PiP J M P) (Pi\<^isub>E J A) = emeasure (P J) (Pi\<^isub>E J A)"
immler@50039
    92
proof -
immler@50039
    93
  have "Pi\<^isub>E J (restrict A J) \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
immler@50039
    94
  proof safe
immler@50039
    95
    fix x j assume "x \<in> Pi J (restrict A J)" "j \<in> J"
immler@50039
    96
    hence "x j \<in> restrict A J j" by (auto simp: Pi_def)
immler@50039
    97
    also have "\<dots> \<subseteq> space (M j)" using sets_into_space A `j \<in> J` by auto
immler@50039
    98
    finally show "x j \<in> space (M j)" .
immler@50039
    99
  qed
immler@50039
   100
  hence "emeasure (PiP J M P) (Pi\<^isub>E J A) =
immler@50039
   101
    emeasure (PiP J M P) (prod_emb J M J (Pi\<^isub>E J A))"
immler@50039
   102
    using assms(1-3) sets_into_space by (auto simp add: prod_emb_id Pi_def)
immler@50039
   103
  also have "\<dots> = emeasure (P J) (Pi\<^isub>E J A)"
immler@50040
   104
  proof (rule emeasure_extend_measure_Pair[OF PiP_def])
immler@50040
   105
    show "positive (sets (PiP J M P)) (P J)" unfolding positive_def by auto
immler@50040
   106
    show "countably_additive (sets (PiP J M P)) (P J)" unfolding countably_additive_def
immler@50039
   107
      by (auto simp: suminf_emeasure proj_sets[OF `finite J`])
immler@50040
   108
    show "(J \<noteq> {} \<or> J = {}) \<and> finite J \<and> J \<subseteq> J \<and> A \<in> (\<Pi> j\<in>J. sets (M j))"
immler@50039
   109
      using assms by auto
immler@50040
   110
    fix K and X::"'i \<Rightarrow> 'a set"
immler@50040
   111
    show "prod_emb J M K (Pi\<^isub>E K X) \<in> Pow (\<Pi>\<^isub>E i\<in>J. space (M i))"
immler@50040
   112
      by (auto simp: prod_emb_def)
immler@50040
   113
    assume JX: "(K \<noteq> {} \<or> J = {}) \<and> finite K \<and> K \<subseteq> J \<and> X \<in> (\<Pi> j\<in>K. sets (M j))"
immler@50040
   114
    thus "emeasure (P J) (prod_emb J M K (Pi\<^isub>E K X)) = emeasure (P K) (Pi\<^isub>E K X)"
immler@50040
   115
      using assms
immler@50040
   116
      apply (cases "J = {}")
immler@50040
   117
      apply (simp add: prod_emb_id)
immler@50040
   118
      apply (fastforce simp add: intro!: projective sets_PiM_I_finite)
immler@50040
   119
      done
immler@50039
   120
  qed
immler@50039
   121
  finally show ?thesis .
immler@50039
   122
qed
immler@50039
   123
immler@50039
   124
lemma PiP_finite:
immler@50039
   125
  assumes "finite J"
immler@50039
   126
  assumes "J \<subseteq> I"
immler@50039
   127
  shows "PiP J M P = P J" (is "?P = _")
immler@50039
   128
proof (rule measure_eqI_generator_eq)
immler@50039
   129
  let ?J = "{Pi\<^isub>E J E | E. \<forall>i\<in>J. E i \<in> sets (M i)}"
immler@50039
   130
  let ?F = "\<lambda>i. \<Pi>\<^isub>E k\<in>J. space (M k)"
immler@50039
   131
  let ?\<Omega> = "(\<Pi>\<^isub>E k\<in>J. space (M k))"
immler@50039
   132
  show "Int_stable ?J"
immler@50039
   133
    by (rule Int_stable_PiE)
immler@50041
   134
  interpret prob_space "P J" using prob_space `finite J` by simp
immler@50039
   135
  show "emeasure ?P (?F _) \<noteq> \<infinity>" using assms `finite J` by (auto simp: emeasure_PiP)
immler@50039
   136
  show "?J \<subseteq> Pow ?\<Omega>" by (auto simp: Pi_iff dest: sets_into_space)
immler@50039
   137
  show "sets (PiP J M P) = sigma_sets ?\<Omega> ?J" "sets (P J) = sigma_sets ?\<Omega> ?J"
immler@50039
   138
    using `finite J` proj_sets by (simp_all add: sets_PiM prod_algebra_eq_finite Pi_iff)
immler@50039
   139
  fix X assume "X \<in> ?J"
immler@50039
   140
  then obtain E where X: "X = Pi\<^isub>E J E" and E: "\<forall>i\<in>J. E i \<in> sets (M i)" by auto
immler@50039
   141
  with `finite J` have "X \<in> sets (PiP J M P)" by simp
immler@50039
   142
  have emb_self: "prod_emb J M J (Pi\<^isub>E J E) = Pi\<^isub>E J E"
immler@50039
   143
    using E sets_into_space
immler@50039
   144
    by (auto intro!: prod_emb_PiE_same_index)
immler@50039
   145
  show "emeasure (PiP J M P) X = emeasure (P J) X"
immler@50039
   146
    unfolding X using E
immler@50039
   147
    by (intro emeasure_PiP assms) simp
immler@50039
   148
qed (insert `finite J`, auto intro!: prod_algebraI_finite)
immler@50039
   149
immler@50039
   150
lemma emeasure_fun_emb[simp]:
immler@50039
   151
  assumes L: "J \<noteq> {}" "J \<subseteq> L" "finite L" "L \<subseteq> I" and X: "X \<in> sets (PiM J M)"
immler@50039
   152
  shows "emeasure (PiP L M P) (prod_emb L M J X) = emeasure (PiP J M P) X"
immler@50039
   153
  using assms
immler@50039
   154
  by (subst PiP_finite) (auto simp: PiP_finite finite_subset projective)
immler@50039
   155
immler@50042
   156
lemma prod_emb_injective:
immler@50042
   157
  assumes "J \<noteq> {}" "J \<subseteq> L" "finite J" and sets: "X \<in> sets (Pi\<^isub>M J M)" "Y \<in> sets (Pi\<^isub>M J M)"
immler@50042
   158
  assumes "prod_emb L M J X = prod_emb L M J Y"
immler@50042
   159
  shows "X = Y"
immler@50042
   160
proof (rule injective_vimage_restrict)
immler@50042
   161
  show "X \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))" "Y \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
immler@50042
   162
    using sets[THEN sets_into_space] by (auto simp: space_PiM)
immler@50042
   163
  have "\<forall>i\<in>L. \<exists>x. x \<in> space (M i)"
immler@50042
   164
  proof
immler@50042
   165
    fix i assume "i \<in> L"
immler@50042
   166
    interpret prob_space "P {i}" using prob_space by simp
immler@50042
   167
    from not_empty show "\<exists>x. x \<in> space (M i)" by (auto simp add: proj_space space_PiM)
immler@50042
   168
  qed
immler@50042
   169
  from bchoice[OF this]
immler@50042
   170
  show "(\<Pi>\<^isub>E i\<in>L. space (M i)) \<noteq> {}" by auto
immler@50042
   171
  show "(\<lambda>x. restrict x J) -` X \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i)) = (\<lambda>x. restrict x J) -` Y \<inter> (\<Pi>\<^isub>E i\<in>L. space (M i))"
immler@50042
   172
    using `prod_emb L M J X = prod_emb L M J Y` by (simp add: prod_emb_def)
immler@50042
   173
qed fact
immler@50042
   174
immler@50042
   175
abbreviation
immler@50042
   176
  "emb L K X \<equiv> prod_emb L M K X"
immler@50042
   177
immler@50042
   178
definition generator :: "('i \<Rightarrow> 'a) set set" where
immler@50042
   179
  "generator = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M))"
immler@50042
   180
immler@50042
   181
lemma generatorI':
immler@50042
   182
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> emb I J X \<in> generator"
immler@50042
   183
  unfolding generator_def by auto
immler@50042
   184
immler@50042
   185
lemma algebra_generator:
immler@50042
   186
  assumes "I \<noteq> {}" shows "algebra (\<Pi>\<^isub>E i\<in>I. space (M i)) generator" (is "algebra ?\<Omega> ?G")
immler@50042
   187
  unfolding algebra_def algebra_axioms_def ring_of_sets_iff
immler@50042
   188
proof (intro conjI ballI)
immler@50042
   189
  let ?G = generator
immler@50042
   190
  show "?G \<subseteq> Pow ?\<Omega>"
immler@50042
   191
    by (auto simp: generator_def prod_emb_def)
immler@50042
   192
  from `I \<noteq> {}` obtain i where "i \<in> I" by auto
immler@50042
   193
  then show "{} \<in> ?G"
immler@50042
   194
    by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\<lambda>i. {}"]
immler@50042
   195
             simp: sigma_sets.Empty generator_def prod_emb_def)
immler@50042
   196
  from `i \<in> I` show "?\<Omega> \<in> ?G"
immler@50042
   197
    by (auto intro!: exI[of _ "{i}"] image_eqI[where x="Pi\<^isub>E {i} (\<lambda>i. space (M i))"]
immler@50042
   198
             simp: generator_def prod_emb_def)
immler@50042
   199
  fix A assume "A \<in> ?G"
immler@50042
   200
  then obtain JA XA where XA: "JA \<noteq> {}" "finite JA" "JA \<subseteq> I" "XA \<in> sets (Pi\<^isub>M JA M)" and A: "A = emb I JA XA"
immler@50042
   201
    by (auto simp: generator_def)
immler@50042
   202
  fix B assume "B \<in> ?G"
immler@50042
   203
  then obtain JB XB where XB: "JB \<noteq> {}" "finite JB" "JB \<subseteq> I" "XB \<in> sets (Pi\<^isub>M JB M)" and B: "B = emb I JB XB"
immler@50042
   204
    by (auto simp: generator_def)
immler@50042
   205
  let ?RA = "emb (JA \<union> JB) JA XA"
immler@50042
   206
  let ?RB = "emb (JA \<union> JB) JB XB"
immler@50042
   207
  have *: "A - B = emb I (JA \<union> JB) (?RA - ?RB)" "A \<union> B = emb I (JA \<union> JB) (?RA \<union> ?RB)"
immler@50042
   208
    using XA A XB B by auto
immler@50042
   209
  show "A - B \<in> ?G" "A \<union> B \<in> ?G"
immler@50042
   210
    unfolding * using XA XB by (safe intro!: generatorI') auto
immler@50042
   211
qed
immler@50042
   212
immler@50042
   213
lemma sets_PiM_generator:
immler@50042
   214
  "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
immler@50042
   215
proof cases
immler@50042
   216
  assume "I = {}" then show ?thesis
immler@50042
   217
    unfolding generator_def
immler@50042
   218
    by (auto simp: sets_PiM_empty sigma_sets_empty_eq cong: conj_cong)
immler@50042
   219
next
immler@50042
   220
  assume "I \<noteq> {}"
immler@50042
   221
  show ?thesis
immler@50042
   222
  proof
immler@50042
   223
    show "sets (Pi\<^isub>M I M) \<subseteq> sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
immler@50042
   224
      unfolding sets_PiM
immler@50042
   225
    proof (safe intro!: sigma_sets_subseteq)
immler@50042
   226
      fix A assume "A \<in> prod_algebra I M" with `I \<noteq> {}` show "A \<in> generator"
immler@50042
   227
        by (auto intro!: generatorI' sets_PiM_I_finite elim!: prod_algebraE)
immler@50042
   228
    qed
immler@50042
   229
  qed (auto simp: generator_def space_PiM[symmetric] intro!: sigma_sets_subset)
immler@50042
   230
qed
immler@50042
   231
immler@50042
   232
lemma generatorI:
immler@50042
   233
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> A = emb I J X \<Longrightarrow> A \<in> generator"
immler@50042
   234
  unfolding generator_def by auto
immler@50042
   235
immler@50042
   236
definition
immler@50042
   237
  "\<mu>G A =
immler@50042
   238
    (THE x. \<forall>J. J \<noteq> {} \<longrightarrow> finite J \<longrightarrow> J \<subseteq> I \<longrightarrow> (\<forall>X\<in>sets (Pi\<^isub>M J M). A = emb I J X \<longrightarrow> x = emeasure (PiP J M P) X))"
immler@50042
   239
immler@50042
   240
lemma \<mu>G_spec:
immler@50042
   241
  assumes J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
immler@50042
   242
  shows "\<mu>G A = emeasure (PiP J M P) X"
immler@50042
   243
  unfolding \<mu>G_def
immler@50042
   244
proof (intro the_equality allI impI ballI)
immler@50042
   245
  fix K Y assume K: "K \<noteq> {}" "finite K" "K \<subseteq> I" "A = emb I K Y" "Y \<in> sets (Pi\<^isub>M K M)"
immler@50042
   246
  have "emeasure (PiP K M P) Y = emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) K Y)"
immler@50042
   247
    using K J by simp
immler@50042
   248
  also have "emb (K \<union> J) K Y = emb (K \<union> J) J X"
immler@50042
   249
    using K J by (simp add: prod_emb_injective[of "K \<union> J" I])
immler@50042
   250
  also have "emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) J X) = emeasure (PiP J M P) X"
immler@50042
   251
    using K J by simp
immler@50042
   252
  finally show "emeasure (PiP J M P) X = emeasure (PiP K M P) Y" ..
immler@50042
   253
qed (insert J, force)
immler@50042
   254
immler@50042
   255
lemma \<mu>G_eq:
immler@50042
   256
  "J \<noteq> {} \<Longrightarrow> finite J \<Longrightarrow> J \<subseteq> I \<Longrightarrow> X \<in> sets (Pi\<^isub>M J M) \<Longrightarrow> \<mu>G (emb I J X) = emeasure (PiP J M P) X"
immler@50042
   257
  by (intro \<mu>G_spec) auto
immler@50042
   258
immler@50042
   259
lemma generator_Ex:
immler@50042
   260
  assumes *: "A \<in> generator"
immler@50042
   261
  shows "\<exists>J X. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I \<and> X \<in> sets (Pi\<^isub>M J M) \<and> A = emb I J X \<and> \<mu>G A = emeasure (PiP J M P) X"
immler@50042
   262
proof -
immler@50042
   263
  from * obtain J X where J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
immler@50042
   264
    unfolding generator_def by auto
immler@50042
   265
  with \<mu>G_spec[OF this] show ?thesis by auto
immler@50042
   266
qed
immler@50042
   267
immler@50042
   268
lemma generatorE:
immler@50042
   269
  assumes A: "A \<in> generator"
immler@50042
   270
  obtains J X where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A" "\<mu>G A = emeasure (PiP J M P) X"
immler@50042
   271
proof -
immler@50042
   272
  from generator_Ex[OF A] obtain X J where "J \<noteq> {}" "finite J" "J \<subseteq> I" "X \<in> sets (Pi\<^isub>M J M)" "emb I J X = A"
immler@50042
   273
    "\<mu>G A = emeasure (PiP J M P) X" by auto
immler@50042
   274
  then show thesis by (intro that) auto
immler@50042
   275
qed
immler@50042
   276
immler@50042
   277
lemma merge_sets:
immler@50042
   278
  "J \<inter> K = {} \<Longrightarrow> A \<in> sets (Pi\<^isub>M (J \<union> K) M) \<Longrightarrow> x \<in> space (Pi\<^isub>M J M) \<Longrightarrow> (\<lambda>y. merge J K (x,y)) -` A \<inter> space (Pi\<^isub>M K M) \<in> sets (Pi\<^isub>M K M)"
immler@50042
   279
  by simp
immler@50042
   280
immler@50042
   281
lemma merge_emb:
immler@50042
   282
  assumes "K \<subseteq> I" "J \<subseteq> I" and y: "y \<in> space (Pi\<^isub>M J M)"
immler@50042
   283
  shows "((\<lambda>x. merge J (I - J) (y, x)) -` emb I K X \<inter> space (Pi\<^isub>M I M)) =
immler@50042
   284
    emb I (K - J) ((\<lambda>x. merge J (K - J) (y, x)) -` emb (J \<union> K) K X \<inter> space (Pi\<^isub>M (K - J) M))"
immler@50042
   285
proof -
immler@50042
   286
  have [simp]: "\<And>x J K L. merge J K (y, restrict x L) = merge J (K \<inter> L) (y, x)"
immler@50042
   287
    by (auto simp: restrict_def merge_def)
immler@50042
   288
  have [simp]: "\<And>x J K L. restrict (merge J K (y, x)) L = merge (J \<inter> L) (K \<inter> L) (y, x)"
immler@50042
   289
    by (auto simp: restrict_def merge_def)
immler@50042
   290
  have [simp]: "(I - J) \<inter> K = K - J" using `K \<subseteq> I` `J \<subseteq> I` by auto
immler@50042
   291
  have [simp]: "(K - J) \<inter> (K \<union> J) = K - J" by auto
immler@50042
   292
  have [simp]: "(K - J) \<inter> K = K - J" by auto
immler@50042
   293
  from y `K \<subseteq> I` `J \<subseteq> I` show ?thesis
immler@50042
   294
    by (simp split: split_merge add: prod_emb_def Pi_iff extensional_merge_sub set_eq_iff space_PiM)
immler@50042
   295
       auto
immler@50042
   296
qed
immler@50042
   297
immler@50042
   298
lemma positive_\<mu>G:
immler@50042
   299
  assumes "I \<noteq> {}"
immler@50042
   300
  shows "positive generator \<mu>G"
immler@50042
   301
proof -
immler@50042
   302
  interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
immler@50042
   303
  show ?thesis
immler@50042
   304
  proof (intro positive_def[THEN iffD2] conjI ballI)
immler@50042
   305
    from generatorE[OF G.empty_sets] guess J X . note this[simp]
immler@50042
   306
    have "X = {}"
immler@50042
   307
      by (rule prod_emb_injective[of J I]) simp_all
immler@50042
   308
    then show "\<mu>G {} = 0" by simp
immler@50042
   309
  next
immler@50042
   310
    fix A assume "A \<in> generator"
immler@50042
   311
    from generatorE[OF this] guess J X . note this[simp]
immler@50042
   312
    show "0 \<le> \<mu>G A" by (simp add: emeasure_nonneg)
immler@50042
   313
  qed
immler@50042
   314
qed
immler@50042
   315
immler@50042
   316
lemma additive_\<mu>G:
immler@50042
   317
  assumes "I \<noteq> {}"
immler@50042
   318
  shows "additive generator \<mu>G"
immler@50042
   319
proof -
immler@50042
   320
  interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
immler@50042
   321
  show ?thesis
immler@50042
   322
  proof (intro additive_def[THEN iffD2] ballI impI)
immler@50042
   323
    fix A assume "A \<in> generator" with generatorE guess J X . note J = this
immler@50042
   324
    fix B assume "B \<in> generator" with generatorE guess K Y . note K = this
immler@50042
   325
    assume "A \<inter> B = {}"
immler@50042
   326
    have JK: "J \<union> K \<noteq> {}" "J \<union> K \<subseteq> I" "finite (J \<union> K)"
immler@50042
   327
      using J K by auto
immler@50042
   328
    have JK_disj: "emb (J \<union> K) J X \<inter> emb (J \<union> K) K Y = {}"
immler@50042
   329
      apply (rule prod_emb_injective[of "J \<union> K" I])
immler@50042
   330
      apply (insert `A \<inter> B = {}` JK J K)
immler@50042
   331
      apply (simp_all add: Int prod_emb_Int)
immler@50042
   332
      done
immler@50042
   333
    have AB: "A = emb I (J \<union> K) (emb (J \<union> K) J X)" "B = emb I (J \<union> K) (emb (J \<union> K) K Y)"
immler@50042
   334
      using J K by simp_all
immler@50042
   335
    then have "\<mu>G (A \<union> B) = \<mu>G (emb I (J \<union> K) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y))"
immler@50042
   336
      by simp
immler@50042
   337
    also have "\<dots> = emeasure (PiP (J \<union> K) M P) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y)"
immler@50042
   338
      using JK J(1, 4) K(1, 4) by (simp add: \<mu>G_eq Un del: prod_emb_Un)
immler@50042
   339
    also have "\<dots> = \<mu>G A + \<mu>G B"
immler@50042
   340
      using J K JK_disj by (simp add: plus_emeasure[symmetric])
immler@50042
   341
    finally show "\<mu>G (A \<union> B) = \<mu>G A + \<mu>G B" .
immler@50042
   342
  qed
immler@50042
   343
qed
immler@50042
   344
immler@50039
   345
end
immler@50039
   346
immler@50087
   347
sublocale product_prob_space \<subseteq> projective_family I "\<lambda>J. PiM J M" M
immler@50087
   348
proof
immler@50087
   349
  fix J::"'i set" assume "finite J"
immler@50087
   350
  interpret f: finite_product_prob_space M J proof qed fact
immler@50087
   351
  show "emeasure (Pi\<^isub>M J M) (space (Pi\<^isub>M J M)) \<noteq> \<infinity>" by simp
immler@50087
   352
  show "\<exists>A. range A \<subseteq> sets (Pi\<^isub>M J M) \<and>
immler@50087
   353
            (\<Union>i. A i) = space (Pi\<^isub>M J M) \<and>
immler@50087
   354
            (\<forall>i. emeasure (Pi\<^isub>M J M) (A i) \<noteq> \<infinity>)" using sigma_finite[OF `finite J`]
immler@50087
   355
    by (auto simp add: sigma_finite_measure_def)
immler@50087
   356
  show "emeasure (Pi\<^isub>M J M) (space (Pi\<^isub>M J M)) = 1" by (rule f.emeasure_space_1)
immler@50087
   357
qed simp_all
immler@50087
   358
immler@50087
   359
lemma (in product_prob_space) PiP_PiM_finite[simp]:
immler@50087
   360
  assumes "J \<noteq> {}" "finite J" "J \<subseteq> I" shows "PiP J M (\<lambda>J. PiM J M) = PiM J M"
immler@50087
   361
  using assms by (simp add: PiP_finite)
immler@50087
   362
immler@50039
   363
end