# HG changeset patch # User immler # Date 1360769707 -3600 # Node ID a27fcd14c3846d7dbd725484176de447b02a657a # Parent 59b574c6f803727f2cde485f709372273da0db8b fine grained instantiations diff -r 59b574c6f803 -r a27fcd14c384 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Wed Feb 13 16:35:07 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Wed Feb 13 16:35:07 2013 +0100 @@ -304,6 +304,31 @@ using first_countable_basis[of x] by atomize_elim auto +lemma (in first_countable_topology) first_countable_basis_Int_stableE: + obtains A where "countable A" "\a. a \ A \ x \ a" "\a. a \ A \ open a" + "\S. open S \ x \ S \ (\a\A. a \ S)" + "\a b. a \ A \ b \ A \ a \ b \ A" +proof atomize_elim + from first_countable_basisE[of x] guess A' . note A' = this + def A \ "(\N. \((\n. from_nat_into A' n) ` N)) ` (Collect finite::nat set set)" + thus "\A. countable A \ (\a. a \ A \ x \ a) \ (\a. a \ A \ open a) \ + (\S. open S \ x \ S \ (\a\A. a \ S)) \ (\a b. a \ A \ b \ A \ a \ b \ A)" + proof (safe intro!: exI[where x=A]) + show "countable A" unfolding A_def by (intro countable_image countable_Collect_finite) + fix a assume "a \ A" + thus "x \ a" "open a" using A'(4)[OF open_UNIV] by (auto simp: A_def intro: A' from_nat_into) + next + let ?int = "\N. \from_nat_into A' ` N" + fix a b assume "a \ A" "b \ A" + then obtain N M where "a = ?int N" "b = ?int M" "finite (N \ M)" by (auto simp: A_def) + thus "a \ b \ A" by (auto simp: A_def intro!: image_eqI[where x="N \ M"]) + next + fix S assume "open S" "x \ S" then obtain a where a: "a\A'" "a \ S" using A' by blast + thus "\a\A. a \ S" using a A' + by (intro bexI[where x=a]) (auto simp: A_def intro: image_eqI[where x="{to_nat_on A' a}"]) + qed +qed + instance prod :: (first_countable_topology, first_countable_topology) first_countable_topology proof fix x :: "'a \ 'b" diff -r 59b574c6f803 -r a27fcd14c384 src/HOL/Probability/Fin_Map.thy --- a/src/HOL/Probability/Fin_Map.thy Wed Feb 13 16:35:07 2013 +0100 +++ b/src/HOL/Probability/Fin_Map.thy Wed Feb 13 16:35:07 2013 +0100 @@ -162,6 +162,115 @@ apply auto done +subsection {* Topological Space of Finite Maps *} + +instantiation finmap :: (type, topological_space) topological_space +begin + +definition open_finmap :: "('a \\<^isub>F 'b) set \ bool" where + "open_finmap = generate_topology {Pi' a b|a b. \i\a. open (b i)}" + +lemma open_Pi'I: "(\i. i \ I \ open (A i)) \ open (Pi' I A)" + by (auto intro: generate_topology.Basis simp: open_finmap_def) + +instance using topological_space_generate_topology + by intro_classes (auto simp: open_finmap_def class.topological_space_def) + +end + +lemma open_restricted_space: + shows "open {m. P (domain m)}" +proof - + have "{m. P (domain m)} = (\i \ Collect P. {m. domain m = i})" by auto + also have "open \" + proof (rule, safe, cases) + fix i::"'a set" + assume "finite i" + hence "{m. domain m = i} = Pi' i (\_. UNIV)" by (auto simp: Pi'_def) + also have "open \" by (auto intro: open_Pi'I simp: `finite i`) + finally show "open {m. domain m = i}" . + next + fix i::"'a set" + assume "\ finite i" hence "{m. domain m = i} = {}" by auto + also have "open \" by simp + finally show "open {m. domain m = i}" . + qed + finally show ?thesis . +qed + +lemma closed_restricted_space: + shows "closed {m. P (domain m)}" + using open_restricted_space[of "\x. \ P x"] + unfolding closed_def by (rule back_subst) auto + +lemma tendsto_proj: "((\x. x) ---> a) F \ ((\x. (x)\<^isub>F i) ---> (a)\<^isub>F i) F" + unfolding tendsto_def +proof safe + fix S::"'b set" + let ?S = "Pi' (domain a) (\x. if x = i then S else UNIV)" + assume "open S" hence "open ?S" by (auto intro!: open_Pi'I) + moreover assume "\S. open S \ a \ S \ eventually (\x. x \ S) F" "a i \ S" + ultimately have "eventually (\x. x \ ?S) F" by auto + thus "eventually (\x. (x)\<^isub>F i \ S) F" + by eventually_elim (insert `a i \ S`, force simp: Pi'_iff split: split_if_asm) +qed + +lemma continuous_proj: + shows "continuous_on s (\x. (x)\<^isub>F i)" + unfolding continuous_on_def + by (safe intro!: tendsto_proj tendsto_ident_at_within) + +instance finmap :: (type, first_countable_topology) first_countable_topology +proof + fix x::"'a\\<^isub>F'b" + have "\i. \A. countable A \ (\a\A. x i \ a) \ (\a\A. open a) \ + (\S. open S \ x i \ S \ (\a\A. a \ S)) \ (\a b. a \ A \ b \ A \ a \ b \ A)" (is "\i. ?th i") + proof + fix i from first_countable_basis_Int_stableE[of "x i"] guess A . + thus "?th i" by (intro exI[where x=A]) simp + qed + then guess A unfolding choice_iff .. note A = this + hence open_sub: "\i S. i\domain x \ open (S i) \ x i\(S i) \ (\a\A i. a\(S i))" by auto + have A_notempty: "\i. i \ domain x \ A i \ {}" using open_sub[of _ "\_. UNIV"] by auto + let ?A = "(\f. Pi' (domain x) f) ` (Pi\<^isub>E (domain x) A)" + show "\A. countable A \ (\a\A. x \ a \ open a) \ (\S. open S \ x \ S \ (\a\A. a \ S))" + proof (rule exI[where x="?A"], safe) + show "countable ?A" using A by (simp add: countable_PiE) + next + fix S::"('a \\<^isub>F 'b) set" assume "open S" "x \ S" + thus "\a\?A. a \ S" unfolding open_finmap_def + proof (induct rule: generate_topology.induct) + case UNIV thus ?case by (auto simp add: ex_in_conv PiE_eq_empty_iff A_notempty) + next + case (Int a b) + then obtain f g where + "f \ Pi\<^isub>E (domain x) A" "Pi' (domain x) f \ a" "g \ Pi\<^isub>E (domain x) A" "Pi' (domain x) g \ b" + by auto + thus ?case using A + by (auto simp: Pi'_iff PiE_iff extensional_def Int_stable_def + intro!: bexI[where x="\i. f i \ g i"]) + next + case (UN B) + then obtain b where "x \ b" "b \ B" by auto + hence "\a\?A. a \ b" using UN by simp + thus ?case using `b \ B` by blast + next + case (Basis s) + then obtain a b where xs: "x\ Pi' a b" "s = Pi' a b" "\i. i\a \ open (b i)" by auto + have "\i. \a. (i \ domain x \ open (b i) \ (x)\<^isub>F i \ b i) \ (a\A i \ a \ b i)" + using open_sub[of _ b] by auto + then obtain b' + where "\i. i \ domain x \ open (b i) \ (x)\<^isub>F i \ b i \ (b' i \A i \ b' i \ b i)" + unfolding choice_iff by auto + with xs have "\i. i \ a \ (b' i \A i \ b' i \ b i)" "Pi' a b' \ Pi' a b" + by (auto simp: Pi'_iff intro!: Pi'_mono) + thus ?case using xs + by (intro bexI[where x="Pi' a b'"]) + (auto simp: Pi'_iff intro!: image_eqI[where x="restrict b' (domain x)"]) + qed + qed (insert A,auto simp: PiE_iff intro!: open_Pi'I) +qed + subsection {* Metric Space of Finite Maps *} instantiation finmap :: (type, metric_space) metric_space @@ -170,9 +279,6 @@ definition dist_finmap where "dist P Q = Max (range (\i. dist ((P)\<^isub>F i) ((Q)\<^isub>F i))) + (if domain P = domain Q then 0 else 1)" -definition open_finmap :: "('a \\<^isub>F 'b) set \ bool" where - "open_finmap S = (\x\S. \e>0. \y. dist y x < e \ y \ S)" - lemma add_eq_zero_iff[simp]: fixes a b::real assumes "a \ 0" "b \ 0" @@ -208,72 +314,106 @@ qed lemma dist_finmap_lessI: - assumes "domain P = domain Q" "0 < e" "\i. i \ domain P \ dist (P i) (Q i) < e" + assumes "domain P = domain Q" + assumes "0 < e" + assumes "\i. i \ domain P \ dist (P i) (Q i) < e" shows "dist P Q < e" proof - have "dist P Q = Max (range (\i. dist (P i) (Q i)))" using assms by (simp add: dist_finmap_def finite_proj_diag) also have "\ < e" proof (subst Max_less_iff, safe) - fix i show "dist ((P)\<^isub>F i) ((Q)\<^isub>F i) < e" using assms by (cases "i \ domain P") simp_all + fix i + show "dist ((P)\<^isub>F i) ((Q)\<^isub>F i) < e" using assms + by (cases "i \ domain P") simp_all qed (simp add: finite_proj_diag) finally show ?thesis . qed -lemma open_Pi'I: - assumes open_component: "\i. i \ I \ open (A i)" - shows "open (Pi' I A)" -proof (subst open_finmap_def, safe) - fix x assume x: "x \ Pi' I A" - hence dim_x: "domain x = I" by (simp add: Pi'_def) - hence [simp]: "finite I" unfolding dim_x[symmetric] by simp - have "\ei. \i\I. 0 < ei i \ (\y. dist y (x i) < ei i \ y \ A i)" - proof (safe intro!: bchoice) - fix i assume i: "i \ I" - moreover with open_component have "open (A i)" by simp - moreover have "x i \ A i" using x i - by (auto simp: proj_def) - ultimately show "\e>0. \y. dist y (x i) < e \ y \ A i" - using x by (auto simp: open_dist Ball_def) - qed - then guess ei .. note ei = this - def es \ "ei ` I" - def e \ "if es = {} then 0.5 else min 0.5 (Min es)" - from ei have "e > 0" using x - by (auto simp add: e_def es_def Pi'_def Ball_def) - moreover have "\y. dist y x < e \ y \ Pi' I A" - proof (intro allI impI) - fix y - assume "dist y x < e" - also have "\ < 1" by (auto simp: e_def) - finally have "domain y = domain x" by (rule dist_le_1_imp_domain_eq) - with dim_x have dims: "domain y = domain x" "domain x = I" by auto - show "y \ Pi' I A" - proof - show "domain y = I" using dims by simp - next - fix i - assume "i \ I" - have "dist (y i) (x i) \ dist y x" using dims `i \ I` - by (auto intro: dist_proj) - also have "\ < e" using `dist y x < e` dims - by (simp add: dist_finmap_def) - also have "e \ Min (ei ` I)" using dims `i \ I` - by (auto simp: e_def es_def) - also have "\ \ ei i" using `i \ I` by (simp add: e_def) - finally have "dist (y i) (x i) < ei i" . - with ei `i \ I` show "y i \ A i" by simp - qed - qed - ultimately - show "\e>0. \y. dist y x < e \ y \ Pi' I A" by blast -qed - instance proof fix S::"('a \\<^isub>F 'b) set" - show "open S = (\x\S. \e>0. \y. dist y x < e \ y \ S)" - unfolding open_finmap_def .. + show "open S = (\x\S. \e>0. \y. dist y x < e \ y \ S)" (is "_ = ?od") + proof + assume "open S" + thus ?od + unfolding open_finmap_def + proof (induct rule: generate_topology.induct) + case UNIV thus ?case by (auto intro: zero_less_one) + next + case (Int a b) + show ?case + proof safe + fix x assume x: "x \ a" "x \ b" + with Int x obtain e1 e2 where + "e1>0" "\y. dist y x < e1 \ y \ a" "e2>0" "\y. dist y x < e2 \ y \ b" by force + thus "\e>0. \y. dist y x < e \ y \ a \ b" + by (auto intro!: exI[where x="min e1 e2"]) + qed + next + case (UN K) + show ?case + proof safe + fix x X assume "x \ X" "X \ K" + moreover with UN obtain e where "e>0" "\y. dist y x < e \ y \ X" by force + ultimately show "\e>0. \y. dist y x < e \ y \ \K" by auto + qed + next + case (Basis s) then obtain a b where s: "s = Pi' a b" and b: "\i. i\a \ open (b i)" by auto + show ?case + proof safe + fix x assume "x \ s" + hence [simp]: "finite a" and a_dom: "a = domain x" using s by (auto simp: Pi'_iff) + obtain es where es: "\i \ a. es i > 0 \ (\y. dist y (proj x i) < es i \ y \ b i)" + using b `x \ s` by atomize_elim (intro bchoice, auto simp: open_dist s) + hence in_b: "\i y. i \ a \ dist y (proj x i) < es i \ y \ b i" by auto + show "\e>0. \y. dist y x < e \ y \ s" + proof (cases, rule, safe) + assume "a \ {}" + show "0 < min 1 (Min (es ` a))" using es by (auto simp: `a \ {}`) + fix y assume d: "dist y x < min 1 (Min (es ` a))" + show "y \ s" unfolding s + proof + show "domain y = a" using d s `a \ {}` by (auto simp: dist_le_1_imp_domain_eq a_dom) + fix i assume "i \ a" + moreover + hence "dist ((y)\<^isub>F i) ((x)\<^isub>F i) < es i" using d + by (auto simp: dist_finmap_def `a \ {}` intro!: le_less_trans[OF dist_proj]) + ultimately + show "y i \ b i" by (rule in_b) + qed + next + assume "\a \ {}" + thus "\e>0. \y. dist y x < e \ y \ s" + using s `x \ s` by (auto simp: Pi'_def dist_le_1_imp_domain_eq intro!: exI[where x=1]) + qed + qed + qed + next + assume "\x\S. \e>0. \y. dist y x < e \ y \ S" + then obtain e where e_pos: "\x. x \ S \ e x > 0" and + e_in: "\x y . x \ S \ dist y x < e x \ y \ S" + unfolding bchoice_iff + by auto + have S_eq: "S = \{Pi' a b| a b. \x\S. domain x = a \ b = (\i. ball (x i) (e x))}" + proof safe + fix x assume "x \ S" + thus "x \ \{Pi' a b| a b. \x\S. domain x = a \ b = (\i. ball (x i) (e x))}" + using e_pos by (auto intro!: exI[where x="Pi' (domain x) (\i. ball (x i) (e x))"]) + next + fix x y + assume "y \ S" + moreover + assume "x \ (\' i\domain y. ball (y i) (e y))" + hence "dist x y < e y" using e_pos `y \ S` + by (auto simp: dist_finmap_def Pi'_iff finite_proj_diag dist_commute) + ultimately show "x \ S" by (rule e_in) + qed + also have "open \" + unfolding open_finmap_def + by (intro generate_topology.UN) (auto intro: generate_topology.Basis) + finally show "open S" . + qed next fix P Q::"'a \\<^isub>F 'b" have Max_eq_iff: "\A m. finite A \ A \ {} \ (Max A = m) = (m \ A \ (\a\A. a \ m))" @@ -299,69 +439,6 @@ end -lemma open_restricted_space: - shows "open {m. P (domain m)}" -proof - - have "{m. P (domain m)} = (\i \ Collect P. {m. domain m = i})" by auto - also have "open \" - proof (rule, safe, cases) - fix i::"'a set" - assume "finite i" - hence "{m. domain m = i} = Pi' i (\_. UNIV)" by (auto simp: Pi'_def) - also have "open \" by (auto intro: open_Pi'I simp: `finite i`) - finally show "open {m. domain m = i}" . - next - fix i::"'a set" - assume "\ finite i" hence "{m. domain m = i} = {}" by auto - also have "open \" by simp - finally show "open {m. domain m = i}" . - qed - finally show ?thesis . -qed - -lemma closed_restricted_space: - shows "closed {m. P (domain m)}" -proof - - have "{m. P (domain m)} = - (\i \ - Collect P. {m. domain m = i})" by auto - also have "closed \" - proof (rule, rule, rule, cases) - fix i::"'a set" - assume "finite i" - hence "{m. domain m = i} = Pi' i (\_. UNIV)" by (auto simp: Pi'_def) - also have "open \" by (auto intro: open_Pi'I simp: `finite i`) - finally show "open {m. domain m = i}" . - next - fix i::"'a set" - assume "\ finite i" hence "{m. domain m = i} = {}" by auto - also have "open \" by simp - finally show "open {m. domain m = i}" . - qed - finally show ?thesis . -qed - -lemma continuous_proj: - shows "continuous_on s (\x. (x)\<^isub>F i)" - unfolding continuous_on_topological -proof safe - fix x B assume "x \ s" "open B" "x i \ B" - let ?A = "Pi' (domain x) (\j. if i = j then B else UNIV)" - have "open ?A" using `open B` by (auto intro: open_Pi'I) - moreover have "x \ ?A" using `x i \ B` by auto - moreover have "(\y\s. y \ ?A \ y i \ B)" - proof (cases, safe) - fix y assume "y \ s" - assume "i \ domain x" hence "undefined \ B" using `x i \ B` - by simp - moreover - assume "y \ ?A" hence "domain y = domain x" by (simp add: Pi'_def) - hence "y i = undefined" using `i \ domain x` by simp - ultimately - show "y i \ B" by simp - qed force - ultimately - show "\A. open A \ x \ A \ (\y\s. y \ A \ y i \ B)" by blast -qed - subsection {* Complete Space of Finite Maps *} lemma tendsto_finmap: @@ -450,9 +527,9 @@ thus "convergent P" by (auto simp: convergent_def) qed -subsection {* Polish Space of Finite Maps *} +subsection {* Second Countable Space of Finite Maps *} -instantiation finmap :: (countable, polish_space) polish_space +instantiation finmap :: (countable, second_countable_topology) second_countable_topology begin definition basis_finmap::"('a \\<^isub>F 'b) set set" @@ -492,38 +569,36 @@ simp: topological_basis_def basis_finmap_def Let_def) next fix O'::"('a \\<^isub>F 'b) set" and x - assume "open O'" "x \ O'" - then obtain e where e: "e > 0" "\y. dist y x < e \ y \ O'" unfolding open_dist by blast + assume O': "open O'" "x \ O'" + then obtain a where a: + "x \ Pi' (domain x) a" "Pi' (domain x) a \ O'" "\i. i\domain x \ open (a i)" + unfolding open_finmap_def + proof (atomize_elim, induct rule: generate_topology.induct) + case (Int a b) + let ?p="\a f. x \ Pi' (domain x) f \ Pi' (domain x) f \ a \ (\i. i \ domain x \ open (f i))" + from Int obtain f g where "?p a f" "?p b g" by auto + thus ?case by (force intro!: exI[where x="\i. f i \ g i"] simp: Pi'_def) + next + case (UN k) + then obtain kk a where "x \ kk" "kk \ k" "x \ Pi' (domain x) a" "Pi' (domain x) a \ kk" + "\i. i\domain x \ open (a i)" + by force + thus ?case by blast + qed (auto simp: Pi'_def) have "\B. - (\i\domain x. x i \ B i \ B i \ ball (x i) e \ B i \ union_closed_basis)" + (\i\domain x. x i \ B i \ B i \ a i \ B i \ union_closed_basis)" proof (rule bchoice, safe) fix i assume "i \ domain x" - have "open (ball (x i) e)" "x i \ ball (x i) e" using e - by (auto simp add: intro!: divide_pos_pos) + hence "open (a i)" "x i \ a i" using a by auto from topological_basisE[OF basis_union_closed_basis this] guess b' . - thus "\y. x i \ y \ y \ ball (x i) e \ y \ union_closed_basis" by auto + thus "\y. x i \ y \ y \ a i \ y \ union_closed_basis" by auto qed then guess B .. note B = this def B' \ "Pi' (domain x) (\i. (B i)::'b set)" - hence "B' \ basis_finmap" unfolding B'_def using B - by (intro in_basis_finmapI) auto - moreover have "x \ B'" unfolding B'_def using B by auto - moreover have "B' \ O'" - proof - fix y assume "y \ B'" with B have dom: "domain y = domain x" unfolding B'_def - by (simp add: Pi'_def) - show "y \ O'" - proof (rule e, rule dist_finmap_lessI[OF dom `0 < e`]) - fix i assume "i \ domain y" - with `y \ B'` B have "y i \ B i" - by (simp add: Pi'_def B'_def) - hence "y i \ ball (x i) e" using B `domain y = domain x` `i \ domain y` - by force - thus "dist (y i) (x i) < e" by (simp add: dist_commute) - qed - qed - ultimately - show "\B'\basis_finmap. x \ B' \ B' \ O'" by blast + have "B' \ Pi' (domain x) a" using B by (auto intro!: Pi'_mono simp: B'_def) + also note `\ \ O'` + finally show "\B'\basis_finmap. x \ B' \ B' \ O'" using B + by (auto intro!: bexI[where x=B'] Pi'_mono in_basis_finmapI simp: B'_def) qed lemma range_enum_basis_finmap_imp_open: @@ -535,6 +610,11 @@ end +subsection {* Polish Space of Finite Maps *} + +instance finmap :: (countable, polish_space) polish_space proof qed + + subsection {* Product Measurable Space of Finite Maps *} definition "PiF I M \