--- a/src/HOL/Probability/Finite_Product_Measure.thy Fri Nov 09 14:14:45 2012 +0100
+++ b/src/HOL/Probability/Finite_Product_Measure.thy Fri Nov 09 14:31:26 2012 +0100
@@ -94,6 +94,33 @@
"J \<inter> I = {} \<Longrightarrow> restrict (merge I J (x, y)) J = restrict y J"
by (auto simp: restrict_def)
+lemma split_merge: "P (merge I J (x,y) i) \<longleftrightarrow> (i \<in> I \<longrightarrow> P (x i)) \<and> (i \<in> J - I \<longrightarrow> P (y i)) \<and> (i \<notin> I \<union> J \<longrightarrow> P undefined)"
+ unfolding merge_def by auto
+
+lemma extensional_merge_sub: "I \<union> J \<subseteq> K \<Longrightarrow> merge I J (x, y) \<in> extensional K"
+ unfolding merge_def extensional_def by auto
+
+lemma injective_vimage_restrict:
+ assumes J: "J \<subseteq> I"
+ and sets: "A \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" "B \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" and ne: "(\<Pi>\<^isub>E i\<in>I. S i) \<noteq> {}"
+ and eq: "(\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i) = (\<lambda>x. restrict x J) -` B \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
+ shows "A = B"
+proof (intro set_eqI)
+ fix x
+ from ne obtain y where y: "\<And>i. i \<in> I \<Longrightarrow> y i \<in> S i" by auto
+ have "J \<inter> (I - J) = {}" by auto
+ show "x \<in> A \<longleftrightarrow> x \<in> B"
+ proof cases
+ assume x: "x \<in> (\<Pi>\<^isub>E i\<in>J. S i)"
+ have "x \<in> A \<longleftrightarrow> merge J (I - J) (x,y) \<in> (\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
+ using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub split: split_merge)
+ then show "x \<in> A \<longleftrightarrow> x \<in> B"
+ using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub eq split: split_merge)
+ next
+ assume "x \<notin> (\<Pi>\<^isub>E i\<in>J. S i)" with sets show "x \<in> A \<longleftrightarrow> x \<in> B" by auto
+ qed
+qed
+
lemma extensional_insert_undefined[intro, simp]:
assumes "a \<in> extensional (insert i I)"
shows "a(i := undefined) \<in> extensional I"
--- a/src/HOL/Probability/Infinite_Product_Measure.thy Fri Nov 09 14:14:45 2012 +0100
+++ b/src/HOL/Probability/Infinite_Product_Measure.thy Fri Nov 09 14:31:26 2012 +0100
@@ -8,33 +8,6 @@
imports Probability_Measure Caratheodory Projective_Family
begin
-lemma split_merge: "P (merge I J (x,y) i) \<longleftrightarrow> (i \<in> I \<longrightarrow> P (x i)) \<and> (i \<in> J - I \<longrightarrow> P (y i)) \<and> (i \<notin> I \<union> J \<longrightarrow> P undefined)"
- unfolding merge_def by auto
-
-lemma extensional_merge_sub: "I \<union> J \<subseteq> K \<Longrightarrow> merge I J (x, y) \<in> extensional K"
- unfolding merge_def extensional_def by auto
-
-lemma injective_vimage_restrict:
- assumes J: "J \<subseteq> I"
- and sets: "A \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" "B \<subseteq> (\<Pi>\<^isub>E i\<in>J. S i)" and ne: "(\<Pi>\<^isub>E i\<in>I. S i) \<noteq> {}"
- and eq: "(\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i) = (\<lambda>x. restrict x J) -` B \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
- shows "A = B"
-proof (intro set_eqI)
- fix x
- from ne obtain y where y: "\<And>i. i \<in> I \<Longrightarrow> y i \<in> S i" by auto
- have "J \<inter> (I - J) = {}" by auto
- show "x \<in> A \<longleftrightarrow> x \<in> B"
- proof cases
- assume x: "x \<in> (\<Pi>\<^isub>E i\<in>J. S i)"
- have "x \<in> A \<longleftrightarrow> merge J (I - J) (x,y) \<in> (\<lambda>x. restrict x J) -` A \<inter> (\<Pi>\<^isub>E i\<in>I. S i)"
- using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub split: split_merge)
- then show "x \<in> A \<longleftrightarrow> x \<in> B"
- using y x `J \<subseteq> I` by (auto simp add: Pi_iff extensional_restrict extensional_merge_sub eq split: split_merge)
- next
- assume "x \<notin> (\<Pi>\<^isub>E i\<in>J. S i)" with sets show "x \<in> A \<longleftrightarrow> x \<in> B" by auto
- qed
-qed
-
lemma (in product_prob_space) distr_restrict:
assumes "J \<noteq> {}" "J \<subseteq> K" "finite K"
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")
@@ -94,195 +67,6 @@
show "emeasure (Pi\<^isub>M J M) (space (Pi\<^isub>M J M)) = 1" by (rule f.emeasure_space_1)
qed simp_all
-lemma (in projective_family) prod_emb_injective:
- 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)"
- assumes "prod_emb L M J X = prod_emb L M J Y"
- shows "X = Y"
-proof (rule injective_vimage_restrict)
- show "X \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))" "Y \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
- using sets[THEN sets_into_space] by (auto simp: space_PiM)
- have "\<forall>i\<in>L. \<exists>x. x \<in> space (M i)"
- proof
- fix i assume "i \<in> L"
- interpret prob_space "P {i}" using prob_space by simp
- from not_empty show "\<exists>x. x \<in> space (M i)" by (auto simp add: proj_space space_PiM)
- qed
- from bchoice[OF this]
- show "(\<Pi>\<^isub>E i\<in>L. space (M i)) \<noteq> {}" by auto
- 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))"
- using `prod_emb L M J X = prod_emb L M J Y` by (simp add: prod_emb_def)
-qed fact
-
-abbreviation (in projective_family)
- "emb L K X \<equiv> prod_emb L M K X"
-
-definition (in projective_family) generator :: "('i \<Rightarrow> 'a) set set" where
- "generator = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M))"
-
-lemma (in projective_family) generatorI':
- "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"
- unfolding generator_def by auto
-
-lemma (in projective_family) algebra_generator:
- assumes "I \<noteq> {}" shows "algebra (\<Pi>\<^isub>E i\<in>I. space (M i)) generator" (is "algebra ?\<Omega> ?G")
- unfolding algebra_def algebra_axioms_def ring_of_sets_iff
-proof (intro conjI ballI)
- let ?G = generator
- show "?G \<subseteq> Pow ?\<Omega>"
- by (auto simp: generator_def prod_emb_def)
- from `I \<noteq> {}` obtain i where "i \<in> I" by auto
- then show "{} \<in> ?G"
- by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\<lambda>i. {}"]
- simp: sigma_sets.Empty generator_def prod_emb_def)
- from `i \<in> I` show "?\<Omega> \<in> ?G"
- by (auto intro!: exI[of _ "{i}"] image_eqI[where x="Pi\<^isub>E {i} (\<lambda>i. space (M i))"]
- simp: generator_def prod_emb_def)
- fix A assume "A \<in> ?G"
- 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"
- by (auto simp: generator_def)
- fix B assume "B \<in> ?G"
- 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"
- by (auto simp: generator_def)
- let ?RA = "emb (JA \<union> JB) JA XA"
- let ?RB = "emb (JA \<union> JB) JB XB"
- have *: "A - B = emb I (JA \<union> JB) (?RA - ?RB)" "A \<union> B = emb I (JA \<union> JB) (?RA \<union> ?RB)"
- using XA A XB B by auto
- show "A - B \<in> ?G" "A \<union> B \<in> ?G"
- unfolding * using XA XB by (safe intro!: generatorI') auto
-qed
-
-lemma (in projective_family) sets_PiM_generator:
- "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
-proof cases
- assume "I = {}" then show ?thesis
- unfolding generator_def
- by (auto simp: sets_PiM_empty sigma_sets_empty_eq cong: conj_cong)
-next
- assume "I \<noteq> {}"
- show ?thesis
- proof
- show "sets (Pi\<^isub>M I M) \<subseteq> sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
- unfolding sets_PiM
- proof (safe intro!: sigma_sets_subseteq)
- fix A assume "A \<in> prod_algebra I M" with `I \<noteq> {}` show "A \<in> generator"
- by (auto intro!: generatorI' sets_PiM_I_finite elim!: prod_algebraE)
- qed
- qed (auto simp: generator_def space_PiM[symmetric] intro!: sigma_sets_subset)
-qed
-
-lemma (in projective_family) generatorI:
- "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"
- unfolding generator_def by auto
-
-definition (in projective_family)
- "\<mu>G A =
- (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))"
-
-lemma (in projective_family) \<mu>G_spec:
- assumes J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
- shows "\<mu>G A = emeasure (PiP J M P) X"
- unfolding \<mu>G_def
-proof (intro the_equality allI impI ballI)
- 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)"
- have "emeasure (PiP K M P) Y = emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) K Y)"
- using K J by simp
- also have "emb (K \<union> J) K Y = emb (K \<union> J) J X"
- using K J by (simp add: prod_emb_injective[of "K \<union> J" I])
- also have "emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) J X) = emeasure (PiP J M P) X"
- using K J by simp
- finally show "emeasure (PiP J M P) X = emeasure (PiP K M P) Y" ..
-qed (insert J, force)
-
-lemma (in projective_family) \<mu>G_eq:
- "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"
- by (intro \<mu>G_spec) auto
-
-lemma (in projective_family) generator_Ex:
- assumes *: "A \<in> generator"
- 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"
-proof -
- 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)"
- unfolding generator_def by auto
- with \<mu>G_spec[OF this] show ?thesis by auto
-qed
-
-lemma (in projective_family) generatorE:
- assumes A: "A \<in> generator"
- 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"
-proof -
- 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"
- "\<mu>G A = emeasure (PiP J M P) X" by auto
- then show thesis by (intro that) auto
-qed
-
-lemma (in projective_family) merge_sets:
- "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)"
- by simp
-
-lemma (in projective_family) merge_emb:
- assumes "K \<subseteq> I" "J \<subseteq> I" and y: "y \<in> space (Pi\<^isub>M J M)"
- shows "((\<lambda>x. merge J (I - J) (y, x)) -` emb I K X \<inter> space (Pi\<^isub>M I M)) =
- 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))"
-proof -
- have [simp]: "\<And>x J K L. merge J K (y, restrict x L) = merge J (K \<inter> L) (y, x)"
- by (auto simp: restrict_def merge_def)
- have [simp]: "\<And>x J K L. restrict (merge J K (y, x)) L = merge (J \<inter> L) (K \<inter> L) (y, x)"
- by (auto simp: restrict_def merge_def)
- have [simp]: "(I - J) \<inter> K = K - J" using `K \<subseteq> I` `J \<subseteq> I` by auto
- have [simp]: "(K - J) \<inter> (K \<union> J) = K - J" by auto
- have [simp]: "(K - J) \<inter> K = K - J" by auto
- from y `K \<subseteq> I` `J \<subseteq> I` show ?thesis
- by (simp split: split_merge add: prod_emb_def Pi_iff extensional_merge_sub set_eq_iff space_PiM)
- auto
-qed
-
-lemma (in projective_family) positive_\<mu>G:
- assumes "I \<noteq> {}"
- shows "positive generator \<mu>G"
-proof -
- interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
- show ?thesis
- proof (intro positive_def[THEN iffD2] conjI ballI)
- from generatorE[OF G.empty_sets] guess J X . note this[simp]
- have "X = {}"
- by (rule prod_emb_injective[of J I]) simp_all
- then show "\<mu>G {} = 0" by simp
- next
- fix A assume "A \<in> generator"
- from generatorE[OF this] guess J X . note this[simp]
- show "0 \<le> \<mu>G A" by (simp add: emeasure_nonneg)
- qed
-qed
-
-lemma (in projective_family) additive_\<mu>G:
- assumes "I \<noteq> {}"
- shows "additive generator \<mu>G"
-proof -
- interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
- show ?thesis
- proof (intro additive_def[THEN iffD2] ballI impI)
- fix A assume "A \<in> generator" with generatorE guess J X . note J = this
- fix B assume "B \<in> generator" with generatorE guess K Y . note K = this
- assume "A \<inter> B = {}"
- have JK: "J \<union> K \<noteq> {}" "J \<union> K \<subseteq> I" "finite (J \<union> K)"
- using J K by auto
- have JK_disj: "emb (J \<union> K) J X \<inter> emb (J \<union> K) K Y = {}"
- apply (rule prod_emb_injective[of "J \<union> K" I])
- apply (insert `A \<inter> B = {}` JK J K)
- apply (simp_all add: Int prod_emb_Int)
- done
- 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)"
- using J K by simp_all
- 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))"
- by simp
- also have "\<dots> = emeasure (PiP (J \<union> K) M P) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y)"
- using JK J(1, 4) K(1, 4) by (simp add: \<mu>G_eq Un del: prod_emb_Un)
- also have "\<dots> = \<mu>G A + \<mu>G B"
- using J K JK_disj by (simp add: plus_emeasure[symmetric])
- finally show "\<mu>G (A \<union> B) = \<mu>G A + \<mu>G B" .
- qed
-qed
-
lemma (in product_prob_space) PiP_PiM_finite[simp]:
assumes "J \<noteq> {}" "finite J" "J \<subseteq> I" shows "PiP J M (\<lambda>J. PiM J M) = PiM J M"
using assms by (simp add: PiP_finite)
--- a/src/HOL/Probability/Projective_Family.thy Fri Nov 09 14:14:45 2012 +0100
+++ b/src/HOL/Probability/Projective_Family.thy Fri Nov 09 14:31:26 2012 +0100
@@ -1,3 +1,10 @@
+(* Title: HOL/Probability/Projective_Family.thy
+ Author: Fabian Immler, TU München
+ Author: Johannes Hölzl, TU München
+*)
+
+header {*Projective Family*}
+
theory Projective_Family
imports Finite_Product_Measure Probability_Measure
begin
@@ -99,6 +106,195 @@
using assms
by (subst PiP_finite) (auto simp: PiP_finite finite_subset projective)
+lemma prod_emb_injective:
+ 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)"
+ assumes "prod_emb L M J X = prod_emb L M J Y"
+ shows "X = Y"
+proof (rule injective_vimage_restrict)
+ show "X \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))" "Y \<subseteq> (\<Pi>\<^isub>E i\<in>J. space (M i))"
+ using sets[THEN sets_into_space] by (auto simp: space_PiM)
+ have "\<forall>i\<in>L. \<exists>x. x \<in> space (M i)"
+ proof
+ fix i assume "i \<in> L"
+ interpret prob_space "P {i}" using prob_space by simp
+ from not_empty show "\<exists>x. x \<in> space (M i)" by (auto simp add: proj_space space_PiM)
+ qed
+ from bchoice[OF this]
+ show "(\<Pi>\<^isub>E i\<in>L. space (M i)) \<noteq> {}" by auto
+ 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))"
+ using `prod_emb L M J X = prod_emb L M J Y` by (simp add: prod_emb_def)
+qed fact
+
+abbreviation
+ "emb L K X \<equiv> prod_emb L M K X"
+
+definition generator :: "('i \<Rightarrow> 'a) set set" where
+ "generator = (\<Union>J\<in>{J. J \<noteq> {} \<and> finite J \<and> J \<subseteq> I}. emb I J ` sets (Pi\<^isub>M J M))"
+
+lemma generatorI':
+ "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"
+ unfolding generator_def by auto
+
+lemma algebra_generator:
+ assumes "I \<noteq> {}" shows "algebra (\<Pi>\<^isub>E i\<in>I. space (M i)) generator" (is "algebra ?\<Omega> ?G")
+ unfolding algebra_def algebra_axioms_def ring_of_sets_iff
+proof (intro conjI ballI)
+ let ?G = generator
+ show "?G \<subseteq> Pow ?\<Omega>"
+ by (auto simp: generator_def prod_emb_def)
+ from `I \<noteq> {}` obtain i where "i \<in> I" by auto
+ then show "{} \<in> ?G"
+ by (auto intro!: exI[of _ "{i}"] image_eqI[where x="\<lambda>i. {}"]
+ simp: sigma_sets.Empty generator_def prod_emb_def)
+ from `i \<in> I` show "?\<Omega> \<in> ?G"
+ by (auto intro!: exI[of _ "{i}"] image_eqI[where x="Pi\<^isub>E {i} (\<lambda>i. space (M i))"]
+ simp: generator_def prod_emb_def)
+ fix A assume "A \<in> ?G"
+ 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"
+ by (auto simp: generator_def)
+ fix B assume "B \<in> ?G"
+ 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"
+ by (auto simp: generator_def)
+ let ?RA = "emb (JA \<union> JB) JA XA"
+ let ?RB = "emb (JA \<union> JB) JB XB"
+ have *: "A - B = emb I (JA \<union> JB) (?RA - ?RB)" "A \<union> B = emb I (JA \<union> JB) (?RA \<union> ?RB)"
+ using XA A XB B by auto
+ show "A - B \<in> ?G" "A \<union> B \<in> ?G"
+ unfolding * using XA XB by (safe intro!: generatorI') auto
+qed
+
+lemma sets_PiM_generator:
+ "sets (PiM I M) = sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
+proof cases
+ assume "I = {}" then show ?thesis
+ unfolding generator_def
+ by (auto simp: sets_PiM_empty sigma_sets_empty_eq cong: conj_cong)
+next
+ assume "I \<noteq> {}"
+ show ?thesis
+ proof
+ show "sets (Pi\<^isub>M I M) \<subseteq> sigma_sets (\<Pi>\<^isub>E i\<in>I. space (M i)) generator"
+ unfolding sets_PiM
+ proof (safe intro!: sigma_sets_subseteq)
+ fix A assume "A \<in> prod_algebra I M" with `I \<noteq> {}` show "A \<in> generator"
+ by (auto intro!: generatorI' sets_PiM_I_finite elim!: prod_algebraE)
+ qed
+ qed (auto simp: generator_def space_PiM[symmetric] intro!: sigma_sets_subset)
+qed
+
+lemma generatorI:
+ "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"
+ unfolding generator_def by auto
+
+definition
+ "\<mu>G A =
+ (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))"
+
+lemma \<mu>G_spec:
+ assumes J: "J \<noteq> {}" "finite J" "J \<subseteq> I" "A = emb I J X" "X \<in> sets (Pi\<^isub>M J M)"
+ shows "\<mu>G A = emeasure (PiP J M P) X"
+ unfolding \<mu>G_def
+proof (intro the_equality allI impI ballI)
+ 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)"
+ have "emeasure (PiP K M P) Y = emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) K Y)"
+ using K J by simp
+ also have "emb (K \<union> J) K Y = emb (K \<union> J) J X"
+ using K J by (simp add: prod_emb_injective[of "K \<union> J" I])
+ also have "emeasure (PiP (K \<union> J) M P) (emb (K \<union> J) J X) = emeasure (PiP J M P) X"
+ using K J by simp
+ finally show "emeasure (PiP J M P) X = emeasure (PiP K M P) Y" ..
+qed (insert J, force)
+
+lemma \<mu>G_eq:
+ "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"
+ by (intro \<mu>G_spec) auto
+
+lemma generator_Ex:
+ assumes *: "A \<in> generator"
+ 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"
+proof -
+ 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)"
+ unfolding generator_def by auto
+ with \<mu>G_spec[OF this] show ?thesis by auto
+qed
+
+lemma generatorE:
+ assumes A: "A \<in> generator"
+ 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"
+proof -
+ 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"
+ "\<mu>G A = emeasure (PiP J M P) X" by auto
+ then show thesis by (intro that) auto
+qed
+
+lemma merge_sets:
+ "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)"
+ by simp
+
+lemma merge_emb:
+ assumes "K \<subseteq> I" "J \<subseteq> I" and y: "y \<in> space (Pi\<^isub>M J M)"
+ shows "((\<lambda>x. merge J (I - J) (y, x)) -` emb I K X \<inter> space (Pi\<^isub>M I M)) =
+ 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))"
+proof -
+ have [simp]: "\<And>x J K L. merge J K (y, restrict x L) = merge J (K \<inter> L) (y, x)"
+ by (auto simp: restrict_def merge_def)
+ have [simp]: "\<And>x J K L. restrict (merge J K (y, x)) L = merge (J \<inter> L) (K \<inter> L) (y, x)"
+ by (auto simp: restrict_def merge_def)
+ have [simp]: "(I - J) \<inter> K = K - J" using `K \<subseteq> I` `J \<subseteq> I` by auto
+ have [simp]: "(K - J) \<inter> (K \<union> J) = K - J" by auto
+ have [simp]: "(K - J) \<inter> K = K - J" by auto
+ from y `K \<subseteq> I` `J \<subseteq> I` show ?thesis
+ by (simp split: split_merge add: prod_emb_def Pi_iff extensional_merge_sub set_eq_iff space_PiM)
+ auto
+qed
+
+lemma positive_\<mu>G:
+ assumes "I \<noteq> {}"
+ shows "positive generator \<mu>G"
+proof -
+ interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
+ show ?thesis
+ proof (intro positive_def[THEN iffD2] conjI ballI)
+ from generatorE[OF G.empty_sets] guess J X . note this[simp]
+ have "X = {}"
+ by (rule prod_emb_injective[of J I]) simp_all
+ then show "\<mu>G {} = 0" by simp
+ next
+ fix A assume "A \<in> generator"
+ from generatorE[OF this] guess J X . note this[simp]
+ show "0 \<le> \<mu>G A" by (simp add: emeasure_nonneg)
+ qed
+qed
+
+lemma additive_\<mu>G:
+ assumes "I \<noteq> {}"
+ shows "additive generator \<mu>G"
+proof -
+ interpret G!: algebra "\<Pi>\<^isub>E i\<in>I. space (M i)" generator by (rule algebra_generator) fact
+ show ?thesis
+ proof (intro additive_def[THEN iffD2] ballI impI)
+ fix A assume "A \<in> generator" with generatorE guess J X . note J = this
+ fix B assume "B \<in> generator" with generatorE guess K Y . note K = this
+ assume "A \<inter> B = {}"
+ have JK: "J \<union> K \<noteq> {}" "J \<union> K \<subseteq> I" "finite (J \<union> K)"
+ using J K by auto
+ have JK_disj: "emb (J \<union> K) J X \<inter> emb (J \<union> K) K Y = {}"
+ apply (rule prod_emb_injective[of "J \<union> K" I])
+ apply (insert `A \<inter> B = {}` JK J K)
+ apply (simp_all add: Int prod_emb_Int)
+ done
+ 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)"
+ using J K by simp_all
+ 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))"
+ by simp
+ also have "\<dots> = emeasure (PiP (J \<union> K) M P) (emb (J \<union> K) J X \<union> emb (J \<union> K) K Y)"
+ using JK J(1, 4) K(1, 4) by (simp add: \<mu>G_eq Un del: prod_emb_Un)
+ also have "\<dots> = \<mu>G A + \<mu>G B"
+ using J K JK_disj by (simp add: plus_emeasure[symmetric])
+ finally show "\<mu>G (A \<union> B) = \<mu>G A + \<mu>G B" .
+ qed
+qed
+
end
end