src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy
changeset 50245 dea9363887a6
parent 50105 65d5b18e1626
child 50324 0a1242d5e7d4
equal deleted inserted replaced
50244:de72bbe42190 50245:dea9363887a6
     8 
     8 
     9 theory Topology_Euclidean_Space
     9 theory Topology_Euclidean_Space
    10 imports
    10 imports
    11   SEQ
    11   SEQ
    12   "~~/src/HOL/Library/Diagonal_Subsequence"
    12   "~~/src/HOL/Library/Diagonal_Subsequence"
    13   "~~/src/HOL/Library/Countable"
    13   "~~/src/HOL/Library/Countable_Set"
    14   Linear_Algebra
    14   Linear_Algebra
    15   "~~/src/HOL/Library/Glbs"
    15   "~~/src/HOL/Library/Glbs"
    16   Norm_Arith
    16   Norm_Arith
    17 begin
    17 begin
    18 
    18 
    69   assumes "X \<in> B"
    69   assumes "X \<in> B"
    70   shows "open X"
    70   shows "open X"
    71   using assms
    71   using assms
    72   by (simp add: topological_basis_def)
    72   by (simp add: topological_basis_def)
    73 
    73 
       
    74 lemma basis_dense:
       
    75   fixes B::"'a set set" and f::"'a set \<Rightarrow> 'a"
       
    76   assumes "topological_basis B"
       
    77   assumes choosefrom_basis: "\<And>B'. B' \<noteq> {} \<Longrightarrow> f B' \<in> B'"
       
    78   shows "(\<forall>X. open X \<longrightarrow> X \<noteq> {} \<longrightarrow> (\<exists>B' \<in> B. f B' \<in> X))"
       
    79 proof (intro allI impI)
       
    80   fix X::"'a set" assume "open X" "X \<noteq> {}"
       
    81   from topological_basisE[OF `topological_basis B` `open X` choosefrom_basis[OF `X \<noteq> {}`]]
       
    82   guess B' . note B' = this
       
    83   thus "\<exists>B'\<in>B. f B' \<in> X" by (auto intro!: choosefrom_basis)
       
    84 qed
       
    85 
    74 end
    86 end
    75 
    87 
    76 subsection {* Enumerable Basis *}
    88 subsection {* Countable Basis *}
    77 
    89 
    78 locale enumerates_basis =
    90 locale countable_basis =
    79   fixes f::"nat \<Rightarrow> 'a::topological_space set"
    91   fixes B::"'a::topological_space set set"
    80   assumes enumerable_basis: "topological_basis (range f)"
    92   assumes is_basis: "topological_basis B"
       
    93   assumes countable_basis: "countable B"
    81 begin
    94 begin
    82 
    95 
    83 lemma open_enumerable_basis_ex:
    96 lemma open_countable_basis_ex:
    84   assumes "open X"
    97   assumes "open X"
    85   shows "\<exists>N. X = (\<Union>n\<in>N. f n)"
    98   shows "\<exists>B' \<subseteq> B. X = Union B'"
       
    99   using assms countable_basis is_basis unfolding topological_basis_def by blast
       
   100 
       
   101 lemma open_countable_basisE:
       
   102   assumes "open X"
       
   103   obtains B' where "B' \<subseteq> B" "X = Union B'"
       
   104   using assms open_countable_basis_ex by (atomize_elim) simp
       
   105 
       
   106 lemma countable_dense_exists:
       
   107   shows "\<exists>D::'a set. countable D \<and> (\<forall>X. open X \<longrightarrow> X \<noteq> {} \<longrightarrow> (\<exists>d \<in> D. d \<in> X))"
    86 proof -
   108 proof -
    87   from enumerable_basis assms obtain B' where "B' \<subseteq> range f" "X = Union B'"
   109   let ?f = "(\<lambda>B'. SOME x. x \<in> B')"
    88     unfolding topological_basis_def by blast
   110   have "countable (?f ` B)" using countable_basis by simp
    89   hence "Union B' = (\<Union>n\<in>{n. f n \<in> B'}. f n)" by auto
   111   with basis_dense[OF is_basis, of ?f] show ?thesis
    90   with `X = Union B'` show ?thesis by blast
   112     by (intro exI[where x="?f ` B"]) (metis (mono_tags) all_not_in_conv imageI someI)
    91 qed
       
    92 
       
    93 lemma open_enumerable_basisE:
       
    94   assumes "open X"
       
    95   obtains N where "X = (\<Union>n\<in>N. f n)"
       
    96   using assms open_enumerable_basis_ex by (atomize_elim) simp
       
    97 
       
    98 lemma countable_dense_set:
       
    99   shows "\<exists>x::nat \<Rightarrow> 'a. \<forall>y. open y \<longrightarrow> y \<noteq> {} \<longrightarrow> (\<exists>n. x n \<in> y)"
       
   100 proof -
       
   101   def x \<equiv> "\<lambda>n. (SOME x::'a. x \<in> f n)"
       
   102   have x: "\<And>n. f n \<noteq> ({}::'a set) \<Longrightarrow> x n \<in> f n" unfolding x_def
       
   103     by (rule someI_ex) auto
       
   104   have "\<forall>y. open y \<longrightarrow> y \<noteq> {} \<longrightarrow> (\<exists>n. x n \<in> y)"
       
   105   proof (intro allI impI)
       
   106     fix y::"'a set" assume "open y" "y \<noteq> {}"
       
   107     from open_enumerable_basisE[OF `open y`] guess N . note N = this
       
   108     obtain n where n: "n \<in> N" "f n \<noteq> ({}::'a set)"
       
   109     proof (atomize_elim, rule ccontr, clarsimp)
       
   110       assume "\<forall>n. n \<in> N \<longrightarrow> f n = ({}::'a set)"
       
   111       hence "(\<Union>n\<in>N. f n) = (\<Union>n\<in>N. {}::'a set)"
       
   112         by (intro UN_cong) auto
       
   113       hence "y = {}" unfolding N by simp
       
   114       with `y \<noteq> {}` show False by auto
       
   115     qed
       
   116     with x N n have "x n \<in> y" by auto
       
   117     thus "\<exists>n. x n \<in> y" ..
       
   118   qed
       
   119   thus ?thesis by blast
       
   120 qed
   113 qed
   121 
   114 
   122 lemma countable_dense_setE:
   115 lemma countable_dense_setE:
   123   obtains x :: "nat \<Rightarrow> 'a"
   116   obtains D :: "'a set"
   124   where "\<And>y. open y \<Longrightarrow> y \<noteq> {} \<Longrightarrow> \<exists>n. x n \<in> y"
   117   where "countable D" "\<And>X. open X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> \<exists>d \<in> D. d \<in> X"
   125   using countable_dense_set by blast
   118   using countable_dense_exists by blast
   126 
   119 
   127 text {* Construction of an increasing sequence approximating open sets, therefore enumeration of
   120 text {* Construction of an increasing sequence approximating open sets,
   128   basis which is closed under union. *}
   121   therefore basis which is closed under union. *}
   129 
   122 
   130 definition enum_basis::"nat \<Rightarrow> 'a set"
   123 definition union_closed_basis::"'a set set" where
   131   where "enum_basis n = \<Union>(set (map f (from_nat n)))"
   124   "union_closed_basis = (\<lambda>l. \<Union>set l) ` lists B"
   132 
   125 
   133 lemma enum_basis_basis: "topological_basis (range enum_basis)"
   126 lemma basis_union_closed_basis: "topological_basis union_closed_basis"
   134 proof (rule topological_basisI)
   127 proof (rule topological_basisI)
   135   fix O' and x::'a assume "open O'" "x \<in> O'"
   128   fix O' and x::'a assume "open O'" "x \<in> O'"
   136   from topological_basisE[OF enumerable_basis this] guess B' . note B' = this
   129   from topological_basisE[OF is_basis this] guess B' . note B' = this
   137   moreover then obtain n where "B' = f n" by auto
   130   thus "\<exists>B'\<in>union_closed_basis. x \<in> B' \<and> B' \<subseteq> O'" unfolding union_closed_basis_def
   138   moreover hence "B' = enum_basis (to_nat [n])" by (auto simp: enum_basis_def)
   131     by (auto intro!: bexI[where x="[B']"])
   139   ultimately show "\<exists>B'\<in>range enum_basis. x \<in> B' \<and> B' \<subseteq> O'" by blast
       
   140 next
   132 next
   141   fix B' assume "B' \<in> range enum_basis"
   133   fix B' assume "B' \<in> union_closed_basis"
   142   with topological_basis_open[OF enumerable_basis]
   134   thus "open B'"
   143   show "open B'" by (auto simp add: enum_basis_def intro!: open_UN)
   135     using topological_basis_open[OF is_basis]
   144 qed
   136     by (auto simp: union_closed_basis_def)
   145 
   137 qed
   146 lemmas open_enum_basis = topological_basis_open[OF enum_basis_basis]
   138 
   147 
   139 lemma countable_union_closed_basis: "countable union_closed_basis"
   148 lemma empty_basisI[intro]: "{} \<in> range enum_basis"
   140   unfolding union_closed_basis_def using countable_basis by simp
   149 proof
   141 
   150   show "{} = enum_basis (to_nat ([]::nat list))" by (simp add: enum_basis_def)
   142 lemmas open_union_closed_basis = topological_basis_open[OF basis_union_closed_basis]
   151 qed rule
   143 
       
   144 lemma union_closed_basis_ex:
       
   145  assumes X: "X \<in> union_closed_basis"
       
   146  shows "\<exists>B'. finite B' \<and> X = \<Union>B' \<and> B' \<subseteq> B"
       
   147 proof -
       
   148   from X obtain l where "\<And>x. x\<in>set l \<Longrightarrow> x\<in>B" "X = \<Union>set l" by (auto simp: union_closed_basis_def)
       
   149   thus ?thesis by auto
       
   150 qed
       
   151 
       
   152 lemma union_closed_basisE:
       
   153   assumes "X \<in> union_closed_basis"
       
   154   obtains B' where "finite B'" "X = \<Union>B'" "B' \<subseteq> B" using union_closed_basis_ex[OF assms] by blast
       
   155 
       
   156 lemma union_closed_basisI:
       
   157   assumes "finite B'" "X = \<Union>B'" "B' \<subseteq> B"
       
   158   shows "X \<in> union_closed_basis"
       
   159 proof -
       
   160   from finite_list[OF `finite B'`] guess l ..
       
   161   thus ?thesis using assms unfolding union_closed_basis_def by (auto intro!: image_eqI[where x=l])
       
   162 qed
       
   163 
       
   164 lemma empty_basisI[intro]: "{} \<in> union_closed_basis"
       
   165   by (rule union_closed_basisI[of "{}"]) auto
   152 
   166 
   153 lemma union_basisI[intro]:
   167 lemma union_basisI[intro]:
   154   assumes "A \<in> range enum_basis" "B \<in> range enum_basis"
   168   assumes "X \<in> union_closed_basis" "Y \<in> union_closed_basis"
   155   shows "A \<union> B \<in> range enum_basis"
   169   shows "X \<union> Y \<in> union_closed_basis"
   156 proof -
   170   using assms by (auto intro: union_closed_basisI elim!:union_closed_basisE)
   157   from assms obtain a b where "A \<union> B = enum_basis a \<union> enum_basis b" by auto
       
   158   also have "\<dots> = enum_basis (to_nat (from_nat a @ from_nat b::nat list))"
       
   159     by (simp add: enum_basis_def)
       
   160   finally show ?thesis by simp
       
   161 qed
       
   162 
   171 
   163 lemma open_imp_Union_of_incseq:
   172 lemma open_imp_Union_of_incseq:
   164   assumes "open X"
   173   assumes "open X"
   165   shows "\<exists>S. incseq S \<and> (\<Union>j. S j) = X \<and> range S \<subseteq> range enum_basis"
   174   shows "\<exists>S. incseq S \<and> (\<Union>j. S j) = X \<and> range S \<subseteq> union_closed_basis"
   166 proof -
   175 proof -
   167   interpret E: enumerates_basis enum_basis proof qed (rule enum_basis_basis)
   176   from open_countable_basis_ex[OF `open X`]
   168   from E.open_enumerable_basis_ex[OF `open X`] obtain N where N: "X = (\<Union>n\<in>N. enum_basis n)" by auto
   177   obtain B' where B': "B'\<subseteq>B" "X = \<Union>B'" by auto
   169   hence X: "X = (\<Union>n. if n \<in> N then enum_basis n else {})" by (auto split: split_if_asm)
   178   from this(1) countable_basis have "countable B'" by (rule countable_subset)
   170   def S \<equiv> "nat_rec (if 0 \<in> N then enum_basis 0 else {})
   179   show ?thesis
   171     (\<lambda>n S. if (Suc n) \<in> N then S \<union> enum_basis (Suc n) else S)"
   180   proof cases
   172   have S_simps[simp]:
   181     assume "B' \<noteq> {}"
   173     "S 0 = (if 0 \<in> N then enum_basis 0 else {})"
   182     def S \<equiv> "\<lambda>n. \<Union>i\<in>{0..n}. from_nat_into B' i"
   174     "\<And>n. S (Suc n) = (if (Suc n) \<in> N then S n \<union> enum_basis (Suc n) else S n)"
   183     have S:"\<And>n. S n = \<Union>{from_nat_into B' i|i. i\<in>{0..n}}" unfolding S_def by force
   175     by (simp_all add: S_def)
   184     have "incseq S" by (force simp: S_def incseq_Suc_iff)
   176   have "incseq S" by (rule incseq_SucI) auto
   185     moreover
   177   moreover
   186     have "(\<Union>j. S j) = X" unfolding B'
   178   have "(\<Union>j. S j) = X" unfolding N
   187     proof safe
   179   proof safe
   188       fix x X assume "X \<in> B'" "x \<in> X"
   180     fix x n assume "n \<in> N" "x \<in> enum_basis n"
   189       then obtain n where "X = from_nat_into B' n"
   181     hence "x \<in> S n" by (cases n) auto
   190         by (metis `countable B'` from_nat_into_surj)
   182     thus "x \<in> (\<Union>j. S j)" by auto
   191       also have "\<dots> \<subseteq> S n" by (auto simp: S_def)
   183   next
   192       finally show "x \<in> (\<Union>j. S j)" using `x \<in> X` by auto
   184     fix x j
   193     next
   185     assume "x \<in> S j"
   194       fix x n
   186     thus "x \<in> UNION N enum_basis" by (induct j) (auto split: split_if_asm)
   195       assume "x \<in> S n"
   187   qed
   196       also have "\<dots> = (\<Union>i\<in>{0..n}. from_nat_into B' i)"
   188   moreover have "range S \<subseteq> range enum_basis"
   197         by (simp add: S_def)
   189   proof safe
   198       also have "\<dots> \<subseteq> (\<Union>i. from_nat_into B' i)" by auto
   190     fix j show "S j \<in> range enum_basis" by (induct j) auto
   199       also have "\<dots> \<subseteq> \<Union>B'" using `B' \<noteq> {}` by (auto intro: from_nat_into)
   191   qed
   200       finally show "x \<in> \<Union>B'" .
   192   ultimately show ?thesis by auto
   201     qed
       
   202     moreover have "range S \<subseteq> union_closed_basis" using B'
       
   203       by (auto intro!: union_closed_basisI[OF _ S] simp: from_nat_into `B' \<noteq> {}`)
       
   204     ultimately show ?thesis by auto
       
   205   qed (auto simp: B')
   193 qed
   206 qed
   194 
   207 
   195 lemma open_incseqE:
   208 lemma open_incseqE:
   196   assumes "open X"
   209   assumes "open X"
   197   obtains S where "incseq S" "(\<Union>j. S j) = X" "range S \<subseteq> range enum_basis"
   210   obtains S where "incseq S" "(\<Union>j. S j) = X" "range S \<subseteq> union_closed_basis"
   198   using open_imp_Union_of_incseq assms by atomize_elim
   211   using open_imp_Union_of_incseq assms by atomize_elim
   199 
   212 
   200 end
   213 end
   201 
   214 
   202 class enumerable_basis = topological_space +
   215 class countable_basis_space = topological_space +
   203   assumes ex_enum_basis: "\<exists>f::nat \<Rightarrow> 'a::topological_space set. topological_basis (range f)"
   216   assumes ex_countable_basis:
   204 
   217     "\<exists>B::'a::topological_space set set. countable B \<and> topological_basis B"
   205 sublocale enumerable_basis < enumerates_basis "Eps (topological_basis o range)"
   218 
   206   unfolding o_def
   219 sublocale countable_basis_space < countable_basis "SOME B. countable B \<and> topological_basis B"
   207   proof qed (rule someI_ex[OF ex_enum_basis])
   220   using someI_ex[OF ex_countable_basis] by unfold_locales safe
   208 
   221 
   209 subsection {* Polish spaces *}
   222 subsection {* Polish spaces *}
   210 
   223 
   211 text {* Textbooks define Polish spaces as completely metrizable.
   224 text {* Textbooks define Polish spaces as completely metrizable.
   212   We assume the topology to be complete for a given metric. *}
   225   We assume the topology to be complete for a given metric. *}
   213 
   226 
   214 class polish_space = complete_space + enumerable_basis
   227 class polish_space = complete_space + countable_basis_space
   215 
   228 
   216 subsection {* General notion of a topology as a value *}
   229 subsection {* General notion of a topology as a value *}
   217 
   230 
   218 definition "istopology L \<longleftrightarrow> L {} \<and> (\<forall>S T. L S \<longrightarrow> L T \<longrightarrow> L (S \<inter> T)) \<and> (\<forall>K. Ball K L \<longrightarrow> L (\<Union> K))"
   231 definition "istopology L \<longleftrightarrow> L {} \<and> (\<forall>S T. L S \<longrightarrow> L T \<longrightarrow> L (S \<inter> T)) \<and> (\<forall>K. Ball K L \<longrightarrow> L (\<Union> K))"
   219 typedef 'a topology = "{L::('a set) \<Rightarrow> bool. istopology L}"
   232 typedef 'a topology = "{L::('a set) \<Rightarrow> bool. istopology L}"
  5442       hence False using component_le_norm[of "y - x" i] unfolding dist_norm and euclidean_simps by auto   }
  5455       hence False using component_le_norm[of "y - x" i] unfolding dist_norm and euclidean_simps by auto   }
  5443     hence "a$$i \<le> x$$i" by(rule ccontr)auto  }
  5456     hence "a$$i \<le> x$$i" by(rule ccontr)auto  }
  5444   thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast
  5457   thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast
  5445 qed
  5458 qed
  5446 
  5459 
  5447 instance ordered_euclidean_space \<subseteq> enumerable_basis
  5460 instance ordered_euclidean_space \<subseteq> countable_basis_space
  5448 proof
  5461 proof
  5449   def to_cube \<equiv> "\<lambda>(a, b). {Chi (real_of_rat \<circ> op ! a)<..<Chi (real_of_rat \<circ> op ! b)}::'a set"
  5462   def to_cube \<equiv> "\<lambda>(a, b). {Chi (real_of_rat \<circ> op ! a)<..<Chi (real_of_rat \<circ> op ! b)}::'a set"
  5450   def enum \<equiv> "\<lambda>n. (to_cube (from_nat n)::'a set)"
  5463   def B \<equiv> "(\<lambda>n. (to_cube (from_nat n)::'a set)) ` UNIV"
  5451   have "Ball (range enum) open" unfolding enum_def
  5464   have "countable B" unfolding B_def by simp
       
  5465   moreover
       
  5466   have "Ball B open" unfolding B_def
  5452   proof safe
  5467   proof safe
  5453     fix n show "open (to_cube (from_nat n))"
  5468     fix n show "open (to_cube (from_nat n))"
  5454       by (cases "from_nat n::rat list \<times> rat list")
  5469       by (cases "from_nat n::rat list \<times> rat list")
  5455          (simp add: open_interval to_cube_def)
  5470          (simp add: open_interval to_cube_def)
  5456   qed
  5471   qed
  5457   moreover have "(\<forall>x. open x \<longrightarrow> (\<exists>B'\<subseteq>range enum. \<Union>B' = x))"
  5472   moreover have "(\<forall>x. open x \<longrightarrow> (\<exists>B'\<subseteq>B. \<Union>B' = x))"
  5458   proof safe
  5473   proof safe
  5459     fix x::"'a set" assume "open x"
  5474     fix x::"'a set" assume "open x"
  5460     def lists \<equiv> "{(a, b) |a b. to_cube (a, b) \<subseteq> x}"
  5475     def lists \<equiv> "{(a, b) |a b. to_cube (a, b) \<subseteq> x}"
  5461     from open_UNION[OF `open x`]
  5476     from open_UNION[OF `open x`]
  5462     have "\<Union>(to_cube ` lists) = x" unfolding lists_def to_cube_def
  5477     have "\<Union>(to_cube ` lists) = x" unfolding lists_def to_cube_def
  5463      by simp
  5478      by simp
  5464     moreover have "to_cube ` lists \<subseteq> range enum"
  5479     moreover have "to_cube ` lists \<subseteq> B"
  5465     proof
  5480     proof
  5466       fix x assume "x \<in> to_cube ` lists"
  5481       fix x assume "x \<in> to_cube ` lists"
  5467       then obtain l where "l \<in> lists" "x = to_cube l" by auto
  5482       then obtain l where "l \<in> lists" "x = to_cube l" by auto
  5468       hence "x = enum (to_nat l)" by (simp add: to_cube_def enum_def)
  5483       thus "x \<in> B" by (auto simp add: B_def intro!: image_eqI[where x="to_nat l"])
  5469       thus "x \<in> range enum" by simp
       
  5470     qed
  5484     qed
  5471     ultimately
  5485     ultimately
  5472     show "\<exists>B'\<subseteq>range enum. \<Union>B' = x" by blast
  5486     show "\<exists>B'\<subseteq>B. \<Union>B' = x" by blast
  5473   qed
  5487   qed
  5474   ultimately
  5488   ultimately
  5475   show "\<exists>f::nat\<Rightarrow>'a set. topological_basis (range f)" unfolding topological_basis_def by blast
  5489   show "\<exists>B::'a set set. countable B \<and> topological_basis B" unfolding topological_basis_def by blast
  5476 qed
  5490 qed
  5477 
  5491 
  5478 instance ordered_euclidean_space \<subseteq> polish_space ..
  5492 instance ordered_euclidean_space \<subseteq> polish_space ..
  5479 
  5493 
  5480 text {* Intervals in general, including infinite and mixtures of open and closed. *}
  5494 text {* Intervals in general, including infinite and mixtures of open and closed. *}