src/HOL/Library/Topology_Euclidean_Space.thy
changeset 30658 79e2d95649fe
parent 30649 57753e0ec1d4
parent 30654 254478a8dd05
child 30952 7ab2716dd93b
equal deleted inserted replaced
30650:226c91456e54 30658:79e2d95649fe
     4 *)
     4 *)
     5 
     5 
     6 header {* Elementary topology in Euclidean space. *}
     6 header {* Elementary topology in Euclidean space. *}
     7 
     7 
     8 theory Topology_Euclidean_Space
     8 theory Topology_Euclidean_Space
     9   imports SEQ Euclidean_Space
     9 imports SEQ Euclidean_Space
    10 begin
    10 begin
    11 
       
    12 
    11 
    13 declare fstcart_pastecart[simp] sndcart_pastecart[simp]
    12 declare fstcart_pastecart[simp] sndcart_pastecart[simp]
    14 
    13 
    15 subsection{* General notion of a topology *}
    14 subsection{* General notion of a topology *}
    16 
    15 
   472   let ?U = "ball x (dist x y / 2)"
   471   let ?U = "ball x (dist x y / 2)"
   473   let ?V = "ball y (dist x y / 2)"
   472   let ?V = "ball y (dist x y / 2)"
   474   have th0: "\<And>d x y z. (d x z :: real) <= d x y + d y z \<Longrightarrow> d y z = d z y
   473   have th0: "\<And>d x y z. (d x z :: real) <= d x y + d y z \<Longrightarrow> d y z = d z y
   475                ==> ~(d x y * 2 < d x z \<and> d z y * 2 < d x z)" by arith
   474                ==> ~(d x y * 2 < d x z \<and> d z y * 2 < d x z)" by arith
   476   have "?P ?U ?V" using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_sym]
   475   have "?P ?U ?V" using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_sym]
   477     by (auto simp add: dist_refl expand_set_eq Arith_Tools.less_divide_eq_number_of1)
   476     by (auto simp add: dist_refl expand_set_eq less_divide_eq_number_of1)
   478   then show ?thesis by blast
   477   then show ?thesis by blast
   479 qed
   478 qed
   480 
   479 
   481 lemma separation_t2: "x \<noteq> y \<longleftrightarrow> (\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {})"
   480 lemma separation_t2: "x \<noteq> y \<longleftrightarrow> (\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {})"
   482   using hausdorff[of x y] by blast
   481   using hausdorff[of x y] by blast
   660 	let ?k = "min d (e - dist x y)"
   659 	let ?k = "min d (e - dist x y)"
   661 	have kp: "?k > 0" using d e(1) y[unfolded mem_ball] by norm
   660 	have kp: "?k > 0" using d e(1) y[unfolded mem_ball] by norm
   662 	have "?k/2 \<ge> 0" using kp by simp
   661 	have "?k/2 \<ge> 0" using kp by simp
   663 	then obtain w where w: "dist y w = ?k/ 2" by (metis vector_choose_dist)
   662 	then obtain w where w: "dist y w = ?k/ 2" by (metis vector_choose_dist)
   664 	from iT[unfolded expand_set_eq mem_interior]
   663 	from iT[unfolded expand_set_eq mem_interior]
   665 	have "\<not> ball w (?k/4) \<subseteq> T" using kp by (auto simp add: Arith_Tools.less_divide_eq_number_of1)
   664 	have "\<not> ball w (?k/4) \<subseteq> T" using kp by (auto simp add: less_divide_eq_number_of1)
   666 	then obtain z where z: "dist w z < ?k/4" "z \<notin> T" by (auto simp add: subset_eq)
   665 	then obtain z where z: "dist w z < ?k/4" "z \<notin> T" by (auto simp add: subset_eq)
   667 	have "z \<notin> T \<and> z\<noteq> y \<and> dist z y < d \<and> dist x z < e" using z apply simp
   666 	have "z \<notin> T \<and> z\<noteq> y \<and> dist z y < d \<and> dist x z < e" using z apply simp
   668 	  using w e(1) d apply (auto simp only: dist_sym)
   667 	  using w e(1) d apply (auto simp only: dist_sym)
   669 	  apply (auto simp add: min_def cong del: if_weak_cong)
   668 	  apply (auto simp add: min_def cong del: if_weak_cong)
   670 	  apply (cases "d \<le> e - dist x y", auto simp add: ring_simps cong del: if_weak_cong)
   669 	  apply (cases "d \<le> e - dist x y", auto simp add: ring_simps cong del: if_weak_cong)
  1321   assume as:"(f ---> l) net" "(g ---> m) net"
  1320   assume as:"(f ---> l) net" "(g ---> m) net"
  1322   { fix e::real
  1321   { fix e::real
  1323     assume "e>0"
  1322     assume "e>0"
  1324     hence *:"eventually (\<lambda>x. dist (f x) l < e/2) net"
  1323     hence *:"eventually (\<lambda>x. dist (f x) l < e/2) net"
  1325             "eventually (\<lambda>x. dist (g x) m < e/2) net" using as
  1324             "eventually (\<lambda>x. dist (g x) m < e/2) net" using as
  1326       by (auto intro: tendstoD simp del: Arith_Tools.less_divide_eq_number_of1)
  1325       by (auto intro: tendstoD simp del: less_divide_eq_number_of1)
  1327     hence "eventually (\<lambda>x. dist (f x + g x) (l + m) < e) net"
  1326     hence "eventually (\<lambda>x. dist (f x + g x) (l + m) < e) net"
  1328     proof(cases "trivial_limit net")
  1327     proof(cases "trivial_limit net")
  1329       case True
  1328       case True
  1330       thus ?thesis unfolding eventually_def by auto
  1329       thus ?thesis unfolding eventually_def by auto
  1331     next
  1330     next
  3954     { fix x assume "netord net x y"
  3953     { fix x assume "netord net x y"
  3955       hence *:"\<bar>f x - l\<bar> < min (\<bar>l\<bar> / 2) (l\<twosuperior> * e / 2)" using y[THEN spec[where x=x]] unfolding o_def dist_vec1 by auto
  3954       hence *:"\<bar>f x - l\<bar> < min (\<bar>l\<bar> / 2) (l\<twosuperior> * e / 2)" using y[THEN spec[where x=x]] unfolding o_def dist_vec1 by auto
  3956       hence fx0:"f x \<noteq> 0" using `l \<noteq> 0` by auto
  3955       hence fx0:"f x \<noteq> 0" using `l \<noteq> 0` by auto
  3957       hence fxl0: "(f x) * l \<noteq> 0" using `l \<noteq> 0` by auto
  3956       hence fxl0: "(f x) * l \<noteq> 0" using `l \<noteq> 0` by auto
  3958       from * have **:"\<bar>f x - l\<bar> < l\<twosuperior> * e / 2" by auto
  3957       from * have **:"\<bar>f x - l\<bar> < l\<twosuperior> * e / 2" by auto
  3959       have "\<bar>f x\<bar> * 2 \<ge> \<bar>l\<bar>" using * by (auto simp del: Arith_Tools.less_divide_eq_number_of1)
  3958       have "\<bar>f x\<bar> * 2 \<ge> \<bar>l\<bar>" using * by (auto simp del: less_divide_eq_number_of1)
  3960       hence "\<bar>f x\<bar> * 2 * \<bar>l\<bar>  \<ge> \<bar>l\<bar> * \<bar>l\<bar>" unfolding mult_le_cancel_right by auto
  3959       hence "\<bar>f x\<bar> * 2 * \<bar>l\<bar>  \<ge> \<bar>l\<bar> * \<bar>l\<bar>" unfolding mult_le_cancel_right by auto
  3961       hence "\<bar>f x * l\<bar> * 2  \<ge> \<bar>l\<bar>^2" unfolding real_mult_commute and power2_eq_square by auto
  3960       hence "\<bar>f x * l\<bar> * 2  \<ge> \<bar>l\<bar>^2" unfolding real_mult_commute and power2_eq_square by auto
  3962       hence ***:"inverse \<bar>f x * l\<bar> \<le> inverse (l\<twosuperior> / 2)" using fxl0
  3961       hence ***:"inverse \<bar>f x * l\<bar> \<le> inverse (l\<twosuperior> / 2)" using fxl0
  3963 	using le_imp_inverse_le[of "l^2 / 2" "\<bar>f x * l\<bar>"]  by auto
  3962 	using le_imp_inverse_le[of "l^2 / 2" "\<bar>f x * l\<bar>"]  by auto
  3964 
  3963 
  4316     let ?x = "(1/2) *s (a + b)"
  4315     let ?x = "(1/2) *s (a + b)"
  4317     { fix i
  4316     { fix i
  4318       have "a$i < b$i" using as[THEN spec[where x=i]] by auto
  4317       have "a$i < b$i" using as[THEN spec[where x=i]] by auto
  4319       hence "a$i < ((1/2) *s (a+b)) $ i" "((1/2) *s (a+b)) $ i < b$i"
  4318       hence "a$i < ((1/2) *s (a+b)) $ i" "((1/2) *s (a+b)) $ i < b$i"
  4320 	unfolding vector_smult_component and vector_add_component
  4319 	unfolding vector_smult_component and vector_add_component
  4321 	by (auto simp add: Arith_Tools.less_divide_eq_number_of1)  }
  4320 	by (auto simp add: less_divide_eq_number_of1)  }
  4322     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
  4321     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
  4323   ultimately show ?th1 by blast
  4322   ultimately show ?th1 by blast
  4324 
  4323 
  4325   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
  4324   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
  4326     hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto
  4325     hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto
  4331     let ?x = "(1/2) *s (a + b)"
  4330     let ?x = "(1/2) *s (a + b)"
  4332     { fix i
  4331     { fix i
  4333       have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto
  4332       have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto
  4334       hence "a$i \<le> ((1/2) *s (a+b)) $ i" "((1/2) *s (a+b)) $ i \<le> b$i"
  4333       hence "a$i \<le> ((1/2) *s (a+b)) $ i" "((1/2) *s (a+b)) $ i \<le> b$i"
  4335 	unfolding vector_smult_component and vector_add_component
  4334 	unfolding vector_smult_component and vector_add_component
  4336 	by (auto simp add: Arith_Tools.less_divide_eq_number_of1)  }
  4335 	by (auto simp add: less_divide_eq_number_of1)  }
  4337     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
  4336     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
  4338   ultimately show ?th2 by blast
  4337   ultimately show ?th2 by blast
  4339 qed
  4338 qed
  4340 
  4339 
  4341 lemma interval_ne_empty: fixes a :: "real^'n::finite" shows
  4340 lemma interval_ne_empty: fixes a :: "real^'n::finite" shows
  4395     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
  4394     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
  4396       assume as2: "a$i > c$i"
  4395       assume as2: "a$i > c$i"
  4397       { fix j
  4396       { fix j
  4398 	have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta
  4397 	have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta
  4399 	  apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4398 	  apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4400 	  by (auto simp add: Arith_Tools.less_divide_eq_number_of1 as2)  }
  4399 	  by (auto simp add: less_divide_eq_number_of1 as2)  }
  4401       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4400       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4402       moreover
  4401       moreover
  4403       have "?x\<notin>{a .. b}"
  4402       have "?x\<notin>{a .. b}"
  4404 	unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4403 	unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4405 	using as(2)[THEN spec[where x=i]] and as2
  4404 	using as(2)[THEN spec[where x=i]] and as2
  4406 	by (auto simp add: Arith_Tools.less_divide_eq_number_of1)
  4405 	by (auto simp add: less_divide_eq_number_of1)
  4407       ultimately have False using as by auto  }
  4406       ultimately have False using as by auto  }
  4408     hence "a$i \<le> c$i" by(rule ccontr)auto
  4407     hence "a$i \<le> c$i" by(rule ccontr)auto
  4409     moreover
  4408     moreover
  4410     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
  4409     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
  4411       assume as2: "b$i < d$i"
  4410       assume as2: "b$i < d$i"
  4412       { fix j
  4411       { fix j
  4413 	have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta
  4412 	have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta
  4414 	  apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4413 	  apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4415 	  by (auto simp add: Arith_Tools.less_divide_eq_number_of1 as2)  }
  4414 	  by (auto simp add: less_divide_eq_number_of1 as2)  }
  4416       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4415       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4417       moreover
  4416       moreover
  4418       have "?x\<notin>{a .. b}"
  4417       have "?x\<notin>{a .. b}"
  4419 	unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4418 	unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4420 	using as(2)[THEN spec[where x=i]] and as2
  4419 	using as(2)[THEN spec[where x=i]] and as2
  4421 	by (auto simp add: Arith_Tools.less_divide_eq_number_of1)
  4420 	by (auto simp add: less_divide_eq_number_of1)
  4422       ultimately have False using as by auto  }
  4421       ultimately have False using as by auto  }
  4423     hence "b$i \<ge> d$i" by(rule ccontr)auto
  4422     hence "b$i \<ge> d$i" by(rule ccontr)auto
  4424     ultimately
  4423     ultimately
  4425     have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto
  4424     have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto
  4426   } note part1 = this
  4425   } note part1 = this
  4447 qed
  4446 qed
  4448 
  4447 
  4449 lemma inter_interval: fixes a :: "'a::linorder^'n::finite" shows
  4448 lemma inter_interval: fixes a :: "'a::linorder^'n::finite" shows
  4450  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
  4449  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
  4451   unfolding expand_set_eq and Int_iff and mem_interval
  4450   unfolding expand_set_eq and Int_iff and mem_interval
  4452   by (auto simp add: Arith_Tools.less_divide_eq_number_of1 intro!: bexI)
  4451   by (auto simp add: less_divide_eq_number_of1 intro!: bexI)
  4453 
  4452 
  4454 (* Moved interval_open_subset_closed a bit upwards *)
  4453 (* Moved interval_open_subset_closed a bit upwards *)
  4455 
  4454 
  4456 lemma open_interval_lemma: fixes x :: "real" shows
  4455 lemma open_interval_lemma: fixes x :: "real" shows
  4457  "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)"
  4456  "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)"
  4562 proof-
  4561 proof-
  4563   { fix i
  4562   { fix i
  4564     have "a $ i < ((1 / 2) *s (a + b)) $ i \<and> ((1 / 2) *s (a + b)) $ i < b $ i"
  4563     have "a $ i < ((1 / 2) *s (a + b)) $ i \<and> ((1 / 2) *s (a + b)) $ i < b $ i"
  4565       using assms[unfolded interval_ne_empty, THEN spec[where x=i]]
  4564       using assms[unfolded interval_ne_empty, THEN spec[where x=i]]
  4566       unfolding vector_smult_component and vector_add_component
  4565       unfolding vector_smult_component and vector_add_component
  4567       by(auto simp add: Arith_Tools.less_divide_eq_number_of1)  }
  4566       by(auto simp add: less_divide_eq_number_of1)  }
  4568   thus ?thesis unfolding mem_interval by auto
  4567   thus ?thesis unfolding mem_interval by auto
  4569 qed
  4568 qed
  4570 
  4569 
  4571 lemma open_closed_interval_convex: fixes x :: "real^'n::finite"
  4570 lemma open_closed_interval_convex: fixes x :: "real^'n::finite"
  4572   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
  4571   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
  5630 	using norm_minus_cancel[of "x - y"] by (auto simp add: uminus_add_conv_diff) } note ** = this
  5629 	using norm_minus_cancel[of "x - y"] by (auto simp add: uminus_add_conv_diff) } note ** = this
  5631 
  5630 
  5632     { assume as:"dist a b > dist (f n x) (f n y)"
  5631     { assume as:"dist a b > dist (f n x) (f n y)"
  5633       then obtain Na Nb where "\<forall>m\<ge>Na. dist (f (r m) x) a < (dist a b - dist (f n x) (f n y)) / 2"
  5632       then obtain Na Nb where "\<forall>m\<ge>Na. dist (f (r m) x) a < (dist a b - dist (f n x) (f n y)) / 2"
  5634 	and "\<forall>m\<ge>Nb. dist (f (r m) y) b < (dist a b - dist (f n x) (f n y)) / 2"
  5633 	and "\<forall>m\<ge>Nb. dist (f (r m) y) b < (dist a b - dist (f n x) (f n y)) / 2"
  5635 	using lima limb unfolding h_def Lim_sequentially by (fastsimp simp del: Arith_Tools.less_divide_eq_number_of1)
  5634 	using lima limb unfolding h_def Lim_sequentially by (fastsimp simp del: less_divide_eq_number_of1)
  5636       hence "dist (f (r (Na + Nb + n)) x - f (r (Na + Nb + n)) y) (a - b) < dist a b - dist (f n x) (f n y)"
  5635       hence "dist (f (r (Na + Nb + n)) x - f (r (Na + Nb + n)) y) (a - b) < dist a b - dist (f n x) (f n y)"
  5637 	apply(erule_tac x="Na+Nb+n" in allE)
  5636 	apply(erule_tac x="Na+Nb+n" in allE)
  5638 	apply(erule_tac x="Na+Nb+n" in allE) apply simp
  5637 	apply(erule_tac x="Na+Nb+n" in allE) apply simp
  5639 	using dist_triangle_add_half[of a "f (r (Na + Nb + n)) x" "dist a b - dist (f n x) (f n y)"
  5638 	using dist_triangle_add_half[of a "f (r (Na + Nb + n)) x" "dist a b - dist (f n x) (f n y)"
  5640           "-b"  "- f (r (Na + Nb + n)) y"]
  5639           "-b"  "- f (r (Na + Nb + n)) y"]