| author | wenzelm | 
| Tue, 20 Nov 2012 22:52:04 +0100 | |
| changeset 50136 | a96bd08258a2 | 
| parent 50096 | 7c9c5b1b6cd7 | 
| child 50244 | de72bbe42190 | 
| permissions | -rw-r--r-- | 
| 41983 | 1 | (* Title: HOL/Probability/Sigma_Algebra.thy | 
| 42067 | 2 | Author: Stefan Richter, Markus Wenzel, TU München | 
| 3 | Author: Johannes Hölzl, TU München | |
| 41981 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41959diff
changeset | 4 | Plus material from the Hurd/Coble measure theory development, | 
| 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41959diff
changeset | 5 | translated by Lawrence Paulson. | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 6 | *) | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 7 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 8 | header {* Sigma Algebras *}
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 9 | |
| 41413 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 10 | theory Sigma_Algebra | 
| 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 11 | imports | 
| 42145 | 12 | Complex_Main | 
| 41413 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 13 | "~~/src/HOL/Library/Countable" | 
| 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 14 | "~~/src/HOL/Library/FuncSet" | 
| 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 15 | "~~/src/HOL/Library/Indicator_Function" | 
| 47694 | 16 | "~~/src/HOL/Library/Extended_Real" | 
| 41413 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 17 | begin | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 18 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 19 | text {* Sigma algebras are an elementary concept in measure
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 20 | theory. To measure --- that is to integrate --- functions, we first have | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 21 | to measure sets. Unfortunately, when dealing with a large universe, | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 22 | it is often not possible to consistently assign a measure to every | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 23 | subset. Therefore it is necessary to define the set of measurable | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 24 | subsets of the universe. A sigma algebra is such a set that has | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 25 | three very natural and desirable properties. *} | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 26 | |
| 47762 | 27 | subsection {* Families of sets *}
 | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 28 | |
| 47694 | 29 | locale subset_class = | 
| 30 | fixes \<Omega> :: "'a set" and M :: "'a set set" | |
| 31 | assumes space_closed: "M \<subseteq> Pow \<Omega>" | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 32 | |
| 47694 | 33 | lemma (in subset_class) sets_into_space: "x \<in> M \<Longrightarrow> x \<subseteq> \<Omega>" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 34 | by (metis PowD contra_subsetD space_closed) | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 35 | |
| 47762 | 36 | subsection {* Semiring of sets *}
 | 
| 37 | ||
| 38 | subsubsection {* Disjoint sets *}
 | |
| 39 | ||
| 40 | definition "disjoint A \<longleftrightarrow> (\<forall>a\<in>A. \<forall>b\<in>A. a \<noteq> b \<longrightarrow> a \<inter> b = {})"
 | |
| 41 | ||
| 42 | lemma disjointI: | |
| 43 |   "(\<And>a b. a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<noteq> b \<Longrightarrow> a \<inter> b = {}) \<Longrightarrow> disjoint A"
 | |
| 44 | unfolding disjoint_def by auto | |
| 45 | ||
| 46 | lemma disjointD: | |
| 47 |   "disjoint A \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<noteq> b \<Longrightarrow> a \<inter> b = {}"
 | |
| 48 | unfolding disjoint_def by auto | |
| 49 | ||
| 50 | lemma disjoint_empty[iff]: "disjoint {}"
 | |
| 51 | by (auto simp: disjoint_def) | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 52 | |
| 47762 | 53 | lemma disjoint_union: | 
| 54 |   assumes C: "disjoint C" and B: "disjoint B" and disj: "\<Union>C \<inter> \<Union>B = {}"
 | |
| 55 | shows "disjoint (C \<union> B)" | |
| 56 | proof (rule disjointI) | |
| 57 | fix c d assume sets: "c \<in> C \<union> B" "d \<in> C \<union> B" and "c \<noteq> d" | |
| 58 |   show "c \<inter> d = {}"
 | |
| 59 | proof cases | |
| 60 | assume "(c \<in> C \<and> d \<in> C) \<or> (c \<in> B \<and> d \<in> B)" | |
| 61 | then show ?thesis | |
| 62 | proof | |
| 63 |       assume "c \<in> C \<and> d \<in> C" with `c \<noteq> d` C show "c \<inter> d = {}"
 | |
| 64 | by (auto simp: disjoint_def) | |
| 65 | next | |
| 66 |       assume "c \<in> B \<and> d \<in> B" with `c \<noteq> d` B show "c \<inter> d = {}"
 | |
| 67 | by (auto simp: disjoint_def) | |
| 68 | qed | |
| 69 | next | |
| 70 | assume "\<not> ((c \<in> C \<and> d \<in> C) \<or> (c \<in> B \<and> d \<in> B))" | |
| 71 | with sets have "(c \<subseteq> \<Union>C \<and> d \<subseteq> \<Union>B) \<or> (c \<subseteq> \<Union>B \<and> d \<subseteq> \<Union>C)" | |
| 72 | by auto | |
| 73 |     with disj show "c \<inter> d = {}" by auto
 | |
| 74 | qed | |
| 75 | qed | |
| 76 | ||
| 77 | locale semiring_of_sets = subset_class + | |
| 78 |   assumes empty_sets[iff]: "{} \<in> M"
 | |
| 79 | assumes Int[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M" | |
| 80 | assumes Diff_cover: | |
| 81 | "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> \<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C" | |
| 82 | ||
| 83 | lemma (in semiring_of_sets) finite_INT[intro]: | |
| 84 |   assumes "finite I" "I \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> M"
 | |
| 85 | shows "(\<Inter>i\<in>I. A i) \<in> M" | |
| 86 | using assms by (induct rule: finite_ne_induct) auto | |
| 87 | ||
| 88 | lemma (in semiring_of_sets) Int_space_eq1 [simp]: "x \<in> M \<Longrightarrow> \<Omega> \<inter> x = x" | |
| 89 | by (metis Int_absorb1 sets_into_space) | |
| 90 | ||
| 91 | lemma (in semiring_of_sets) Int_space_eq2 [simp]: "x \<in> M \<Longrightarrow> x \<inter> \<Omega> = x" | |
| 92 | by (metis Int_absorb2 sets_into_space) | |
| 93 | ||
| 94 | lemma (in semiring_of_sets) sets_Collect_conj: | |
| 95 |   assumes "{x\<in>\<Omega>. P x} \<in> M" "{x\<in>\<Omega>. Q x} \<in> M"
 | |
| 96 |   shows "{x\<in>\<Omega>. Q x \<and> P x} \<in> M"
 | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 97 | proof - | 
| 47762 | 98 |   have "{x\<in>\<Omega>. Q x \<and> P x} = {x\<in>\<Omega>. Q x} \<inter> {x\<in>\<Omega>. P x}"
 | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 99 | by auto | 
| 47762 | 100 | with assms show ?thesis by auto | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 101 | qed | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 102 | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 103 | lemma (in semiring_of_sets) sets_Collect_finite_All': | 
| 47762 | 104 |   assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S" "S \<noteq> {}"
 | 
| 105 |   shows "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} \<in> M"
 | |
| 106 | proof - | |
| 107 |   have "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} = (\<Inter>i\<in>S. {x\<in>\<Omega>. P i x})"
 | |
| 108 |     using `S \<noteq> {}` by auto
 | |
| 109 | with assms show ?thesis by auto | |
| 110 | qed | |
| 111 | ||
| 112 | locale ring_of_sets = semiring_of_sets + | |
| 113 | assumes Un [intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M" | |
| 114 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 115 | lemma (in ring_of_sets) finite_Union [intro]: | 
| 47694 | 116 | "finite X \<Longrightarrow> X \<subseteq> M \<Longrightarrow> Union X \<in> M" | 
| 38656 | 117 | by (induct set: finite) (auto simp add: Un) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 118 | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 119 | lemma (in ring_of_sets) finite_UN[intro]: | 
| 47694 | 120 | assumes "finite I" and "\<And>i. i \<in> I \<Longrightarrow> A i \<in> M" | 
| 121 | shows "(\<Union>i\<in>I. A i) \<in> M" | |
| 41981 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41959diff
changeset | 122 | using assms by induct auto | 
| 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41959diff
changeset | 123 | |
| 47762 | 124 | lemma (in ring_of_sets) Diff [intro]: | 
| 125 | assumes "a \<in> M" "b \<in> M" shows "a - b \<in> M" | |
| 126 | using Diff_cover[OF assms] by auto | |
| 127 | ||
| 128 | lemma ring_of_setsI: | |
| 129 | assumes space_closed: "M \<subseteq> Pow \<Omega>" | |
| 130 |   assumes empty_sets[iff]: "{} \<in> M"
 | |
| 131 | assumes Un[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M" | |
| 132 | assumes Diff[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a - b \<in> M" | |
| 133 | shows "ring_of_sets \<Omega> M" | |
| 134 | proof | |
| 135 | fix a b assume ab: "a \<in> M" "b \<in> M" | |
| 136 | from ab show "\<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C" | |
| 137 |     by (intro exI[of _ "{a - b}"]) (auto simp: disjoint_def)
 | |
| 138 | have "a \<inter> b = a - (a - b)" by auto | |
| 139 | also have "\<dots> \<in> M" using ab by auto | |
| 140 | finally show "a \<inter> b \<in> M" . | |
| 141 | qed fact+ | |
| 142 | ||
| 143 | lemma ring_of_sets_iff: "ring_of_sets \<Omega> M \<longleftrightarrow> M \<subseteq> Pow \<Omega> \<and> {} \<in> M \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a \<union> b \<in> M) \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a - b \<in> M)"
 | |
| 144 | proof | |
| 145 | assume "ring_of_sets \<Omega> M" | |
| 146 | then interpret ring_of_sets \<Omega> M . | |
| 147 |   show "M \<subseteq> Pow \<Omega> \<and> {} \<in> M \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a \<union> b \<in> M) \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a - b \<in> M)"
 | |
| 148 | using space_closed by auto | |
| 149 | qed (auto intro!: ring_of_setsI) | |
| 41981 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41959diff
changeset | 150 | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 151 | lemma (in ring_of_sets) insert_in_sets: | 
| 47694 | 152 |   assumes "{x} \<in> M" "A \<in> M" shows "insert x A \<in> M"
 | 
| 38656 | 153 | proof - | 
| 47694 | 154 |   have "{x} \<union> A \<in> M" using assms by (rule Un)
 | 
| 38656 | 155 | thus ?thesis by auto | 
| 156 | qed | |
| 157 | ||
| 42867 | 158 | lemma (in ring_of_sets) sets_Collect_disj: | 
| 47694 | 159 |   assumes "{x\<in>\<Omega>. P x} \<in> M" "{x\<in>\<Omega>. Q x} \<in> M"
 | 
| 160 |   shows "{x\<in>\<Omega>. Q x \<or> P x} \<in> M"
 | |
| 42867 | 161 | proof - | 
| 47694 | 162 |   have "{x\<in>\<Omega>. Q x \<or> P x} = {x\<in>\<Omega>. Q x} \<union> {x\<in>\<Omega>. P x}"
 | 
| 42867 | 163 | by auto | 
| 164 | with assms show ?thesis by auto | |
| 165 | qed | |
| 166 | ||
| 167 | lemma (in ring_of_sets) sets_Collect_finite_Ex: | |
| 47694 | 168 |   assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S"
 | 
| 169 |   shows "{x\<in>\<Omega>. \<exists>i\<in>S. P i x} \<in> M"
 | |
| 42867 | 170 | proof - | 
| 47694 | 171 |   have "{x\<in>\<Omega>. \<exists>i\<in>S. P i x} = (\<Union>i\<in>S. {x\<in>\<Omega>. P i x})"
 | 
| 42867 | 172 | by auto | 
| 173 | with assms show ?thesis by auto | |
| 174 | qed | |
| 175 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 176 | locale algebra = ring_of_sets + | 
| 47694 | 177 | assumes top [iff]: "\<Omega> \<in> M" | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 178 | |
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 179 | lemma (in algebra) compl_sets [intro]: | 
| 47694 | 180 | "a \<in> M \<Longrightarrow> \<Omega> - a \<in> M" | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 181 | by auto | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 182 | |
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 183 | lemma algebra_iff_Un: | 
| 47694 | 184 | "algebra \<Omega> M \<longleftrightarrow> | 
| 185 | M \<subseteq> Pow \<Omega> \<and> | |
| 186 |     {} \<in> M \<and>
 | |
| 187 | (\<forall>a \<in> M. \<Omega> - a \<in> M) \<and> | |
| 188 | (\<forall>a \<in> M. \<forall> b \<in> M. a \<union> b \<in> M)" (is "_ \<longleftrightarrow> ?Un") | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 189 | proof | 
| 47694 | 190 | assume "algebra \<Omega> M" | 
| 191 | then interpret algebra \<Omega> M . | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 192 | show ?Un using sets_into_space by auto | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 193 | next | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 194 | assume ?Un | 
| 47762 | 195 | then have "\<Omega> \<in> M" by auto | 
| 196 | interpret ring_of_sets \<Omega> M | |
| 197 | proof (rule ring_of_setsI) | |
| 198 |     show \<Omega>: "M \<subseteq> Pow \<Omega>" "{} \<in> M"
 | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 199 | using `?Un` by auto | 
| 47694 | 200 | fix a b assume a: "a \<in> M" and b: "b \<in> M" | 
| 201 | then show "a \<union> b \<in> M" using `?Un` by auto | |
| 202 | have "a - b = \<Omega> - ((\<Omega> - a) \<union> b)" | |
| 203 | using \<Omega> a b by auto | |
| 204 | then show "a - b \<in> M" | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 205 | using a b `?Un` by auto | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 206 | qed | 
| 47762 | 207 | show "algebra \<Omega> M" proof qed fact | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 208 | qed | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 209 | |
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 210 | lemma algebra_iff_Int: | 
| 47694 | 211 | "algebra \<Omega> M \<longleftrightarrow> | 
| 212 |        M \<subseteq> Pow \<Omega> & {} \<in> M &
 | |
| 213 | (\<forall>a \<in> M. \<Omega> - a \<in> M) & | |
| 214 | (\<forall>a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)" (is "_ \<longleftrightarrow> ?Int") | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 215 | proof | 
| 47694 | 216 | assume "algebra \<Omega> M" | 
| 217 | then interpret algebra \<Omega> M . | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 218 | show ?Int using sets_into_space by auto | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 219 | next | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 220 | assume ?Int | 
| 47694 | 221 | show "algebra \<Omega> M" | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 222 | proof (unfold algebra_iff_Un, intro conjI ballI) | 
| 47694 | 223 |     show \<Omega>: "M \<subseteq> Pow \<Omega>" "{} \<in> M"
 | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 224 | using `?Int` by auto | 
| 47694 | 225 | from `?Int` show "\<And>a. a \<in> M \<Longrightarrow> \<Omega> - a \<in> M" by auto | 
| 226 | fix a b assume M: "a \<in> M" "b \<in> M" | |
| 227 | hence "a \<union> b = \<Omega> - ((\<Omega> - a) \<inter> (\<Omega> - b))" | |
| 228 | using \<Omega> by blast | |
| 229 | also have "... \<in> M" | |
| 230 | using M `?Int` by auto | |
| 231 | finally show "a \<union> b \<in> M" . | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 232 | qed | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 233 | qed | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 234 | |
| 42867 | 235 | lemma (in algebra) sets_Collect_neg: | 
| 47694 | 236 |   assumes "{x\<in>\<Omega>. P x} \<in> M"
 | 
| 237 |   shows "{x\<in>\<Omega>. \<not> P x} \<in> M"
 | |
| 42867 | 238 | proof - | 
| 47694 | 239 |   have "{x\<in>\<Omega>. \<not> P x} = \<Omega> - {x\<in>\<Omega>. P x}" by auto
 | 
| 42867 | 240 | with assms show ?thesis by auto | 
| 241 | qed | |
| 242 | ||
| 243 | lemma (in algebra) sets_Collect_imp: | |
| 47694 | 244 |   "{x\<in>\<Omega>. P x} \<in> M \<Longrightarrow> {x\<in>\<Omega>. Q x} \<in> M \<Longrightarrow> {x\<in>\<Omega>. Q x \<longrightarrow> P x} \<in> M"
 | 
| 42867 | 245 | unfolding imp_conv_disj by (intro sets_Collect_disj sets_Collect_neg) | 
| 246 | ||
| 247 | lemma (in algebra) sets_Collect_const: | |
| 47694 | 248 |   "{x\<in>\<Omega>. P} \<in> M"
 | 
| 42867 | 249 | by (cases P) auto | 
| 250 | ||
| 42984 | 251 | lemma algebra_single_set: | 
| 47762 | 252 |   "X \<subseteq> S \<Longrightarrow> algebra S { {}, X, S - X, S }"
 | 
| 253 | by (auto simp: algebra_iff_Int) | |
| 42984 | 254 | |
| 39092 | 255 | section {* Restricted algebras *}
 | 
| 256 | ||
| 257 | abbreviation (in algebra) | |
| 47694 | 258 | "restricted_space A \<equiv> (op \<inter> A) ` M" | 
| 39092 | 259 | |
| 38656 | 260 | lemma (in algebra) restricted_algebra: | 
| 47694 | 261 | assumes "A \<in> M" shows "algebra A (restricted_space A)" | 
| 47762 | 262 | using assms by (auto simp: algebra_iff_Int) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 263 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 264 | subsection {* Sigma Algebras *}
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 265 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 266 | locale sigma_algebra = algebra + | 
| 47694 | 267 | assumes countable_nat_UN [intro]: "\<And>A. range A \<subseteq> M \<Longrightarrow> (\<Union>i::nat. A i) \<in> M" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 268 | |
| 42984 | 269 | lemma (in algebra) is_sigma_algebra: | 
| 47694 | 270 | assumes "finite M" | 
| 271 | shows "sigma_algebra \<Omega> M" | |
| 42984 | 272 | proof | 
| 47694 | 273 | fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> M" | 
| 274 | then have "(\<Union>i. A i) = (\<Union>s\<in>M \<inter> range A. s)" | |
| 42984 | 275 | by auto | 
| 47694 | 276 | also have "(\<Union>s\<in>M \<inter> range A. s) \<in> M" | 
| 277 | using `finite M` by auto | |
| 278 | finally show "(\<Union>i. A i) \<in> M" . | |
| 42984 | 279 | qed | 
| 280 | ||
| 38656 | 281 | lemma countable_UN_eq: | 
| 282 | fixes A :: "'i::countable \<Rightarrow> 'a set" | |
| 47694 | 283 | shows "(range A \<subseteq> M \<longrightarrow> (\<Union>i. A i) \<in> M) \<longleftrightarrow> | 
| 284 | (range (A \<circ> from_nat) \<subseteq> M \<longrightarrow> (\<Union>i. (A \<circ> from_nat) i) \<in> M)" | |
| 38656 | 285 | proof - | 
| 286 | let ?A' = "A \<circ> from_nat" | |
| 287 | have *: "(\<Union>i. ?A' i) = (\<Union>i. A i)" (is "?l = ?r") | |
| 288 | proof safe | |
| 289 | fix x i assume "x \<in> A i" thus "x \<in> ?l" | |
| 290 | by (auto intro!: exI[of _ "to_nat i"]) | |
| 291 | next | |
| 292 | fix x i assume "x \<in> ?A' i" thus "x \<in> ?r" | |
| 293 | by (auto intro!: exI[of _ "from_nat i"]) | |
| 294 | qed | |
| 295 | have **: "range ?A' = range A" | |
| 40702 | 296 | using surj_from_nat | 
| 38656 | 297 | by (auto simp: image_compose intro!: imageI) | 
| 298 | show ?thesis unfolding * ** .. | |
| 299 | qed | |
| 300 | ||
| 301 | lemma (in sigma_algebra) countable_UN[intro]: | |
| 302 | fixes A :: "'i::countable \<Rightarrow> 'a set" | |
| 47694 | 303 | assumes "A`X \<subseteq> M" | 
| 304 | shows "(\<Union>x\<in>X. A x) \<in> M" | |
| 38656 | 305 | proof - | 
| 46731 | 306 |   let ?A = "\<lambda>i. if i \<in> X then A i else {}"
 | 
| 47694 | 307 | from assms have "range ?A \<subseteq> M" by auto | 
| 38656 | 308 | with countable_nat_UN[of "?A \<circ> from_nat"] countable_UN_eq[of ?A M] | 
| 47694 | 309 | have "(\<Union>x. ?A x) \<in> M" by auto | 
| 38656 | 310 | moreover have "(\<Union>x. ?A x) = (\<Union>x\<in>X. A x)" by (auto split: split_if_asm) | 
| 311 | ultimately show ?thesis by simp | |
| 312 | qed | |
| 313 | ||
| 33533 
40b44cb20c8c
New theory Probability/Borel.thy, and some associated lemmas
 paulson parents: 
33271diff
changeset | 314 | lemma (in sigma_algebra) countable_INT [intro]: | 
| 38656 | 315 | fixes A :: "'i::countable \<Rightarrow> 'a set" | 
| 47694 | 316 |   assumes A: "A`X \<subseteq> M" "X \<noteq> {}"
 | 
| 317 | shows "(\<Inter>i\<in>X. A i) \<in> M" | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 318 | proof - | 
| 47694 | 319 | from A have "\<forall>i\<in>X. A i \<in> M" by fast | 
| 320 | hence "\<Omega> - (\<Union>i\<in>X. \<Omega> - A i) \<in> M" by blast | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 321 | moreover | 
| 47694 | 322 | have "(\<Inter>i\<in>X. A i) = \<Omega> - (\<Union>i\<in>X. \<Omega> - A i)" using space_closed A | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 323 | by blast | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 324 | ultimately show ?thesis by metis | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 325 | qed | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 326 | |
| 47694 | 327 | lemma ring_of_sets_Pow: "ring_of_sets sp (Pow sp)" | 
| 47762 | 328 | by (auto simp: ring_of_sets_iff) | 
| 42145 | 329 | |
| 47694 | 330 | lemma algebra_Pow: "algebra sp (Pow sp)" | 
| 47762 | 331 | by (auto simp: algebra_iff_Un) | 
| 38656 | 332 | |
| 333 | lemma sigma_algebra_iff: | |
| 47694 | 334 | "sigma_algebra \<Omega> M \<longleftrightarrow> | 
| 335 | algebra \<Omega> M \<and> (\<forall>A. range A \<subseteq> M \<longrightarrow> (\<Union>i::nat. A i) \<in> M)" | |
| 38656 | 336 | by (simp add: sigma_algebra_def sigma_algebra_axioms_def) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 337 | |
| 47762 | 338 | lemma sigma_algebra_Pow: "sigma_algebra sp (Pow sp)" | 
| 339 | by (auto simp: sigma_algebra_iff algebra_iff_Int) | |
| 340 | ||
| 42867 | 341 | lemma (in sigma_algebra) sets_Collect_countable_All: | 
| 47694 | 342 |   assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
 | 
| 343 |   shows "{x\<in>\<Omega>. \<forall>i::'i::countable. P i x} \<in> M"
 | |
| 42867 | 344 | proof - | 
| 47694 | 345 |   have "{x\<in>\<Omega>. \<forall>i::'i::countable. P i x} = (\<Inter>i. {x\<in>\<Omega>. P i x})" by auto
 | 
| 42867 | 346 | with assms show ?thesis by auto | 
| 347 | qed | |
| 348 | ||
| 349 | lemma (in sigma_algebra) sets_Collect_countable_Ex: | |
| 47694 | 350 |   assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
 | 
| 351 |   shows "{x\<in>\<Omega>. \<exists>i::'i::countable. P i x} \<in> M"
 | |
| 42867 | 352 | proof - | 
| 47694 | 353 |   have "{x\<in>\<Omega>. \<exists>i::'i::countable. P i x} = (\<Union>i. {x\<in>\<Omega>. P i x})" by auto
 | 
| 42867 | 354 | with assms show ?thesis by auto | 
| 355 | qed | |
| 356 | ||
| 357 | lemmas (in sigma_algebra) sets_Collect = | |
| 358 | sets_Collect_imp sets_Collect_disj sets_Collect_conj sets_Collect_neg sets_Collect_const | |
| 359 | sets_Collect_countable_All sets_Collect_countable_Ex sets_Collect_countable_All | |
| 360 | ||
| 47694 | 361 | lemma (in sigma_algebra) sets_Collect_countable_Ball: | 
| 362 |   assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
 | |
| 363 |   shows "{x\<in>\<Omega>. \<forall>i::'i::countable\<in>X. P i x} \<in> M"
 | |
| 364 | unfolding Ball_def by (intro sets_Collect assms) | |
| 365 | ||
| 366 | lemma (in sigma_algebra) sets_Collect_countable_Bex: | |
| 367 |   assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
 | |
| 368 |   shows "{x\<in>\<Omega>. \<exists>i::'i::countable\<in>X. P i x} \<in> M"
 | |
| 369 | unfolding Bex_def by (intro sets_Collect assms) | |
| 370 | ||
| 42984 | 371 | lemma sigma_algebra_single_set: | 
| 372 | assumes "X \<subseteq> S" | |
| 47694 | 373 |   shows "sigma_algebra S { {}, X, S - X, S }"
 | 
| 42984 | 374 | using algebra.is_sigma_algebra[OF algebra_single_set[OF `X \<subseteq> S`]] by simp | 
| 375 | ||
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 376 | subsection {* Binary Unions *}
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 377 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 378 | definition binary :: "'a \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 379 | where "binary a b = (\<lambda>\<^isup>x. b)(0 := a)" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 380 | |
| 38656 | 381 | lemma range_binary_eq: "range(binary a b) = {a,b}"
 | 
| 382 | by (auto simp add: binary_def) | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 383 | |
| 38656 | 384 | lemma Un_range_binary: "a \<union> b = (\<Union>i::nat. binary a b i)" | 
| 44106 | 385 | by (simp add: SUP_def range_binary_eq) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 386 | |
| 38656 | 387 | lemma Int_range_binary: "a \<inter> b = (\<Inter>i::nat. binary a b i)" | 
| 44106 | 388 | by (simp add: INF_def range_binary_eq) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 389 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 390 | lemma sigma_algebra_iff2: | 
| 47694 | 391 | "sigma_algebra \<Omega> M \<longleftrightarrow> | 
| 392 | M \<subseteq> Pow \<Omega> \<and> | |
| 393 |        {} \<in> M \<and> (\<forall>s \<in> M. \<Omega> - s \<in> M) \<and>
 | |
| 394 | (\<forall>A. range A \<subseteq> M \<longrightarrow> (\<Union>i::nat. A i) \<in> M)" | |
| 38656 | 395 | by (auto simp add: range_binary_eq sigma_algebra_def sigma_algebra_axioms_def | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 396 | algebra_iff_Un Un_range_binary) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 397 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 398 | subsection {* Initial Sigma Algebra *}
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 399 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 400 | text {*Sigma algebras can naturally be created as the closure of any set of
 | 
| 47694 | 401 | M with regard to the properties just postulated. *} | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 402 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 403 | inductive_set | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 404 | sigma_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 405 | for sp :: "'a set" and A :: "'a set set" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 406 | where | 
| 47694 | 407 | Basic[intro, simp]: "a \<in> A \<Longrightarrow> a \<in> sigma_sets sp A" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 408 |   | Empty: "{} \<in> sigma_sets sp A"
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 409 | | Compl: "a \<in> sigma_sets sp A \<Longrightarrow> sp - a \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 410 | | Union: "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Union>i. a i) \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 411 | |
| 41543 | 412 | lemma (in sigma_algebra) sigma_sets_subset: | 
| 47694 | 413 | assumes a: "a \<subseteq> M" | 
| 414 | shows "sigma_sets \<Omega> a \<subseteq> M" | |
| 41543 | 415 | proof | 
| 416 | fix x | |
| 47694 | 417 | assume "x \<in> sigma_sets \<Omega> a" | 
| 418 | from this show "x \<in> M" | |
| 41543 | 419 | by (induct rule: sigma_sets.induct, auto) (metis a subsetD) | 
| 420 | qed | |
| 421 | ||
| 422 | lemma sigma_sets_into_sp: "A \<subseteq> Pow sp \<Longrightarrow> x \<in> sigma_sets sp A \<Longrightarrow> x \<subseteq> sp" | |
| 423 | by (erule sigma_sets.induct, auto) | |
| 424 | ||
| 425 | lemma sigma_algebra_sigma_sets: | |
| 47694 | 426 | "a \<subseteq> Pow \<Omega> \<Longrightarrow> sigma_algebra \<Omega> (sigma_sets \<Omega> a)" | 
| 41543 | 427 | by (auto simp add: sigma_algebra_iff2 dest: sigma_sets_into_sp | 
| 428 | intro!: sigma_sets.Union sigma_sets.Empty sigma_sets.Compl) | |
| 429 | ||
| 430 | lemma sigma_sets_least_sigma_algebra: | |
| 431 | assumes "A \<subseteq> Pow S" | |
| 47694 | 432 |   shows "sigma_sets S A = \<Inter>{B. A \<subseteq> B \<and> sigma_algebra S B}"
 | 
| 41543 | 433 | proof safe | 
| 47694 | 434 | fix B X assume "A \<subseteq> B" and sa: "sigma_algebra S B" | 
| 41543 | 435 | and X: "X \<in> sigma_sets S A" | 
| 436 | from sigma_algebra.sigma_sets_subset[OF sa, simplified, OF `A \<subseteq> B`] X | |
| 437 | show "X \<in> B" by auto | |
| 438 | next | |
| 47694 | 439 |   fix X assume "X \<in> \<Inter>{B. A \<subseteq> B \<and> sigma_algebra S B}"
 | 
| 440 | then have [intro!]: "\<And>B. A \<subseteq> B \<Longrightarrow> sigma_algebra S B \<Longrightarrow> X \<in> B" | |
| 41543 | 441 | by simp | 
| 47694 | 442 | have "A \<subseteq> sigma_sets S A" using assms by auto | 
| 443 | moreover have "sigma_algebra S (sigma_sets S A)" | |
| 41543 | 444 | using assms by (intro sigma_algebra_sigma_sets[of A]) auto | 
| 445 | ultimately show "X \<in> sigma_sets S A" by auto | |
| 446 | qed | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 447 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 448 | lemma sigma_sets_top: "sp \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 449 | by (metis Diff_empty sigma_sets.Compl sigma_sets.Empty) | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 450 | |
| 38656 | 451 | lemma sigma_sets_Un: | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 452 | "a \<in> sigma_sets sp A \<Longrightarrow> b \<in> sigma_sets sp A \<Longrightarrow> a \<union> b \<in> sigma_sets sp A" | 
| 38656 | 453 | apply (simp add: Un_range_binary range_binary_eq) | 
| 40859 | 454 | apply (rule Union, simp add: binary_def) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 455 | done | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 456 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 457 | lemma sigma_sets_Inter: | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 458 | assumes Asb: "A \<subseteq> Pow sp" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 459 | shows "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Inter>i. a i) \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 460 | proof - | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 461 | assume ai: "\<And>i::nat. a i \<in> sigma_sets sp A" | 
| 38656 | 462 | hence "\<And>i::nat. sp-(a i) \<in> sigma_sets sp A" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 463 | by (rule sigma_sets.Compl) | 
| 38656 | 464 | hence "(\<Union>i. sp-(a i)) \<in> sigma_sets sp A" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 465 | by (rule sigma_sets.Union) | 
| 38656 | 466 | hence "sp-(\<Union>i. sp-(a i)) \<in> sigma_sets sp A" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 467 | by (rule sigma_sets.Compl) | 
| 38656 | 468 | also have "sp-(\<Union>i. sp-(a i)) = sp Int (\<Inter>i. a i)" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 469 | by auto | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 470 | also have "... = (\<Inter>i. a i)" using ai | 
| 38656 | 471 | by (blast dest: sigma_sets_into_sp [OF Asb]) | 
| 472 | finally show ?thesis . | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 473 | qed | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 474 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 475 | lemma sigma_sets_INTER: | 
| 38656 | 476 | assumes Asb: "A \<subseteq> Pow sp" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 477 |       and ai: "\<And>i::nat. i \<in> S \<Longrightarrow> a i \<in> sigma_sets sp A" and non: "S \<noteq> {}"
 | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 478 | shows "(\<Inter>i\<in>S. a i) \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 479 | proof - | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 480 | from ai have "\<And>i. (if i\<in>S then a i else sp) \<in> sigma_sets sp A" | 
| 47694 | 481 | by (simp add: sigma_sets.intros(2-) sigma_sets_top) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 482 | hence "(\<Inter>i. (if i\<in>S then a i else sp)) \<in> sigma_sets sp A" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 483 | by (rule sigma_sets_Inter [OF Asb]) | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 484 | also have "(\<Inter>i. (if i\<in>S then a i else sp)) = (\<Inter>i\<in>S. a i)" | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 485 | by auto (metis ai non sigma_sets_into_sp subset_empty subset_iff Asb)+ | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 486 | finally show ?thesis . | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 487 | qed | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 488 | |
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 489 | lemma (in sigma_algebra) sigma_sets_eq: | 
| 47694 | 490 | "sigma_sets \<Omega> M = M" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 491 | proof | 
| 47694 | 492 | show "M \<subseteq> sigma_sets \<Omega> M" | 
| 37032 | 493 | by (metis Set.subsetI sigma_sets.Basic) | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 494 | next | 
| 47694 | 495 | show "sigma_sets \<Omega> M \<subseteq> M" | 
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 496 | by (metis sigma_sets_subset subset_refl) | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 497 | qed | 
| 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 498 | |
| 42981 | 499 | lemma sigma_sets_eqI: | 
| 500 | assumes A: "\<And>a. a \<in> A \<Longrightarrow> a \<in> sigma_sets M B" | |
| 501 | assumes B: "\<And>b. b \<in> B \<Longrightarrow> b \<in> sigma_sets M A" | |
| 502 | shows "sigma_sets M A = sigma_sets M B" | |
| 503 | proof (intro set_eqI iffI) | |
| 504 | fix a assume "a \<in> sigma_sets M A" | |
| 505 | from this A show "a \<in> sigma_sets M B" | |
| 47694 | 506 | by induct (auto intro!: sigma_sets.intros(2-) del: sigma_sets.Basic) | 
| 42981 | 507 | next | 
| 508 | fix b assume "b \<in> sigma_sets M B" | |
| 509 | from this B show "b \<in> sigma_sets M A" | |
| 47694 | 510 | by induct (auto intro!: sigma_sets.intros(2-) del: sigma_sets.Basic) | 
| 42981 | 511 | qed | 
| 512 | ||
| 42984 | 513 | lemma sigma_sets_subseteq: assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B" | 
| 514 | proof | |
| 515 | fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B" | |
| 47694 | 516 | by induct (insert `A \<subseteq> B`, auto intro: sigma_sets.intros(2-)) | 
| 42984 | 517 | qed | 
| 518 | ||
| 47762 | 519 | lemma sigma_sets_mono: assumes "A \<subseteq> sigma_sets X B" shows "sigma_sets X A \<subseteq> sigma_sets X B" | 
| 520 | proof | |
| 521 | fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B" | |
| 522 | by induct (insert `A \<subseteq> sigma_sets X B`, auto intro: sigma_sets.intros(2-)) | |
| 523 | qed | |
| 524 | ||
| 525 | lemma sigma_sets_mono': assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B" | |
| 526 | proof | |
| 527 | fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B" | |
| 528 | by induct (insert `A \<subseteq> B`, auto intro: sigma_sets.intros(2-)) | |
| 529 | qed | |
| 530 | ||
| 531 | lemma sigma_sets_superset_generator: "A \<subseteq> sigma_sets X A" | |
| 532 | by (auto intro: sigma_sets.Basic) | |
| 533 | ||
| 38656 | 534 | lemma (in sigma_algebra) restriction_in_sets: | 
| 535 | fixes A :: "nat \<Rightarrow> 'a set" | |
| 47694 | 536 | assumes "S \<in> M" | 
| 537 | and *: "range A \<subseteq> (\<lambda>A. S \<inter> A) ` M" (is "_ \<subseteq> ?r") | |
| 538 | shows "range A \<subseteq> M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` M" | |
| 38656 | 539 | proof - | 
| 540 |   { fix i have "A i \<in> ?r" using * by auto
 | |
| 47694 | 541 | hence "\<exists>B. A i = B \<inter> S \<and> B \<in> M" by auto | 
| 542 | hence "A i \<subseteq> S" "A i \<in> M" using `S \<in> M` by auto } | |
| 543 | thus "range A \<subseteq> M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` M" | |
| 38656 | 544 | by (auto intro!: image_eqI[of _ _ "(\<Union>i. A i)"]) | 
| 545 | qed | |
| 546 | ||
| 547 | lemma (in sigma_algebra) restricted_sigma_algebra: | |
| 47694 | 548 | assumes "S \<in> M" | 
| 549 | shows "sigma_algebra S (restricted_space S)" | |
| 38656 | 550 | unfolding sigma_algebra_def sigma_algebra_axioms_def | 
| 551 | proof safe | |
| 47694 | 552 | show "algebra S (restricted_space S)" using restricted_algebra[OF assms] . | 
| 38656 | 553 | next | 
| 47694 | 554 | fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> restricted_space S" | 
| 38656 | 555 | from restriction_in_sets[OF assms this[simplified]] | 
| 47694 | 556 | show "(\<Union>i. A i) \<in> restricted_space S" by simp | 
| 38656 | 557 | qed | 
| 558 | ||
| 40859 | 559 | lemma sigma_sets_Int: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 560 | assumes "A \<in> sigma_sets sp st" "A \<subseteq> sp" | 
| 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 561 | shows "op \<inter> A ` sigma_sets sp st = sigma_sets A (op \<inter> A ` st)" | 
| 40859 | 562 | proof (intro equalityI subsetI) | 
| 563 | fix x assume "x \<in> op \<inter> A ` sigma_sets sp st" | |
| 564 | then obtain y where "y \<in> sigma_sets sp st" "x = y \<inter> A" by auto | |
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 565 | then have "x \<in> sigma_sets (A \<inter> sp) (op \<inter> A ` st)" | 
| 40859 | 566 | proof (induct arbitrary: x) | 
| 567 | case (Compl a) | |
| 568 | then show ?case | |
| 569 | by (force intro!: sigma_sets.Compl simp: Diff_Int_distrib ac_simps) | |
| 570 | next | |
| 571 | case (Union a) | |
| 572 | then show ?case | |
| 573 | by (auto intro!: sigma_sets.Union | |
| 574 | simp add: UN_extend_simps simp del: UN_simps) | |
| 47694 | 575 | qed (auto intro!: sigma_sets.intros(2-)) | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 576 | then show "x \<in> sigma_sets A (op \<inter> A ` st)" | 
| 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 577 | using `A \<subseteq> sp` by (simp add: Int_absorb2) | 
| 40859 | 578 | next | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 579 | fix x assume "x \<in> sigma_sets A (op \<inter> A ` st)" | 
| 40859 | 580 | then show "x \<in> op \<inter> A ` sigma_sets sp st" | 
| 581 | proof induct | |
| 582 | case (Compl a) | |
| 583 | then obtain x where "a = A \<inter> x" "x \<in> sigma_sets sp st" by auto | |
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 584 | then show ?case using `A \<subseteq> sp` | 
| 40859 | 585 | by (force simp add: image_iff intro!: bexI[of _ "sp - x"] sigma_sets.Compl) | 
| 586 | next | |
| 587 | case (Union a) | |
| 588 | then have "\<forall>i. \<exists>x. x \<in> sigma_sets sp st \<and> a i = A \<inter> x" | |
| 589 | by (auto simp: image_iff Bex_def) | |
| 590 | from choice[OF this] guess f .. | |
| 591 | then show ?case | |
| 592 | by (auto intro!: bexI[of _ "(\<Union>x. f x)"] sigma_sets.Union | |
| 593 | simp add: image_iff) | |
| 47694 | 594 | qed (auto intro!: sigma_sets.intros(2-)) | 
| 40859 | 595 | qed | 
| 596 | ||
| 47694 | 597 | lemma sigma_sets_empty_eq: "sigma_sets A {} = {{}, A}"
 | 
| 40859 | 598 | proof (intro set_eqI iffI) | 
| 47694 | 599 |   fix a assume "a \<in> sigma_sets A {}" then show "a \<in> {{}, A}"
 | 
| 600 | by induct blast+ | |
| 601 | qed (auto intro: sigma_sets.Empty sigma_sets_top) | |
| 602 | ||
| 603 | lemma sigma_sets_single[simp]: "sigma_sets A {A} = {{}, A}"
 | |
| 604 | proof (intro set_eqI iffI) | |
| 605 |   fix x assume "x \<in> sigma_sets A {A}"
 | |
| 606 |   then show "x \<in> {{}, A}"
 | |
| 607 | by induct blast+ | |
| 40859 | 608 | next | 
| 47694 | 609 |   fix x assume "x \<in> {{}, A}"
 | 
| 610 |   then show "x \<in> sigma_sets A {A}"
 | |
| 40859 | 611 | by (auto intro: sigma_sets.Empty sigma_sets_top) | 
| 612 | qed | |
| 613 | ||
| 42987 | 614 | lemma sigma_sets_sigma_sets_eq: | 
| 615 | "M \<subseteq> Pow S \<Longrightarrow> sigma_sets S (sigma_sets S M) = sigma_sets S M" | |
| 47694 | 616 | by (rule sigma_algebra.sigma_sets_eq[OF sigma_algebra_sigma_sets, of M S]) auto | 
| 42987 | 617 | |
| 42984 | 618 | lemma sigma_sets_singleton: | 
| 619 | assumes "X \<subseteq> S" | |
| 620 |   shows "sigma_sets S { X } = { {}, X, S - X, S }"
 | |
| 621 | proof - | |
| 47694 | 622 |   interpret sigma_algebra S "{ {}, X, S - X, S }"
 | 
| 42984 | 623 | by (rule sigma_algebra_single_set) fact | 
| 624 |   have "sigma_sets S { X } \<subseteq> sigma_sets S { {}, X, S - X, S }"
 | |
| 625 | by (rule sigma_sets_subseteq) simp | |
| 626 |   moreover have "\<dots> = { {}, X, S - X, S }"
 | |
| 47694 | 627 | using sigma_sets_eq by simp | 
| 42984 | 628 | moreover | 
| 629 |   { fix A assume "A \<in> { {}, X, S - X, S }"
 | |
| 630 |     then have "A \<in> sigma_sets S { X }"
 | |
| 47694 | 631 | by (auto intro: sigma_sets.intros(2-) sigma_sets_top) } | 
| 42984 | 632 |   ultimately have "sigma_sets S { X } = sigma_sets S { {}, X, S - X, S }"
 | 
| 633 | by (intro antisym) auto | |
| 47694 | 634 | with sigma_sets_eq show ?thesis by simp | 
| 42984 | 635 | qed | 
| 636 | ||
| 42863 | 637 | lemma restricted_sigma: | 
| 47694 | 638 | assumes S: "S \<in> sigma_sets \<Omega> M" and M: "M \<subseteq> Pow \<Omega>" | 
| 639 | shows "algebra.restricted_space (sigma_sets \<Omega> M) S = | |
| 640 | sigma_sets S (algebra.restricted_space M S)" | |
| 42863 | 641 | proof - | 
| 642 | from S sigma_sets_into_sp[OF M] | |
| 47694 | 643 | have "S \<in> sigma_sets \<Omega> M" "S \<subseteq> \<Omega>" by auto | 
| 42863 | 644 | from sigma_sets_Int[OF this] | 
| 47694 | 645 | show ?thesis by simp | 
| 42863 | 646 | qed | 
| 647 | ||
| 42987 | 648 | lemma sigma_sets_vimage_commute: | 
| 47694 | 649 | assumes X: "X \<in> \<Omega> \<rightarrow> \<Omega>'" | 
| 650 |   shows "{X -` A \<inter> \<Omega> |A. A \<in> sigma_sets \<Omega>' M'}
 | |
| 651 |        = sigma_sets \<Omega> {X -` A \<inter> \<Omega> |A. A \<in> M'}" (is "?L = ?R")
 | |
| 42987 | 652 | proof | 
| 653 | show "?L \<subseteq> ?R" | |
| 654 | proof clarify | |
| 47694 | 655 | fix A assume "A \<in> sigma_sets \<Omega>' M'" | 
| 656 | then show "X -` A \<inter> \<Omega> \<in> ?R" | |
| 42987 | 657 | proof induct | 
| 658 | case Empty then show ?case | |
| 659 | by (auto intro!: sigma_sets.Empty) | |
| 660 | next | |
| 661 | case (Compl B) | |
| 47694 | 662 | have [simp]: "X -` (\<Omega>' - B) \<inter> \<Omega> = \<Omega> - (X -` B \<inter> \<Omega>)" | 
| 42987 | 663 | by (auto simp add: funcset_mem [OF X]) | 
| 664 | with Compl show ?case | |
| 665 | by (auto intro!: sigma_sets.Compl) | |
| 666 | next | |
| 667 | case (Union F) | |
| 668 | then show ?case | |
| 669 | by (auto simp add: vimage_UN UN_extend_simps(4) simp del: UN_simps | |
| 670 | intro!: sigma_sets.Union) | |
| 47694 | 671 | qed auto | 
| 42987 | 672 | qed | 
| 673 | show "?R \<subseteq> ?L" | |
| 674 | proof clarify | |
| 675 | fix A assume "A \<in> ?R" | |
| 47694 | 676 | then show "\<exists>B. A = X -` B \<inter> \<Omega> \<and> B \<in> sigma_sets \<Omega>' M'" | 
| 42987 | 677 | proof induct | 
| 678 | case (Basic B) then show ?case by auto | |
| 679 | next | |
| 680 | case Empty then show ?case | |
| 47694 | 681 |         by (auto intro!: sigma_sets.Empty exI[of _ "{}"])
 | 
| 42987 | 682 | next | 
| 683 | case (Compl B) | |
| 47694 | 684 | then obtain A where A: "B = X -` A \<inter> \<Omega>" "A \<in> sigma_sets \<Omega>' M'" by auto | 
| 685 | then have [simp]: "\<Omega> - B = X -` (\<Omega>' - A) \<inter> \<Omega>" | |
| 42987 | 686 | by (auto simp add: funcset_mem [OF X]) | 
| 687 | with A(2) show ?case | |
| 47694 | 688 | by (auto intro: sigma_sets.Compl) | 
| 42987 | 689 | next | 
| 690 | case (Union F) | |
| 47694 | 691 | then have "\<forall>i. \<exists>B. F i = X -` B \<inter> \<Omega> \<and> B \<in> sigma_sets \<Omega>' M'" by auto | 
| 42987 | 692 | from choice[OF this] guess A .. note A = this | 
| 693 | with A show ?case | |
| 47694 | 694 | by (auto simp: vimage_UN[symmetric] intro: sigma_sets.Union) | 
| 42987 | 695 | qed | 
| 696 | qed | |
| 697 | qed | |
| 698 | ||
| 38656 | 699 | section "Disjoint families" | 
| 700 | ||
| 701 | definition | |
| 702 | disjoint_family_on where | |
| 703 |   "disjoint_family_on A S \<longleftrightarrow> (\<forall>m\<in>S. \<forall>n\<in>S. m \<noteq> n \<longrightarrow> A m \<inter> A n = {})"
 | |
| 704 | ||
| 705 | abbreviation | |
| 706 | "disjoint_family A \<equiv> disjoint_family_on A UNIV" | |
| 707 | ||
| 708 | lemma range_subsetD: "range f \<subseteq> B \<Longrightarrow> f i \<in> B" | |
| 709 | by blast | |
| 710 | ||
| 711 | lemma Int_Diff_disjoint: "A \<inter> B \<inter> (A - B) = {}"
 | |
| 712 | by blast | |
| 713 | ||
| 714 | lemma Int_Diff_Un: "A \<inter> B \<union> (A - B) = A" | |
| 715 | by blast | |
| 716 | ||
| 717 | lemma disjoint_family_subset: | |
| 718 | "disjoint_family A \<Longrightarrow> (!!x. B x \<subseteq> A x) \<Longrightarrow> disjoint_family B" | |
| 719 | by (force simp add: disjoint_family_on_def) | |
| 720 | ||
| 40859 | 721 | lemma disjoint_family_on_bisimulation: | 
| 722 | assumes "disjoint_family_on f S" | |
| 723 |   and "\<And>n m. n \<in> S \<Longrightarrow> m \<in> S \<Longrightarrow> n \<noteq> m \<Longrightarrow> f n \<inter> f m = {} \<Longrightarrow> g n \<inter> g m = {}"
 | |
| 724 | shows "disjoint_family_on g S" | |
| 725 | using assms unfolding disjoint_family_on_def by auto | |
| 726 | ||
| 38656 | 727 | lemma disjoint_family_on_mono: | 
| 728 | "A \<subseteq> B \<Longrightarrow> disjoint_family_on f B \<Longrightarrow> disjoint_family_on f A" | |
| 729 | unfolding disjoint_family_on_def by auto | |
| 730 | ||
| 731 | lemma disjoint_family_Suc: | |
| 732 | assumes Suc: "!!n. A n \<subseteq> A (Suc n)" | |
| 733 | shows "disjoint_family (\<lambda>i. A (Suc i) - A i)" | |
| 734 | proof - | |
| 735 |   {
 | |
| 736 | fix m | |
| 737 | have "!!n. A n \<subseteq> A (m+n)" | |
| 738 | proof (induct m) | |
| 739 | case 0 show ?case by simp | |
| 740 | next | |
| 741 | case (Suc m) thus ?case | |
| 742 | by (metis Suc_eq_plus1 assms nat_add_commute nat_add_left_commute subset_trans) | |
| 743 | qed | |
| 744 | } | |
| 745 | hence "!!m n. m < n \<Longrightarrow> A m \<subseteq> A n" | |
| 746 | by (metis add_commute le_add_diff_inverse nat_less_le) | |
| 747 | thus ?thesis | |
| 748 | by (auto simp add: disjoint_family_on_def) | |
| 749 | (metis insert_absorb insert_subset le_SucE le_antisym not_leE) | |
| 750 | qed | |
| 751 | ||
| 39092 | 752 | lemma setsum_indicator_disjoint_family: | 
| 753 | fixes f :: "'d \<Rightarrow> 'e::semiring_1" | |
| 754 | assumes d: "disjoint_family_on A P" and "x \<in> A j" and "finite P" and "j \<in> P" | |
| 755 | shows "(\<Sum>i\<in>P. f i * indicator (A i) x) = f j" | |
| 756 | proof - | |
| 757 |   have "P \<inter> {i. x \<in> A i} = {j}"
 | |
| 758 | using d `x \<in> A j` `j \<in> P` unfolding disjoint_family_on_def | |
| 759 | by auto | |
| 760 | thus ?thesis | |
| 761 | unfolding indicator_def | |
| 762 | by (simp add: if_distrib setsum_cases[OF `finite P`]) | |
| 763 | qed | |
| 764 | ||
| 38656 | 765 | definition disjointed :: "(nat \<Rightarrow> 'a set) \<Rightarrow> nat \<Rightarrow> 'a set " | 
| 766 |   where "disjointed A n = A n - (\<Union>i\<in>{0..<n}. A i)"
 | |
| 767 | ||
| 768 | lemma finite_UN_disjointed_eq: "(\<Union>i\<in>{0..<n}. disjointed A i) = (\<Union>i\<in>{0..<n}. A i)"
 | |
| 769 | proof (induct n) | |
| 770 | case 0 show ?case by simp | |
| 771 | next | |
| 772 | case (Suc n) | |
| 773 | thus ?case by (simp add: atLeastLessThanSuc disjointed_def) | |
| 774 | qed | |
| 775 | ||
| 776 | lemma UN_disjointed_eq: "(\<Union>i. disjointed A i) = (\<Union>i. A i)" | |
| 777 | apply (rule UN_finite2_eq [where k=0]) | |
| 778 | apply (simp add: finite_UN_disjointed_eq) | |
| 779 | done | |
| 780 | ||
| 781 | lemma less_disjoint_disjointed: "m<n \<Longrightarrow> disjointed A m \<inter> disjointed A n = {}"
 | |
| 782 | by (auto simp add: disjointed_def) | |
| 783 | ||
| 784 | lemma disjoint_family_disjointed: "disjoint_family (disjointed A)" | |
| 785 | by (simp add: disjoint_family_on_def) | |
| 786 | (metis neq_iff Int_commute less_disjoint_disjointed) | |
| 787 | ||
| 788 | lemma disjointed_subset: "disjointed A n \<subseteq> A n" | |
| 789 | by (auto simp add: disjointed_def) | |
| 790 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 791 | lemma (in ring_of_sets) UNION_in_sets: | 
| 38656 | 792 | fixes A:: "nat \<Rightarrow> 'a set" | 
| 47694 | 793 | assumes A: "range A \<subseteq> M" | 
| 794 |   shows  "(\<Union>i\<in>{0..<n}. A i) \<in> M"
 | |
| 38656 | 795 | proof (induct n) | 
| 796 | case 0 show ?case by simp | |
| 797 | next | |
| 798 | case (Suc n) | |
| 799 | thus ?case | |
| 800 | by (simp add: atLeastLessThanSuc) (metis A Un UNIV_I image_subset_iff) | |
| 801 | qed | |
| 802 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 803 | lemma (in ring_of_sets) range_disjointed_sets: | 
| 47694 | 804 | assumes A: "range A \<subseteq> M" | 
| 805 | shows "range (disjointed A) \<subseteq> M" | |
| 38656 | 806 | proof (auto simp add: disjointed_def) | 
| 807 | fix n | |
| 47694 | 808 |   show "A n - (\<Union>i\<in>{0..<n}. A i) \<in> M" using UNION_in_sets
 | 
| 38656 | 809 | by (metis A Diff UNIV_I image_subset_iff) | 
| 810 | qed | |
| 811 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 812 | lemma (in algebra) range_disjointed_sets': | 
| 47694 | 813 | "range A \<subseteq> M \<Longrightarrow> range (disjointed A) \<subseteq> M" | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 814 | using range_disjointed_sets . | 
| 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 815 | |
| 42145 | 816 | lemma disjointed_0[simp]: "disjointed A 0 = A 0" | 
| 817 | by (simp add: disjointed_def) | |
| 818 | ||
| 819 | lemma incseq_Un: | |
| 820 | "incseq A \<Longrightarrow> (\<Union>i\<le>n. A i) = A n" | |
| 821 | unfolding incseq_def by auto | |
| 822 | ||
| 823 | lemma disjointed_incseq: | |
| 824 | "incseq A \<Longrightarrow> disjointed A (Suc n) = A (Suc n) - A n" | |
| 825 | using incseq_Un[of A] | |
| 826 | by (simp add: disjointed_def atLeastLessThanSuc_atLeastAtMost atLeast0AtMost) | |
| 827 | ||
| 38656 | 828 | lemma sigma_algebra_disjoint_iff: | 
| 47694 | 829 | "sigma_algebra \<Omega> M \<longleftrightarrow> algebra \<Omega> M \<and> | 
| 830 | (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M)" | |
| 38656 | 831 | proof (auto simp add: sigma_algebra_iff) | 
| 832 | fix A :: "nat \<Rightarrow> 'a set" | |
| 47694 | 833 | assume M: "algebra \<Omega> M" | 
| 834 | and A: "range A \<subseteq> M" | |
| 835 | and UnA: "\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M" | |
| 836 | hence "range (disjointed A) \<subseteq> M \<longrightarrow> | |
| 38656 | 837 | disjoint_family (disjointed A) \<longrightarrow> | 
| 47694 | 838 | (\<Union>i. disjointed A i) \<in> M" by blast | 
| 839 | hence "(\<Union>i. disjointed A i) \<in> M" | |
| 840 | by (simp add: algebra.range_disjointed_sets'[of \<Omega>] M A disjoint_family_disjointed) | |
| 841 | thus "(\<Union>i::nat. A i) \<in> M" by (simp add: UN_disjointed_eq) | |
| 842 | qed | |
| 843 | ||
| 47762 | 844 | lemma disjoint_family_on_disjoint_image: | 
| 845 | "disjoint_family_on A I \<Longrightarrow> disjoint (A ` I)" | |
| 846 | unfolding disjoint_family_on_def disjoint_def by force | |
| 847 | ||
| 848 | lemma disjoint_image_disjoint_family_on: | |
| 849 | assumes d: "disjoint (A ` I)" and i: "inj_on A I" | |
| 850 | shows "disjoint_family_on A I" | |
| 851 | unfolding disjoint_family_on_def | |
| 852 | proof (intro ballI impI) | |
| 853 | fix n m assume nm: "m \<in> I" "n \<in> I" and "n \<noteq> m" | |
| 854 |   with i[THEN inj_onD, of n m] show "A n \<inter> A m = {}"
 | |
| 855 | by (intro disjointD[OF d]) auto | |
| 856 | qed | |
| 857 | ||
| 858 | section {* Ring generated by a semiring *}
 | |
| 859 | ||
| 860 | definition (in semiring_of_sets) | |
| 861 |   "generated_ring = { \<Union>C | C. C \<subseteq> M \<and> finite C \<and> disjoint C }"
 | |
| 862 | ||
| 863 | lemma (in semiring_of_sets) generated_ringE[elim?]: | |
| 864 | assumes "a \<in> generated_ring" | |
| 865 | obtains C where "finite C" "disjoint C" "C \<subseteq> M" "a = \<Union>C" | |
| 866 | using assms unfolding generated_ring_def by auto | |
| 867 | ||
| 868 | lemma (in semiring_of_sets) generated_ringI[intro?]: | |
| 869 | assumes "finite C" "disjoint C" "C \<subseteq> M" "a = \<Union>C" | |
| 870 | shows "a \<in> generated_ring" | |
| 871 | using assms unfolding generated_ring_def by auto | |
| 872 | ||
| 873 | lemma (in semiring_of_sets) generated_ringI_Basic: | |
| 874 | "A \<in> M \<Longrightarrow> A \<in> generated_ring" | |
| 875 |   by (rule generated_ringI[of "{A}"]) (auto simp: disjoint_def)
 | |
| 876 | ||
| 877 | lemma (in semiring_of_sets) generated_ring_disjoint_Un[intro]: | |
| 878 | assumes a: "a \<in> generated_ring" and b: "b \<in> generated_ring" | |
| 879 |   and "a \<inter> b = {}"
 | |
| 880 | shows "a \<union> b \<in> generated_ring" | |
| 881 | proof - | |
| 882 | from a guess Ca .. note Ca = this | |
| 883 | from b guess Cb .. note Cb = this | |
| 884 | show ?thesis | |
| 885 | proof | |
| 886 | show "disjoint (Ca \<union> Cb)" | |
| 887 |       using `a \<inter> b = {}` Ca Cb by (auto intro!: disjoint_union)
 | |
| 888 | qed (insert Ca Cb, auto) | |
| 889 | qed | |
| 890 | ||
| 891 | lemma (in semiring_of_sets) generated_ring_empty: "{} \<in> generated_ring"
 | |
| 892 | by (auto simp: generated_ring_def disjoint_def) | |
| 893 | ||
| 894 | lemma (in semiring_of_sets) generated_ring_disjoint_Union: | |
| 895 | assumes "finite A" shows "A \<subseteq> generated_ring \<Longrightarrow> disjoint A \<Longrightarrow> \<Union>A \<in> generated_ring" | |
| 896 | using assms by (induct A) (auto simp: disjoint_def intro!: generated_ring_disjoint_Un generated_ring_empty) | |
| 897 | ||
| 898 | lemma (in semiring_of_sets) generated_ring_disjoint_UNION: | |
| 899 | "finite I \<Longrightarrow> disjoint (A ` I) \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> A i \<in> generated_ring) \<Longrightarrow> UNION I A \<in> generated_ring" | |
| 900 | unfolding SUP_def by (intro generated_ring_disjoint_Union) auto | |
| 901 | ||
| 902 | lemma (in semiring_of_sets) generated_ring_Int: | |
| 903 | assumes a: "a \<in> generated_ring" and b: "b \<in> generated_ring" | |
| 904 | shows "a \<inter> b \<in> generated_ring" | |
| 905 | proof - | |
| 906 | from a guess Ca .. note Ca = this | |
| 907 | from b guess Cb .. note Cb = this | |
| 908 | def C \<equiv> "(\<lambda>(a,b). a \<inter> b)` (Ca\<times>Cb)" | |
| 909 | show ?thesis | |
| 910 | proof | |
| 911 | show "disjoint C" | |
| 912 | proof (simp add: disjoint_def C_def, intro ballI impI) | |
| 913 | fix a1 b1 a2 b2 assume sets: "a1 \<in> Ca" "b1 \<in> Cb" "a2 \<in> Ca" "b2 \<in> Cb" | |
| 914 | assume "a1 \<inter> b1 \<noteq> a2 \<inter> b2" | |
| 915 | then have "a1 \<noteq> a2 \<or> b1 \<noteq> b2" by auto | |
| 916 |       then show "(a1 \<inter> b1) \<inter> (a2 \<inter> b2) = {}"
 | |
| 917 | proof | |
| 918 | assume "a1 \<noteq> a2" | |
| 919 |         with sets Ca have "a1 \<inter> a2 = {}"
 | |
| 920 | by (auto simp: disjoint_def) | |
| 921 | then show ?thesis by auto | |
| 922 | next | |
| 923 | assume "b1 \<noteq> b2" | |
| 924 |         with sets Cb have "b1 \<inter> b2 = {}"
 | |
| 925 | by (auto simp: disjoint_def) | |
| 926 | then show ?thesis by auto | |
| 927 | qed | |
| 928 | qed | |
| 929 | qed (insert Ca Cb, auto simp: C_def) | |
| 930 | qed | |
| 931 | ||
| 932 | lemma (in semiring_of_sets) generated_ring_Inter: | |
| 933 |   assumes "finite A" "A \<noteq> {}" shows "A \<subseteq> generated_ring \<Longrightarrow> \<Inter>A \<in> generated_ring"
 | |
| 934 | using assms by (induct A rule: finite_ne_induct) (auto intro: generated_ring_Int) | |
| 935 | ||
| 936 | lemma (in semiring_of_sets) generated_ring_INTER: | |
| 937 |   "finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> A i \<in> generated_ring) \<Longrightarrow> INTER I A \<in> generated_ring"
 | |
| 938 | unfolding INF_def by (intro generated_ring_Inter) auto | |
| 939 | ||
| 940 | lemma (in semiring_of_sets) generating_ring: | |
| 941 | "ring_of_sets \<Omega> generated_ring" | |
| 942 | proof (rule ring_of_setsI) | |
| 943 | let ?R = generated_ring | |
| 944 | show "?R \<subseteq> Pow \<Omega>" | |
| 945 | using sets_into_space by (auto simp: generated_ring_def generated_ring_empty) | |
| 946 |   show "{} \<in> ?R" by (rule generated_ring_empty)
 | |
| 947 | ||
| 948 |   { fix a assume a: "a \<in> ?R" then guess Ca .. note Ca = this
 | |
| 949 | fix b assume b: "b \<in> ?R" then guess Cb .. note Cb = this | |
| 950 | ||
| 951 | show "a - b \<in> ?R" | |
| 952 | proof cases | |
| 953 |       assume "Cb = {}" with Cb `a \<in> ?R` show ?thesis
 | |
| 954 | by simp | |
| 955 | next | |
| 956 |       assume "Cb \<noteq> {}"
 | |
| 957 | with Ca Cb have "a - b = (\<Union>a'\<in>Ca. \<Inter>b'\<in>Cb. a' - b')" by auto | |
| 958 | also have "\<dots> \<in> ?R" | |
| 959 | proof (intro generated_ring_INTER generated_ring_disjoint_UNION) | |
| 960 | fix a b assume "a \<in> Ca" "b \<in> Cb" | |
| 961 | with Ca Cb Diff_cover[of a b] show "a - b \<in> ?R" | |
| 962 | by (auto simp add: generated_ring_def) | |
| 963 | next | |
| 964 | show "disjoint ((\<lambda>a'. \<Inter>b'\<in>Cb. a' - b')`Ca)" | |
| 965 |           using Ca by (auto simp add: disjoint_def `Cb \<noteq> {}`)
 | |
| 966 | next | |
| 967 |         show "finite Ca" "finite Cb" "Cb \<noteq> {}" by fact+
 | |
| 968 | qed | |
| 969 | finally show "a - b \<in> ?R" . | |
| 970 | qed } | |
| 971 | note Diff = this | |
| 972 | ||
| 973 | fix a b assume sets: "a \<in> ?R" "b \<in> ?R" | |
| 974 | have "a \<union> b = (a - b) \<union> (a \<inter> b) \<union> (b - a)" by auto | |
| 975 | also have "\<dots> \<in> ?R" | |
| 976 | by (intro sets generated_ring_disjoint_Un generated_ring_Int Diff) auto | |
| 977 | finally show "a \<union> b \<in> ?R" . | |
| 978 | qed | |
| 979 | ||
| 980 | lemma (in semiring_of_sets) sigma_sets_generated_ring_eq: "sigma_sets \<Omega> generated_ring = sigma_sets \<Omega> M" | |
| 981 | proof | |
| 982 | interpret M: sigma_algebra \<Omega> "sigma_sets \<Omega> M" | |
| 983 | using space_closed by (rule sigma_algebra_sigma_sets) | |
| 984 | show "sigma_sets \<Omega> generated_ring \<subseteq> sigma_sets \<Omega> M" | |
| 985 | by (blast intro!: sigma_sets_mono elim: generated_ringE) | |
| 986 | qed (auto intro!: generated_ringI_Basic sigma_sets_mono) | |
| 987 | ||
| 47694 | 988 | section {* Measure type *}
 | 
| 989 | ||
| 990 | definition positive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> bool" where
 | |
| 991 |   "positive M \<mu> \<longleftrightarrow> \<mu> {} = 0 \<and> (\<forall>A\<in>M. 0 \<le> \<mu> A)"
 | |
| 992 | ||
| 993 | definition countably_additive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> bool" where
 | |
| 994 | "countably_additive M f \<longleftrightarrow> (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> | |
| 995 | (\<Sum>i. f (A i)) = f (\<Union>i. A i))" | |
| 996 | ||
| 997 | definition measure_space :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> bool" where
 | |
| 998 | "measure_space \<Omega> A \<mu> \<longleftrightarrow> sigma_algebra \<Omega> A \<and> positive A \<mu> \<and> countably_additive A \<mu>" | |
| 999 | ||
| 49834 | 1000 | typedef 'a measure = "{(\<Omega>::'a set, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu> }"
 | 
| 47694 | 1001 | proof | 
| 1002 |   have "sigma_algebra UNIV {{}, UNIV}"
 | |
| 47762 | 1003 | by (auto simp: sigma_algebra_iff2) | 
| 47694 | 1004 |   then show "(UNIV, {{}, UNIV}, \<lambda>A. 0) \<in> {(\<Omega>, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu>} "
 | 
| 1005 | by (auto simp: measure_space_def positive_def countably_additive_def) | |
| 1006 | qed | |
| 1007 | ||
| 1008 | definition space :: "'a measure \<Rightarrow> 'a set" where | |
| 1009 | "space M = fst (Rep_measure M)" | |
| 1010 | ||
| 1011 | definition sets :: "'a measure \<Rightarrow> 'a set set" where | |
| 1012 | "sets M = fst (snd (Rep_measure M))" | |
| 1013 | ||
| 1014 | definition emeasure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ereal" where | |
| 1015 | "emeasure M = snd (snd (Rep_measure M))" | |
| 1016 | ||
| 1017 | definition measure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> real" where | |
| 1018 | "measure M A = real (emeasure M A)" | |
| 1019 | ||
| 1020 | declare [[coercion sets]] | |
| 1021 | ||
| 1022 | declare [[coercion measure]] | |
| 1023 | ||
| 1024 | declare [[coercion emeasure]] | |
| 1025 | ||
| 1026 | lemma measure_space: "measure_space (space M) (sets M) (emeasure M)" | |
| 1027 | by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse) | |
| 1028 | ||
| 1029 | interpretation sigma_algebra "space M" "sets M" for M :: "'a measure" | |
| 1030 | using measure_space[of M] by (auto simp: measure_space_def) | |
| 1031 | ||
| 1032 | definition measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
 | |
| 1033 | "measure_of \<Omega> A \<mu> = Abs_measure (\<Omega>, sigma_sets \<Omega> A, | |
| 1034 | \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)" | |
| 1035 | ||
| 1036 | abbreviation "sigma \<Omega> A \<equiv> measure_of \<Omega> A (\<lambda>x. 0)" | |
| 1037 | ||
| 1038 | lemma measure_space_0: "A \<subseteq> Pow \<Omega> \<Longrightarrow> measure_space \<Omega> (sigma_sets \<Omega> A) (\<lambda>x. 0)" | |
| 1039 | unfolding measure_space_def | |
| 1040 | by (auto intro!: sigma_algebra_sigma_sets simp: positive_def countably_additive_def) | |
| 1041 | ||
| 1042 | lemma (in ring_of_sets) positive_cong_eq: | |
| 1043 | "(\<And>a. a \<in> M \<Longrightarrow> \<mu>' a = \<mu> a) \<Longrightarrow> positive M \<mu>' = positive M \<mu>" | |
| 1044 | by (auto simp add: positive_def) | |
| 1045 | ||
| 1046 | lemma (in sigma_algebra) countably_additive_eq: | |
| 1047 | "(\<And>a. a \<in> M \<Longrightarrow> \<mu>' a = \<mu> a) \<Longrightarrow> countably_additive M \<mu>' = countably_additive M \<mu>" | |
| 1048 | unfolding countably_additive_def | |
| 1049 | by (intro arg_cong[where f=All] ext) (auto simp add: countably_additive_def subset_eq) | |
| 1050 | ||
| 1051 | lemma measure_space_eq: | |
| 1052 | assumes closed: "A \<subseteq> Pow \<Omega>" and eq: "\<And>a. a \<in> sigma_sets \<Omega> A \<Longrightarrow> \<mu> a = \<mu>' a" | |
| 1053 | shows "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>'" | |
| 1054 | proof - | |
| 1055 | interpret sigma_algebra \<Omega> "sigma_sets \<Omega> A" using closed by (rule sigma_algebra_sigma_sets) | |
| 1056 | from positive_cong_eq[OF eq, of "\<lambda>i. i"] countably_additive_eq[OF eq, of "\<lambda>i. i"] show ?thesis | |
| 1057 | by (auto simp: measure_space_def) | |
| 1058 | qed | |
| 1059 | ||
| 1060 | lemma measure_of_eq: | |
| 1061 | assumes closed: "A \<subseteq> Pow \<Omega>" and eq: "(\<And>a. a \<in> sigma_sets \<Omega> A \<Longrightarrow> \<mu> a = \<mu>' a)" | |
| 1062 | shows "measure_of \<Omega> A \<mu> = measure_of \<Omega> A \<mu>'" | |
| 1063 | proof - | |
| 1064 | have "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>'" | |
| 1065 | using assms by (rule measure_space_eq) | |
| 1066 | with eq show ?thesis | |
| 1067 | by (auto simp add: measure_of_def intro!: arg_cong[where f=Abs_measure]) | |
| 1068 | qed | |
| 1069 | ||
| 1070 | lemma | |
| 1071 | assumes A: "A \<subseteq> Pow \<Omega>" | |
| 1072 | shows sets_measure_of[simp]: "sets (measure_of \<Omega> A \<mu>) = sigma_sets \<Omega> A" (is ?sets) | |
| 1073 | and space_measure_of[simp]: "space (measure_of \<Omega> A \<mu>) = \<Omega>" (is ?space) | |
| 1074 | proof - | |
| 1075 | have "?sets \<and> ?space" | |
| 1076 | proof cases | |
| 1077 | assume "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>" | |
| 1078 | moreover have "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A) | |
| 1079 | (\<lambda>a. if a \<in> sigma_sets \<Omega> A then \<mu> a else 0)" | |
| 1080 | using A by (rule measure_space_eq) auto | |
| 1081 | ultimately show "?sets \<and> ?space" | |
| 1082 | by (auto simp: Abs_measure_inverse measure_of_def sets_def space_def) | |
| 1083 | next | |
| 1084 | assume "\<not> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>" | |
| 1085 | with A show "?sets \<and> ?space" | |
| 1086 | by (auto simp: Abs_measure_inverse measure_of_def sets_def space_def measure_space_0) | |
| 1087 | qed | |
| 1088 | then show ?sets ?space by auto | |
| 1089 | qed | |
| 1090 | ||
| 1091 | lemma (in sigma_algebra) sets_measure_of_eq[simp]: | |
| 1092 | "sets (measure_of \<Omega> M \<mu>) = M" | |
| 1093 | using space_closed by (auto intro!: sigma_sets_eq) | |
| 1094 | ||
| 1095 | lemma (in sigma_algebra) space_measure_of_eq[simp]: | |
| 1096 | "space (measure_of \<Omega> M \<mu>) = \<Omega>" | |
| 1097 | using space_closed by (auto intro!: sigma_sets_eq) | |
| 1098 | ||
| 1099 | lemma measure_of_subset: | |
| 1100 | "M \<subseteq> Pow \<Omega> \<Longrightarrow> M' \<subseteq> M \<Longrightarrow> sets (measure_of \<Omega> M' \<mu>) \<subseteq> sets (measure_of \<Omega> M \<mu>')" | |
| 1101 | by (auto intro!: sigma_sets_subseteq) | |
| 1102 | ||
| 47756 | 1103 | lemma in_measure_of[intro, simp]: "M \<subseteq> Pow \<Omega> \<Longrightarrow> A \<in> M \<Longrightarrow> A \<in> sets (measure_of \<Omega> M \<mu>)" | 
| 47694 | 1104 | by auto | 
| 1105 | ||
| 1106 | section {* Constructing simple @{typ "'a measure"} *}
 | |
| 1107 | ||
| 1108 | lemma emeasure_measure_of: | |
| 1109 | assumes M: "M = measure_of \<Omega> A \<mu>" | |
| 1110 | assumes ms: "A \<subseteq> Pow \<Omega>" "positive (sets M) \<mu>" "countably_additive (sets M) \<mu>" | |
| 1111 | assumes X: "X \<in> sets M" | |
| 1112 | shows "emeasure M X = \<mu> X" | |
| 1113 | proof - | |
| 1114 | interpret sigma_algebra \<Omega> "sigma_sets \<Omega> A" by (rule sigma_algebra_sigma_sets) fact | |
| 1115 | have "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>" | |
| 1116 | using ms M by (simp add: measure_space_def sigma_algebra_sigma_sets) | |
| 1117 | moreover have "measure_space \<Omega> (sigma_sets \<Omega> A) (\<lambda>a. if a \<in> sigma_sets \<Omega> A then \<mu> a else 0) | |
| 1118 | = measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>" | |
| 1119 | using ms(1) by (rule measure_space_eq) auto | |
| 1120 | moreover have "X \<in> sigma_sets \<Omega> A" | |
| 1121 | using X M ms by simp | |
| 1122 | ultimately show ?thesis | |
| 1123 | unfolding emeasure_def measure_of_def M | |
| 1124 | by (subst Abs_measure_inverse) (simp_all add: sigma_sets_eq) | |
| 1125 | qed | |
| 1126 | ||
| 1127 | lemma emeasure_measure_of_sigma: | |
| 1128 | assumes ms: "sigma_algebra \<Omega> M" "positive M \<mu>" "countably_additive M \<mu>" | |
| 1129 | assumes A: "A \<in> M" | |
| 1130 | shows "emeasure (measure_of \<Omega> M \<mu>) A = \<mu> A" | |
| 1131 | proof - | |
| 1132 | interpret sigma_algebra \<Omega> M by fact | |
| 1133 | have "measure_space \<Omega> (sigma_sets \<Omega> M) \<mu>" | |
| 1134 | using ms sigma_sets_eq by (simp add: measure_space_def) | |
| 1135 | moreover have "measure_space \<Omega> (sigma_sets \<Omega> M) (\<lambda>a. if a \<in> sigma_sets \<Omega> M then \<mu> a else 0) | |
| 1136 | = measure_space \<Omega> (sigma_sets \<Omega> M) \<mu>" | |
| 1137 | using space_closed by (rule measure_space_eq) auto | |
| 1138 | ultimately show ?thesis using A | |
| 1139 | unfolding emeasure_def measure_of_def | |
| 1140 | by (subst Abs_measure_inverse) (simp_all add: sigma_sets_eq) | |
| 1141 | qed | |
| 1142 | ||
| 1143 | lemma measure_cases[cases type: measure]: | |
| 1144 | obtains (measure) \<Omega> A \<mu> where "x = Abs_measure (\<Omega>, A, \<mu>)" "\<forall>a\<in>-A. \<mu> a = 0" "measure_space \<Omega> A \<mu>" | |
| 1145 | by atomize_elim (cases x, auto) | |
| 1146 | ||
| 1147 | lemma sets_eq_imp_space_eq: | |
| 1148 | "sets M = sets M' \<Longrightarrow> space M = space M'" | |
| 1149 | using top[of M] top[of M'] space_closed[of M] space_closed[of M'] | |
| 1150 | by blast | |
| 1151 | ||
| 1152 | lemma emeasure_notin_sets: "A \<notin> sets M \<Longrightarrow> emeasure M A = 0" | |
| 1153 | by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def) | |
| 1154 | ||
| 1155 | lemma measure_notin_sets: "A \<notin> sets M \<Longrightarrow> measure M A = 0" | |
| 1156 | by (simp add: measure_def emeasure_notin_sets) | |
| 1157 | ||
| 1158 | lemma measure_eqI: | |
| 1159 | fixes M N :: "'a measure" | |
| 1160 | assumes "sets M = sets N" and eq: "\<And>A. A \<in> sets M \<Longrightarrow> emeasure M A = emeasure N A" | |
| 1161 | shows "M = N" | |
| 1162 | proof (cases M N rule: measure_cases[case_product measure_cases]) | |
| 1163 | case (measure_measure \<Omega> A \<mu> \<Omega>' A' \<mu>') | |
| 1164 | interpret M: sigma_algebra \<Omega> A using measure_measure by (auto simp: measure_space_def) | |
| 1165 | interpret N: sigma_algebra \<Omega>' A' using measure_measure by (auto simp: measure_space_def) | |
| 1166 | have "A = sets M" "A' = sets N" | |
| 1167 | using measure_measure by (simp_all add: sets_def Abs_measure_inverse) | |
| 1168 | with `sets M = sets N` have "A = A'" by simp | |
| 1169 | moreover with M.top N.top M.space_closed N.space_closed have "\<Omega> = \<Omega>'" by auto | |
| 1170 |   moreover { fix B have "\<mu> B = \<mu>' B"
 | |
| 1171 | proof cases | |
| 1172 | assume "B \<in> A" | |
| 1173 | with eq `A = sets M` have "emeasure M B = emeasure N B" by simp | |
| 1174 | with measure_measure show "\<mu> B = \<mu>' B" | |
| 1175 | by (simp add: emeasure_def Abs_measure_inverse) | |
| 1176 | next | |
| 1177 | assume "B \<notin> A" | |
| 1178 | with `A = sets M` `A' = sets N` `A = A'` have "B \<notin> sets M" "B \<notin> sets N" | |
| 1179 | by auto | |
| 1180 | then have "emeasure M B = 0" "emeasure N B = 0" | |
| 1181 | by (simp_all add: emeasure_notin_sets) | |
| 1182 | with measure_measure show "\<mu> B = \<mu>' B" | |
| 1183 | by (simp add: emeasure_def Abs_measure_inverse) | |
| 1184 | qed } | |
| 1185 | then have "\<mu> = \<mu>'" by auto | |
| 1186 | ultimately show "M = N" | |
| 1187 | by (simp add: measure_measure) | |
| 38656 | 1188 | qed | 
| 1189 | ||
| 47694 | 1190 | lemma emeasure_sigma: "A \<subseteq> Pow \<Omega> \<Longrightarrow> emeasure (sigma \<Omega> A) = (\<lambda>_. 0)" | 
| 1191 | using measure_space_0[of A \<Omega>] | |
| 1192 | by (simp add: measure_of_def emeasure_def Abs_measure_inverse) | |
| 1193 | ||
| 1194 | lemma sigma_eqI: | |
| 1195 | assumes [simp]: "M \<subseteq> Pow \<Omega>" "N \<subseteq> Pow \<Omega>" "sigma_sets \<Omega> M = sigma_sets \<Omega> N" | |
| 1196 | shows "sigma \<Omega> M = sigma \<Omega> N" | |
| 1197 | by (rule measure_eqI) (simp_all add: emeasure_sigma) | |
| 1198 | ||
| 1199 | section {* Measurable functions *}
 | |
| 1200 | ||
| 1201 | definition measurable :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) set" where
 | |
| 1202 |   "measurable A B = {f \<in> space A -> space B. \<forall>y \<in> sets B. f -` y \<inter> space A \<in> sets A}"
 | |
| 1203 | ||
| 1204 | lemma measurable_space: | |
| 1205 | "f \<in> measurable M A \<Longrightarrow> x \<in> space M \<Longrightarrow> f x \<in> space A" | |
| 1206 | unfolding measurable_def by auto | |
| 1207 | ||
| 1208 | lemma measurable_sets: | |
| 1209 | "f \<in> measurable M A \<Longrightarrow> S \<in> sets A \<Longrightarrow> f -` S \<inter> space M \<in> sets M" | |
| 1210 | unfolding measurable_def by auto | |
| 1211 | ||
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1212 | lemma measurable_sets_Collect: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1213 |   assumes f: "f \<in> measurable M N" and P: "{x\<in>space N. P x} \<in> sets N" shows "{x\<in>space M. P (f x)} \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1214 | proof - | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1215 |   have "f -` {x \<in> space N. P x} \<inter> space M = {x\<in>space M. P (f x)}"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1216 | using measurable_space[OF f] by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1217 | with measurable_sets[OF f P] show ?thesis | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1218 | by simp | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1219 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1220 | |
| 47694 | 1221 | lemma measurable_sigma_sets: | 
| 1222 | assumes B: "sets N = sigma_sets \<Omega> A" "A \<subseteq> Pow \<Omega>" | |
| 1223 | and f: "f \<in> space M \<rightarrow> \<Omega>" | |
| 1224 | and ba: "\<And>y. y \<in> A \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M" | |
| 1225 | shows "f \<in> measurable M N" | |
| 1226 | proof - | |
| 1227 | interpret A: sigma_algebra \<Omega> "sigma_sets \<Omega> A" using B(2) by (rule sigma_algebra_sigma_sets) | |
| 1228 | from B top[of N] A.top space_closed[of N] A.space_closed have \<Omega>: "\<Omega> = space N" by force | |
| 1229 | ||
| 1230 |   { fix X assume "X \<in> sigma_sets \<Omega> A"
 | |
| 1231 | then have "f -` X \<inter> space M \<in> sets M \<and> X \<subseteq> \<Omega>" | |
| 1232 | proof induct | |
| 1233 | case (Basic a) then show ?case | |
| 1234 | by (auto simp add: ba) (metis B(2) subsetD PowD) | |
| 1235 | next | |
| 1236 | case (Compl a) | |
| 1237 | have [simp]: "f -` \<Omega> \<inter> space M = space M" | |
| 1238 | by (auto simp add: funcset_mem [OF f]) | |
| 1239 | then show ?case | |
| 1240 | by (auto simp add: vimage_Diff Diff_Int_distrib2 compl_sets Compl) | |
| 1241 | next | |
| 1242 | case (Union a) | |
| 1243 | then show ?case | |
| 1244 | by (simp add: vimage_UN, simp only: UN_extend_simps(4)) blast | |
| 1245 | qed auto } | |
| 1246 | with f show ?thesis | |
| 1247 | by (auto simp add: measurable_def B \<Omega>) | |
| 1248 | qed | |
| 1249 | ||
| 1250 | lemma measurable_measure_of: | |
| 1251 | assumes B: "N \<subseteq> Pow \<Omega>" | |
| 1252 | and f: "f \<in> space M \<rightarrow> \<Omega>" | |
| 1253 | and ba: "\<And>y. y \<in> N \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M" | |
| 1254 | shows "f \<in> measurable M (measure_of \<Omega> N \<mu>)" | |
| 1255 | proof - | |
| 1256 | have "sets (measure_of \<Omega> N \<mu>) = sigma_sets \<Omega> N" | |
| 1257 | using B by (rule sets_measure_of) | |
| 1258 | from this assms show ?thesis by (rule measurable_sigma_sets) | |
| 1259 | qed | |
| 1260 | ||
| 1261 | lemma measurable_iff_measure_of: | |
| 1262 | assumes "N \<subseteq> Pow \<Omega>" "f \<in> space M \<rightarrow> \<Omega>" | |
| 1263 | shows "f \<in> measurable M (measure_of \<Omega> N \<mu>) \<longleftrightarrow> (\<forall>A\<in>N. f -` A \<inter> space M \<in> sets M)" | |
| 47756 | 1264 | by (metis assms in_measure_of measurable_measure_of assms measurable_sets) | 
| 47694 | 1265 | |
| 50003 | 1266 | lemma measurable_cong_sets: | 
| 1267 | assumes sets: "sets M = sets M'" "sets N = sets N'" | |
| 1268 | shows "measurable M N = measurable M' N'" | |
| 1269 | using sets[THEN sets_eq_imp_space_eq] sets by (simp add: measurable_def) | |
| 1270 | ||
| 47694 | 1271 | lemma measurable_cong: | 
| 1272 | assumes "\<And> w. w \<in> space M \<Longrightarrow> f w = g w" | |
| 1273 | shows "f \<in> measurable M M' \<longleftrightarrow> g \<in> measurable M M'" | |
| 1274 | unfolding measurable_def using assms | |
| 1275 | by (simp cong: vimage_inter_cong Pi_cong) | |
| 1276 | ||
| 1277 | lemma measurable_eqI: | |
| 1278 | "\<lbrakk> space m1 = space m1' ; space m2 = space m2' ; | |
| 1279 | sets m1 = sets m1' ; sets m2 = sets m2' \<rbrakk> | |
| 1280 | \<Longrightarrow> measurable m1 m2 = measurable m1' m2'" | |
| 1281 | by (simp add: measurable_def sigma_algebra_iff2) | |
| 1282 | ||
| 50003 | 1283 | lemma measurable_compose: | 
| 1284 | assumes f: "f \<in> measurable M N" and g: "g \<in> measurable N L" | |
| 1285 | shows "(\<lambda>x. g (f x)) \<in> measurable M L" | |
| 1286 | proof - | |
| 1287 | have "\<And>A. (\<lambda>x. g (f x)) -` A \<inter> space M = f -` (g -` A \<inter> space N) \<inter> space M" | |
| 1288 | using measurable_space[OF f] by auto | |
| 1289 | with measurable_space[OF f] measurable_space[OF g] show ?thesis | |
| 1290 | by (auto intro: measurable_sets[OF f] measurable_sets[OF g] | |
| 1291 | simp del: vimage_Int simp add: measurable_def) | |
| 1292 | qed | |
| 1293 | ||
| 1294 | lemma measurable_comp: | |
| 1295 | "f \<in> measurable M N \<Longrightarrow> g \<in> measurable N L \<Longrightarrow> g \<circ> f \<in> measurable M L" | |
| 1296 | using measurable_compose[of f M N g L] by (simp add: comp_def) | |
| 1297 | ||
| 1298 | lemma measurable_const: | |
| 47694 | 1299 | "c \<in> space M' \<Longrightarrow> (\<lambda>x. c) \<in> measurable M M'" | 
| 1300 | by (auto simp add: measurable_def) | |
| 1301 | ||
| 1302 | lemma measurable_If: | |
| 1303 | assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'" | |
| 1304 |   assumes P: "{x\<in>space M. P x} \<in> sets M"
 | |
| 1305 | shows "(\<lambda>x. if P x then f x else g x) \<in> measurable M M'" | |
| 1306 | unfolding measurable_def | |
| 1307 | proof safe | |
| 1308 | fix x assume "x \<in> space M" | |
| 1309 | thus "(if P x then f x else g x) \<in> space M'" | |
| 1310 | using measure unfolding measurable_def by auto | |
| 1311 | next | |
| 1312 | fix A assume "A \<in> sets M'" | |
| 1313 | hence *: "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M = | |
| 1314 |     ((f -` A \<inter> space M) \<inter> {x\<in>space M. P x}) \<union>
 | |
| 1315 |     ((g -` A \<inter> space M) \<inter> (space M - {x\<in>space M. P x}))"
 | |
| 1316 | using measure unfolding measurable_def by (auto split: split_if_asm) | |
| 1317 | show "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M \<in> sets M" | |
| 1318 | using `A \<in> sets M'` measure P unfolding * measurable_def | |
| 1319 | by (auto intro!: Un) | |
| 1320 | qed | |
| 1321 | ||
| 1322 | lemma measurable_If_set: | |
| 1323 | assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'" | |
| 49773 
16907431e477
tuned measurable_If; moved countably_additive equalities to Measure_Space; tuned proofs
 hoelzl parents: 
47762diff
changeset | 1324 | assumes P: "A \<inter> space M \<in> sets M" | 
| 47694 | 1325 | shows "(\<lambda>x. if x \<in> A then f x else g x) \<in> measurable M M'" | 
| 1326 | proof (rule measurable_If[OF measure]) | |
| 49773 
16907431e477
tuned measurable_If; moved countably_additive equalities to Measure_Space; tuned proofs
 hoelzl parents: 
47762diff
changeset | 1327 |   have "{x \<in> space M. x \<in> A} = A \<inter> space M" by auto
 | 
| 
16907431e477
tuned measurable_If; moved countably_additive equalities to Measure_Space; tuned proofs
 hoelzl parents: 
47762diff
changeset | 1328 |   thus "{x \<in> space M. x \<in> A} \<in> sets M" using `A \<inter> space M \<in> sets M` by auto
 | 
| 47694 | 1329 | qed | 
| 1330 | ||
| 50003 | 1331 | lemma measurable_ident: "id \<in> measurable M M" | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1332 | by (auto simp add: measurable_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1333 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1334 | lemma measurable_ident_sets: | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1335 | assumes eq: "sets M = sets M'" shows "(\<lambda>x. x) \<in> measurable M M'" | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1336 | using measurable_ident[of M] | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1337 | unfolding id_def measurable_def eq sets_eq_imp_space_eq[OF eq] . | 
| 49782 | 1338 | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1339 | lemma sets_Least: | 
| 47694 | 1340 |   assumes meas: "\<And>i::nat. {x\<in>space M. P i x} \<in> M"
 | 
| 1341 | shows "(\<lambda>x. LEAST j. P j x) -` A \<inter> space M \<in> sets M" | |
| 1342 | proof - | |
| 1343 |   { fix i have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M \<in> sets M"
 | |
| 1344 | proof cases | |
| 1345 | assume i: "(LEAST j. False) = i" | |
| 1346 |       have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
 | |
| 1347 |         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x})) \<union> (space M - (\<Union>i. {x\<in>space M. P i x}))"
 | |
| 1348 | by (simp add: set_eq_iff, safe) | |
| 1349 | (insert i, auto dest: Least_le intro: LeastI intro!: Least_equality) | |
| 1350 | with meas show ?thesis | |
| 1351 | by (auto intro!: Int) | |
| 1352 | next | |
| 1353 | assume i: "(LEAST j. False) \<noteq> i" | |
| 1354 |       then have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
 | |
| 1355 |         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x}))"
 | |
| 1356 | proof (simp add: set_eq_iff, safe) | |
| 1357 | fix x assume neq: "(LEAST j. False) \<noteq> (LEAST j. P j x)" | |
| 1358 | have "\<exists>j. P j x" | |
| 1359 | by (rule ccontr) (insert neq, auto) | |
| 1360 | then show "P (LEAST j. P j x) x" by (rule LeastI_ex) | |
| 1361 | qed (auto dest: Least_le intro!: Least_equality) | |
| 1362 | with meas show ?thesis | |
| 1363 | by auto | |
| 1364 | qed } | |
| 1365 |   then have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) \<in> sets M"
 | |
| 1366 | by (intro countable_UN) auto | |
| 1367 |   moreover have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) =
 | |
| 1368 | (\<lambda>x. LEAST j. P j x) -` A \<inter> space M" by auto | |
| 1369 | ultimately show ?thesis by auto | |
| 1370 | qed | |
| 1371 | ||
| 1372 | lemma measurable_strong: | |
| 1373 | fixes f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c" | |
| 1374 | assumes f: "f \<in> measurable a b" and g: "g \<in> space b \<rightarrow> space c" | |
| 1375 | and t: "f ` (space a) \<subseteq> t" | |
| 1376 | and cb: "\<And>s. s \<in> sets c \<Longrightarrow> (g -` s) \<inter> t \<in> sets b" | |
| 1377 | shows "(g o f) \<in> measurable a c" | |
| 1378 | proof - | |
| 1379 | have fab: "f \<in> (space a -> space b)" | |
| 1380 | and ba: "\<And>y. y \<in> sets b \<Longrightarrow> (f -` y) \<inter> (space a) \<in> sets a" using f | |
| 1381 | by (auto simp add: measurable_def) | |
| 1382 | have eq: "\<And>y. f -` g -` y \<inter> space a = f -` (g -` y \<inter> t) \<inter> space a" using t | |
| 1383 | by force | |
| 1384 | show ?thesis | |
| 1385 | apply (auto simp add: measurable_def vimage_compose) | |
| 1386 | apply (metis funcset_mem fab g) | |
| 1387 | apply (subst eq, metis ba cb) | |
| 1388 | done | |
| 1389 | qed | |
| 1390 | ||
| 1391 | lemma measurable_mono1: | |
| 1392 | "M' \<subseteq> Pow \<Omega> \<Longrightarrow> M \<subseteq> M' \<Longrightarrow> | |
| 1393 | measurable (measure_of \<Omega> M \<mu>) N \<subseteq> measurable (measure_of \<Omega> M' \<mu>') N" | |
| 1394 | using measure_of_subset[of M' \<Omega> M] by (auto simp add: measurable_def) | |
| 1395 | ||
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1396 | section {* Counting space *}
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1397 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1398 | definition count_space :: "'a set \<Rightarrow> 'a measure" where | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1399 | "count_space \<Omega> = measure_of \<Omega> (Pow \<Omega>) (\<lambda>A. if finite A then ereal (card A) else \<infinity>)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1400 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1401 | lemma | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1402 | shows space_count_space[simp]: "space (count_space \<Omega>) = \<Omega>" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1403 | and sets_count_space[simp]: "sets (count_space \<Omega>) = Pow \<Omega>" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1404 | using sigma_sets_into_sp[of "Pow \<Omega>" \<Omega>] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1405 | by (auto simp: count_space_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1406 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1407 | lemma measurable_count_space_eq1[simp]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1408 | "f \<in> measurable (count_space A) M \<longleftrightarrow> f \<in> A \<rightarrow> space M" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1409 | unfolding measurable_def by simp | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1410 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1411 | lemma measurable_count_space_eq2: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1412 | assumes "finite A" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1413 |   shows "f \<in> measurable M (count_space A) \<longleftrightarrow> (f \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M))"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1414 | proof - | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1415 |   { fix X assume "X \<subseteq> A" "f \<in> space M \<rightarrow> A"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1416 |     with `finite A` have "f -` X \<inter> space M = (\<Union>a\<in>X. f -` {a} \<inter> space M)" "finite X"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1417 | by (auto dest: finite_subset) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1418 |     moreover assume "\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1419 | ultimately have "f -` X \<inter> space M \<in> sets M" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1420 | using `X \<subseteq> A` by (auto intro!: finite_UN simp del: UN_simps) } | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1421 | then show ?thesis | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1422 | unfolding measurable_def by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1423 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1424 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1425 | lemma measurable_compose_countable: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1426 | assumes f: "\<And>i::'i::countable. (\<lambda>x. f i x) \<in> measurable M N" and g: "g \<in> measurable M (count_space UNIV)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1427 | shows "(\<lambda>x. f (g x) x) \<in> measurable M N" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1428 | unfolding measurable_def | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1429 | proof safe | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1430 | fix x assume "x \<in> space M" then show "f (g x) x \<in> space N" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1431 | using f[THEN measurable_space] g[THEN measurable_space] by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1432 | next | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1433 | fix A assume A: "A \<in> sets N" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1434 |   have "(\<lambda>x. f (g x) x) -` A \<inter> space M = (\<Union>i. (g -` {i} \<inter> space M) \<inter> (f i -` A \<inter> space M))"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1435 | by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1436 | also have "\<dots> \<in> sets M" using f[THEN measurable_sets, OF A] g[THEN measurable_sets] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1437 | by (auto intro!: countable_UN measurable_sets) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1438 | finally show "(\<lambda>x. f (g x) x) -` A \<inter> space M \<in> sets M" . | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1439 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1440 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1441 | subsection {* Measurable method *}
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1442 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1443 | lemma (in algebra) sets_Collect_finite_All: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1444 |   assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1445 |   shows "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} \<in> M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1446 | proof - | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1447 |   have "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} = (if S = {} then \<Omega> else \<Inter>i\<in>S. {x\<in>\<Omega>. P i x})"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1448 | by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1449 | with assms show ?thesis by (auto intro!: sets_Collect_finite_All') | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1450 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1451 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1452 | abbreviation "pred M P \<equiv> P \<in> measurable M (count_space (UNIV::bool set))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1453 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1454 | lemma pred_def: "pred M P \<longleftrightarrow> {x\<in>space M. P x} \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1455 | proof | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1456 | assume "pred M P" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1457 |   then have "P -` {True} \<inter> space M \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1458 | by (auto simp: measurable_count_space_eq2) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1459 |   also have "P -` {True} \<inter> space M = {x\<in>space M. P x}" by auto
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1460 |   finally show "{x\<in>space M. P x} \<in> sets M" .
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1461 | next | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1462 |   assume P: "{x\<in>space M. P x} \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1463 | moreover | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1464 |   { fix X
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1465 | have "X \<in> Pow (UNIV :: bool set)" by simp | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1466 |     then have "P -` X \<inter> space M = {x\<in>space M. ((X = {True} \<longrightarrow> P x) \<and> (X = {False} \<longrightarrow> \<not> P x) \<and> X \<noteq> {})}"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1467 | unfolding UNIV_bool Pow_insert Pow_empty by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1468 | then have "P -` X \<inter> space M \<in> sets M" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1469 | by (auto intro!: sets_Collect_neg sets_Collect_imp sets_Collect_conj sets_Collect_const P) } | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1470 | then show "pred M P" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1471 | by (auto simp: measurable_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1472 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1473 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1474 | lemma pred_sets1: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> f \<in> measurable N M \<Longrightarrow> pred N (\<lambda>x. P (f x))"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1475 | by (rule measurable_compose[where f=f and N=M]) (auto simp: pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1476 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1477 | lemma pred_sets2: "A \<in> sets N \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> pred M (\<lambda>x. f x \<in> A)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1478 | by (rule measurable_compose[where f=f and N=N]) (auto simp: pred_def Int_def[symmetric]) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1479 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1480 | lemma measurable_count_space_const: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1481 | "(\<lambda>x. c) \<in> measurable M (count_space UNIV)" | 
| 50003 | 1482 | by (simp add: measurable_const) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1483 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1484 | lemma measurable_count_space: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1485 | "f \<in> measurable (count_space A) (count_space UNIV)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1486 | by simp | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1487 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1488 | lemma measurable_compose_rev: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1489 | assumes f: "f \<in> measurable L N" and g: "g \<in> measurable M L" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1490 | shows "(\<lambda>x. f (g x)) \<in> measurable M N" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1491 | using measurable_compose[OF g f] . | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1492 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1493 | ML {*
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1494 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1495 | structure Measurable = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1496 | struct | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1497 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1498 | datatype level = Concrete | Generic; | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1499 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1500 | structure Data = Generic_Data | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1501 | ( | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1502 |   type T = {
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1503 | concrete_thms : thm Item_Net.T, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1504 | generic_thms : thm Item_Net.T, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1505 | dest_thms : thm Item_Net.T, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1506 | app_thms : thm Item_Net.T } | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1507 |   val empty = {
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1508 | concrete_thms = Thm.full_rules, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1509 | generic_thms = Thm.full_rules, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1510 | dest_thms = Thm.full_rules, | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1511 | app_thms = Thm.full_rules}; | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1512 | val extend = I; | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1513 |   fun merge (t1, t2) = {
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1514 | concrete_thms = Item_Net.merge (#concrete_thms t1, #concrete_thms t2), | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1515 | generic_thms = Item_Net.merge (#generic_thms t1, #generic_thms t2), | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1516 | dest_thms = Item_Net.merge (#dest_thms t1, #dest_thms t2), | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1517 | app_thms = Item_Net.merge (#app_thms t1, #app_thms t2) }; | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1518 | ); | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1519 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1520 | val debug = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1521 |   Attrib.setup_config_bool @{binding measurable_debug} (K false)
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1522 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1523 | val backtrack = | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1524 |   Attrib.setup_config_int @{binding measurable_backtrack} (K 20)
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1525 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1526 | val split = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1527 |   Attrib.setup_config_bool @{binding measurable_split} (K true)
 | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1528 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1529 | fun TAKE n tac = Seq.take n o tac | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1530 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1531 | fun get lv = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1532 | rev o Item_Net.content o (case lv of Concrete => #concrete_thms | Generic => #generic_thms) o | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1533 | Data.get o Context.Proof; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1534 | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1535 | fun get_all ctxt = get Concrete ctxt @ get Generic ctxt; | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1536 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1537 | fun map_data f1 f2 f3 f4 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1538 |   {generic_thms = t1,    concrete_thms = t2,    dest_thms = t3,    app_thms = t4} =
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1539 |   {generic_thms = f1 t1, concrete_thms = f2 t2, dest_thms = f3 t3, app_thms = f4 t4 }
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1540 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1541 | fun map_concrete_thms f = map_data f I I I | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1542 | fun map_generic_thms f = map_data I f I I | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1543 | fun map_dest_thms f = map_data I I f I | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1544 | fun map_app_thms f = map_data I I I f | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1545 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1546 | fun update f lv = Data.map (case lv of Concrete => map_concrete_thms f | Generic => map_generic_thms f); | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1547 | fun add thms' = update (fold Item_Net.update thms'); | 
| 50003 | 1548 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1549 | val get_dest = Item_Net.content o #dest_thms o Data.get; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1550 | val add_dest = Data.map o map_dest_thms o Item_Net.update; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1551 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1552 | val get_app = Item_Net.content o #app_thms o Data.get; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1553 | val add_app = Data.map o map_app_thms o Item_Net.update; | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1554 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1555 | fun is_too_generic thm = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1556 | let | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1557 | val concl = concl_of thm | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1558 | val concl' = HOLogic.dest_Trueprop concl handle TERM _ => concl | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1559 | in is_Var (head_of concl') end | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1560 | |
| 50003 | 1561 | fun import_theorem ctxt thm = if is_too_generic thm then [] else | 
| 1562 | [thm] @ map_filter (try (fn th' => thm RS th')) (get_dest ctxt); | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1563 | |
| 50003 | 1564 | fun add_thm (raw, lv) thm ctxt = add (if raw then [thm] else import_theorem ctxt thm) lv ctxt; | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1565 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1566 | fun debug_tac ctxt msg f = if Config.get ctxt debug then print_tac (msg ()) THEN f else f | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1567 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1568 | fun nth_hol_goal thm i = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1569 | HOLogic.dest_Trueprop (Logic.strip_imp_concl (strip_all_body (nth (prems_of thm) (i - 1)))) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1570 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1571 | fun dest_measurable_fun t = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1572 | (case t of | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1573 |     (Const (@{const_name "Set.member"}, _) $ f $ (Const (@{const_name "measurable"}, _) $ _ $ _)) => f
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1574 |   | _ => raise (TERM ("not a measurability predicate", [t])))
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1575 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1576 | fun is_cond_formula n thm = if length (prems_of thm) < n then false else | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1577 | (case nth_hol_goal thm n of | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1578 |     (Const (@{const_name "Set.member"}, _) $ _ $ (Const (@{const_name "sets"}, _) $ _)) => false
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1579 |   | (Const (@{const_name "Set.member"}, _) $ _ $ (Const (@{const_name "measurable"}, _) $ _ $ _)) => false
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1580 | | _ => true) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1581 | handle TERM _ => true; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1582 | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1583 | fun indep (Bound i) t b = i < b orelse t <= i | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1584 | | indep (f $ t) top bot = indep f top bot andalso indep t top bot | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1585 | | indep (Abs (_,_,t)) top bot = indep t (top + 1) (bot + 1) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1586 | | indep _ _ _ = true; | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1587 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1588 | fun cnt_prefixes ctxt (Abs (n, T, t)) = let | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1589 |       fun is_countable t = Type.of_sort (Proof_Context.tsig_of ctxt) (t, @{sort countable})
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1590 | fun cnt_walk (Abs (ns, T, t)) Ts = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1591 | map (fn (t', t'') => (Abs (ns, T, t'), t'')) (cnt_walk t (T::Ts)) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1592 | | cnt_walk (f $ g) Ts = let | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1593 | val n = length Ts - 1 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1594 | in | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1595 | map (fn (f', t) => (f' $ g, t)) (cnt_walk f Ts) @ | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1596 | map (fn (g', t) => (f $ g', t)) (cnt_walk g Ts) @ | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1597 | (if is_countable (type_of1 (Ts, g)) andalso loose_bvar1 (g, n) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1598 | andalso indep g n 0 andalso g <> Bound n | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1599 | then [(f $ Bound (n + 1), incr_boundvars (~ n) g)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1600 | else []) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1601 | end | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1602 | | cnt_walk _ _ = [] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1603 | in map (fn (t1, t2) => let | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1604 | val T1 = type_of1 ([T], t2) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1605 | val T2 = type_of1 ([T], t) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1606 | in ([SOME (Abs (n, T1, Abs (n, T, t1))), NONE, NONE, SOME (Abs (n, T, t2))], | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1607 | [SOME T1, SOME T, SOME T2]) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1608 | end) (cnt_walk t [T]) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1609 | end | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1610 | | cnt_prefixes _ _ = [] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1611 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1612 | val split_countable_tac = | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1613 |   Subgoal.FOCUS (fn {context = ctxt, ...} => SUBGOAL (fn (t, i) =>
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1614 | let | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1615 | val f = dest_measurable_fun (HOLogic.dest_Trueprop t) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1616 | fun cert f = map (Option.map (f (Proof_Context.theory_of ctxt))) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1617 | fun inst t (ts, Ts) = Drule.instantiate' (cert ctyp_of Ts) (cert cterm_of ts) t | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1618 |       val cps = cnt_prefixes ctxt f |> map (inst @{thm measurable_compose_countable})
 | 
| 50096 | 1619 | in if null cps then no_tac else debug_tac ctxt (K "split countable fun") (resolve_tac cps i) end | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1620 | handle TERM _ => no_tac) 1) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1621 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1622 | fun measurable_tac' ctxt ss facts = let | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1623 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1624 | val imported_thms = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1625 | (maps (import_theorem (Context.Proof ctxt) o Simplifier.norm_hhf) facts) @ get_all ctxt | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1626 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1627 | fun debug_facts msg () = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1628 | msg ^ " + " ^ Pretty.str_of (Pretty.list "[" "]" | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1629 | (map (Syntax.pretty_term ctxt o prop_of) (maps (import_theorem (Context.Proof ctxt)) facts))); | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1630 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1631 | val splitter = if Config.get ctxt split then split_countable_tac ctxt else K no_tac | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1632 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1633 | val split_app_tac = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1634 |       Subgoal.FOCUS (fn {context = ctxt, ...} => SUBGOAL (fn (t, i) =>
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1635 | let | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1636 | fun app_prefixes (Abs (n, T, (f $ g))) = let | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1637 | val ps = (if not (loose_bvar1 (g, 0)) then [(f, g)] else []) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1638 | in map (fn (f, c) => (Abs (n, T, f), c, T, type_of c, type_of1 ([T], f $ c))) ps end | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1639 | | app_prefixes _ = [] | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1640 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1641 | fun dest_app (Abs (_, T, t as ((f $ Bound 0) $ c))) = (f, c, T, type_of c, type_of1 ([T], t)) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1642 |             | dest_app t = raise (TERM ("not a measurability predicate of an application", [t]))
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1643 | val thy = Proof_Context.theory_of ctxt | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1644 | val tunify = Sign.typ_unify thy | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1645 | val thms = map | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1646 | (fn thm => (thm, dest_app (dest_measurable_fun (HOLogic.dest_Trueprop (concl_of thm))))) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1647 | (get_app (Context.Proof ctxt)) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1648 | fun cert f = map (fn (t, t') => (f thy t, f thy t')) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1649 | fun inst (f, c, T, Tc, Tf) (thm, (thmf, thmc, thmT, thmTc, thmTf)) = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1650 | let | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1651 | val inst = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1652 | (Vartab.empty, ~1) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1653 | |> tunify (T, thmT) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1654 | |> tunify (Tf, thmTf) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1655 | |> tunify (Tc, thmTc) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1656 | |> Vartab.dest o fst | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1657 | val subst = subst_TVars (map (apsnd snd) inst) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1658 | in | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1659 | Thm.instantiate (cert ctyp_of (map (fn (n, (s, T)) => (TVar (n, s), T)) inst), | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1660 | cert cterm_of [(subst thmf, f), (subst thmc, c)]) thm | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1661 | end | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1662 | val cps = map_product inst (app_prefixes (dest_measurable_fun (HOLogic.dest_Trueprop t))) thms | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1663 | in if null cps then no_tac | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1664 |             else debug_tac ctxt (K ("split app fun")) (resolve_tac cps i)
 | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1665 | ORELSE debug_tac ctxt (fn () => "FAILED") no_tac end | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1666 | handle TERM t => debug_tac ctxt (fn () => "TERM " ^ fst t ^ Pretty.str_of (Pretty.list "[" "]" (map (Syntax.pretty_term ctxt) (snd t)))) no_tac | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1667 | handle Type.TUNIFY => debug_tac ctxt (fn () => "TUNIFY") no_tac) 1) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1668 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1669 | val depth_measurable_tac = REPEAT | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1670 | (COND (is_cond_formula 1) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1671 | (debug_tac ctxt (K "simp") (SOLVED' (asm_full_simp_tac ss) 1)) | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1672 | ((debug_tac ctxt (K "single") (resolve_tac imported_thms 1)) APPEND | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1673 | (split_app_tac ctxt 1) APPEND | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1674 | (splitter 1))) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1675 | |
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1676 | in debug_tac ctxt (debug_facts "start") depth_measurable_tac end; | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1677 | |
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1678 | fun measurable_tac ctxt facts = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1679 | TAKE (Config.get ctxt backtrack) (measurable_tac' ctxt (simpset_of ctxt) facts); | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1680 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1681 | val attr_add = Thm.declaration_attribute o add_thm; | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1682 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1683 | val attr : attribute context_parser = | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1684 | Scan.lift (Scan.optional (Args.parens (Scan.optional (Args.$$$ "raw" >> K true) false -- | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1685 | Scan.optional (Args.$$$ "generic" >> K Generic) Concrete)) (false, Concrete) >> attr_add); | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1686 | |
| 50003 | 1687 | val dest_attr : attribute context_parser = | 
| 1688 | Scan.lift (Scan.succeed (Thm.declaration_attribute add_dest)); | |
| 1689 | ||
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1690 | val app_attr : attribute context_parser = | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1691 | Scan.lift (Scan.succeed (Thm.declaration_attribute add_app)); | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1692 | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1693 | val method : (Proof.context -> Method.method) context_parser = | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1694 | Scan.lift (Scan.succeed (fn ctxt => METHOD (fn facts => measurable_tac ctxt facts))); | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1695 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1696 | fun simproc ss redex = let | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1697 | val ctxt = Simplifier.the_context ss; | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1698 | val t = HOLogic.mk_Trueprop (term_of redex); | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1699 |     fun tac {context = ctxt, ...} =
 | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1700 | SOLVE (measurable_tac' ctxt ss (Simplifier.prems_of ss)); | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1701 |   in try (fn () => Goal.prove ctxt [] [] t tac RS @{thm Eq_TrueI}) () end;
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1702 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1703 | end | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1704 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1705 | *} | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1706 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1707 | attribute_setup measurable = {* Measurable.attr *} "declaration of measurability theorems"
 | 
| 50003 | 1708 | attribute_setup measurable_dest = {* Measurable.dest_attr *} "add dest rule for measurability prover"
 | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1709 | attribute_setup measurable_app = {* Measurable.app_attr *} "add application rule for measurability prover"
 | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1710 | method_setup measurable = {* Measurable.method *} "measurability prover"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1711 | simproc_setup measurable ("A \<in> sets M" | "f \<in> measurable M N") = {* K Measurable.simproc *}
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1712 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1713 | declare | 
| 50003 | 1714 | measurable_compose_rev[measurable_dest] | 
| 1715 | pred_sets1[measurable_dest] | |
| 1716 | pred_sets2[measurable_dest] | |
| 1717 | sets_into_space[measurable_dest] | |
| 1718 | ||
| 1719 | declare | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1720 | top[measurable] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1721 | empty_sets[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1722 | Un[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1723 | Diff[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1724 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1725 | declare | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1726 | measurable_count_space[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1727 | measurable_ident[measurable (raw)] | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1728 | measurable_ident_sets[measurable (raw)] | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1729 | measurable_const[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1730 | measurable_If[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1731 | measurable_comp[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1732 | measurable_sets[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1733 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1734 | lemma predE[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1735 |   "pred M P \<Longrightarrow> {x\<in>space M. P x} \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1736 | unfolding pred_def . | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1737 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1738 | lemma pred_intros_imp'[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1739 | "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<longrightarrow> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1740 | by (cases K) auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1741 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1742 | lemma pred_intros_conj1'[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1743 | "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<and> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1744 | by (cases K) auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1745 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1746 | lemma pred_intros_conj2'[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1747 | "(K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. P x \<and> K)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1748 | by (cases K) auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1749 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1750 | lemma pred_intros_disj1'[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1751 | "(\<not> K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. K \<or> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1752 | by (cases K) auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1753 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1754 | lemma pred_intros_disj2'[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1755 | "(\<not> K \<Longrightarrow> pred M (\<lambda>x. P x)) \<Longrightarrow> pred M (\<lambda>x. P x \<or> K)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1756 | by (cases K) auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1757 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1758 | lemma pred_intros_logic[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1759 | "pred M (\<lambda>x. x \<in> space M)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1760 | "pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. \<not> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1761 | "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<and> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1762 | "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<longrightarrow> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1763 | "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x \<or> P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1764 | "pred M (\<lambda>x. Q x) \<Longrightarrow> pred M (\<lambda>x. P x) \<Longrightarrow> pred M (\<lambda>x. Q x = P x)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1765 | "pred M (\<lambda>x. f x \<in> UNIV)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1766 |   "pred M (\<lambda>x. f x \<in> {})"
 | 
| 50096 | 1767 |   "pred M (\<lambda>x. P' (f x) x) \<Longrightarrow> pred M (\<lambda>x. f x \<in> {y. P' y x})"
 | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1768 | "pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> - (B x))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1769 | "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) - (B x))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1770 | "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) \<inter> (B x))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1771 | "pred M (\<lambda>x. f x \<in> (A x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (B x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (A x) \<union> (B x))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1772 | "pred M (\<lambda>x. g x (f x) \<in> (X x)) \<Longrightarrow> pred M (\<lambda>x. f x \<in> (g x) -` (X x))" | 
| 50003 | 1773 | by (auto simp: iff_conv_conj_imp pred_def) | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1774 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1775 | lemma pred_intros_countable[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1776 | fixes P :: "'a \<Rightarrow> 'i :: countable \<Rightarrow> bool" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1777 | shows | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1778 | "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1779 | "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1780 | by (auto intro!: sets_Collect_countable_All sets_Collect_countable_Ex simp: pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1781 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1782 | lemma pred_intros_countable_bounded[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1783 | fixes X :: "'i :: countable set" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1784 | shows | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1785 | "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>X. N x i))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1786 | "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>X. N x i))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1787 | "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>X. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1788 | "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>X. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1789 | by (auto simp: Bex_def Ball_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1790 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1791 | lemma pred_intros_finite[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1792 | "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>I. N x i))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1793 | "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>I. N x i))" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1794 | "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>I. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1795 | "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>I. P x i)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1796 | by (auto intro!: sets_Collect_finite_Ex sets_Collect_finite_All simp: iff_conv_conj_imp pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1797 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1798 | lemma countable_Un_Int[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1799 | "(\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Union>i\<in>I. N i) \<in> sets M" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1800 |   "I \<noteq> {} \<Longrightarrow> (\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Inter>i\<in>I. N i) \<in> sets M"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1801 | by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1802 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1803 | declare | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1804 | finite_UN[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1805 | finite_INT[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1806 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1807 | lemma sets_Int_pred[measurable (raw)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1808 | assumes space: "A \<inter> B \<subseteq> space M" and [measurable]: "pred M (\<lambda>x. x \<in> A)" "pred M (\<lambda>x. x \<in> B)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1809 | shows "A \<inter> B \<in> sets M" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1810 | proof - | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1811 |   have "{x\<in>space M. x \<in> A \<inter> B} \<in> sets M" by auto
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1812 |   also have "{x\<in>space M. x \<in> A \<inter> B} = A \<inter> B"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1813 | using space by auto | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1814 | finally show ?thesis . | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1815 | qed | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1816 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1817 | lemma [measurable (raw generic)]: | 
| 50096 | 1818 |   assumes f: "f \<in> measurable M N" and c: "c \<in> space N \<Longrightarrow> {c} \<in> sets N"
 | 
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1819 | shows pred_eq_const1: "pred M (\<lambda>x. f x = c)" | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1820 | and pred_eq_const2: "pred M (\<lambda>x. c = f x)" | 
| 50096 | 1821 | proof - | 
| 1822 | show "pred M (\<lambda>x. f x = c)" | |
| 1823 | proof cases | |
| 1824 | assume "c \<in> space N" | |
| 1825 | with measurable_sets[OF f c] show ?thesis | |
| 1826 | by (auto simp: Int_def conj_commute pred_def) | |
| 1827 | next | |
| 1828 | assume "c \<notin> space N" | |
| 1829 |     with f[THEN measurable_space] have "{x \<in> space M. f x = c} = {}" by auto
 | |
| 1830 | then show ?thesis by (auto simp: pred_def cong: conj_cong) | |
| 1831 | qed | |
| 1832 | then show "pred M (\<lambda>x. c = f x)" | |
| 1833 | by (simp add: eq_commute) | |
| 1834 | qed | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1835 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1836 | lemma pred_le_const[measurable (raw generic)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1837 |   assumes f: "f \<in> measurable M N" and c: "{.. c} \<in> sets N" shows "pred M (\<lambda>x. f x \<le> c)"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1838 | using measurable_sets[OF f c] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1839 | by (auto simp: Int_def conj_commute eq_commute pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1840 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1841 | lemma pred_const_le[measurable (raw generic)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1842 |   assumes f: "f \<in> measurable M N" and c: "{c ..} \<in> sets N" shows "pred M (\<lambda>x. c \<le> f x)"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1843 | using measurable_sets[OF f c] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1844 | by (auto simp: Int_def conj_commute eq_commute pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1845 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1846 | lemma pred_less_const[measurable (raw generic)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1847 |   assumes f: "f \<in> measurable M N" and c: "{..< c} \<in> sets N" shows "pred M (\<lambda>x. f x < c)"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1848 | using measurable_sets[OF f c] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1849 | by (auto simp: Int_def conj_commute eq_commute pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1850 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1851 | lemma pred_const_less[measurable (raw generic)]: | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1852 |   assumes f: "f \<in> measurable M N" and c: "{c <..} \<in> sets N" shows "pred M (\<lambda>x. c < f x)"
 | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1853 | using measurable_sets[OF f c] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1854 | by (auto simp: Int_def conj_commute eq_commute pred_def) | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1855 | |
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1856 | declare | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1857 | Int[measurable (raw)] | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1858 | |
| 50003 | 1859 | lemma pred_in_If[measurable (raw)]: | 
| 50021 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1860 | "(P \<Longrightarrow> pred M (\<lambda>x. x \<in> A x)) \<Longrightarrow> (\<not> P \<Longrightarrow> pred M (\<lambda>x. x \<in> B x)) \<Longrightarrow> | 
| 
d96a3f468203
add support for function application to measurability prover
 hoelzl parents: 
50003diff
changeset | 1861 | pred M (\<lambda>x. x \<in> (if P then A x else B x))" | 
| 50003 | 1862 | by auto | 
| 1863 | ||
| 1864 | lemma sets_range[measurable_dest]: | |
| 1865 | "A ` I \<subseteq> sets M \<Longrightarrow> i \<in> I \<Longrightarrow> A i \<in> sets M" | |
| 1866 | by auto | |
| 1867 | ||
| 1868 | lemma pred_sets_range[measurable_dest]: | |
| 1869 | "A ` I \<subseteq> sets N \<Longrightarrow> i \<in> I \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)" | |
| 1870 | using pred_sets2[OF sets_range] by auto | |
| 1871 | ||
| 1872 | lemma sets_All[measurable_dest]: | |
| 1873 | "\<forall>i. A i \<in> sets (M i) \<Longrightarrow> A i \<in> sets (M i)" | |
| 1874 | by auto | |
| 1875 | ||
| 1876 | lemma pred_sets_All[measurable_dest]: | |
| 1877 | "\<forall>i. A i \<in> sets (N i) \<Longrightarrow> f \<in> measurable M (N i) \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)" | |
| 1878 | using pred_sets2[OF sets_All, of A N f] by auto | |
| 1879 | ||
| 1880 | lemma sets_Ball[measurable_dest]: | |
| 1881 | "\<forall>i\<in>I. A i \<in> sets (M i) \<Longrightarrow> i\<in>I \<Longrightarrow> A i \<in> sets (M i)" | |
| 1882 | by auto | |
| 1883 | ||
| 1884 | lemma pred_sets_Ball[measurable_dest]: | |
| 1885 | "\<forall>i\<in>I. A i \<in> sets (N i) \<Longrightarrow> i\<in>I \<Longrightarrow> f \<in> measurable M (N i) \<Longrightarrow> pred M (\<lambda>x. f x \<in> A i)" | |
| 1886 | using pred_sets2[OF sets_Ball, of _ _ _ f] by auto | |
| 1887 | ||
| 50096 | 1888 | lemma measurable_finite[measurable (raw)]: | 
| 1889 | fixes S :: "'a \<Rightarrow> nat set" | |
| 1890 |   assumes [measurable]: "\<And>i. {x\<in>space M. i \<in> S x} \<in> sets M"
 | |
| 1891 | shows "pred M (\<lambda>x. finite (S x))" | |
| 1892 | unfolding finite_nat_set_iff_bounded by (simp add: Ball_def) | |
| 1893 | ||
| 1894 | lemma measurable_Least[measurable]: | |
| 1895 | assumes [measurable]: "(\<And>i::nat. (\<lambda>x. P i x) \<in> measurable M (count_space UNIV))"q | |
| 1896 | shows "(\<lambda>x. LEAST i. P i x) \<in> measurable M (count_space UNIV)" | |
| 1897 | unfolding measurable_def by (safe intro!: sets_Least) simp_all | |
| 1898 | ||
| 1899 | lemma measurable_count_space_insert[measurable (raw)]: | |
| 1900 | "s \<in> S \<Longrightarrow> A \<in> sets (count_space S) \<Longrightarrow> insert s A \<in> sets (count_space S)" | |
| 1901 | by simp | |
| 1902 | ||
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1903 | hide_const (open) pred | 
| 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49834diff
changeset | 1904 | |
| 47694 | 1905 | subsection {* Extend measure *}
 | 
| 1906 | ||
| 1907 | definition "extend_measure \<Omega> I G \<mu> = | |
| 1908 | (if (\<exists>\<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>') \<and> \<not> (\<forall>i\<in>I. \<mu> i = 0) | |
| 1909 | then measure_of \<Omega> (G`I) (SOME \<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>') | |
| 1910 | else measure_of \<Omega> (G`I) (\<lambda>_. 0))" | |
| 1911 | ||
| 1912 | lemma space_extend_measure: "G ` I \<subseteq> Pow \<Omega> \<Longrightarrow> space (extend_measure \<Omega> I G \<mu>) = \<Omega>" | |
| 1913 | unfolding extend_measure_def by simp | |
| 1914 | ||
| 1915 | lemma sets_extend_measure: "G ` I \<subseteq> Pow \<Omega> \<Longrightarrow> sets (extend_measure \<Omega> I G \<mu>) = sigma_sets \<Omega> (G`I)" | |
| 1916 | unfolding extend_measure_def by simp | |
| 1917 | ||
| 1918 | lemma emeasure_extend_measure: | |
| 1919 | assumes M: "M = extend_measure \<Omega> I G \<mu>" | |
| 1920 | and eq: "\<And>i. i \<in> I \<Longrightarrow> \<mu>' (G i) = \<mu> i" | |
| 1921 | and ms: "G ` I \<subseteq> Pow \<Omega>" "positive (sets M) \<mu>'" "countably_additive (sets M) \<mu>'" | |
| 1922 | and "i \<in> I" | |
| 1923 | shows "emeasure M (G i) = \<mu> i" | |
| 1924 | proof cases | |
| 1925 | assume *: "(\<forall>i\<in>I. \<mu> i = 0)" | |
| 1926 | with M have M_eq: "M = measure_of \<Omega> (G`I) (\<lambda>_. 0)" | |
| 1927 | by (simp add: extend_measure_def) | |
| 1928 | from measure_space_0[OF ms(1)] ms `i\<in>I` | |
| 1929 | have "emeasure M (G i) = 0" | |
| 1930 | by (intro emeasure_measure_of[OF M_eq]) (auto simp add: M measure_space_def sets_extend_measure) | |
| 1931 | with `i\<in>I` * show ?thesis | |
| 1932 | by simp | |
| 1933 | next | |
| 1934 | def P \<equiv> "\<lambda>\<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>'" | |
| 1935 | assume "\<not> (\<forall>i\<in>I. \<mu> i = 0)" | |
| 1936 | moreover | |
| 1937 | have "measure_space (space M) (sets M) \<mu>'" | |
| 1938 | using ms unfolding measure_space_def by auto default | |
| 1939 | with ms eq have "\<exists>\<mu>'. P \<mu>'" | |
| 1940 | unfolding P_def | |
| 1941 | by (intro exI[of _ \<mu>']) (auto simp add: M space_extend_measure sets_extend_measure) | |
| 1942 | ultimately have M_eq: "M = measure_of \<Omega> (G`I) (Eps P)" | |
| 1943 | by (simp add: M extend_measure_def P_def[symmetric]) | |
| 1944 | ||
| 1945 | from `\<exists>\<mu>'. P \<mu>'` have P: "P (Eps P)" by (rule someI_ex) | |
| 1946 | show "emeasure M (G i) = \<mu> i" | |
| 1947 | proof (subst emeasure_measure_of[OF M_eq]) | |
| 1948 | have sets_M: "sets M = sigma_sets \<Omega> (G`I)" | |
| 1949 | using M_eq ms by (auto simp: sets_extend_measure) | |
| 1950 | then show "G i \<in> sets M" using `i \<in> I` by auto | |
| 1951 | show "positive (sets M) (Eps P)" "countably_additive (sets M) (Eps P)" "Eps P (G i) = \<mu> i" | |
| 1952 | using P `i\<in>I` by (auto simp add: sets_M measure_space_def P_def) | |
| 1953 | qed fact | |
| 1954 | qed | |
| 1955 | ||
| 1956 | lemma emeasure_extend_measure_Pair: | |
| 1957 |   assumes M: "M = extend_measure \<Omega> {(i, j). I i j} (\<lambda>(i, j). G i j) (\<lambda>(i, j). \<mu> i j)"
 | |
| 1958 | and eq: "\<And>i j. I i j \<Longrightarrow> \<mu>' (G i j) = \<mu> i j" | |
| 1959 | and ms: "\<And>i j. I i j \<Longrightarrow> G i j \<in> Pow \<Omega>" "positive (sets M) \<mu>'" "countably_additive (sets M) \<mu>'" | |
| 1960 | and "I i j" | |
| 1961 | shows "emeasure M (G i j) = \<mu> i j" | |
| 1962 | using emeasure_extend_measure[OF M _ _ ms(2,3), of "(i,j)"] eq ms(1) `I i j` | |
| 1963 | by (auto simp: subset_eq) | |
| 1964 | ||
| 39090 
a2d38b8b693e
Introduced sigma algebra generated by function preimages.
 hoelzl parents: 
38656diff
changeset | 1965 | subsection {* Sigma algebra generated by function preimages *}
 | 
| 
a2d38b8b693e
Introduced sigma algebra generated by function preimages.
 hoelzl parents: 
38656diff
changeset | 1966 | |
| 47694 | 1967 | definition | 
| 1968 | "vimage_algebra M S f = sigma S ((\<lambda>A. f -` A \<inter> S) ` sets M)" | |
| 39090 
a2d38b8b693e
Introduced sigma algebra generated by function preimages.
 hoelzl parents: 
38656diff
changeset | 1969 | |
| 47694 | 1970 | lemma sigma_algebra_preimages: | 
| 40859 | 1971 | fixes f :: "'x \<Rightarrow> 'a" | 
| 47694 | 1972 | assumes "f \<in> S \<rightarrow> space M" | 
| 1973 | shows "sigma_algebra S ((\<lambda>A. f -` A \<inter> S) ` sets M)" | |
| 1974 | (is "sigma_algebra _ (?F ` sets M)") | |
| 40859 | 1975 | proof (simp add: sigma_algebra_iff2, safe) | 
| 1976 |   show "{} \<in> ?F ` sets M" by blast
 | |
| 1977 | next | |
| 47694 | 1978 | fix A assume "A \<in> sets M" | 
| 1979 | moreover have "S - ?F A = ?F (space M - A)" | |
| 40859 | 1980 | using assms by auto | 
| 47694 | 1981 | ultimately show "S - ?F A \<in> ?F ` sets M" | 
| 40859 | 1982 | by blast | 
| 1983 | next | |
| 47694 | 1984 | fix A :: "nat \<Rightarrow> 'x set" assume *: "range A \<subseteq> ?F ` M" | 
| 1985 | have "\<forall>i. \<exists>b. b \<in> M \<and> A i = ?F b" | |
| 40859 | 1986 | proof safe | 
| 1987 | fix i | |
| 47694 | 1988 | have "A i \<in> ?F ` M" using * by auto | 
| 1989 | then show "\<exists>b. b \<in> M \<and> A i = ?F b" by auto | |
| 40859 | 1990 | qed | 
| 47694 | 1991 | from choice[OF this] obtain b where b: "range b \<subseteq> M" "\<And>i. A i = ?F (b i)" | 
| 40859 | 1992 | by auto | 
| 47694 | 1993 | then have "(\<Union>i. A i) = ?F (\<Union>i. b i)" by auto | 
| 1994 | then show "(\<Union>i. A i) \<in> ?F ` M" using b(1) by blast | |
| 40859 | 1995 | qed | 
| 1996 | ||
| 47694 | 1997 | lemma sets_vimage_algebra[simp]: | 
| 1998 | "f \<in> S \<rightarrow> space M \<Longrightarrow> sets (vimage_algebra M S f) = (\<lambda>A. f -` A \<inter> S) ` sets M" | |
| 1999 | using sigma_algebra.sets_measure_of_eq[OF sigma_algebra_preimages, of f S M] | |
| 2000 | by (simp add: vimage_algebra_def) | |
| 2001 | ||
| 2002 | lemma space_vimage_algebra[simp]: | |
| 2003 | "f \<in> S \<rightarrow> space M \<Longrightarrow> space (vimage_algebra M S f) = S" | |
| 2004 | using sigma_algebra.space_measure_of_eq[OF sigma_algebra_preimages, of f S M] | |
| 2005 | by (simp add: vimage_algebra_def) | |
| 2006 | ||
| 2007 | lemma in_vimage_algebra[simp]: | |
| 2008 | "f \<in> S \<rightarrow> space M \<Longrightarrow> A \<in> sets (vimage_algebra M S f) \<longleftrightarrow> (\<exists>B\<in>sets M. A = f -` B \<inter> S)" | |
| 2009 | by (simp add: image_iff) | |
| 2010 | ||
| 2011 | lemma measurable_vimage_algebra: | |
| 39090 
a2d38b8b693e
Introduced sigma algebra generated by function preimages.
 hoelzl parents: 
38656diff
changeset | 2012 | fixes S :: "'c set" assumes "f \<in> S \<rightarrow> space M" | 
| 47694 | 2013 | shows "f \<in> measurable (vimage_algebra M S f) M" | 
| 2014 | unfolding measurable_def using assms by force | |
| 39090 
a2d38b8b693e
Introduced sigma algebra generated by function preimages.
 hoelzl parents: 
38656diff
changeset | 2015 | |
| 47694 | 2016 | lemma measurable_vimage: | 
| 40859 | 2017 | fixes g :: "'a \<Rightarrow> 'c" and f :: "'d \<Rightarrow> 'a" | 
| 2018 | assumes "g \<in> measurable M M2" "f \<in> S \<rightarrow> space M" | |
| 47694 | 2019 | shows "(\<lambda>x. g (f x)) \<in> measurable (vimage_algebra M S f) M2" | 
| 40859 | 2020 | proof - | 
| 2021 | note measurable_vimage_algebra[OF assms(2)] | |
| 2022 | from measurable_comp[OF this assms(1)] | |
| 2023 | show ?thesis by (simp add: comp_def) | |
| 2024 | qed | |
| 2025 | ||
| 2026 | lemma sigma_sets_vimage: | |
| 2027 | assumes "f \<in> S' \<rightarrow> S" and "A \<subseteq> Pow S" | |
| 2028 | shows "sigma_sets S' ((\<lambda>X. f -` X \<inter> S') ` A) = (\<lambda>X. f -` X \<inter> S') ` sigma_sets S A" | |
| 2029 | proof (intro set_eqI iffI) | |
| 2030 | let ?F = "\<lambda>X. f -` X \<inter> S'" | |
| 2031 | fix X assume "X \<in> sigma_sets S' (?F ` A)" | |
| 2032 | then show "X \<in> ?F ` sigma_sets S A" | |
| 2033 | proof induct | |
| 2034 | case (Basic X) then obtain X' where "X = ?F X'" "X' \<in> A" | |
| 2035 | by auto | |
| 47694 | 2036 | then show ?case by auto | 
| 40859 | 2037 | next | 
| 2038 | case Empty then show ?case | |
| 2039 |       by (auto intro!: image_eqI[of _ _ "{}"] sigma_sets.Empty)
 | |
| 2040 | next | |
| 2041 | case (Compl X) then obtain X' where X: "X = ?F X'" and "X' \<in> sigma_sets S A" | |
| 2042 | by auto | |
| 2043 | then have "S - X' \<in> sigma_sets S A" | |
| 2044 | by (auto intro!: sigma_sets.Compl) | |
| 2045 | then show ?case | |
| 2046 | using X assms by (auto intro!: image_eqI[where x="S - X'"]) | |
| 2047 | next | |
| 2048 | case (Union F) | |
| 2049 | then have "\<forall>i. \<exists>F'. F' \<in> sigma_sets S A \<and> F i = f -` F' \<inter> S'" | |
| 2050 | by (auto simp: image_iff Bex_def) | |
| 2051 | from choice[OF this] obtain F' where | |
| 2052 | "\<And>i. F' i \<in> sigma_sets S A" and "\<And>i. F i = f -` F' i \<inter> S'" | |
| 2053 | by auto | |
| 2054 | then show ?case | |
| 2055 | by (auto intro!: sigma_sets.Union image_eqI[where x="\<Union>i. F' i"]) | |
| 2056 | qed | |
| 2057 | next | |
| 2058 | let ?F = "\<lambda>X. f -` X \<inter> S'" | |
| 2059 | fix X assume "X \<in> ?F ` sigma_sets S A" | |
| 2060 | then obtain X' where "X' \<in> sigma_sets S A" "X = ?F X'" by auto | |
| 2061 | then show "X \<in> sigma_sets S' (?F ` A)" | |
| 2062 | proof (induct arbitrary: X) | |
| 2063 | case Empty then show ?case by (auto intro: sigma_sets.Empty) | |
| 2064 | next | |
| 2065 | case (Compl X') | |
| 2066 | have "S' - (S' - X) \<in> sigma_sets S' (?F ` A)" | |
| 2067 | apply (rule sigma_sets.Compl) | |
| 2068 | using assms by (auto intro!: Compl.hyps simp: Compl.prems) | |
| 2069 | also have "S' - (S' - X) = X" | |
| 2070 | using assms Compl by auto | |
| 2071 | finally show ?case . | |
| 2072 | next | |
| 2073 | case (Union F) | |
| 2074 | have "(\<Union>i. f -` F i \<inter> S') \<in> sigma_sets S' (?F ` A)" | |
| 2075 | by (intro sigma_sets.Union Union.hyps) simp | |
| 2076 | also have "(\<Union>i. f -` F i \<inter> S') = X" | |
| 2077 | using assms Union by auto | |
| 2078 | finally show ?case . | |
| 47694 | 2079 | qed auto | 
| 39092 | 2080 | qed | 
| 2081 | ||
| 38656 | 2082 | subsection {* A Two-Element Series *}
 | 
| 2083 | ||
| 2084 | definition binaryset :: "'a set \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set " | |
| 2085 |   where "binaryset A B = (\<lambda>\<^isup>x. {})(0 := A, Suc 0 := B)"
 | |
| 2086 | ||
| 2087 | lemma range_binaryset_eq: "range(binaryset A B) = {A,B,{}}"
 | |
| 2088 | apply (simp add: binaryset_def) | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39092diff
changeset | 2089 | apply (rule set_eqI) | 
| 38656 | 2090 | apply (auto simp add: image_iff) | 
| 2091 | done | |
| 2092 | ||
| 2093 | lemma UN_binaryset_eq: "(\<Union>i. binaryset A B i) = A \<union> B" | |
| 44106 | 2094 | by (simp add: SUP_def range_binaryset_eq) | 
| 38656 | 2095 | |
| 2096 | section {* Closed CDI *}
 | |
| 2097 | ||
| 47694 | 2098 | definition closed_cdi where | 
| 2099 | "closed_cdi \<Omega> M \<longleftrightarrow> | |
| 2100 | M \<subseteq> Pow \<Omega> & | |
| 2101 | (\<forall>s \<in> M. \<Omega> - s \<in> M) & | |
| 2102 |    (\<forall>A. (range A \<subseteq> M) & (A 0 = {}) & (\<forall>n. A n \<subseteq> A (Suc n)) \<longrightarrow>
 | |
| 2103 | (\<Union>i. A i) \<in> M) & | |
| 2104 | (\<forall>A. (range A \<subseteq> M) & disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M)" | |
| 38656 | 2105 | |
| 2106 | inductive_set | |
| 47694 | 2107 | smallest_ccdi_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set" | 
| 2108 | for \<Omega> M | |
| 38656 | 2109 | where | 
| 2110 | Basic [intro]: | |
| 47694 | 2111 | "a \<in> M \<Longrightarrow> a \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2112 | | Compl [intro]: | 
| 47694 | 2113 | "a \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> \<Omega> - a \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2114 | | Inc: | 
| 47694 | 2115 |       "range A \<in> Pow(smallest_ccdi_sets \<Omega> M) \<Longrightarrow> A 0 = {} \<Longrightarrow> (\<And>n. A n \<subseteq> A (Suc n))
 | 
| 2116 | \<Longrightarrow> (\<Union>i. A i) \<in> smallest_ccdi_sets \<Omega> M" | |
| 38656 | 2117 | | Disj: | 
| 47694 | 2118 | "range A \<in> Pow(smallest_ccdi_sets \<Omega> M) \<Longrightarrow> disjoint_family A | 
| 2119 | \<Longrightarrow> (\<Union>i::nat. A i) \<in> smallest_ccdi_sets \<Omega> M" | |
| 38656 | 2120 | |
| 47694 | 2121 | lemma (in subset_class) smallest_closed_cdi1: "M \<subseteq> smallest_ccdi_sets \<Omega> M" | 
| 2122 | by auto | |
| 38656 | 2123 | |
| 47694 | 2124 | lemma (in subset_class) smallest_ccdi_sets: "smallest_ccdi_sets \<Omega> M \<subseteq> Pow \<Omega>" | 
| 38656 | 2125 | apply (rule subsetI) | 
| 2126 | apply (erule smallest_ccdi_sets.induct) | |
| 2127 | apply (auto intro: range_subsetD dest: sets_into_space) | |
| 2128 | done | |
| 2129 | ||
| 47694 | 2130 | lemma (in subset_class) smallest_closed_cdi2: "closed_cdi \<Omega> (smallest_ccdi_sets \<Omega> M)" | 
| 2131 | apply (auto simp add: closed_cdi_def smallest_ccdi_sets) | |
| 38656 | 2132 | apply (blast intro: smallest_ccdi_sets.Inc smallest_ccdi_sets.Disj) + | 
| 2133 | done | |
| 2134 | ||
| 47694 | 2135 | lemma closed_cdi_subset: "closed_cdi \<Omega> M \<Longrightarrow> M \<subseteq> Pow \<Omega>" | 
| 38656 | 2136 | by (simp add: closed_cdi_def) | 
| 2137 | ||
| 47694 | 2138 | lemma closed_cdi_Compl: "closed_cdi \<Omega> M \<Longrightarrow> s \<in> M \<Longrightarrow> \<Omega> - s \<in> M" | 
| 38656 | 2139 | by (simp add: closed_cdi_def) | 
| 2140 | ||
| 2141 | lemma closed_cdi_Inc: | |
| 47694 | 2142 |   "closed_cdi \<Omega> M \<Longrightarrow> range A \<subseteq> M \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n)) \<Longrightarrow> (\<Union>i. A i) \<in> M"
 | 
| 38656 | 2143 | by (simp add: closed_cdi_def) | 
| 2144 | ||
| 2145 | lemma closed_cdi_Disj: | |
| 47694 | 2146 | "closed_cdi \<Omega> M \<Longrightarrow> range A \<subseteq> M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> M" | 
| 38656 | 2147 | by (simp add: closed_cdi_def) | 
| 2148 | ||
| 2149 | lemma closed_cdi_Un: | |
| 47694 | 2150 |   assumes cdi: "closed_cdi \<Omega> M" and empty: "{} \<in> M"
 | 
| 2151 | and A: "A \<in> M" and B: "B \<in> M" | |
| 38656 | 2152 |       and disj: "A \<inter> B = {}"
 | 
| 47694 | 2153 | shows "A \<union> B \<in> M" | 
| 38656 | 2154 | proof - | 
| 47694 | 2155 | have ra: "range (binaryset A B) \<subseteq> M" | 
| 38656 | 2156 | by (simp add: range_binaryset_eq empty A B) | 
| 2157 | have di: "disjoint_family (binaryset A B)" using disj | |
| 2158 | by (simp add: disjoint_family_on_def binaryset_def Int_commute) | |
| 2159 | from closed_cdi_Disj [OF cdi ra di] | |
| 2160 | show ?thesis | |
| 2161 | by (simp add: UN_binaryset_eq) | |
| 2162 | qed | |
| 2163 | ||
| 2164 | lemma (in algebra) smallest_ccdi_sets_Un: | |
| 47694 | 2165 | assumes A: "A \<in> smallest_ccdi_sets \<Omega> M" and B: "B \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2166 |       and disj: "A \<inter> B = {}"
 | 
| 47694 | 2167 | shows "A \<union> B \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2168 | proof - | 
| 47694 | 2169 | have ra: "range (binaryset A B) \<in> Pow (smallest_ccdi_sets \<Omega> M)" | 
| 38656 | 2170 | by (simp add: range_binaryset_eq A B smallest_ccdi_sets.Basic) | 
| 2171 | have di: "disjoint_family (binaryset A B)" using disj | |
| 2172 | by (simp add: disjoint_family_on_def binaryset_def Int_commute) | |
| 2173 | from Disj [OF ra di] | |
| 2174 | show ?thesis | |
| 2175 | by (simp add: UN_binaryset_eq) | |
| 2176 | qed | |
| 2177 | ||
| 2178 | lemma (in algebra) smallest_ccdi_sets_Int1: | |
| 47694 | 2179 | assumes a: "a \<in> M" | 
| 2180 | shows "b \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets \<Omega> M" | |
| 38656 | 2181 | proof (induct rule: smallest_ccdi_sets.induct) | 
| 2182 | case (Basic x) | |
| 2183 | thus ?case | |
| 2184 | by (metis a Int smallest_ccdi_sets.Basic) | |
| 2185 | next | |
| 2186 | case (Compl x) | |
| 47694 | 2187 | have "a \<inter> (\<Omega> - x) = \<Omega> - ((\<Omega> - a) \<union> (a \<inter> x))" | 
| 38656 | 2188 | by blast | 
| 47694 | 2189 | also have "... \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2190 | by (metis smallest_ccdi_sets.Compl a Compl(2) Diff_Int2 Diff_Int_distrib2 | 
| 47694 | 2191 | Diff_disjoint Int_Diff Int_empty_right smallest_ccdi_sets_Un | 
| 2192 | smallest_ccdi_sets.Basic smallest_ccdi_sets.Compl) | |
| 38656 | 2193 | finally show ?case . | 
| 2194 | next | |
| 2195 | case (Inc A) | |
| 2196 | have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)" | |
| 2197 | by blast | |
| 47694 | 2198 | have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Inc | 
| 38656 | 2199 | by blast | 
| 2200 |   moreover have "(\<lambda>i. a \<inter> A i) 0 = {}"
 | |
| 2201 | by (simp add: Inc) | |
| 2202 | moreover have "!!n. (\<lambda>i. a \<inter> A i) n \<subseteq> (\<lambda>i. a \<inter> A i) (Suc n)" using Inc | |
| 2203 | by blast | |
| 47694 | 2204 | ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2205 | by (rule smallest_ccdi_sets.Inc) | 
| 2206 | show ?case | |
| 2207 | by (metis 1 2) | |
| 2208 | next | |
| 2209 | case (Disj A) | |
| 2210 | have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)" | |
| 2211 | by blast | |
| 47694 | 2212 | have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Disj | 
| 38656 | 2213 | by blast | 
| 2214 | moreover have "disjoint_family (\<lambda>i. a \<inter> A i)" using Disj | |
| 2215 | by (auto simp add: disjoint_family_on_def) | |
| 47694 | 2216 | ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2217 | by (rule smallest_ccdi_sets.Disj) | 
| 2218 | show ?case | |
| 2219 | by (metis 1 2) | |
| 2220 | qed | |
| 2221 | ||
| 2222 | ||
| 2223 | lemma (in algebra) smallest_ccdi_sets_Int: | |
| 47694 | 2224 | assumes b: "b \<in> smallest_ccdi_sets \<Omega> M" | 
| 2225 | shows "a \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets \<Omega> M" | |
| 38656 | 2226 | proof (induct rule: smallest_ccdi_sets.induct) | 
| 2227 | case (Basic x) | |
| 2228 | thus ?case | |
| 2229 | by (metis b smallest_ccdi_sets_Int1) | |
| 2230 | next | |
| 2231 | case (Compl x) | |
| 47694 | 2232 | have "(\<Omega> - x) \<inter> b = \<Omega> - (x \<inter> b \<union> (\<Omega> - b))" | 
| 38656 | 2233 | by blast | 
| 47694 | 2234 | also have "... \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2235 | by (metis Compl(2) Diff_disjoint Int_Diff Int_commute Int_empty_right b | 
| 2236 | smallest_ccdi_sets.Compl smallest_ccdi_sets_Un) | |
| 2237 | finally show ?case . | |
| 2238 | next | |
| 2239 | case (Inc A) | |
| 2240 | have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b" | |
| 2241 | by blast | |
| 47694 | 2242 | have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Inc | 
| 38656 | 2243 | by blast | 
| 2244 |   moreover have "(\<lambda>i. A i \<inter> b) 0 = {}"
 | |
| 2245 | by (simp add: Inc) | |
| 2246 | moreover have "!!n. (\<lambda>i. A i \<inter> b) n \<subseteq> (\<lambda>i. A i \<inter> b) (Suc n)" using Inc | |
| 2247 | by blast | |
| 47694 | 2248 | ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2249 | by (rule smallest_ccdi_sets.Inc) | 
| 2250 | show ?case | |
| 2251 | by (metis 1 2) | |
| 2252 | next | |
| 2253 | case (Disj A) | |
| 2254 | have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b" | |
| 2255 | by blast | |
| 47694 | 2256 | have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Disj | 
| 38656 | 2257 | by blast | 
| 2258 | moreover have "disjoint_family (\<lambda>i. A i \<inter> b)" using Disj | |
| 2259 | by (auto simp add: disjoint_family_on_def) | |
| 47694 | 2260 | ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2261 | by (rule smallest_ccdi_sets.Disj) | 
| 2262 | show ?case | |
| 2263 | by (metis 1 2) | |
| 2264 | qed | |
| 2265 | ||
| 2266 | lemma (in algebra) sigma_property_disjoint_lemma: | |
| 47694 | 2267 | assumes sbC: "M \<subseteq> C" | 
| 2268 | and ccdi: "closed_cdi \<Omega> C" | |
| 2269 | shows "sigma_sets \<Omega> M \<subseteq> C" | |
| 38656 | 2270 | proof - | 
| 47694 | 2271 |   have "smallest_ccdi_sets \<Omega> M \<in> {B . M \<subseteq> B \<and> sigma_algebra \<Omega> B}"
 | 
| 38656 | 2272 | apply (auto simp add: sigma_algebra_disjoint_iff algebra_iff_Int | 
| 2273 | smallest_ccdi_sets_Int) | |
| 2274 | apply (metis Union_Pow_eq Union_upper subsetD smallest_ccdi_sets) | |
| 2275 | apply (blast intro: smallest_ccdi_sets.Disj) | |
| 2276 | done | |
| 47694 | 2277 | hence "sigma_sets (\<Omega>) (M) \<subseteq> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2278 | by clarsimp | 
| 47694 | 2279 | (drule sigma_algebra.sigma_sets_subset [where a="M"], auto) | 
| 38656 | 2280 | also have "... \<subseteq> C" | 
| 2281 | proof | |
| 2282 | fix x | |
| 47694 | 2283 | assume x: "x \<in> smallest_ccdi_sets \<Omega> M" | 
| 38656 | 2284 | thus "x \<in> C" | 
| 2285 | proof (induct rule: smallest_ccdi_sets.induct) | |
| 2286 | case (Basic x) | |
| 2287 | thus ?case | |
| 2288 | by (metis Basic subsetD sbC) | |
| 2289 | next | |
| 2290 | case (Compl x) | |
| 2291 | thus ?case | |
| 2292 | by (blast intro: closed_cdi_Compl [OF ccdi, simplified]) | |
| 2293 | next | |
| 2294 | case (Inc A) | |
| 2295 | thus ?case | |
| 2296 | by (auto intro: closed_cdi_Inc [OF ccdi, simplified]) | |
| 2297 | next | |
| 2298 | case (Disj A) | |
| 2299 | thus ?case | |
| 2300 | by (auto intro: closed_cdi_Disj [OF ccdi, simplified]) | |
| 2301 | qed | |
| 2302 | qed | |
| 2303 | finally show ?thesis . | |
| 2304 | qed | |
| 2305 | ||
| 2306 | lemma (in algebra) sigma_property_disjoint: | |
| 47694 | 2307 | assumes sbC: "M \<subseteq> C" | 
| 2308 | and compl: "!!s. s \<in> C \<inter> sigma_sets (\<Omega>) (M) \<Longrightarrow> \<Omega> - s \<in> C" | |
| 2309 | and inc: "!!A. range A \<subseteq> C \<inter> sigma_sets (\<Omega>) (M) | |
| 38656 | 2310 |                      \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n))
 | 
| 2311 | \<Longrightarrow> (\<Union>i. A i) \<in> C" | |
| 47694 | 2312 | and disj: "!!A. range A \<subseteq> C \<inter> sigma_sets (\<Omega>) (M) | 
| 38656 | 2313 | \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> C" | 
| 47694 | 2314 | shows "sigma_sets (\<Omega>) (M) \<subseteq> C" | 
| 38656 | 2315 | proof - | 
| 47694 | 2316 | have "sigma_sets (\<Omega>) (M) \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)" | 
| 38656 | 2317 | proof (rule sigma_property_disjoint_lemma) | 
| 47694 | 2318 | show "M \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)" | 
| 38656 | 2319 | by (metis Int_greatest Set.subsetI sbC sigma_sets.Basic) | 
| 2320 | next | |
| 47694 | 2321 | show "closed_cdi \<Omega> (C \<inter> sigma_sets (\<Omega>) (M))" | 
| 38656 | 2322 | by (simp add: closed_cdi_def compl inc disj) | 
| 2323 | (metis PowI Set.subsetI le_infI2 sigma_sets_into_sp space_closed | |
| 2324 | IntE sigma_sets.Compl range_subsetD sigma_sets.Union) | |
| 2325 | qed | |
| 2326 | thus ?thesis | |
| 2327 | by blast | |
| 2328 | qed | |
| 2329 | ||
| 40859 | 2330 | section {* Dynkin systems *}
 | 
| 2331 | ||
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 2332 | locale dynkin_system = subset_class + | 
| 47694 | 2333 | assumes space: "\<Omega> \<in> M" | 
| 2334 | and compl[intro!]: "\<And>A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M" | |
| 2335 | and UN[intro!]: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> M | |
| 2336 | \<Longrightarrow> (\<Union>i::nat. A i) \<in> M" | |
| 40859 | 2337 | |
| 47694 | 2338 | lemma (in dynkin_system) empty[intro, simp]: "{} \<in> M"
 | 
| 2339 | using space compl[of "\<Omega>"] by simp | |
| 40859 | 2340 | |
| 2341 | lemma (in dynkin_system) diff: | |
| 47694 | 2342 | assumes sets: "D \<in> M" "E \<in> M" and "D \<subseteq> E" | 
| 2343 | shows "E - D \<in> M" | |
| 40859 | 2344 | proof - | 
| 47694 | 2345 |   let ?f = "\<lambda>x. if x = 0 then D else if x = Suc 0 then \<Omega> - E else {}"
 | 
| 2346 |   have "range ?f = {D, \<Omega> - E, {}}"
 | |
| 40859 | 2347 | by (auto simp: image_iff) | 
| 47694 | 2348 | moreover have "D \<union> (\<Omega> - E) = (\<Union>i. ?f i)" | 
| 40859 | 2349 | by (auto simp: image_iff split: split_if_asm) | 
| 2350 | moreover | |
| 2351 | then have "disjoint_family ?f" unfolding disjoint_family_on_def | |
| 47694 | 2352 | using `D \<in> M`[THEN sets_into_space] `D \<subseteq> E` by auto | 
| 2353 | ultimately have "\<Omega> - (D \<union> (\<Omega> - E)) \<in> M" | |
| 40859 | 2354 | using sets by auto | 
| 47694 | 2355 | also have "\<Omega> - (D \<union> (\<Omega> - E)) = E - D" | 
| 40859 | 2356 | using assms sets_into_space by auto | 
| 2357 | finally show ?thesis . | |
| 2358 | qed | |
| 2359 | ||
| 2360 | lemma dynkin_systemI: | |
| 47694 | 2361 | assumes "\<And> A. A \<in> M \<Longrightarrow> A \<subseteq> \<Omega>" "\<Omega> \<in> M" | 
| 2362 | assumes "\<And> A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M" | |
| 2363 | assumes "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> M | |
| 2364 | \<Longrightarrow> (\<Union>i::nat. A i) \<in> M" | |
| 2365 | shows "dynkin_system \<Omega> M" | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 2366 | using assms by (auto simp: dynkin_system_def dynkin_system_axioms_def subset_class_def) | 
| 40859 | 2367 | |
| 42988 | 2368 | lemma dynkin_systemI': | 
| 47694 | 2369 | assumes 1: "\<And> A. A \<in> M \<Longrightarrow> A \<subseteq> \<Omega>" | 
| 2370 |   assumes empty: "{} \<in> M"
 | |
| 2371 | assumes Diff: "\<And> A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M" | |
| 2372 | assumes 2: "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> M | |
| 2373 | \<Longrightarrow> (\<Union>i::nat. A i) \<in> M" | |
| 2374 | shows "dynkin_system \<Omega> M" | |
| 42988 | 2375 | proof - | 
| 47694 | 2376 | from Diff[OF empty] have "\<Omega> \<in> M" by auto | 
| 42988 | 2377 | from 1 this Diff 2 show ?thesis | 
| 2378 | by (intro dynkin_systemI) auto | |
| 2379 | qed | |
| 2380 | ||
| 40859 | 2381 | lemma dynkin_system_trivial: | 
| 47694 | 2382 | shows "dynkin_system A (Pow A)" | 
| 40859 | 2383 | by (rule dynkin_systemI) auto | 
| 2384 | ||
| 2385 | lemma sigma_algebra_imp_dynkin_system: | |
| 47694 | 2386 | assumes "sigma_algebra \<Omega> M" shows "dynkin_system \<Omega> M" | 
| 40859 | 2387 | proof - | 
| 47694 | 2388 | interpret sigma_algebra \<Omega> M by fact | 
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44537diff
changeset | 2389 | show ?thesis using sets_into_space by (fastforce intro!: dynkin_systemI) | 
| 40859 | 2390 | qed | 
| 2391 | ||
| 2392 | subsection "Intersection stable algebras" | |
| 2393 | ||
| 47694 | 2394 | definition "Int_stable M \<longleftrightarrow> (\<forall> a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)" | 
| 40859 | 2395 | |
| 2396 | lemma (in algebra) Int_stable: "Int_stable M" | |
| 2397 | unfolding Int_stable_def by auto | |
| 2398 | ||
| 42981 | 2399 | lemma Int_stableI: | 
| 47694 | 2400 | "(\<And>a b. a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<inter> b \<in> A) \<Longrightarrow> Int_stable A" | 
| 42981 | 2401 | unfolding Int_stable_def by auto | 
| 2402 | ||
| 2403 | lemma Int_stableD: | |
| 47694 | 2404 | "Int_stable M \<Longrightarrow> a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M" | 
| 42981 | 2405 | unfolding Int_stable_def by auto | 
| 2406 | ||
| 40859 | 2407 | lemma (in dynkin_system) sigma_algebra_eq_Int_stable: | 
| 47694 | 2408 | "sigma_algebra \<Omega> M \<longleftrightarrow> Int_stable M" | 
| 40859 | 2409 | proof | 
| 47694 | 2410 | assume "sigma_algebra \<Omega> M" then show "Int_stable M" | 
| 40859 | 2411 | unfolding sigma_algebra_def using algebra.Int_stable by auto | 
| 2412 | next | |
| 2413 | assume "Int_stable M" | |
| 47694 | 2414 | show "sigma_algebra \<Omega> M" | 
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 2415 | unfolding sigma_algebra_disjoint_iff algebra_iff_Un | 
| 40859 | 2416 | proof (intro conjI ballI allI impI) | 
| 47694 | 2417 | show "M \<subseteq> Pow (\<Omega>)" using sets_into_space by auto | 
| 40859 | 2418 | next | 
| 47694 | 2419 | fix A B assume "A \<in> M" "B \<in> M" | 
| 2420 | then have "A \<union> B = \<Omega> - ((\<Omega> - A) \<inter> (\<Omega> - B))" | |
| 2421 | "\<Omega> - A \<in> M" "\<Omega> - B \<in> M" | |
| 40859 | 2422 | using sets_into_space by auto | 
| 47694 | 2423 | then show "A \<union> B \<in> M" | 
| 40859 | 2424 | using `Int_stable M` unfolding Int_stable_def by auto | 
| 2425 | qed auto | |
| 2426 | qed | |
| 2427 | ||
| 2428 | subsection "Smallest Dynkin systems" | |
| 2429 | ||
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 2430 | definition dynkin where | 
| 47694 | 2431 |   "dynkin \<Omega> M =  (\<Inter>{D. dynkin_system \<Omega> D \<and> M \<subseteq> D})"
 | 
| 40859 | 2432 | |
| 2433 | lemma dynkin_system_dynkin: | |
| 47694 | 2434 | assumes "M \<subseteq> Pow (\<Omega>)" | 
| 2435 | shows "dynkin_system \<Omega> (dynkin \<Omega> M)" | |
| 40859 | 2436 | proof (rule dynkin_systemI) | 
| 47694 | 2437 | fix A assume "A \<in> dynkin \<Omega> M" | 
| 40859 | 2438 | moreover | 
| 47694 | 2439 |   { fix D assume "A \<in> D" and d: "dynkin_system \<Omega> D"
 | 
| 2440 | then have "A \<subseteq> \<Omega>" by (auto simp: dynkin_system_def subset_class_def) } | |
| 2441 |   moreover have "{D. dynkin_system \<Omega> D \<and> M \<subseteq> D} \<noteq> {}"
 | |
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44537diff
changeset | 2442 | using assms dynkin_system_trivial by fastforce | 
| 47694 | 2443 | ultimately show "A \<subseteq> \<Omega>" | 
| 40859 | 2444 | unfolding dynkin_def using assms | 
| 47694 | 2445 | by auto | 
| 40859 | 2446 | next | 
| 47694 | 2447 | show "\<Omega> \<in> dynkin \<Omega> M" | 
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44537diff
changeset | 2448 | unfolding dynkin_def using dynkin_system.space by fastforce | 
| 40859 | 2449 | next | 
| 47694 | 2450 | fix A assume "A \<in> dynkin \<Omega> M" | 
| 2451 | then show "\<Omega> - A \<in> dynkin \<Omega> M" | |
| 40859 | 2452 | unfolding dynkin_def using dynkin_system.compl by force | 
| 2453 | next | |
| 2454 | fix A :: "nat \<Rightarrow> 'a set" | |
| 47694 | 2455 | assume A: "disjoint_family A" "range A \<subseteq> dynkin \<Omega> M" | 
| 2456 | show "(\<Union>i. A i) \<in> dynkin \<Omega> M" unfolding dynkin_def | |
| 40859 | 2457 | proof (simp, safe) | 
| 47694 | 2458 | fix D assume "dynkin_system \<Omega> D" "M \<subseteq> D" | 
| 2459 | with A have "(\<Union>i. A i) \<in> D" | |
| 40859 | 2460 | by (intro dynkin_system.UN) (auto simp: dynkin_def) | 
| 2461 | then show "(\<Union>i. A i) \<in> D" by auto | |
| 2462 | qed | |
| 2463 | qed | |
| 2464 | ||
| 47694 | 2465 | lemma dynkin_Basic[intro]: "A \<in> M \<Longrightarrow> A \<in> dynkin \<Omega> M" | 
| 40859 | 2466 | unfolding dynkin_def by auto | 
| 2467 | ||
| 2468 | lemma (in dynkin_system) restricted_dynkin_system: | |
| 47694 | 2469 | assumes "D \<in> M" | 
| 2470 |   shows "dynkin_system \<Omega> {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> D \<in> M}"
 | |
| 40859 | 2471 | proof (rule dynkin_systemI, simp_all) | 
| 47694 | 2472 | have "\<Omega> \<inter> D = D" | 
| 2473 | using `D \<in> M` sets_into_space by auto | |
| 2474 | then show "\<Omega> \<inter> D \<in> M" | |
| 2475 | using `D \<in> M` by auto | |
| 40859 | 2476 | next | 
| 47694 | 2477 | fix A assume "A \<subseteq> \<Omega> \<and> A \<inter> D \<in> M" | 
| 2478 | moreover have "(\<Omega> - A) \<inter> D = (\<Omega> - (A \<inter> D)) - (\<Omega> - D)" | |
| 40859 | 2479 | by auto | 
| 47694 | 2480 | ultimately show "\<Omega> - A \<subseteq> \<Omega> \<and> (\<Omega> - A) \<inter> D \<in> M" | 
| 2481 | using `D \<in> M` by (auto intro: diff) | |
| 40859 | 2482 | next | 
| 2483 | fix A :: "nat \<Rightarrow> 'a set" | |
| 47694 | 2484 |   assume "disjoint_family A" "range A \<subseteq> {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> D \<in> M}"
 | 
| 2485 | then have "\<And>i. A i \<subseteq> \<Omega>" "disjoint_family (\<lambda>i. A i \<inter> D)" | |
| 2486 | "range (\<lambda>i. A i \<inter> D) \<subseteq> M" "(\<Union>x. A x) \<inter> D = (\<Union>x. A x \<inter> D)" | |
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44537diff
changeset | 2487 | by ((fastforce simp: disjoint_family_on_def)+) | 
| 47694 | 2488 | then show "(\<Union>x. A x) \<subseteq> \<Omega> \<and> (\<Union>x. A x) \<inter> D \<in> M" | 
| 40859 | 2489 | by (auto simp del: UN_simps) | 
| 2490 | qed | |
| 2491 | ||
| 2492 | lemma (in dynkin_system) dynkin_subset: | |
| 47694 | 2493 | assumes "N \<subseteq> M" | 
| 2494 | shows "dynkin \<Omega> N \<subseteq> M" | |
| 40859 | 2495 | proof - | 
| 47694 | 2496 | have "dynkin_system \<Omega> M" by default | 
| 2497 | then have "dynkin_system \<Omega> M" | |
| 42065 
2b98b4c2e2f1
add ring_of_sets and subset_class as basis for algebra
 hoelzl parents: 
41983diff
changeset | 2498 | using assms unfolding dynkin_system_def dynkin_system_axioms_def subset_class_def by simp | 
| 47694 | 2499 | with `N \<subseteq> M` show ?thesis by (auto simp add: dynkin_def) | 
| 40859 | 2500 | qed | 
| 2501 | ||
| 2502 | lemma sigma_eq_dynkin: | |
| 47694 | 2503 | assumes sets: "M \<subseteq> Pow \<Omega>" | 
| 40859 | 2504 | assumes "Int_stable M" | 
| 47694 | 2505 | shows "sigma_sets \<Omega> M = dynkin \<Omega> M" | 
| 40859 | 2506 | proof - | 
| 47694 | 2507 | have "dynkin \<Omega> M \<subseteq> sigma_sets (\<Omega>) (M)" | 
| 40859 | 2508 | using sigma_algebra_imp_dynkin_system | 
| 47694 | 2509 | unfolding dynkin_def sigma_sets_least_sigma_algebra[OF sets] by auto | 
| 40859 | 2510 | moreover | 
| 47694 | 2511 | interpret dynkin_system \<Omega> "dynkin \<Omega> M" | 
| 40859 | 2512 | using dynkin_system_dynkin[OF sets] . | 
| 47694 | 2513 | have "sigma_algebra \<Omega> (dynkin \<Omega> M)" | 
| 40859 | 2514 | unfolding sigma_algebra_eq_Int_stable Int_stable_def | 
| 2515 | proof (intro ballI) | |
| 47694 | 2516 | fix A B assume "A \<in> dynkin \<Omega> M" "B \<in> dynkin \<Omega> M" | 
| 2517 |     let ?D = "\<lambda>E. {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> E \<in> dynkin \<Omega> M}"
 | |
| 2518 | have "M \<subseteq> ?D B" | |
| 40859 | 2519 | proof | 
| 47694 | 2520 | fix E assume "E \<in> M" | 
| 2521 | then have "M \<subseteq> ?D E" "E \<in> dynkin \<Omega> M" | |
| 40859 | 2522 | using sets_into_space `Int_stable M` by (auto simp: Int_stable_def) | 
| 47694 | 2523 | then have "dynkin \<Omega> M \<subseteq> ?D E" | 
| 2524 | using restricted_dynkin_system `E \<in> dynkin \<Omega> M` | |
| 40859 | 2525 | by (intro dynkin_system.dynkin_subset) simp_all | 
| 47694 | 2526 | then have "B \<in> ?D E" | 
| 2527 | using `B \<in> dynkin \<Omega> M` by auto | |
| 2528 | then have "E \<inter> B \<in> dynkin \<Omega> M" | |
| 40859 | 2529 | by (subst Int_commute) simp | 
| 47694 | 2530 | then show "E \<in> ?D B" | 
| 2531 | using sets `E \<in> M` by auto | |
| 40859 | 2532 | qed | 
| 47694 | 2533 | then have "dynkin \<Omega> M \<subseteq> ?D B" | 
| 2534 | using restricted_dynkin_system `B \<in> dynkin \<Omega> M` | |
| 40859 | 2535 | by (intro dynkin_system.dynkin_subset) simp_all | 
| 47694 | 2536 | then show "A \<inter> B \<in> dynkin \<Omega> M" | 
| 2537 | using `A \<in> dynkin \<Omega> M` sets_into_space by auto | |
| 40859 | 2538 | qed | 
| 47694 | 2539 | from sigma_algebra.sigma_sets_subset[OF this, of "M"] | 
| 2540 | have "sigma_sets (\<Omega>) (M) \<subseteq> dynkin \<Omega> M" by auto | |
| 2541 | ultimately have "sigma_sets (\<Omega>) (M) = dynkin \<Omega> M" by auto | |
| 40859 | 2542 | then show ?thesis | 
| 47694 | 2543 | by (auto simp: dynkin_def) | 
| 40859 | 2544 | qed | 
| 2545 | ||
| 2546 | lemma (in dynkin_system) dynkin_idem: | |
| 47694 | 2547 | "dynkin \<Omega> M = M" | 
| 40859 | 2548 | proof - | 
| 47694 | 2549 | have "dynkin \<Omega> M = M" | 
| 40859 | 2550 | proof | 
| 47694 | 2551 | show "M \<subseteq> dynkin \<Omega> M" | 
| 40859 | 2552 | using dynkin_Basic by auto | 
| 47694 | 2553 | show "dynkin \<Omega> M \<subseteq> M" | 
| 40859 | 2554 | by (intro dynkin_subset) auto | 
| 2555 | qed | |
| 2556 | then show ?thesis | |
| 47694 | 2557 | by (auto simp: dynkin_def) | 
| 40859 | 2558 | qed | 
| 2559 | ||
| 2560 | lemma (in dynkin_system) dynkin_lemma: | |
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 2561 | assumes "Int_stable E" | 
| 47694 | 2562 | and E: "E \<subseteq> M" "M \<subseteq> sigma_sets \<Omega> E" | 
| 2563 | shows "sigma_sets \<Omega> E = M" | |
| 40859 | 2564 | proof - | 
| 47694 | 2565 | have "E \<subseteq> Pow \<Omega>" | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41543diff
changeset | 2566 | using E sets_into_space by force | 
| 47694 | 2567 | then have "sigma_sets \<Omega> E = dynkin \<Omega> E" | 
| 40859 | 2568 | using `Int_stable E` by (rule sigma_eq_dynkin) | 
| 47694 | 2569 | moreover then have "dynkin \<Omega> E = M" | 
| 2570 | using assms dynkin_subset[OF E(1)] by simp | |
| 40859 | 2571 | ultimately show ?thesis | 
| 47694 | 2572 | using assms by (auto simp: dynkin_def) | 
| 42864 | 2573 | qed | 
| 2574 | ||
| 49789 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2575 | lemma sigma_sets_induct_disjoint[consumes 3, case_names basic empty compl union]: | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2576 | assumes "Int_stable G" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2577 | and closed: "G \<subseteq> Pow \<Omega>" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2578 | and A: "A \<in> sigma_sets \<Omega> G" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2579 | assumes basic: "\<And>A. A \<in> G \<Longrightarrow> P A" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2580 |     and empty: "P {}"
 | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2581 | and compl: "\<And>A. A \<in> sigma_sets \<Omega> G \<Longrightarrow> P A \<Longrightarrow> P (\<Omega> - A)" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2582 | and union: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> sigma_sets \<Omega> G \<Longrightarrow> (\<And>i. P (A i)) \<Longrightarrow> P (\<Union>i::nat. A i)" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2583 | shows "P A" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2584 | proof - | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2585 |   let ?D = "{ A \<in> sigma_sets \<Omega> G. P A }"
 | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2586 | interpret sigma_algebra \<Omega> "sigma_sets \<Omega> G" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2587 | using closed by (rule sigma_algebra_sigma_sets) | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2588 | from compl[OF _ empty] closed have space: "P \<Omega>" by simp | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2589 | interpret dynkin_system \<Omega> ?D | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2590 | by default (auto dest: sets_into_space intro!: space compl union) | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2591 | have "sigma_sets \<Omega> G = ?D" | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2592 | by (rule dynkin_lemma) (auto simp: basic `Int_stable G`) | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2593 | with A show ?thesis by auto | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2594 | qed | 
| 
e0a4cb91a8a9
add induction rule for intersection-stable sigma-sets
 hoelzl parents: 
49782diff
changeset | 2595 | |
| 33271 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 paulson parents: diff
changeset | 2596 | end |