| author | haftmann | 
| Sun, 08 Oct 2017 22:28:21 +0200 | |
| changeset 66812 | 7163b780549d | 
| parent 66453 | cc19f7ca2ed6 | 
| child 67399 | eab6ce8368fa | 
| permissions | -rw-r--r-- | 
| 50091 | 1 | (* Title: HOL/Probability/Fin_Map.thy | 
| 50088 | 2 | Author: Fabian Immler, TU München | 
| 3 | *) | |
| 4 | ||
| 61808 | 5 | section \<open>Finite Maps\<close> | 
| 50091 | 6 | |
| 50088 | 7 | theory Fin_Map | 
| 66453 
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
 wenzelm parents: 
66267diff
changeset | 8 | imports "HOL-Analysis.Finite_Product_Measure" "HOL-Library.Finite_Map" | 
| 50088 | 9 | begin | 
| 10 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 11 | text \<open>The @{type fmap} type can be instantiated to @{class polish_space}, needed for the proof of
 | 
| 50088 | 12 |   projective limit. @{const extensional} functions are used for the representation in order to
 | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 13 |   stay close to the developments of (finite) products @{const Pi\<^sub>E} and their sigma-algebra
 | 
| 61808 | 14 |   @{const Pi\<^sub>M}.\<close>
 | 
| 50088 | 15 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 16 | type_notation fmap ("(_ \<Rightarrow>\<^sub>F /_)" [22, 21] 21)
 | 
| 63577 | 17 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 18 | unbundle fmap.lifting | 
| 63577 | 19 | |
| 50088 | 20 | |
| 61808 | 21 | subsection \<open>Domain and Application\<close> | 
| 50088 | 22 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 23 | lift_definition domain::"('i \<Rightarrow>\<^sub>F 'a) \<Rightarrow> 'i set" is dom .
 | 
| 50088 | 24 | |
| 25 | lemma finite_domain[simp, intro]: "finite (domain P)" | |
| 63577 | 26 | by transfer simp | 
| 50088 | 27 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 28 | lift_definition proj :: "('i \<Rightarrow>\<^sub>F 'a) \<Rightarrow> 'i \<Rightarrow> 'a" ("'((_)')\<^sub>F" [0] 1000) is
 | 
| 63577 | 29 | "\<lambda>f x. if x \<in> dom f then the (f x) else undefined" . | 
| 50088 | 30 | |
| 31 | declare [[coercion proj]] | |
| 32 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 33 | lemma extensional_proj[simp, intro]: "(P)\<^sub>F \<in> extensional (domain P)" | 
| 63577 | 34 | by transfer (auto simp: extensional_def) | 
| 50088 | 35 | |
| 36 | lemma proj_undefined[simp, intro]: "i \<notin> domain P \<Longrightarrow> P i = undefined" | |
| 37 | using extensional_proj[of P] unfolding extensional_def by auto | |
| 38 | ||
| 39 | lemma finmap_eq_iff: "P = Q \<longleftrightarrow> (domain P = domain Q \<and> (\<forall>i\<in>domain P. P i = Q i))" | |
| 63577 | 40 | apply transfer | 
| 41 | apply (safe intro!: ext) | |
| 42 | subgoal for P Q x | |
| 43 | by (cases "x \<in> dom P"; cases "P x") (auto dest!: bspec[where x=x]) | |
| 44 | done | |
| 45 | ||
| 50088 | 46 | |
| 61808 | 47 | subsection \<open>Constructor of Finite Maps\<close> | 
| 50088 | 48 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 49 | lift_definition finmap_of::"'i set \<Rightarrow> ('i \<Rightarrow> 'a) \<Rightarrow> ('i \<Rightarrow>\<^sub>F 'a)" is
 | 
| 63577 | 50 | "\<lambda>I f x. if x \<in> I \<and> finite I then Some (f x) else None" | 
| 51 | by (simp add: dom_def) | |
| 50088 | 52 | |
| 53 | lemma proj_finmap_of[simp]: | |
| 54 | assumes "finite inds" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 55 | shows "(finmap_of inds f)\<^sub>F = restrict f inds" | 
| 50088 | 56 | using assms | 
| 63577 | 57 | by transfer force | 
| 50088 | 58 | |
| 59 | lemma domain_finmap_of[simp]: | |
| 60 | assumes "finite inds" | |
| 61 | shows "domain (finmap_of inds f) = inds" | |
| 62 | using assms | |
| 63577 | 63 | by transfer (auto split: if_splits) | 
| 50088 | 64 | |
| 65 | lemma finmap_of_eq_iff[simp]: | |
| 66 | assumes "finite i" "finite j" | |
| 51104 | 67 | shows "finmap_of i m = finmap_of j n \<longleftrightarrow> i = j \<and> (\<forall>k\<in>i. m k= n k)" | 
| 68 | using assms by (auto simp: finmap_eq_iff) | |
| 50088 | 69 | |
| 50124 | 70 | lemma finmap_of_inj_on_extensional_finite: | 
| 50088 | 71 | assumes "finite K" | 
| 72 | assumes "S \<subseteq> extensional K" | |
| 73 | shows "inj_on (finmap_of K) S" | |
| 74 | proof (rule inj_onI) | |
| 75 | fix x y::"'a \<Rightarrow> 'b" | |
| 76 | assume "finmap_of K x = finmap_of K y" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 77 | hence "(finmap_of K x)\<^sub>F = (finmap_of K y)\<^sub>F" by simp | 
| 50088 | 78 | moreover | 
| 79 | assume "x \<in> S" "y \<in> S" hence "x \<in> extensional K" "y \<in> extensional K" using assms by auto | |
| 80 | ultimately | |
| 81 | show "x = y" using assms by (simp add: extensional_restrict) | |
| 82 | qed | |
| 83 | ||
| 61808 | 84 | subsection \<open>Product set of Finite Maps\<close> | 
| 50088 | 85 | |
| 61808 | 86 | text \<open>This is @{term Pi} for Finite Maps, most of this is copied\<close>
 | 
| 50088 | 87 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 88 | definition Pi' :: "'i set \<Rightarrow> ('i \<Rightarrow> 'a set) \<Rightarrow> ('i \<Rightarrow>\<^sub>F 'a) set" where
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 89 |   "Pi' I A = { P. domain P = I \<and> (\<forall>i. i \<in> I \<longrightarrow> (P)\<^sub>F i \<in> A i) } "
 | 
| 50088 | 90 | |
| 91 | syntax | |
| 92 |   "_Pi'" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi>' _\<in>_./ _)"   10)
 | |
| 93 | translations | |
| 61988 | 94 | "\<Pi>' x\<in>A. B" == "CONST Pi' A (\<lambda>x. B)" | 
| 50088 | 95 | |
| 61808 | 96 | subsubsection\<open>Basic Properties of @{term Pi'}\<close>
 | 
| 50088 | 97 | |
| 98 | lemma Pi'_I[intro!]: "domain f = A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<in> B x) \<Longrightarrow> f \<in> Pi' A B" | |
| 99 | by (simp add: Pi'_def) | |
| 100 | ||
| 101 | lemma Pi'_I'[simp]: "domain f = A \<Longrightarrow> (\<And>x. x \<in> A \<longrightarrow> f x \<in> B x) \<Longrightarrow> f \<in> Pi' A B" | |
| 102 | by (simp add:Pi'_def) | |
| 103 | ||
| 104 | lemma Pi'_mem: "f\<in> Pi' A B \<Longrightarrow> x \<in> A \<Longrightarrow> f x \<in> B x" | |
| 105 | by (simp add: Pi'_def) | |
| 106 | ||
| 107 | lemma Pi'_iff: "f \<in> Pi' I X \<longleftrightarrow> domain f = I \<and> (\<forall>i\<in>I. f i \<in> X i)" | |
| 108 | unfolding Pi'_def by auto | |
| 109 | ||
| 110 | lemma Pi'E [elim]: | |
| 111 | "f \<in> Pi' A B \<Longrightarrow> (f x \<in> B x \<Longrightarrow> domain f = A \<Longrightarrow> Q) \<Longrightarrow> (x \<notin> A \<Longrightarrow> Q) \<Longrightarrow> Q" | |
| 112 | by(auto simp: Pi'_def) | |
| 113 | ||
| 114 | lemma in_Pi'_cong: | |
| 115 | "domain f = domain g \<Longrightarrow> (\<And> w. w \<in> A \<Longrightarrow> f w = g w) \<Longrightarrow> f \<in> Pi' A B \<longleftrightarrow> g \<in> Pi' A B" | |
| 116 | by (auto simp: Pi'_def) | |
| 117 | ||
| 118 | lemma Pi'_eq_empty[simp]: | |
| 119 |   assumes "finite A" shows "(Pi' A B) = {} \<longleftrightarrow> (\<exists>x\<in>A. B x = {})"
 | |
| 120 | using assms | |
| 121 | apply (simp add: Pi'_def, auto) | |
| 122 | apply (drule_tac x = "finmap_of A (\<lambda>u. SOME y. y \<in> B u)" in spec, auto) | |
| 123 | apply (cut_tac P= "%y. y \<in> B i" in some_eq_ex, auto) | |
| 124 | done | |
| 125 | ||
| 126 | lemma Pi'_mono: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C x) \<Longrightarrow> Pi' A B \<subseteq> Pi' A C" | |
| 127 | by (auto simp: Pi'_def) | |
| 128 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 129 | lemma Pi_Pi': "finite A \<Longrightarrow> (Pi\<^sub>E A B) = proj ` Pi' A B" | 
| 50088 | 130 | apply (auto simp: Pi'_def Pi_def extensional_def) | 
| 131 | apply (rule_tac x = "finmap_of A (restrict x A)" in image_eqI) | |
| 132 | apply auto | |
| 133 | done | |
| 134 | ||
| 61808 | 135 | subsection \<open>Topological Space of Finite Maps\<close> | 
| 51105 | 136 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 137 | instantiation fmap :: (type, topological_space) topological_space | 
| 51105 | 138 | begin | 
| 139 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 140 | definition open_fmap :: "('a \<Rightarrow>\<^sub>F 'b) set \<Rightarrow> bool" where
 | 
| 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 141 |    [code del]: "open_fmap = generate_topology {Pi' a b|a b. \<forall>i\<in>a. open (b i)}"
 | 
| 51105 | 142 | |
| 143 | lemma open_Pi'I: "(\<And>i. i \<in> I \<Longrightarrow> open (A i)) \<Longrightarrow> open (Pi' I A)" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 144 | by (auto intro: generate_topology.Basis simp: open_fmap_def) | 
| 51105 | 145 | |
| 146 | instance using topological_space_generate_topology | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 147 | by intro_classes (auto simp: open_fmap_def class.topological_space_def) | 
| 51105 | 148 | |
| 149 | end | |
| 150 | ||
| 151 | lemma open_restricted_space: | |
| 152 |   shows "open {m. P (domain m)}"
 | |
| 153 | proof - | |
| 154 |   have "{m. P (domain m)} = (\<Union>i \<in> Collect P. {m. domain m = i})" by auto
 | |
| 155 | also have "open \<dots>" | |
| 156 | proof (rule, safe, cases) | |
| 157 | fix i::"'a set" | |
| 158 | assume "finite i" | |
| 159 |     hence "{m. domain m = i} = Pi' i (\<lambda>_. UNIV)" by (auto simp: Pi'_def)
 | |
| 61808 | 160 | also have "open \<dots>" by (auto intro: open_Pi'I simp: \<open>finite i\<close>) | 
| 51105 | 161 |     finally show "open {m. domain m = i}" .
 | 
| 162 | next | |
| 163 | fix i::"'a set" | |
| 164 |     assume "\<not> finite i" hence "{m. domain m = i} = {}" by auto
 | |
| 165 | also have "open \<dots>" by simp | |
| 166 |     finally show "open {m. domain m = i}" .
 | |
| 167 | qed | |
| 168 | finally show ?thesis . | |
| 169 | qed | |
| 170 | ||
| 171 | lemma closed_restricted_space: | |
| 172 |   shows "closed {m. P (domain m)}"
 | |
| 173 | using open_restricted_space[of "\<lambda>x. \<not> P x"] | |
| 174 | unfolding closed_def by (rule back_subst) auto | |
| 175 | ||
| 61973 | 176 | lemma tendsto_proj: "((\<lambda>x. x) \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. (x)\<^sub>F i) \<longlongrightarrow> (a)\<^sub>F i) F" | 
| 51105 | 177 | unfolding tendsto_def | 
| 178 | proof safe | |
| 179 | fix S::"'b set" | |
| 180 | let ?S = "Pi' (domain a) (\<lambda>x. if x = i then S else UNIV)" | |
| 181 | assume "open S" hence "open ?S" by (auto intro!: open_Pi'I) | |
| 182 | moreover assume "\<forall>S. open S \<longrightarrow> a \<in> S \<longrightarrow> eventually (\<lambda>x. x \<in> S) F" "a i \<in> S" | |
| 183 | ultimately have "eventually (\<lambda>x. x \<in> ?S) F" by auto | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 184 | thus "eventually (\<lambda>x. (x)\<^sub>F i \<in> S) F" | 
| 62390 | 185 | by eventually_elim (insert \<open>a i \<in> S\<close>, force simp: Pi'_iff split: if_split_asm) | 
| 51105 | 186 | qed | 
| 187 | ||
| 188 | lemma continuous_proj: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 189 | shows "continuous_on s (\<lambda>x. (x)\<^sub>F i)" | 
| 51641 
cd05e9fcc63d
remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
 hoelzl parents: 
51489diff
changeset | 190 | unfolding continuous_on_def by (safe intro!: tendsto_proj tendsto_ident_at) | 
| 51105 | 191 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 192 | instance fmap :: (type, first_countable_topology) first_countable_topology | 
| 51105 | 193 | proof | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 194 | fix x::"'a\<Rightarrow>\<^sub>F'b" | 
| 51105 | 195 | have "\<forall>i. \<exists>A. countable A \<and> (\<forall>a\<in>A. x i \<in> a) \<and> (\<forall>a\<in>A. open a) \<and> | 
| 196 | (\<forall>S. open S \<and> x i \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S)) \<and> (\<forall>a b. a \<in> A \<longrightarrow> b \<in> A \<longrightarrow> a \<inter> b \<in> A)" (is "\<forall>i. ?th i") | |
| 197 | proof | |
| 198 | fix i from first_countable_basis_Int_stableE[of "x i"] guess A . | |
| 199 | thus "?th i" by (intro exI[where x=A]) simp | |
| 200 | qed | |
| 201 | then guess A unfolding choice_iff .. note A = this | |
| 202 | hence open_sub: "\<And>i S. i\<in>domain x \<Longrightarrow> open (S i) \<Longrightarrow> x i\<in>(S i) \<Longrightarrow> (\<exists>a\<in>A i. a\<subseteq>(S i))" by auto | |
| 203 |   have A_notempty: "\<And>i. i \<in> domain x \<Longrightarrow> A i \<noteq> {}" using open_sub[of _ "\<lambda>_. UNIV"] by auto
 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 204 | let ?A = "(\<lambda>f. Pi' (domain x) f) ` (Pi\<^sub>E (domain x) A)" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 205 |   show "\<exists>A::nat \<Rightarrow> ('a\<Rightarrow>\<^sub>F'b) set. (\<forall>i. x \<in> (A i) \<and> open (A i)) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>i. A i \<subseteq> S))"
 | 
| 51473 | 206 | proof (rule first_countableI[where A="?A"], safe) | 
| 51105 | 207 | show "countable ?A" using A by (simp add: countable_PiE) | 
| 208 | next | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 209 |     fix S::"('a \<Rightarrow>\<^sub>F 'b) set" assume "open S" "x \<in> S"
 | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 210 | thus "\<exists>a\<in>?A. a \<subseteq> S" unfolding open_fmap_def | 
| 51105 | 211 | proof (induct rule: generate_topology.induct) | 
| 212 | case UNIV thus ?case by (auto simp add: ex_in_conv PiE_eq_empty_iff A_notempty) | |
| 213 | next | |
| 214 | case (Int a b) | |
| 215 | then obtain f g where | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 216 | "f \<in> Pi\<^sub>E (domain x) A" "Pi' (domain x) f \<subseteq> a" "g \<in> Pi\<^sub>E (domain x) A" "Pi' (domain x) g \<subseteq> b" | 
| 51105 | 217 | by auto | 
| 218 | thus ?case using A | |
| 219 | by (auto simp: Pi'_iff PiE_iff extensional_def Int_stable_def | |
| 220 | intro!: bexI[where x="\<lambda>i. f i \<inter> g i"]) | |
| 221 | next | |
| 222 | case (UN B) | |
| 223 | then obtain b where "x \<in> b" "b \<in> B" by auto | |
| 224 | hence "\<exists>a\<in>?A. a \<subseteq> b" using UN by simp | |
| 61808 | 225 | thus ?case using \<open>b \<in> B\<close> by blast | 
| 51105 | 226 | next | 
| 227 | case (Basis s) | |
| 228 | then obtain a b where xs: "x\<in> Pi' a b" "s = Pi' a b" "\<And>i. i\<in>a \<Longrightarrow> open (b i)" by auto | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 229 | have "\<forall>i. \<exists>a. (i \<in> domain x \<and> open (b i) \<and> (x)\<^sub>F i \<in> b i) \<longrightarrow> (a\<in>A i \<and> a \<subseteq> b i)" | 
| 51105 | 230 | using open_sub[of _ b] by auto | 
| 231 | then obtain b' | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 232 | where "\<And>i. i \<in> domain x \<Longrightarrow> open (b i) \<Longrightarrow> (x)\<^sub>F i \<in> b i \<Longrightarrow> (b' i \<in>A i \<and> b' i \<subseteq> b i)" | 
| 51105 | 233 | unfolding choice_iff by auto | 
| 234 | with xs have "\<And>i. i \<in> a \<Longrightarrow> (b' i \<in>A i \<and> b' i \<subseteq> b i)" "Pi' a b' \<subseteq> Pi' a b" | |
| 235 | by (auto simp: Pi'_iff intro!: Pi'_mono) | |
| 236 | thus ?case using xs | |
| 237 | by (intro bexI[where x="Pi' a b'"]) | |
| 238 | (auto simp: Pi'_iff intro!: image_eqI[where x="restrict b' (domain x)"]) | |
| 239 | qed | |
| 240 | qed (insert A,auto simp: PiE_iff intro!: open_Pi'I) | |
| 241 | qed | |
| 242 | ||
| 61808 | 243 | subsection \<open>Metric Space of Finite Maps\<close> | 
| 50088 | 244 | |
| 62101 | 245 | (* TODO: Product of uniform spaces and compatibility with metric_spaces! *) | 
| 246 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 247 | instantiation fmap :: (type, metric_space) dist | 
| 50088 | 248 | begin | 
| 249 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 250 | definition dist_fmap where | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 251 | "dist P Q = Max (range (\<lambda>i. dist ((P)\<^sub>F i) ((Q)\<^sub>F i))) + (if domain P = domain Q then 0 else 1)" | 
| 50088 | 252 | |
| 62101 | 253 | instance .. | 
| 254 | end | |
| 255 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 256 | instantiation fmap :: (type, metric_space) uniformity_dist | 
| 62101 | 257 | begin | 
| 258 | ||
| 259 | definition [code del]: | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 260 |   "(uniformity :: (('a, 'b) fmap \<times> ('a \<Rightarrow>\<^sub>F 'b)) filter) =
 | 
| 62101 | 261 |     (INF e:{0 <..}. principal {(x, y). dist x y < e})"
 | 
| 262 | ||
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 263 | instance | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 264 | by standard (rule uniformity_fmap_def) | 
| 62101 | 265 | end | 
| 266 | ||
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 267 | declare uniformity_Abort[where 'a="('a \<Rightarrow>\<^sub>F 'b::metric_space)", code]
 | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 268 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 269 | instantiation fmap :: (type, metric_space) metric_space | 
| 62101 | 270 | begin | 
| 271 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 272 | lemma finite_proj_image': "x \<notin> domain P \<Longrightarrow> finite ((P)\<^sub>F ` S)" | 
| 51104 | 273 |   by (rule finite_subset[of _ "proj P ` (domain P \<inter> S \<union> {x})"]) auto
 | 
| 274 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 275 | lemma finite_proj_image: "finite ((P)\<^sub>F ` S)" | 
| 51104 | 276 | by (cases "\<exists>x. x \<notin> domain P") (auto intro: finite_proj_image' finite_subset[where B="domain P"]) | 
| 277 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 278 | lemma finite_proj_diag: "finite ((\<lambda>i. d ((P)\<^sub>F i) ((Q)\<^sub>F i)) ` S)" | 
| 50088 | 279 | proof - | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 280 | have "(\<lambda>i. d ((P)\<^sub>F i) ((Q)\<^sub>F i)) ` S = (\<lambda>(i, j). d i j) ` ((\<lambda>i. ((P)\<^sub>F i, (Q)\<^sub>F i)) ` S)" by auto | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 281 | moreover have "((\<lambda>i. ((P)\<^sub>F i, (Q)\<^sub>F i)) ` S) \<subseteq> (\<lambda>i. (P)\<^sub>F i) ` S \<times> (\<lambda>i. (Q)\<^sub>F i) ` S" by auto | 
| 51104 | 282 | moreover have "finite \<dots>" using finite_proj_image[of P S] finite_proj_image[of Q S] | 
| 283 | by (intro finite_cartesian_product) simp_all | |
| 284 | ultimately show ?thesis by (simp add: finite_subset) | |
| 50088 | 285 | qed | 
| 286 | ||
| 51104 | 287 | lemma dist_le_1_imp_domain_eq: | 
| 288 | shows "dist P Q < 1 \<Longrightarrow> domain P = domain Q" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 289 | by (simp add: dist_fmap_def finite_proj_diag split: if_split_asm) | 
| 51104 | 290 | |
| 50088 | 291 | lemma dist_proj: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 292 | shows "dist ((x)\<^sub>F i) ((y)\<^sub>F i) \<le> dist x y" | 
| 50088 | 293 | proof - | 
| 51104 | 294 | have "dist (x i) (y i) \<le> Max (range (\<lambda>i. dist (x i) (y i)))" | 
| 295 | by (simp add: Max_ge_iff finite_proj_diag) | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 296 | also have "\<dots> \<le> dist x y" by (simp add: dist_fmap_def) | 
| 51104 | 297 | finally show ?thesis . | 
| 298 | qed | |
| 299 | ||
| 300 | lemma dist_finmap_lessI: | |
| 51105 | 301 | assumes "domain P = domain Q" | 
| 302 | assumes "0 < e" | |
| 303 | assumes "\<And>i. i \<in> domain P \<Longrightarrow> dist (P i) (Q i) < e" | |
| 51104 | 304 | shows "dist P Q < e" | 
| 305 | proof - | |
| 306 | have "dist P Q = Max (range (\<lambda>i. dist (P i) (Q i)))" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 307 | using assms by (simp add: dist_fmap_def finite_proj_diag) | 
| 51104 | 308 | also have "\<dots> < e" | 
| 309 | proof (subst Max_less_iff, safe) | |
| 51105 | 310 | fix i | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 311 | show "dist ((P)\<^sub>F i) ((Q)\<^sub>F i) < e" using assms | 
| 51105 | 312 | by (cases "i \<in> domain P") simp_all | 
| 51104 | 313 | qed (simp add: finite_proj_diag) | 
| 314 | finally show ?thesis . | |
| 50088 | 315 | qed | 
| 316 | ||
| 317 | instance | |
| 318 | proof | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 319 |   fix S::"('a \<Rightarrow>\<^sub>F 'b) set"
 | 
| 62101 | 320 | have *: "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)" (is "_ = ?od") | 
| 51105 | 321 | proof | 
| 322 | assume "open S" | |
| 323 | thus ?od | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 324 | unfolding open_fmap_def | 
| 51105 | 325 | proof (induct rule: generate_topology.induct) | 
| 326 | case UNIV thus ?case by (auto intro: zero_less_one) | |
| 327 | next | |
| 328 | case (Int a b) | |
| 329 | show ?case | |
| 330 | proof safe | |
| 331 | fix x assume x: "x \<in> a" "x \<in> b" | |
| 332 | with Int x obtain e1 e2 where | |
| 333 | "e1>0" "\<forall>y. dist y x < e1 \<longrightarrow> y \<in> a" "e2>0" "\<forall>y. dist y x < e2 \<longrightarrow> y \<in> b" by force | |
| 334 | thus "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> a \<inter> b" | |
| 335 | by (auto intro!: exI[where x="min e1 e2"]) | |
| 336 | qed | |
| 337 | next | |
| 338 | case (UN K) | |
| 339 | show ?case | |
| 340 | proof safe | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 341 | fix x X assume "x \<in> X" and X: "X \<in> K" | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 342 | with UN obtain e where "e>0" "\<And>y. dist y x < e \<longrightarrow> y \<in> X" by force | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 343 | with X show "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> \<Union>K" by auto | 
| 51105 | 344 | qed | 
| 345 | next | |
| 346 | case (Basis s) then obtain a b where s: "s = Pi' a b" and b: "\<And>i. i\<in>a \<Longrightarrow> open (b i)" by auto | |
| 347 | show ?case | |
| 348 | proof safe | |
| 349 | fix x assume "x \<in> s" | |
| 350 | hence [simp]: "finite a" and a_dom: "a = domain x" using s by (auto simp: Pi'_iff) | |
| 351 | obtain es where es: "\<forall>i \<in> a. es i > 0 \<and> (\<forall>y. dist y (proj x i) < es i \<longrightarrow> y \<in> b i)" | |
| 61808 | 352 | using b \<open>x \<in> s\<close> by atomize_elim (intro bchoice, auto simp: open_dist s) | 
| 51105 | 353 | hence in_b: "\<And>i y. i \<in> a \<Longrightarrow> dist y (proj x i) < es i \<Longrightarrow> y \<in> b i" by auto | 
| 354 | show "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> s" | |
| 355 | proof (cases, rule, safe) | |
| 356 |           assume "a \<noteq> {}"
 | |
| 61808 | 357 |           show "0 < min 1 (Min (es ` a))" using es by (auto simp: \<open>a \<noteq> {}\<close>)
 | 
| 51105 | 358 | fix y assume d: "dist y x < min 1 (Min (es ` a))" | 
| 359 | show "y \<in> s" unfolding s | |
| 360 | proof | |
| 61808 | 361 |             show "domain y = a" using d s \<open>a \<noteq> {}\<close> by (auto simp: dist_le_1_imp_domain_eq a_dom)
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 362 | fix i assume i: "i \<in> a" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 363 | hence "dist ((y)\<^sub>F i) ((x)\<^sub>F i) < es i" using d | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 364 |               by (auto simp: dist_fmap_def \<open>a \<noteq> {}\<close> intro!: le_less_trans[OF dist_proj])
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 365 | with i show "y i \<in> b i" by (rule in_b) | 
| 51105 | 366 | qed | 
| 367 | next | |
| 368 |           assume "\<not>a \<noteq> {}"
 | |
| 369 | thus "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> s" | |
| 61808 | 370 | using s \<open>x \<in> s\<close> by (auto simp: Pi'_def dist_le_1_imp_domain_eq intro!: exI[where x=1]) | 
| 51105 | 371 | qed | 
| 372 | qed | |
| 373 | qed | |
| 374 | next | |
| 375 | assume "\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S" | |
| 376 | then obtain e where e_pos: "\<And>x. x \<in> S \<Longrightarrow> e x > 0" and | |
| 377 | e_in: "\<And>x y . x \<in> S \<Longrightarrow> dist y x < e x \<Longrightarrow> y \<in> S" | |
| 378 | unfolding bchoice_iff | |
| 379 | by auto | |
| 380 |     have S_eq: "S = \<Union>{Pi' a b| a b. \<exists>x\<in>S. domain x = a \<and> b = (\<lambda>i. ball (x i) (e x))}"
 | |
| 381 | proof safe | |
| 382 | fix x assume "x \<in> S" | |
| 383 |       thus "x \<in> \<Union>{Pi' a b| a b. \<exists>x\<in>S. domain x = a \<and> b = (\<lambda>i. ball (x i) (e x))}"
 | |
| 384 | using e_pos by (auto intro!: exI[where x="Pi' (domain x) (\<lambda>i. ball (x i) (e x))"]) | |
| 385 | next | |
| 386 | fix x y | |
| 387 | assume "y \<in> S" | |
| 388 | moreover | |
| 389 | assume "x \<in> (\<Pi>' i\<in>domain y. ball (y i) (e y))" | |
| 61808 | 390 | hence "dist x y < e y" using e_pos \<open>y \<in> S\<close> | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 391 | by (auto simp: dist_fmap_def Pi'_iff finite_proj_diag dist_commute) | 
| 51105 | 392 | ultimately show "x \<in> S" by (rule e_in) | 
| 393 | qed | |
| 394 | also have "open \<dots>" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 395 | unfolding open_fmap_def | 
| 51105 | 396 | by (intro generate_topology.UN) (auto intro: generate_topology.Basis) | 
| 397 | finally show "open S" . | |
| 398 | qed | |
| 62101 | 399 | show "open S = (\<forall>x\<in>S. \<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> S)" | 
| 400 | unfolding * eventually_uniformity_metric | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 401 | by (simp del: split_paired_All add: dist_fmap_def dist_commute eq_commute) | 
| 50088 | 402 | next | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 403 | fix P Q::"'a \<Rightarrow>\<^sub>F 'b" | 
| 51104 | 404 |   have Max_eq_iff: "\<And>A m. finite A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> (Max A = m) = (m \<in> A \<and> (\<forall>a\<in>A. a \<le> m))"
 | 
| 51489 | 405 | by (auto intro: Max_in Max_eqI) | 
| 50088 | 406 | show "dist P Q = 0 \<longleftrightarrow> P = Q" | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 407 | by (auto simp: finmap_eq_iff dist_fmap_def Max_ge_iff finite_proj_diag Max_eq_iff | 
| 56633 
18f50d5f84ef
remove add_eq_zero_iff, it is replaced by add_nonneg_eq_0_iff; also removes it from the simpset
 hoelzl parents: 
56222diff
changeset | 408 | add_nonneg_eq_0_iff | 
| 51104 | 409 | intro!: Max_eqI image_eqI[where x=undefined]) | 
| 50088 | 410 | next | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 411 | fix P Q R::"'a \<Rightarrow>\<^sub>F 'b" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 412 | let ?dists = "\<lambda>P Q i. dist ((P)\<^sub>F i) ((Q)\<^sub>F i)" | 
| 51104 | 413 | let ?dpq = "?dists P Q" and ?dpr = "?dists P R" and ?dqr = "?dists Q R" | 
| 414 | let ?dom = "\<lambda>P Q. (if domain P = domain Q then 0 else 1::real)" | |
| 415 | have "dist P Q = Max (range ?dpq) + ?dom P Q" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 416 | by (simp add: dist_fmap_def) | 
| 51104 | 417 | also obtain t where "t \<in> range ?dpq" "t = Max (range ?dpq)" by (simp add: finite_proj_diag) | 
| 418 | then obtain i where "Max (range ?dpq) = ?dpq i" by auto | |
| 419 | also have "?dpq i \<le> ?dpr i + ?dqr i" by (rule dist_triangle2) | |
| 420 | also have "?dpr i \<le> Max (range ?dpr)" by (simp add: finite_proj_diag) | |
| 421 | also have "?dqr i \<le> Max (range ?dqr)" by (simp add: finite_proj_diag) | |
| 422 | also have "?dom P Q \<le> ?dom P R + ?dom Q R" by simp | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 423 | finally show "dist P Q \<le> dist P R + dist Q R" by (simp add: dist_fmap_def ac_simps) | 
| 50088 | 424 | qed | 
| 425 | ||
| 426 | end | |
| 427 | ||
| 61808 | 428 | subsection \<open>Complete Space of Finite Maps\<close> | 
| 50088 | 429 | |
| 430 | lemma tendsto_finmap: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 431 |   fixes f::"nat \<Rightarrow> ('i \<Rightarrow>\<^sub>F ('a::metric_space))"
 | 
| 50088 | 432 | assumes ind_f: "\<And>n. domain (f n) = domain g" | 
| 61969 | 433 | assumes proj_g: "\<And>i. i \<in> domain g \<Longrightarrow> (\<lambda>n. (f n) i) \<longlonglongrightarrow> g i" | 
| 434 | shows "f \<longlonglongrightarrow> g" | |
| 51104 | 435 | unfolding tendsto_iff | 
| 436 | proof safe | |
| 437 | fix e::real assume "0 < e" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 438 | let ?dists = "\<lambda>x i. dist ((f x)\<^sub>F i) ((g)\<^sub>F i)" | 
| 51104 | 439 | have "eventually (\<lambda>x. \<forall>i\<in>domain g. ?dists x i < e) sequentially" | 
| 440 | using finite_domain[of g] proj_g | |
| 441 | proof induct | |
| 442 | case (insert i G) | |
| 61808 | 443 | with \<open>0 < e\<close> have "eventually (\<lambda>x. ?dists x i < e) sequentially" by (auto simp add: tendsto_iff) | 
| 51104 | 444 | moreover | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 445 | from insert have "eventually (\<lambda>x. \<forall>i\<in>G. dist ((f x)\<^sub>F i) ((g)\<^sub>F i) < e) sequentially" by simp | 
| 51104 | 446 | ultimately show ?case by eventually_elim auto | 
| 447 | qed simp | |
| 448 | thus "eventually (\<lambda>x. dist (f x) g < e) sequentially" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 449 | by eventually_elim (auto simp add: dist_fmap_def finite_proj_diag ind_f \<open>0 < e\<close>) | 
| 51104 | 450 | qed | 
| 50088 | 451 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 452 | instance fmap :: (type, complete_space) complete_space | 
| 50088 | 453 | proof | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 454 | fix P::"nat \<Rightarrow> 'a \<Rightarrow>\<^sub>F 'b" | 
| 50088 | 455 | assume "Cauchy P" | 
| 456 | then obtain Nd where Nd: "\<And>n. n \<ge> Nd \<Longrightarrow> dist (P n) (P Nd) < 1" | |
| 66089 
def95e0bc529
Some new material. SIMPRULE STATUS for sum/prod.delta rules!
 paulson <lp15@cam.ac.uk> parents: 
64462diff
changeset | 457 | by (force simp: Cauchy_altdef2) | 
| 63040 | 458 | define d where "d = domain (P Nd)" | 
| 50088 | 459 | with Nd have dim: "\<And>n. n \<ge> Nd \<Longrightarrow> domain (P n) = d" using dist_le_1_imp_domain_eq by auto | 
| 460 | have [simp]: "finite d" unfolding d_def by simp | |
| 63040 | 461 | define p where "p i n = P n i" for i n | 
| 462 | define q where "q i = lim (p i)" for i | |
| 463 | define Q where "Q = finmap_of d q" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 464 | have q: "\<And>i. i \<in> d \<Longrightarrow> q i = Q i" by (auto simp add: Q_def Abs_fmap_inverse) | 
| 50088 | 465 |   {
 | 
| 466 | fix i assume "i \<in> d" | |
| 66089 
def95e0bc529
Some new material. SIMPRULE STATUS for sum/prod.delta rules!
 paulson <lp15@cam.ac.uk> parents: 
64462diff
changeset | 467 | have "Cauchy (p i)" unfolding Cauchy_altdef2 p_def | 
| 50088 | 468 | proof safe | 
| 469 | fix e::real assume "0 < e" | |
| 61808 | 470 | with \<open>Cauchy P\<close> obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> dist (P n) (P N) < min e 1" | 
| 66089 
def95e0bc529
Some new material. SIMPRULE STATUS for sum/prod.delta rules!
 paulson <lp15@cam.ac.uk> parents: 
64462diff
changeset | 471 | by (force simp: Cauchy_altdef2 min_def) | 
| 50088 | 472 | hence "\<And>n. n \<ge> N \<Longrightarrow> domain (P n) = domain (P N)" using dist_le_1_imp_domain_eq by auto | 
| 473 | with dim have dim: "\<And>n. n \<ge> N \<Longrightarrow> domain (P n) = d" by (metis nat_le_linear) | |
| 474 | show "\<exists>N. \<forall>n\<ge>N. dist ((P n) i) ((P N) i) < e" | |
| 475 | proof (safe intro!: exI[where x="N"]) | |
| 476 | fix n assume "N \<le> n" have "N \<le> N" by simp | |
| 477 | have "dist ((P n) i) ((P N) i) \<le> dist (P n) (P N)" | |
| 61808 | 478 | using dim[OF \<open>N \<le> n\<close>] dim[OF \<open>N \<le> N\<close>] \<open>i \<in> d\<close> | 
| 50088 | 479 | by (auto intro!: dist_proj) | 
| 61808 | 480 | also have "\<dots> < e" using N[OF \<open>N \<le> n\<close>] by simp | 
| 50088 | 481 | finally show "dist ((P n) i) ((P N) i) < e" . | 
| 482 | qed | |
| 483 | qed | |
| 484 | hence "convergent (p i)" by (metis Cauchy_convergent_iff) | |
| 61969 | 485 | hence "p i \<longlonglongrightarrow> q i" unfolding q_def convergent_def by (metis limI) | 
| 50088 | 486 | } note p = this | 
| 61969 | 487 | have "P \<longlonglongrightarrow> Q" | 
| 50088 | 488 | proof (rule metric_LIMSEQ_I) | 
| 489 | fix e::real assume "0 < e" | |
| 51104 | 490 | have "\<exists>ni. \<forall>i\<in>d. \<forall>n\<ge>ni i. dist (p i n) (q i) < e" | 
| 50088 | 491 | proof (safe intro!: bchoice) | 
| 492 | fix i assume "i \<in> d" | |
| 61808 | 493 | from p[OF \<open>i \<in> d\<close>, THEN metric_LIMSEQ_D, OF \<open>0 < e\<close>] | 
| 51104 | 494 | show "\<exists>no. \<forall>n\<ge>no. dist (p i n) (q i) < e" . | 
| 50088 | 495 | qed then guess ni .. note ni = this | 
| 63040 | 496 | define N where "N = max Nd (Max (ni ` d))" | 
| 50088 | 497 | show "\<exists>N. \<forall>n\<ge>N. dist (P n) Q < e" | 
| 498 | proof (safe intro!: exI[where x="N"]) | |
| 499 | fix n assume "N \<le> n" | |
| 51104 | 500 | hence dom: "domain (P n) = d" "domain Q = d" "domain (P n) = domain Q" | 
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 501 | using dim by (simp_all add: N_def Q_def dim_def Abs_fmap_inverse) | 
| 51104 | 502 | show "dist (P n) Q < e" | 
| 61808 | 503 | proof (rule dist_finmap_lessI[OF dom(3) \<open>0 < e\<close>]) | 
| 51104 | 504 | fix i | 
| 505 | assume "i \<in> domain (P n)" | |
| 506 | hence "ni i \<le> Max (ni ` d)" using dom by simp | |
| 50088 | 507 | also have "\<dots> \<le> N" by (simp add: N_def) | 
| 61808 | 508 | finally show "dist ((P n)\<^sub>F i) ((Q)\<^sub>F i) < e" using ni \<open>i \<in> domain (P n)\<close> \<open>N \<le> n\<close> dom | 
| 51104 | 509 | by (auto simp: p_def q N_def less_imp_le) | 
| 50088 | 510 | qed | 
| 511 | qed | |
| 512 | qed | |
| 513 | thus "convergent P" by (auto simp: convergent_def) | |
| 514 | qed | |
| 515 | ||
| 61808 | 516 | subsection \<open>Second Countable Space of Finite Maps\<close> | 
| 50088 | 517 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 518 | instantiation fmap :: (countable, second_countable_topology) second_countable_topology | 
| 50088 | 519 | begin | 
| 520 | ||
| 51106 | 521 | definition basis_proj::"'b set set" | 
| 522 | where "basis_proj = (SOME B. countable B \<and> topological_basis B)" | |
| 523 | ||
| 524 | lemma countable_basis_proj: "countable basis_proj" and basis_proj: "topological_basis basis_proj" | |
| 525 | unfolding basis_proj_def by (intro is_basis countable_basis)+ | |
| 526 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 527 | definition basis_finmap::"('a \<Rightarrow>\<^sub>F 'b) set set"
 | 
| 51106 | 528 |   where "basis_finmap = {Pi' I S|I S. finite I \<and> (\<forall>i \<in> I. S i \<in> basis_proj)}"
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 529 | |
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 530 | lemma in_basis_finmapI: | 
| 51106 | 531 | assumes "finite I" assumes "\<And>i. i \<in> I \<Longrightarrow> S i \<in> basis_proj" | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 532 | shows "Pi' I S \<in> basis_finmap" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 533 | using assms unfolding basis_finmap_def by auto | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 534 | |
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 535 | lemma basis_finmap_eq: | 
| 51106 | 536 |   assumes "basis_proj \<noteq> {}"
 | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 537 | shows "basis_finmap = (\<lambda>f. Pi' (domain f) (\<lambda>i. from_nat_into basis_proj ((f)\<^sub>F i))) ` | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 538 |     (UNIV::('a \<Rightarrow>\<^sub>F nat) set)" (is "_ = ?f ` _")
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 539 | unfolding basis_finmap_def | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 540 | proof safe | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 541 | fix I::"'a set" and S::"'a \<Rightarrow> 'b set" | 
| 51106 | 542 | assume "finite I" "\<forall>i\<in>I. S i \<in> basis_proj" | 
| 543 | hence "Pi' I S = ?f (finmap_of I (\<lambda>x. to_nat_on basis_proj (S x)))" | |
| 544 | by (force simp: Pi'_def countable_basis_proj) | |
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 545 | thus "Pi' I S \<in> range ?f" by simp | 
| 51106 | 546 | next | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 547 | fix x and f::"'a \<Rightarrow>\<^sub>F nat" | 
| 56222 
6599c6278545
tuned -- no need for slightly obscure "local" prefix;
 wenzelm parents: 
53374diff
changeset | 548 | show "\<exists>I S. (\<Pi>' i\<in>domain f. from_nat_into basis_proj ((f)\<^sub>F i)) = Pi' I S \<and> | 
| 
6599c6278545
tuned -- no need for slightly obscure "local" prefix;
 wenzelm parents: 
53374diff
changeset | 549 | finite I \<and> (\<forall>i\<in>I. S i \<in> basis_proj)" | 
| 51106 | 550 | using assms by (auto intro: from_nat_into) | 
| 551 | qed | |
| 552 | ||
| 553 | lemma basis_finmap_eq_empty: "basis_proj = {} \<Longrightarrow> basis_finmap = {Pi' {} undefined}"
 | |
| 554 | by (auto simp: Pi'_iff basis_finmap_def) | |
| 50088 | 555 | |
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 556 | lemma countable_basis_finmap: "countable basis_finmap" | 
| 51106 | 557 |   by (cases "basis_proj = {}") (auto simp: basis_finmap_eq basis_finmap_eq_empty)
 | 
| 50088 | 558 | |
| 559 | lemma finmap_topological_basis: | |
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 560 | "topological_basis basis_finmap" | 
| 50088 | 561 | proof (subst topological_basis_iff, safe) | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 562 | fix B' assume "B' \<in> basis_finmap" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 563 | thus "open B'" | 
| 51106 | 564 | by (auto intro!: open_Pi'I topological_basis_open[OF basis_proj] | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 565 | simp: topological_basis_def basis_finmap_def Let_def) | 
| 50088 | 566 | next | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 567 |   fix O'::"('a \<Rightarrow>\<^sub>F 'b) set" and x
 | 
| 51105 | 568 | assume O': "open O'" "x \<in> O'" | 
| 569 | then obtain a where a: | |
| 570 | "x \<in> Pi' (domain x) a" "Pi' (domain x) a \<subseteq> O'" "\<And>i. i\<in>domain x \<Longrightarrow> open (a i)" | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 571 | unfolding open_fmap_def | 
| 51105 | 572 | proof (atomize_elim, induct rule: generate_topology.induct) | 
| 573 | case (Int a b) | |
| 574 | let ?p="\<lambda>a f. x \<in> Pi' (domain x) f \<and> Pi' (domain x) f \<subseteq> a \<and> (\<forall>i. i \<in> domain x \<longrightarrow> open (f i))" | |
| 575 | from Int obtain f g where "?p a f" "?p b g" by auto | |
| 576 | thus ?case by (force intro!: exI[where x="\<lambda>i. f i \<inter> g i"] simp: Pi'_def) | |
| 577 | next | |
| 578 | case (UN k) | |
| 579 | then obtain kk a where "x \<in> kk" "kk \<in> k" "x \<in> Pi' (domain x) a" "Pi' (domain x) a \<subseteq> kk" | |
| 580 | "\<And>i. i\<in>domain x \<Longrightarrow> open (a i)" | |
| 581 | by force | |
| 582 | thus ?case by blast | |
| 583 | qed (auto simp: Pi'_def) | |
| 50088 | 584 | have "\<exists>B. | 
| 51106 | 585 | (\<forall>i\<in>domain x. x i \<in> B i \<and> B i \<subseteq> a i \<and> B i \<in> basis_proj)" | 
| 50088 | 586 | proof (rule bchoice, safe) | 
| 587 | fix i assume "i \<in> domain x" | |
| 51105 | 588 | hence "open (a i)" "x i \<in> a i" using a by auto | 
| 51106 | 589 | from topological_basisE[OF basis_proj this] guess b' . | 
| 590 | thus "\<exists>y. x i \<in> y \<and> y \<subseteq> a i \<and> y \<in> basis_proj" by auto | |
| 50088 | 591 | qed | 
| 592 | then guess B .. note B = this | |
| 63040 | 593 | define B' where "B' = Pi' (domain x) (\<lambda>i. (B i)::'b set)" | 
| 51105 | 594 | have "B' \<subseteq> Pi' (domain x) a" using B by (auto intro!: Pi'_mono simp: B'_def) | 
| 61808 | 595 | also note \<open>\<dots> \<subseteq> O'\<close> | 
| 51105 | 596 | finally show "\<exists>B'\<in>basis_finmap. x \<in> B' \<and> B' \<subseteq> O'" using B | 
| 597 | by (auto intro!: bexI[where x=B'] Pi'_mono in_basis_finmapI simp: B'_def) | |
| 50088 | 598 | qed | 
| 599 | ||
| 600 | lemma range_enum_basis_finmap_imp_open: | |
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 601 | assumes "x \<in> basis_finmap" | 
| 50088 | 602 | shows "open x" | 
| 603 | using finmap_topological_basis assms by (auto simp: topological_basis_def) | |
| 604 | ||
| 51343 
b61b32f62c78
use generate_topology for second countable topologies, does not require intersection stable basis
 hoelzl parents: 
51106diff
changeset | 605 | instance proof qed (blast intro: finmap_topological_basis countable_basis_finmap topological_basis_imp_subbasis) | 
| 50088 | 606 | |
| 607 | end | |
| 608 | ||
| 61808 | 609 | subsection \<open>Polish Space of Finite Maps\<close> | 
| 51105 | 610 | |
| 63885 
a6cd18af8bf9
new type for finite maps; use it in HOL-Probability
 Lars Hupel <lars.hupel@mytum.de> parents: 
63577diff
changeset | 611 | instance fmap :: (countable, polish_space) polish_space proof qed | 
| 51105 | 612 | |
| 613 | ||
| 61808 | 614 | subsection \<open>Product Measurable Space of Finite Maps\<close> | 
| 50088 | 615 | |
| 616 | definition "PiF I M \<equiv> | |
| 50124 | 617 |   sigma (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j))) {(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}"
 | 
| 50088 | 618 | |
| 619 | abbreviation | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 620 | "Pi\<^sub>F I M \<equiv> PiF I M" | 
| 50088 | 621 | |
| 622 | syntax | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 623 |   "_PiF" :: "pttrn \<Rightarrow> 'i set \<Rightarrow> 'a measure \<Rightarrow> ('i => 'a) measure"  ("(3\<Pi>\<^sub>F _\<in>_./ _)"  10)
 | 
| 50088 | 624 | translations | 
| 61988 | 625 | "\<Pi>\<^sub>F x\<in>I. M" == "CONST PiF I (%x. M)" | 
| 50088 | 626 | |
| 627 | lemma PiF_gen_subset: "{(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))} \<subseteq>
 | |
| 628 | Pow (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))" | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 629 | by (auto simp: Pi'_def) (blast dest: sets.sets_into_space) | 
| 50088 | 630 | |
| 631 | lemma space_PiF: "space (PiF I M) = (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j)))" | |
| 632 | unfolding PiF_def using PiF_gen_subset by (rule space_measure_of) | |
| 633 | ||
| 634 | lemma sets_PiF: | |
| 635 | "sets (PiF I M) = sigma_sets (\<Union>J \<in> I. (\<Pi>' j\<in>J. space (M j))) | |
| 636 |     {(\<Pi>' j\<in>J. X j) |X J. J \<in> I \<and> X \<in> (\<Pi> j\<in>J. sets (M j))}"
 | |
| 637 | unfolding PiF_def using PiF_gen_subset by (rule sets_measure_of) | |
| 638 | ||
| 639 | lemma sets_PiF_singleton: | |
| 640 |   "sets (PiF {I} M) = sigma_sets (\<Pi>' j\<in>I. space (M j))
 | |
| 641 |     {(\<Pi>' j\<in>I. X j) |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
 | |
| 642 | unfolding sets_PiF by simp | |
| 643 | ||
| 644 | lemma in_sets_PiFI: | |
| 645 | assumes "X = (Pi' J S)" "J \<in> I" "\<And>i. i\<in>J \<Longrightarrow> S i \<in> sets (M i)" | |
| 646 | shows "X \<in> sets (PiF I M)" | |
| 647 | unfolding sets_PiF | |
| 648 | using assms by blast | |
| 649 | ||
| 650 | lemma product_in_sets_PiFI: | |
| 651 | assumes "J \<in> I" "\<And>i. i\<in>J \<Longrightarrow> S i \<in> sets (M i)" | |
| 652 | shows "(Pi' J S) \<in> sets (PiF I M)" | |
| 653 | unfolding sets_PiF | |
| 654 | using assms by blast | |
| 655 | ||
| 656 | lemma singleton_space_subset_in_sets: | |
| 657 | fixes J | |
| 658 | assumes "J \<in> I" | |
| 659 | assumes "finite J" | |
| 660 |   shows "space (PiF {J} M) \<in> sets (PiF I M)"
 | |
| 661 | using assms | |
| 662 | by (intro in_sets_PiFI[where J=J and S="\<lambda>i. space (M i)"]) | |
| 663 | (auto simp: product_def space_PiF) | |
| 664 | ||
| 665 | lemma singleton_subspace_set_in_sets: | |
| 666 |   assumes A: "A \<in> sets (PiF {J} M)"
 | |
| 667 | assumes "finite J" | |
| 668 | assumes "J \<in> I" | |
| 669 | shows "A \<in> sets (PiF I M)" | |
| 670 | using A[unfolded sets_PiF] | |
| 671 | apply (induct A) | |
| 672 | unfolding sets_PiF[symmetric] unfolding space_PiF[symmetric] | |
| 673 | using assms | |
| 674 | by (auto intro: in_sets_PiFI intro!: singleton_space_subset_in_sets) | |
| 675 | ||
| 50124 | 676 | lemma finite_measurable_singletonI: | 
| 50088 | 677 | assumes "finite I" | 
| 678 | assumes "\<And>J. J \<in> I \<Longrightarrow> finite J" | |
| 679 |   assumes MN: "\<And>J. J \<in> I \<Longrightarrow> A \<in> measurable (PiF {J} M) N"
 | |
| 680 | shows "A \<in> measurable (PiF I M) N" | |
| 681 | unfolding measurable_def | |
| 682 | proof safe | |
| 683 | fix y assume "y \<in> sets N" | |
| 684 |   have "A -` y \<inter> space (PiF I M) = (\<Union>J\<in>I. A -` y \<inter> space (PiF {J} M))"
 | |
| 685 | by (auto simp: space_PiF) | |
| 686 | also have "\<dots> \<in> sets (PiF I M)" | |
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62102diff
changeset | 687 | proof (rule sets.finite_UN) | 
| 50088 | 688 | show "finite I" by fact | 
| 689 | fix J assume "J \<in> I" | |
| 690 | with assms have "finite J" by simp | |
| 691 |     show "A -` y \<inter> space (PiF {J} M) \<in> sets (PiF I M)"
 | |
| 692 | by (rule singleton_subspace_set_in_sets[OF measurable_sets[OF assms(3)]]) fact+ | |
| 693 | qed | |
| 694 | finally show "A -` y \<inter> space (PiF I M) \<in> sets (PiF I M)" . | |
| 695 | next | |
| 696 | fix x assume "x \<in> space (PiF I M)" thus "A x \<in> space N" | |
| 697 | using MN[of "domain x"] | |
| 698 | by (auto simp: space_PiF measurable_space Pi'_def) | |
| 699 | qed | |
| 700 | ||
| 50124 | 701 | lemma countable_finite_comprehension: | 
| 50088 | 702 | fixes f :: "'a::countable set \<Rightarrow> _" | 
| 703 | assumes "\<And>s. P s \<Longrightarrow> finite s" | |
| 704 | assumes "\<And>s. P s \<Longrightarrow> f s \<in> sets M" | |
| 705 |   shows "\<Union>{f s|s. P s} \<in> sets M"
 | |
| 706 | proof - | |
| 707 |   have "\<Union>{f s|s. P s} = (\<Union>n::nat. let s = set (from_nat n) in if P s then f s else {})"
 | |
| 708 | proof safe | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 709 | fix x X s assume *: "x \<in> f s" "P s" | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 710 | with assms obtain l where "s = set l" using finite_list by blast | 
| 61808 | 711 |     with * show "x \<in> (\<Union>n. let s = set (from_nat n) in if P s then f s else {})" using \<open>P s\<close>
 | 
| 50088 | 712 | by (auto intro!: exI[where x="to_nat l"]) | 
| 713 | next | |
| 714 |     fix x n assume "x \<in> (let s = set (from_nat n) in if P s then f s else {})"
 | |
| 62390 | 715 |     thus "x \<in> \<Union>{f s|s. P s}" using assms by (auto simp: Let_def split: if_split_asm)
 | 
| 50088 | 716 | qed | 
| 717 |   hence "\<Union>{f s|s. P s} = (\<Union>n. let s = set (from_nat n) in if P s then f s else {})" by simp
 | |
| 718 | also have "\<dots> \<in> sets M" using assms by (auto simp: Let_def) | |
| 719 | finally show ?thesis . | |
| 720 | qed | |
| 721 | ||
| 722 | lemma space_subset_in_sets: | |
| 723 | fixes J::"'a::countable set set" | |
| 724 | assumes "J \<subseteq> I" | |
| 725 | assumes "\<And>j. j \<in> J \<Longrightarrow> finite j" | |
| 726 | shows "space (PiF J M) \<in> sets (PiF I M)" | |
| 727 | proof - | |
| 728 |   have "space (PiF J M) = \<Union>{space (PiF {j} M)|j. j \<in> J}"
 | |
| 729 | unfolding space_PiF by blast | |
| 730 | also have "\<dots> \<in> sets (PiF I M)" using assms | |
| 731 | by (intro countable_finite_comprehension) (auto simp: singleton_space_subset_in_sets) | |
| 732 | finally show ?thesis . | |
| 733 | qed | |
| 734 | ||
| 735 | lemma subspace_set_in_sets: | |
| 736 | fixes J::"'a::countable set set" | |
| 737 | assumes A: "A \<in> sets (PiF J M)" | |
| 738 | assumes "J \<subseteq> I" | |
| 739 | assumes "\<And>j. j \<in> J \<Longrightarrow> finite j" | |
| 740 | shows "A \<in> sets (PiF I M)" | |
| 741 | using A[unfolded sets_PiF] | |
| 742 | apply (induct A) | |
| 743 | unfolding sets_PiF[symmetric] unfolding space_PiF[symmetric] | |
| 744 | using assms | |
| 745 | by (auto intro: in_sets_PiFI intro!: space_subset_in_sets) | |
| 746 | ||
| 50124 | 747 | lemma countable_measurable_PiFI: | 
| 50088 | 748 | fixes I::"'a::countable set set" | 
| 749 |   assumes MN: "\<And>J. J \<in> I \<Longrightarrow> finite J \<Longrightarrow> A \<in> measurable (PiF {J} M) N"
 | |
| 750 | shows "A \<in> measurable (PiF I M) N" | |
| 751 | unfolding measurable_def | |
| 752 | proof safe | |
| 753 | fix y assume "y \<in> sets N" | |
| 754 |   have "A -` y = (\<Union>{A -` y \<inter> {x. domain x = J}|J. finite J})" by auto
 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 755 |   { fix x::"'a \<Rightarrow>\<^sub>F 'b"
 | 
| 50088 | 756 | from finite_list[of "domain x"] obtain xs where "set xs = domain x" by auto | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 757 | hence "\<exists>n. domain x = set (from_nat n)" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 758 | by (intro exI[where x="to_nat xs"]) auto } | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 759 |   hence "A -` y \<inter> space (PiF I M) = (\<Union>n. A -` y \<inter> space (PiF ({set (from_nat n)}\<inter>I) M))"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 760 | by (auto simp: space_PiF Pi'_def) | 
| 50088 | 761 | also have "\<dots> \<in> sets (PiF I M)" | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 762 | apply (intro sets.Int sets.countable_nat_UN subsetI, safe) | 
| 50088 | 763 | apply (case_tac "set (from_nat i) \<in> I") | 
| 764 | apply simp_all | |
| 765 | apply (rule singleton_subspace_set_in_sets[OF measurable_sets[OF MN]]) | |
| 61808 | 766 | using assms \<open>y \<in> sets N\<close> | 
| 50088 | 767 | apply (auto simp: space_PiF) | 
| 768 | done | |
| 769 | finally show "A -` y \<inter> space (PiF I M) \<in> sets (PiF I M)" . | |
| 770 | next | |
| 771 | fix x assume "x \<in> space (PiF I M)" thus "A x \<in> space N" | |
| 772 | using MN[of "domain x"] by (auto simp: space_PiF measurable_space Pi'_def) | |
| 773 | qed | |
| 774 | ||
| 775 | lemma measurable_PiF: | |
| 776 | assumes f: "\<And>x. x \<in> space N \<Longrightarrow> domain (f x) \<in> I \<and> (\<forall>i\<in>domain (f x). (f x) i \<in> space (M i))" | |
| 777 | assumes S: "\<And>J S. J \<in> I \<Longrightarrow> (\<And>i. i \<in> J \<Longrightarrow> S i \<in> sets (M i)) \<Longrightarrow> | |
| 778 | f -` (Pi' J S) \<inter> space N \<in> sets N" | |
| 779 | shows "f \<in> measurable N (PiF I M)" | |
| 780 | unfolding PiF_def | |
| 781 | using PiF_gen_subset | |
| 782 | apply (rule measurable_measure_of) | |
| 783 | using f apply force | |
| 784 | apply (insert S, auto) | |
| 785 | done | |
| 786 | ||
| 50124 | 787 | lemma restrict_sets_measurable: | 
| 50088 | 788 | assumes A: "A \<in> sets (PiF I M)" and "J \<subseteq> I" | 
| 789 |   shows "A \<inter> {m. domain m \<in> J} \<in> sets (PiF J M)"
 | |
| 790 | using A[unfolded sets_PiF] | |
| 50124 | 791 | proof (induct A) | 
| 792 | case (Basic a) | |
| 50088 | 793 | then obtain K S where S: "a = Pi' K S" "K \<in> I" "(\<forall>i\<in>K. S i \<in> sets (M i))" | 
| 794 | by auto | |
| 50124 | 795 | show ?case | 
| 50088 | 796 | proof cases | 
| 797 | assume "K \<in> J" | |
| 798 |     hence "a \<inter> {m. domain m \<in> J} \<in> {Pi' K X |X K. K \<in> J \<and> X \<in> (\<Pi> j\<in>K. sets (M j))}" using S
 | |
| 799 | by (auto intro!: exI[where x=K] exI[where x=S] simp: Pi'_def) | |
| 800 | also have "\<dots> \<subseteq> sets (PiF J M)" unfolding sets_PiF by auto | |
| 801 | finally show ?thesis . | |
| 802 | next | |
| 803 | assume "K \<notin> J" | |
| 804 |     hence "a \<inter> {m. domain m \<in> J} = {}" using S by (auto simp: Pi'_def)
 | |
| 805 | also have "\<dots> \<in> sets (PiF J M)" by simp | |
| 806 | finally show ?thesis . | |
| 807 | qed | |
| 808 | next | |
| 50124 | 809 | case (Union a) | 
| 50088 | 810 |   have "UNION UNIV a \<inter> {m. domain m \<in> J} = (\<Union>i. (a i \<inter> {m. domain m \<in> J}))"
 | 
| 811 | by simp | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 812 | also have "\<dots> \<in> sets (PiF J M)" using Union by (intro sets.countable_nat_UN) auto | 
| 50124 | 813 | finally show ?case . | 
| 50088 | 814 | next | 
| 50124 | 815 | case (Compl a) | 
| 50088 | 816 |   have "(space (PiF I M) - a) \<inter> {m. domain m \<in> J} = (space (PiF J M) - (a \<inter> {m. domain m \<in> J}))"
 | 
| 61808 | 817 | using \<open>J \<subseteq> I\<close> by (auto simp: space_PiF Pi'_def) | 
| 50124 | 818 | also have "\<dots> \<in> sets (PiF J M)" using Compl by auto | 
| 819 | finally show ?case by (simp add: space_PiF) | |
| 820 | qed simp | |
| 50088 | 821 | |
| 822 | lemma measurable_finmap_of: | |
| 823 | assumes f: "\<And>i. (\<exists>x \<in> space N. i \<in> J x) \<Longrightarrow> (\<lambda>x. f x i) \<in> measurable N (M i)" | |
| 824 | assumes J: "\<And>x. x \<in> space N \<Longrightarrow> J x \<in> I" "\<And>x. x \<in> space N \<Longrightarrow> finite (J x)" | |
| 825 |   assumes JN: "\<And>S. {x. J x = S} \<inter> space N \<in> sets N"
 | |
| 826 | shows "(\<lambda>x. finmap_of (J x) (f x)) \<in> measurable N (PiF I M)" | |
| 827 | proof (rule measurable_PiF) | |
| 828 | fix x assume "x \<in> space N" | |
| 829 | with J[of x] measurable_space[OF f] | |
| 830 | show "domain (finmap_of (J x) (f x)) \<in> I \<and> | |
| 831 | (\<forall>i\<in>domain (finmap_of (J x) (f x)). (finmap_of (J x) (f x)) i \<in> space (M i))" | |
| 832 | by auto | |
| 833 | next | |
| 834 | fix K S assume "K \<in> I" and *: "\<And>i. i \<in> K \<Longrightarrow> S i \<in> sets (M i)" | |
| 835 | with J have eq: "(\<lambda>x. finmap_of (J x) (f x)) -` Pi' K S \<inter> space N = | |
| 836 |     (if \<exists>x \<in> space N. K = J x \<and> finite K then if K = {} then {x \<in> space N. J x = K}
 | |
| 837 |       else (\<Inter>i\<in>K. (\<lambda>x. f x i) -` S i \<inter> {x \<in> space N. J x = K}) else {})"
 | |
| 838 | by (auto simp: Pi'_def) | |
| 839 |   have r: "{x \<in> space N. J x = K} = space N \<inter> ({x. J x = K} \<inter> space N)" by auto
 | |
| 840 | show "(\<lambda>x. finmap_of (J x) (f x)) -` Pi' K S \<inter> space N \<in> sets N" | |
| 841 | unfolding eq r | |
| 842 | apply (simp del: INT_simps add: ) | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 843 | apply (intro conjI impI sets.finite_INT JN sets.Int[OF sets.top]) | 
| 50088 | 844 | apply simp apply assumption | 
| 845 | apply (subst Int_assoc[symmetric]) | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 846 | apply (rule sets.Int) | 
| 50088 | 847 | apply (intro measurable_sets[OF f] *) apply force apply assumption | 
| 848 | apply (intro JN) | |
| 849 | done | |
| 850 | qed | |
| 851 | ||
| 852 | lemma measurable_PiM_finmap_of: | |
| 853 | assumes "finite J" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 854 |   shows "finmap_of J \<in> measurable (Pi\<^sub>M J M) (PiF {J} M)"
 | 
| 50088 | 855 | apply (rule measurable_finmap_of) | 
| 856 | apply (rule measurable_component_singleton) | |
| 857 | apply simp | |
| 858 | apply rule | |
| 61808 | 859 | apply (rule \<open>finite J\<close>) | 
| 50088 | 860 | apply simp | 
| 861 | done | |
| 862 | ||
| 863 | lemma proj_measurable_singleton: | |
| 50124 | 864 | assumes "A \<in> sets (M i)" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 865 |   shows "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space (PiF {I} M) \<in> sets (PiF {I} M)"
 | 
| 50088 | 866 | proof cases | 
| 867 | assume "i \<in> I" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 868 |   hence "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space (PiF {I} M) =
 | 
| 50088 | 869 | Pi' I (\<lambda>x. if x = i then A else space (M x))" | 
| 61808 | 870 | using sets.sets_into_space[OF ] \<open>A \<in> sets (M i)\<close> assms | 
| 50088 | 871 | by (auto simp: space_PiF Pi'_def) | 
| 61808 | 872 | thus ?thesis using assms \<open>A \<in> sets (M i)\<close> | 
| 50088 | 873 | by (intro in_sets_PiFI) auto | 
| 874 | next | |
| 875 | assume "i \<notin> I" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 876 |   hence "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space (PiF {I} M) =
 | 
| 50088 | 877 |     (if undefined \<in> A then space (PiF {I} M) else {})" by (auto simp: space_PiF Pi'_def)
 | 
| 878 | thus ?thesis by simp | |
| 879 | qed | |
| 880 | ||
| 881 | lemma measurable_proj_singleton: | |
| 50124 | 882 | assumes "i \<in> I" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 883 |   shows "(\<lambda>x. (x)\<^sub>F i) \<in> measurable (PiF {I} M) (M i)"
 | 
| 50124 | 884 | by (unfold measurable_def, intro CollectI conjI ballI proj_measurable_singleton assms) | 
| 61808 | 885 | (insert \<open>i \<in> I\<close>, auto simp: space_PiF) | 
| 50088 | 886 | |
| 887 | lemma measurable_proj_countable: | |
| 888 | fixes I::"'a::countable set set" | |
| 889 | assumes "y \<in> space (M i)" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 890 | shows "(\<lambda>x. if i \<in> domain x then (x)\<^sub>F i else y) \<in> measurable (PiF I M) (M i)" | 
| 50088 | 891 | proof (rule countable_measurable_PiFI) | 
| 892 | fix J assume "J \<in> I" "finite J" | |
| 893 |   show "(\<lambda>x. if i \<in> domain x then x i else y) \<in> measurable (PiF {J} M) (M i)"
 | |
| 894 | unfolding measurable_def | |
| 895 | proof safe | |
| 896 | fix z assume "z \<in> sets (M i)" | |
| 897 |     have "(\<lambda>x. if i \<in> domain x then x i else y) -` z \<inter> space (PiF {J} M) =
 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 898 |       (\<lambda>x. if i \<in> J then (x)\<^sub>F i else y) -` z \<inter> space (PiF {J} M)"
 | 
| 50088 | 899 | by (auto simp: space_PiF Pi'_def) | 
| 61808 | 900 |     also have "\<dots> \<in> sets (PiF {J} M)" using \<open>z \<in> sets (M i)\<close> \<open>finite J\<close>
 | 
| 50088 | 901 | by (cases "i \<in> J") (auto intro!: measurable_sets[OF measurable_proj_singleton]) | 
| 902 |     finally show "(\<lambda>x. if i \<in> domain x then x i else y) -` z \<inter> space (PiF {J} M) \<in>
 | |
| 903 |       sets (PiF {J} M)" .
 | |
| 61808 | 904 | qed (insert \<open>y \<in> space (M i)\<close>, auto simp: space_PiF Pi'_def) | 
| 50088 | 905 | qed | 
| 906 | ||
| 907 | lemma measurable_restrict_proj: | |
| 908 | assumes "J \<in> II" "finite J" | |
| 909 | shows "finmap_of J \<in> measurable (PiM J M) (PiF II M)" | |
| 910 | using assms | |
| 911 | by (intro measurable_finmap_of measurable_component_singleton) auto | |
| 912 | ||
| 50124 | 913 | lemma measurable_proj_PiM: | 
| 50088 | 914 | fixes J K ::"'a::countable set" and I::"'a set set" | 
| 915 | assumes "finite J" "J \<in> I" | |
| 916 | assumes "x \<in> space (PiM J M)" | |
| 50124 | 917 |   shows "proj \<in> measurable (PiF {J} M) (PiM J M)"
 | 
| 50088 | 918 | proof (rule measurable_PiM_single) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 919 |   show "proj \<in> space (PiF {J} M) \<rightarrow> (\<Pi>\<^sub>E i \<in> J. space (M i))"
 | 
| 50088 | 920 | using assms by (auto simp add: space_PiM space_PiF extensional_def sets_PiF Pi'_def) | 
| 921 | next | |
| 922 | fix A i assume A: "i \<in> J" "A \<in> sets (M i)" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 923 |   show "{\<omega> \<in> space (PiF {J} M). (\<omega>)\<^sub>F i \<in> A} \<in> sets (PiF {J} M)"
 | 
| 50088 | 924 | proof | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 925 |     have "{\<omega> \<in> space (PiF {J} M). (\<omega>)\<^sub>F i \<in> A} =
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 926 |       (\<lambda>\<omega>. (\<omega>)\<^sub>F i) -` A \<inter> space (PiF {J} M)" by auto
 | 
| 50088 | 927 |     also have "\<dots> \<in> sets (PiF {J} M)"
 | 
| 928 | using assms A by (auto intro: measurable_sets[OF measurable_proj_singleton] simp: space_PiM) | |
| 929 | finally show ?thesis . | |
| 930 | qed simp | |
| 931 | qed | |
| 932 | ||
| 933 | lemma space_PiF_singleton_eq_product: | |
| 934 | assumes "finite I" | |
| 935 |   shows "space (PiF {I} M) = (\<Pi>' i\<in>I. space (M i))"
 | |
| 936 | by (auto simp: product_def space_PiF assms) | |
| 937 | ||
| 61808 | 938 | text \<open>adapted from @{thm sets_PiM_single}\<close>
 | 
| 50088 | 939 | |
| 940 | lemma sets_PiF_single: | |
| 941 |   assumes "finite I" "I \<noteq> {}"
 | |
| 942 |   shows "sets (PiF {I} M) =
 | |
| 943 | sigma_sets (\<Pi>' i\<in>I. space (M i)) | |
| 944 |       {{f\<in>\<Pi>' i\<in>I. space (M i). f i \<in> A} | i A. i \<in> I \<and> A \<in> sets (M i)}"
 | |
| 945 | (is "_ = sigma_sets ?\<Omega> ?R") | |
| 946 | unfolding sets_PiF_singleton | |
| 947 | proof (rule sigma_sets_eqI) | |
| 948 | interpret R: sigma_algebra ?\<Omega> "sigma_sets ?\<Omega> ?R" by (rule sigma_algebra_sigma_sets) auto | |
| 949 |   fix A assume "A \<in> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
 | |
| 950 | then obtain X where X: "A = Pi' I X" "X \<in> (\<Pi> j\<in>I. sets (M j))" by auto | |
| 951 | show "A \<in> sigma_sets ?\<Omega> ?R" | |
| 952 | proof - | |
| 61808 | 953 |     from \<open>I \<noteq> {}\<close> X have "A = (\<Inter>j\<in>I. {f\<in>space (PiF {I} M). f j \<in> X j})"
 | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 954 | using sets.sets_into_space | 
| 50088 | 955 | by (auto simp: space_PiF product_def) blast | 
| 956 | also have "\<dots> \<in> sigma_sets ?\<Omega> ?R" | |
| 61808 | 957 |       using X \<open>I \<noteq> {}\<close> assms by (intro R.finite_INT) (auto simp: space_PiF)
 | 
| 50088 | 958 | finally show "A \<in> sigma_sets ?\<Omega> ?R" . | 
| 959 | qed | |
| 960 | next | |
| 961 | fix A assume "A \<in> ?R" | |
| 962 |   then obtain i B where A: "A = {f\<in>\<Pi>' i\<in>I. space (M i). f i \<in> B}" "i \<in> I" "B \<in> sets (M i)"
 | |
| 963 | by auto | |
| 964 | then have "A = (\<Pi>' j \<in> I. if j = i then B else space (M j))" | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 965 | using sets.sets_into_space[OF A(3)] | 
| 62390 | 966 | apply (auto simp: Pi'_iff split: if_split_asm) | 
| 50088 | 967 | apply blast | 
| 968 | done | |
| 969 |   also have "\<dots> \<in> sigma_sets ?\<Omega> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}"
 | |
| 970 | using A | |
| 971 | by (intro sigma_sets.Basic ) | |
| 972 | (auto intro: exI[where x="\<lambda>j. if j = i then B else space (M j)"]) | |
| 973 |   finally show "A \<in> sigma_sets ?\<Omega> {Pi' I X |X. X \<in> (\<Pi> j\<in>I. sets (M j))}" .
 | |
| 974 | qed | |
| 975 | ||
| 61808 | 976 | text \<open>adapted from @{thm PiE_cong}\<close>
 | 
| 50088 | 977 | |
| 978 | lemma Pi'_cong: | |
| 979 | assumes "finite I" | |
| 980 | assumes "\<And>i. i \<in> I \<Longrightarrow> f i = g i" | |
| 981 | shows "Pi' I f = Pi' I g" | |
| 982 | using assms by (auto simp: Pi'_def) | |
| 983 | ||
| 61808 | 984 | text \<open>adapted from @{thm Pi_UN}\<close>
 | 
| 50088 | 985 | |
| 986 | lemma Pi'_UN: | |
| 987 | fixes A :: "nat \<Rightarrow> 'i \<Rightarrow> 'a set" | |
| 988 | assumes "finite I" | |
| 989 | assumes mono: "\<And>i n m. i \<in> I \<Longrightarrow> n \<le> m \<Longrightarrow> A n i \<subseteq> A m i" | |
| 990 | shows "(\<Union>n. Pi' I (A n)) = Pi' I (\<lambda>i. \<Union>n. A n i)" | |
| 991 | proof (intro set_eqI iffI) | |
| 992 | fix f assume "f \<in> Pi' I (\<lambda>i. \<Union>n. A n i)" | |
| 61808 | 993 | then have "\<forall>i\<in>I. \<exists>n. f i \<in> A n i" "domain f = I" by (auto simp: \<open>finite I\<close> Pi'_def) | 
| 50088 | 994 | from bchoice[OF this(1)] obtain n where n: "\<And>i. i \<in> I \<Longrightarrow> f i \<in> (A (n i) i)" by auto | 
| 995 | obtain k where k: "\<And>i. i \<in> I \<Longrightarrow> n i \<le> k" | |
| 61808 | 996 | using \<open>finite I\<close> finite_nat_set_iff_bounded_le[of "n`I"] by auto | 
| 50088 | 997 | have "f \<in> Pi' I (\<lambda>i. A k i)" | 
| 998 | proof | |
| 999 | fix i assume "i \<in> I" | |
| 61808 | 1000 | from mono[OF this, of "n i" k] k[OF this] n[OF this] \<open>domain f = I\<close> \<open>i \<in> I\<close> | 
| 1001 | show "f i \<in> A k i " by (auto simp: \<open>finite I\<close>) | |
| 1002 | qed (simp add: \<open>domain f = I\<close> \<open>finite I\<close>) | |
| 50088 | 1003 | then show "f \<in> (\<Union>n. Pi' I (A n))" by auto | 
| 61808 | 1004 | qed (auto simp: Pi'_def \<open>finite I\<close>) | 
| 50088 | 1005 | |
| 61808 | 1006 | text \<open>adapted from @{thm sets_PiM_sigma}\<close>
 | 
| 50088 | 1007 | |
| 1008 | lemma sigma_fprod_algebra_sigma_eq: | |
| 51106 | 1009 | fixes E :: "'i \<Rightarrow> 'a set set" and S :: "'i \<Rightarrow> nat \<Rightarrow> 'a set" | 
| 50088 | 1010 |   assumes [simp]: "finite I" "I \<noteq> {}"
 | 
| 1011 | and S_union: "\<And>i. i \<in> I \<Longrightarrow> (\<Union>j. S i j) = space (M i)" | |
| 1012 | and S_in_E: "\<And>i. i \<in> I \<Longrightarrow> range (S i) \<subseteq> E i" | |
| 1013 | assumes E_closed: "\<And>i. i \<in> I \<Longrightarrow> E i \<subseteq> Pow (space (M i))" | |
| 1014 | and E_generates: "\<And>i. i \<in> I \<Longrightarrow> sets (M i) = sigma_sets (space (M i)) (E i)" | |
| 1015 |   defines "P == { Pi' I F | F. \<forall>i\<in>I. F i \<in> E i }"
 | |
| 1016 |   shows "sets (PiF {I} M) = sigma_sets (space (PiF {I} M)) P"
 | |
| 1017 | proof | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1018 |   let ?P = "sigma (space (Pi\<^sub>F {I} M)) P"
 | 
| 61808 | 1019 | from \<open>finite I\<close>[THEN ex_bij_betw_finite_nat] guess T .. | 
| 51106 | 1020 | then have T: "\<And>i. i \<in> I \<Longrightarrow> T i < card I" "\<And>i. i\<in>I \<Longrightarrow> the_inv_into I T (T i) = i" | 
| 61808 | 1021 | by (auto simp add: bij_betw_def set_eq_iff image_iff the_inv_into_f_f simp del: \<open>finite I\<close>) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1022 |   have P_closed: "P \<subseteq> Pow (space (Pi\<^sub>F {I} M))"
 | 
| 50088 | 1023 | using E_closed by (auto simp: space_PiF P_def Pi'_iff subset_eq) | 
| 1024 | then have space_P: "space ?P = (\<Pi>' i\<in>I. space (M i))" | |
| 1025 | by (simp add: space_PiF) | |
| 1026 |   have "sets (PiF {I} M) =
 | |
| 1027 |       sigma_sets (space ?P) {{f \<in> \<Pi>' i\<in>I. space (M i). f i \<in> A} |i A. i \<in> I \<and> A \<in> sets (M i)}"
 | |
| 1028 | using sets_PiF_single[of I M] by (simp add: space_P) | |
| 1029 |   also have "\<dots> \<subseteq> sets (sigma (space (PiF {I} M)) P)"
 | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 1030 | proof (safe intro!: sets.sigma_sets_subset) | 
| 50088 | 1031 | fix i A assume "i \<in> I" and A: "A \<in> sets (M i)" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1032 | have "(\<lambda>x. (x)\<^sub>F i) \<in> measurable ?P (sigma (space (M i)) (E i))" | 
| 50088 | 1033 | proof (subst measurable_iff_measure_of) | 
| 61808 | 1034 | show "E i \<subseteq> Pow (space (M i))" using \<open>i \<in> I\<close> by fact | 
| 1035 | from space_P \<open>i \<in> I\<close> show "(\<lambda>x. (x)\<^sub>F i) \<in> space ?P \<rightarrow> space (M i)" | |
| 50088 | 1036 | by auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1037 | show "\<forall>A\<in>E i. (\<lambda>x. (x)\<^sub>F i) -` A \<inter> space ?P \<in> sets ?P" | 
| 50088 | 1038 | proof | 
| 1039 | fix A assume A: "A \<in> E i" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1040 | then have "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space ?P = (\<Pi>' j\<in>I. if i = j then A else space (M j))" | 
| 62390 | 1041 | using E_closed \<open>i \<in> I\<close> by (auto simp: space_P Pi_iff subset_eq split: if_split_asm) | 
| 50088 | 1042 | also have "\<dots> = (\<Pi>' j\<in>I. \<Union>n. if i = j then A else S j n)" | 
| 1043 | by (intro Pi'_cong) (simp_all add: S_union) | |
| 51106 | 1044 |         also have "\<dots> = (\<Union>xs\<in>{xs. length xs = card I}. \<Pi>' j\<in>I. if i = j then A else S j (xs ! T j))"
 | 
| 1045 | using T | |
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62102diff
changeset | 1046 | apply (auto simp del: Union_iff) | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62102diff
changeset | 1047 | apply (simp_all add: Pi'_iff bchoice_iff del: Union_iff) | 
| 51106 | 1048 | apply (erule conjE exE)+ | 
| 1049 | apply (rule_tac x="map (\<lambda>n. f (the_inv_into I T n)) [0..<card I]" in exI) | |
| 1050 | apply (auto simp: bij_betw_def) | |
| 1051 | done | |
| 50088 | 1052 | also have "\<dots> \<in> sets ?P" | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 1053 | proof (safe intro!: sets.countable_UN) | 
| 51106 | 1054 | fix xs show "(\<Pi>' j\<in>I. if i = j then A else S j (xs ! T j)) \<in> sets ?P" | 
| 50088 | 1055 | using A S_in_E | 
| 1056 | by (simp add: P_closed) | |
| 51106 | 1057 | (auto simp: P_def subset_eq intro!: exI[of _ "\<lambda>j. if i = j then A else S j (xs ! T j)"]) | 
| 50088 | 1058 | qed | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1059 | finally show "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space ?P \<in> sets ?P" | 
| 50088 | 1060 | using P_closed by simp | 
| 1061 | qed | |
| 1062 | qed | |
| 61808 | 1063 | from measurable_sets[OF this, of A] A \<open>i \<in> I\<close> E_closed | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1064 | have "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space ?P \<in> sets ?P" | 
| 50088 | 1065 | by (simp add: E_generates) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1066 |     also have "(\<lambda>x. (x)\<^sub>F i) -` A \<inter> space ?P = {f \<in> \<Pi>' i\<in>I. space (M i). f i \<in> A}"
 | 
| 50088 | 1067 | using P_closed by (auto simp: space_PiF) | 
| 1068 | finally show "\<dots> \<in> sets ?P" . | |
| 1069 | qed | |
| 1070 |   finally show "sets (PiF {I} M) \<subseteq> sigma_sets (space (PiF {I} M)) P"
 | |
| 1071 | by (simp add: P_closed) | |
| 1072 |   show "sigma_sets (space (PiF {I} M)) P \<subseteq> sets (PiF {I} M)"
 | |
| 61808 | 1073 |     using \<open>finite I\<close> \<open>I \<noteq> {}\<close>
 | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 1074 | by (auto intro!: sets.sigma_sets_subset product_in_sets_PiFI simp: E_generates P_def) | 
| 50088 | 1075 | qed | 
| 1076 | ||
| 1077 | lemma product_open_generates_sets_PiF_single: | |
| 1078 |   assumes "I \<noteq> {}"
 | |
| 1079 | assumes [simp]: "finite I" | |
| 50881 
ae630bab13da
renamed countable_basis_space to second_countable_topology
 hoelzl parents: 
50251diff
changeset | 1080 |   shows "sets (PiF {I} (\<lambda>_. borel::'b::second_countable_topology measure)) =
 | 
| 50088 | 1081 |     sigma_sets (space (PiF {I} (\<lambda>_. borel))) {Pi' I F |F. (\<forall>i\<in>I. F i \<in> Collect open)}"
 | 
| 1082 | proof - | |
| 51106 | 1083 | from open_countable_basisE[OF open_UNIV] guess S::"'b set set" . note S = this | 
| 50088 | 1084 | show ?thesis | 
| 1085 | proof (rule sigma_fprod_algebra_sigma_eq) | |
| 1086 | show "finite I" by simp | |
| 1087 |     show "I \<noteq> {}" by fact
 | |
| 63040 | 1088 | define S' where "S' = from_nat_into S" | 
| 51106 | 1089 | show "(\<Union>j. S' j) = space borel" | 
| 1090 | using S | |
| 1091 | apply (auto simp add: from_nat_into countable_basis_proj S'_def basis_proj_def) | |
| 1092 | apply (metis (lifting, mono_tags) UNIV_I UnionE basis_proj_def countable_basis_proj countable_subset from_nat_into_surj) | |
| 1093 | done | |
| 1094 | show "range S' \<subseteq> Collect open" | |
| 1095 | using S | |
| 1096 | apply (auto simp add: from_nat_into countable_basis_proj S'_def) | |
| 1097 | apply (metis UNIV_not_empty Union_empty from_nat_into set_mp topological_basis_open[OF basis_proj] basis_proj_def) | |
| 1098 | done | |
| 50088 | 1099 | show "Collect open \<subseteq> Pow (space borel)" by simp | 
| 1100 | show "sets borel = sigma_sets (space borel) (Collect open)" | |
| 1101 | by (simp add: borel_def) | |
| 1102 | qed | |
| 1103 | qed | |
| 1104 | ||
| 61988 | 1105 | lemma finmap_UNIV[simp]: "(\<Union>J\<in>Collect finite. \<Pi>' j\<in>J. UNIV) = UNIV" by auto | 
| 50088 | 1106 | |
| 1107 | lemma borel_eq_PiF_borel: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1108 |   shows "(borel :: ('i::countable \<Rightarrow>\<^sub>F 'a::polish_space) measure) =
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1109 | PiF (Collect finite) (\<lambda>_. borel :: 'a measure)" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1110 | unfolding borel_def PiF_def | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1111 | proof (rule measure_eqI, clarsimp, rule sigma_sets_eqI) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1112 |   fix a::"('i \<Rightarrow>\<^sub>F 'a) set" assume "a \<in> Collect open" hence "open a" by simp
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1113 | then obtain B' where B': "B'\<subseteq>basis_finmap" "a = \<Union>B'" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1114 | using finmap_topological_basis by (force simp add: topological_basis_def) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1115 |   have "a \<in> sigma UNIV {Pi' J X |X J. finite J \<and> X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)}"
 | 
| 61808 | 1116 | unfolding \<open>a = \<Union>B'\<close> | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1117 | proof (rule sets.countable_Union) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1118 | from B' countable_basis_finmap show "countable B'" by (metis countable_subset) | 
| 50088 | 1119 | next | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1120 | show "B' \<subseteq> sets (sigma UNIV | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1121 |       {Pi' J X |X J. finite J \<and> X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)})" (is "_ \<subseteq> sets ?s")
 | 
| 50088 | 1122 | proof | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1123 | fix x assume "x \<in> B'" with B' have "x \<in> basis_finmap" by auto | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1124 | then obtain J X where "x = Pi' J X" "finite J" "X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)" | 
| 51106 | 1125 | by (auto simp: basis_finmap_def topological_basis_open[OF basis_proj]) | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1126 | thus "x \<in> sets ?s" by auto | 
| 50088 | 1127 | qed | 
| 1128 | qed | |
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1129 |   thus "a \<in> sigma_sets UNIV {Pi' J X |X J. finite J \<and> X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)}"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1130 | by simp | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1131 | next | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1132 |   fix b::"('i \<Rightarrow>\<^sub>F 'a) set"
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1133 |   assume "b \<in> {Pi' J X |X J. finite J \<and> X \<in> J \<rightarrow> sigma_sets UNIV (Collect open)}"
 | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1134 | hence b': "b \<in> sets (Pi\<^sub>F (Collect finite) (\<lambda>_. borel))" by (auto simp: sets_PiF borel_def) | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1135 |   let ?b = "\<lambda>J. b \<inter> {x. domain x = J}"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1136 | have "b = \<Union>((\<lambda>J. ?b J) ` Collect finite)" by auto | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1137 | also have "\<dots> \<in> sets borel" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1138 | proof (rule sets.countable_Union, safe) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1139 | fix J::"'i set" assume "finite J" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1140 |     { assume ef: "J = {}"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1141 | have "?b J \<in> sets borel" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1142 | proof cases | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1143 |         assume "?b J \<noteq> {}"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1144 |         then obtain f where "f \<in> b" "domain f = {}" using ef by auto
 | 
| 61808 | 1145 |         hence "?b J = {f}" using \<open>J = {}\<close>
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1146 | by (auto simp: finmap_eq_iff) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1147 |         also have "{f} \<in> sets borel" by simp
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1148 | finally show ?thesis . | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1149 | qed simp | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1150 |     } moreover {
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1151 |       assume "J \<noteq> ({}::'i set)"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1152 |       have "(?b J) = b \<inter> {m. domain m \<in> {J}}" by auto
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1153 |       also have "\<dots> \<in> sets (PiF {J} (\<lambda>_. borel))"
 | 
| 61808 | 1154 | using b' by (rule restrict_sets_measurable) (auto simp: \<open>finite J\<close>) | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1155 |       also have "\<dots> = sigma_sets (space (PiF {J} (\<lambda>_. borel)))
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1156 |         {Pi' (J) F |F. (\<forall>j\<in>J. F j \<in> Collect open)}"
 | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1157 | (is "_ = sigma_sets _ ?P") | 
| 61808 | 1158 |        by (rule product_open_generates_sets_PiF_single[OF \<open>J \<noteq> {}\<close> \<open>finite J\<close>])
 | 
| 50245 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1159 | also have "\<dots> \<subseteq> sigma_sets UNIV (Collect open)" | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1160 | by (intro sigma_sets_mono'') (auto intro!: open_Pi'I simp: space_PiF) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1161 | finally have "(?b J) \<in> sets borel" by (simp add: borel_def) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1162 | } ultimately show "(?b J) \<in> sets borel" by blast | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1163 | qed (simp add: countable_Collect_finite) | 
| 
dea9363887a6
based countable topological basis on Countable_Set
 immler parents: 
50244diff
changeset | 1164 | finally show "b \<in> sigma_sets UNIV (Collect open)" by (simp add: borel_def) | 
| 50088 | 1165 | qed (simp add: emeasure_sigma borel_def PiF_def) | 
| 1166 | ||
| 61808 | 1167 | subsection \<open>Isomorphism between Functions and Finite Maps\<close> | 
| 50088 | 1168 | |
| 50124 | 1169 | lemma measurable_finmap_compose: | 
| 50088 | 1170 | shows "(\<lambda>m. compose J m f) \<in> measurable (PiM (f ` J) (\<lambda>_. M)) (PiM J (\<lambda>_. M))" | 
| 50124 | 1171 | unfolding compose_def by measurable | 
| 50088 | 1172 | |
| 50124 | 1173 | lemma measurable_compose_inv: | 
| 50088 | 1174 | assumes inj: "\<And>j. j \<in> J \<Longrightarrow> f' (f j) = j" | 
| 1175 | shows "(\<lambda>m. compose (f ` J) m f') \<in> measurable (PiM J (\<lambda>_. M)) (PiM (f ` J) (\<lambda>_. M))" | |
| 50124 | 1176 | unfolding compose_def by (rule measurable_restrict) (auto simp: inj) | 
| 50088 | 1177 | |
| 1178 | locale function_to_finmap = | |
| 1179 | fixes J::"'a set" and f :: "'a \<Rightarrow> 'b::countable" and f' | |
| 1180 | assumes [simp]: "finite J" | |
| 1181 | assumes inv: "i \<in> J \<Longrightarrow> f' (f i) = i" | |
| 1182 | begin | |
| 1183 | ||
| 61808 | 1184 | text \<open>to measure finmaps\<close> | 
| 50088 | 1185 | |
| 1186 | definition "fm = (finmap_of (f ` J)) o (\<lambda>g. compose (f ` J) g f')" | |
| 1187 | ||
| 1188 | lemma domain_fm[simp]: "domain (fm x) = f ` J" | |
| 1189 | unfolding fm_def by simp | |
| 1190 | ||
| 1191 | lemma fm_restrict[simp]: "fm (restrict y J) = fm y" | |
| 1192 | unfolding fm_def by (auto simp: compose_def inv intro: restrict_ext) | |
| 1193 | ||
| 1194 | lemma fm_product: | |
| 1195 | assumes "\<And>i. space (M i) = UNIV" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1196 | shows "fm -` Pi' (f ` J) S \<inter> space (Pi\<^sub>M J M) = (\<Pi>\<^sub>E j \<in> J. S (f j))" | 
| 50088 | 1197 | using assms | 
| 1198 | by (auto simp: inv fm_def compose_def space_PiM Pi'_def) | |
| 1199 | ||
| 1200 | lemma fm_measurable: | |
| 1201 | assumes "f ` J \<in> N" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1202 | shows "fm \<in> measurable (Pi\<^sub>M J (\<lambda>_. M)) (Pi\<^sub>F N (\<lambda>_. M))" | 
| 50088 | 1203 | unfolding fm_def | 
| 1204 | proof (rule measurable_comp, rule measurable_compose_inv) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1205 | show "finmap_of (f ` J) \<in> measurable (Pi\<^sub>M (f ` J) (\<lambda>_. M)) (PiF N (\<lambda>_. M)) " | 
| 50088 | 1206 | using assms by (intro measurable_finmap_of measurable_component_singleton) auto | 
| 1207 | qed (simp_all add: inv) | |
| 1208 | ||
| 1209 | lemma proj_fm: | |
| 1210 | assumes "x \<in> J" | |
| 1211 | shows "fm m (f x) = m x" | |
| 1212 | using assms by (auto simp: fm_def compose_def o_def inv) | |
| 1213 | ||
| 1214 | lemma inj_on_compose_f': "inj_on (\<lambda>g. compose (f ` J) g f') (extensional J)" | |
| 1215 | proof (rule inj_on_inverseI) | |
| 1216 | fix x::"'a \<Rightarrow> 'c" assume "x \<in> extensional J" | |
| 1217 | thus "(\<lambda>x. compose J x f) (compose (f ` J) x f') = x" | |
| 1218 | by (auto simp: compose_def inv extensional_def) | |
| 1219 | qed | |
| 1220 | ||
| 1221 | lemma inj_on_fm: | |
| 1222 | assumes "\<And>i. space (M i) = UNIV" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1223 | shows "inj_on fm (space (Pi\<^sub>M J M))" | 
| 50088 | 1224 | using assms | 
| 50123 
69b35a75caf3
merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
 hoelzl parents: 
50100diff
changeset | 1225 | apply (auto simp: fm_def space_PiM PiE_def) | 
| 50088 | 1226 | apply (rule comp_inj_on) | 
| 1227 | apply (rule inj_on_compose_f') | |
| 1228 | apply (rule finmap_of_inj_on_extensional_finite) | |
| 1229 | apply simp | |
| 1230 | apply (auto) | |
| 1231 | done | |
| 1232 | ||
| 61808 | 1233 | text \<open>to measure functions\<close> | 
| 50088 | 1234 | |
| 1235 | definition "mf = (\<lambda>g. compose J g f) o proj" | |
| 1236 | ||
| 1237 | lemma mf_fm: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1238 | assumes "x \<in> space (Pi\<^sub>M J (\<lambda>_. M))" | 
| 50088 | 1239 | shows "mf (fm x) = x" | 
| 1240 | proof - | |
| 1241 | have "mf (fm x) \<in> extensional J" | |
| 1242 | by (auto simp: mf_def extensional_def compose_def) | |
| 1243 | moreover | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 1244 | have "x \<in> extensional J" using assms sets.sets_into_space | 
| 50123 
69b35a75caf3
merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
 hoelzl parents: 
50100diff
changeset | 1245 | by (force simp: space_PiM PiE_def) | 
| 50088 | 1246 | moreover | 
| 1247 |   { fix i assume "i \<in> J"
 | |
| 1248 | hence "mf (fm x) i = x i" | |
| 1249 | by (auto simp: inv mf_def compose_def fm_def) | |
| 1250 | } | |
| 1251 | ultimately | |
| 1252 | show ?thesis by (rule extensionalityI) | |
| 1253 | qed | |
| 1254 | ||
| 1255 | lemma mf_measurable: | |
| 1256 | assumes "space M = UNIV" | |
| 1257 |   shows "mf \<in> measurable (PiF {f ` J} (\<lambda>_. M)) (PiM J (\<lambda>_. M))"
 | |
| 1258 | unfolding mf_def | |
| 1259 | proof (rule measurable_comp, rule measurable_proj_PiM) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1260 | show "(\<lambda>g. compose J g f) \<in> measurable (Pi\<^sub>M (f ` J) (\<lambda>x. M)) (Pi\<^sub>M J (\<lambda>_. M))" | 
| 50124 | 1261 | by (rule measurable_finmap_compose) | 
| 50088 | 1262 | qed (auto simp add: space_PiM extensional_def assms) | 
| 1263 | ||
| 1264 | lemma fm_image_measurable: | |
| 1265 | assumes "space M = UNIV" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1266 | assumes "X \<in> sets (Pi\<^sub>M J (\<lambda>_. M))" | 
| 50088 | 1267 |   shows "fm ` X \<in> sets (PiF {f ` J} (\<lambda>_. M))"
 | 
| 1268 | proof - | |
| 1269 |   have "fm ` X = (mf) -` X \<inter> space (PiF {f ` J} (\<lambda>_. M))"
 | |
| 1270 | proof safe | |
| 1271 | fix x assume "x \<in> X" | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50124diff
changeset | 1272 | with mf_fm[of x] sets.sets_into_space[OF assms(2)] show "fm x \<in> mf -` X" by auto | 
| 50088 | 1273 |     show "fm x \<in> space (PiF {f ` J} (\<lambda>_. M))" by (simp add: space_PiF assms)
 | 
| 1274 | next | |
| 1275 | fix y x | |
| 1276 | assume x: "mf y \<in> X" | |
| 1277 |     assume y: "y \<in> space (PiF {f ` J} (\<lambda>_. M))"
 | |
| 1278 | thus "y \<in> fm ` X" | |
| 1279 | by (intro image_eqI[OF _ x], unfold finmap_eq_iff) | |
| 1280 | (auto simp: space_PiF fm_def mf_def compose_def inv Pi'_def) | |
| 1281 | qed | |
| 1282 |   also have "\<dots> \<in> sets (PiF {f ` J} (\<lambda>_. M))"
 | |
| 1283 | using assms | |
| 1284 | by (intro measurable_sets[OF mf_measurable]) auto | |
| 1285 | finally show ?thesis . | |
| 1286 | qed | |
| 1287 | ||
| 1288 | lemma fm_image_measurable_finite: | |
| 1289 | assumes "space M = UNIV" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1290 | assumes "X \<in> sets (Pi\<^sub>M J (\<lambda>_. M::'c measure))" | 
| 50088 | 1291 | shows "fm ` X \<in> sets (PiF (Collect finite) (\<lambda>_. M::'c measure))" | 
| 1292 | using fm_image_measurable[OF assms] | |
| 1293 | by (rule subspace_set_in_sets) (auto simp: finite_subset) | |
| 1294 | ||
| 61808 | 1295 | text \<open>measure on finmaps\<close> | 
| 50088 | 1296 | |
| 1297 | definition "mapmeasure M N = distr M (PiF (Collect finite) N) (fm)" | |
| 1298 | ||
| 1299 | lemma sets_mapmeasure[simp]: "sets (mapmeasure M N) = sets (PiF (Collect finite) N)" | |
| 1300 | unfolding mapmeasure_def by simp | |
| 1301 | ||
| 1302 | lemma space_mapmeasure[simp]: "space (mapmeasure M N) = space (PiF (Collect finite) N)" | |
| 1303 | unfolding mapmeasure_def by simp | |
| 1304 | ||
| 1305 | lemma mapmeasure_PiF: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1306 | assumes s1: "space M = space (Pi\<^sub>M J (\<lambda>_. N))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1307 | assumes s2: "sets M = sets (Pi\<^sub>M J (\<lambda>_. N))" | 
| 50088 | 1308 | assumes "space N = UNIV" | 
| 1309 | assumes "X \<in> sets (PiF (Collect finite) (\<lambda>_. N))" | |
| 1310 | shows "emeasure (mapmeasure M (\<lambda>_. N)) X = emeasure M ((fm -` X \<inter> extensional J))" | |
| 1311 | using assms | |
| 59048 | 1312 | by (auto simp: measurable_cong_sets[OF s2 refl] mapmeasure_def emeasure_distr | 
| 50123 
69b35a75caf3
merge extensional dependent function space from FuncSet with the one in Finite_Product_Measure
 hoelzl parents: 
50100diff
changeset | 1313 | fm_measurable space_PiM PiE_def) | 
| 50088 | 1314 | |
| 1315 | lemma mapmeasure_PiM: | |
| 1316 | fixes N::"'c measure" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1317 | assumes s1: "space M = space (Pi\<^sub>M J (\<lambda>_. N))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1318 | assumes s2: "sets M = (Pi\<^sub>M J (\<lambda>_. N))" | 
| 50088 | 1319 | assumes N: "space N = UNIV" | 
| 1320 | assumes X: "X \<in> sets M" | |
| 1321 | shows "emeasure M X = emeasure (mapmeasure M (\<lambda>_. N)) (fm ` X)" | |
| 1322 | unfolding mapmeasure_def | |
| 59048 | 1323 | proof (subst emeasure_distr, subst measurable_cong_sets[OF s2 refl], rule fm_measurable) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1324 | have "X \<subseteq> space (Pi\<^sub>M J (\<lambda>_. N))" using assms by (simp add: sets.sets_into_space) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
51641diff
changeset | 1325 | from assms inj_on_fm[of "\<lambda>_. N"] set_mp[OF this] have "fm -` fm ` X \<inter> space (Pi\<^sub>M J (\<lambda>_. N)) = X" | 
| 50088 | 1326 | by (auto simp: vimage_image_eq inj_on_def) | 
| 1327 | thus "emeasure M X = emeasure M (fm -` fm ` X \<inter> space M)" using s1 | |
| 1328 | by simp | |
| 1329 | show "fm ` X \<in> sets (PiF (Collect finite) (\<lambda>_. N))" | |
| 1330 | by (rule fm_image_measurable_finite[OF N X[simplified s2]]) | |
| 1331 | qed simp | |
| 1332 | ||
| 1333 | end | |
| 1334 | ||
| 66262 
4a2c9d32e7aa
finite sets are countable
 Lars Hupel <lars.hupel@mytum.de> parents: 
66089diff
changeset | 1335 | end |