author hoelzl Fri Mar 22 10:41:43 2013 +0100 (2013-03-22) changeset 51473 1210309fddab parent 51472 adb441e4b9e9 child 51474 1e9e68247ad1
move first_countable_topology to the HOL image
 src/HOL/Lim.thy file | annotate | diff | revisions src/HOL/Metric_Spaces.thy file | annotate | diff | revisions src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy file | annotate | diff | revisions src/HOL/Probability/Fin_Map.thy file | annotate | diff | revisions src/HOL/Topological_Spaces.thy file | annotate | diff | revisions
```     1.1 --- a/src/HOL/Lim.thy	Fri Mar 22 10:41:43 2013 +0100
1.2 +++ b/src/HOL/Lim.thy	Fri Mar 22 10:41:43 2013 +0100
1.3 @@ -226,58 +226,6 @@
1.4  by (rule isUCont [THEN isUCont_Cauchy])
1.5
1.6
1.7 -subsection {* Relation of LIM and LIMSEQ *}
1.8 -
1.9 -lemma sequentially_imp_eventually_within:
1.10 -  fixes a :: "'a::metric_space"
1.11 -  assumes "\<forall>f. (\<forall>n. f n \<in> s \<and> f n \<noteq> a) \<and> f ----> a \<longrightarrow>
1.12 -    eventually (\<lambda>n. P (f n)) sequentially"
1.13 -  shows "eventually P (at a within s)"
1.14 -proof (rule ccontr)
1.15 -  let ?I = "\<lambda>n. inverse (real (Suc n))"
1.16 -  def F \<equiv> "\<lambda>n::nat. SOME x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x"
1.17 -  assume "\<not> eventually P (at a within s)"
1.18 -  hence P: "\<forall>d>0. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < d \<and> \<not> P x"
1.19 -    unfolding eventually_within eventually_at by fast
1.20 -  hence "\<And>n. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x" by simp
1.21 -  hence F: "\<And>n. F n \<in> s \<and> F n \<noteq> a \<and> dist (F n) a < ?I n \<and> \<not> P (F n)"
1.22 -    unfolding F_def by (rule someI_ex)
1.23 -  hence F0: "\<forall>n. F n \<in> s" and F1: "\<forall>n. F n \<noteq> a"
1.24 -    and F2: "\<forall>n. dist (F n) a < ?I n" and F3: "\<forall>n. \<not> P (F n)"
1.25 -    by fast+
1.26 -  from LIMSEQ_inverse_real_of_nat have "F ----> a"
1.27 -    by (rule metric_tendsto_imp_tendsto,
1.28 -      simp add: dist_norm F2 less_imp_le)
1.29 -  hence "eventually (\<lambda>n. P (F n)) sequentially"
1.30 -    using assms F0 F1 by simp
1.31 -  thus "False" by (simp add: F3)
1.32 -qed
1.33 -
1.34 -lemma sequentially_imp_eventually_at:
1.35 -  fixes a :: "'a::metric_space"
1.36 -  assumes "\<forall>f. (\<forall>n. f n \<noteq> a) \<and> f ----> a \<longrightarrow>
1.37 -    eventually (\<lambda>n. P (f n)) sequentially"
1.38 -  shows "eventually P (at a)"
1.39 -  using assms sequentially_imp_eventually_within [where s=UNIV] by simp
1.40 -
1.41 -lemma LIMSEQ_SEQ_conv1:
1.42 -  fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space"
1.43 -  assumes f: "f -- a --> l"
1.44 -  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
1.45 -  using tendsto_compose_eventually [OF f, where F=sequentially] by simp
1.46 -
1.47 -lemma LIMSEQ_SEQ_conv2:
1.48 -  fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
1.49 -  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
1.50 -  shows "f -- a --> l"
1.51 -  using assms unfolding tendsto_def [where l=l]
1.52 -  by (simp add: sequentially_imp_eventually_at)
1.53 -
1.54 -lemma LIMSEQ_SEQ_conv:
1.55 -  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::'a::metric_space) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
1.56 -   (X -- a --> (L::'b::topological_space))"
1.57 -  using LIMSEQ_SEQ_conv2 LIMSEQ_SEQ_conv1 ..
1.58 -
1.59  lemma LIM_less_bound:
1.60    fixes f :: "real \<Rightarrow> real"
1.61    assumes ev: "b < x" "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and "isCont f x"
```
```     2.1 --- a/src/HOL/Metric_Spaces.thy	Fri Mar 22 10:41:43 2013 +0100
2.2 +++ b/src/HOL/Metric_Spaces.thy	Fri Mar 22 10:41:43 2013 +0100
2.3 @@ -100,13 +100,31 @@
2.4      unfolding open_dist by fast
2.5  qed
2.6
2.7 -lemma (in metric_space) open_ball: "open {y. dist x y < d}"
2.8 +lemma open_ball: "open {y. dist x y < d}"
2.9  proof (unfold open_dist, intro ballI)
2.10    fix y assume *: "y \<in> {y. dist x y < d}"
2.11    then show "\<exists>e>0. \<forall>z. dist z y < e \<longrightarrow> z \<in> {y. dist x y < d}"
2.12      by (auto intro!: exI[of _ "d - dist x y"] simp: field_simps dist_triangle_lt)
2.13  qed
2.14
2.15 +subclass first_countable_topology
2.16 +proof
2.17 +  fix x
2.18 +  show "\<exists>A::nat \<Rightarrow> 'a 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))"
2.19 +  proof (safe intro!: exI[of _ "\<lambda>n. {y. dist x y < inverse (Suc n)}"])
2.20 +    fix S assume "open S" "x \<in> S"
2.21 +    then obtain e where "0 < e" "{y. dist x y < e} \<subseteq> S"
2.22 +      by (auto simp: open_dist subset_eq dist_commute)
2.23 +    moreover
2.24 +    then obtain i where "inverse (Suc i) < e"
2.25 +      by (auto dest!: reals_Archimedean)
2.26 +    then have "{y. dist x y < inverse (Suc i)} \<subseteq> {y. dist x y < e}"
2.27 +      by auto
2.28 +    ultimately show "\<exists>i. {y. dist x y < inverse (Suc i)} \<subseteq> S"
2.29 +      by blast
2.30 +  qed (auto intro: open_ball)
2.31 +qed
2.32 +
2.33  end
2.34
2.35  instance metric_space \<subseteq> t2_space
```
```     3.1 --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy	Fri Mar 22 10:41:43 2013 +0100
3.2 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy	Fri Mar 22 10:41:43 2013 +0100
3.3 @@ -181,44 +181,15 @@
3.4
3.5  end
3.6
3.7 -class first_countable_topology = topological_space +
3.8 -  assumes first_countable_basis:
3.9 -    "\<exists>A. countable A \<and> (\<forall>a\<in>A. x \<in> a \<and> open a) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S))"
3.10 -
3.11 -lemma (in first_countable_topology) countable_basis_at_decseq:
3.12 -  obtains A :: "nat \<Rightarrow> 'a set" where
3.13 -    "\<And>i. open (A i)" "\<And>i. x \<in> (A i)"
3.14 -    "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> eventually (\<lambda>i. A i \<subseteq> S) sequentially"
3.15 -proof atomize_elim
3.16 -  from first_countable_basis[of x] obtain A
3.17 -    where "countable A"
3.18 -    and nhds: "\<And>a. a \<in> A \<Longrightarrow> open a" "\<And>a. a \<in> A \<Longrightarrow> x \<in> a"
3.19 -    and incl: "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> \<exists>a\<in>A. a \<subseteq> S"  by auto
3.20 -  then have "A \<noteq> {}" by auto
3.21 -  with `countable A` have r: "A = range (from_nat_into A)" by auto
3.22 -  def F \<equiv> "\<lambda>n. \<Inter>i\<le>n. from_nat_into A i"
3.23 -  show "\<exists>A. (\<forall>i. open (A i)) \<and> (\<forall>i. x \<in> A i) \<and>
3.24 -      (\<forall>S. open S \<longrightarrow> x \<in> S \<longrightarrow> eventually (\<lambda>i. A i \<subseteq> S) sequentially)"
3.25 -  proof (safe intro!: exI[of _ F])
3.26 -    fix i
3.27 -    show "open (F i)" using nhds(1) r by (auto simp: F_def intro!: open_INT)
3.28 -    show "x \<in> F i" using nhds(2) r by (auto simp: F_def)
3.29 -  next
3.30 -    fix S assume "open S" "x \<in> S"
3.31 -    from incl[OF this] obtain i where "F i \<subseteq> S"
3.32 -      by (subst (asm) r) (auto simp: F_def)
3.33 -    moreover have "\<And>j. i \<le> j \<Longrightarrow> F j \<subseteq> F i"
3.34 -      by (auto simp: F_def)
3.35 -    ultimately show "eventually (\<lambda>i. F i \<subseteq> S) sequentially"
3.36 -      by (auto simp: eventually_sequentially)
3.37 -  qed
3.38 -qed
3.39 -
3.40  lemma (in first_countable_topology) first_countable_basisE:
3.41    obtains A where "countable A" "\<And>a. a \<in> A \<Longrightarrow> x \<in> a" "\<And>a. a \<in> A \<Longrightarrow> open a"
3.42      "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> (\<exists>a\<in>A. a \<subseteq> S)"
3.43    using first_countable_basis[of x]
3.44 -  by atomize_elim auto
3.45 +  apply atomize_elim
3.46 +  apply (elim exE)
3.47 +  apply (rule_tac x="range A" in exI)
3.48 +  apply auto
3.49 +  done
3.50
3.51  lemma (in first_countable_topology) first_countable_basis_Int_stableE:
3.52    obtains A where "countable A" "\<And>a. a \<in> A \<Longrightarrow> x \<in> a" "\<And>a. a \<in> A \<Longrightarrow> open a"
3.53 @@ -245,77 +216,25 @@
3.54    qed
3.55  qed
3.56
3.57 -
3.58 -lemma countable_basis:
3.59 -  obtains A :: "nat \<Rightarrow> 'a::first_countable_topology set" where
3.60 -    "\<And>i. open (A i)" "\<And>i. x \<in> A i"
3.61 -    "\<And>F. (\<forall>n. F n \<in> A n) \<Longrightarrow> F ----> x"
3.62 -proof atomize_elim
3.63 -  from countable_basis_at_decseq[of x] guess A . note A = this
3.64 -  { fix F S assume "\<forall>n. F n \<in> A n" "open S" "x \<in> S"
3.65 -    with A(3)[of S] have "eventually (\<lambda>n. F n \<in> S) sequentially"
3.66 -      by (auto elim: eventually_elim1 simp: subset_eq) }
3.67 -  with A show "\<exists>A. (\<forall>i. open (A i)) \<and> (\<forall>i. x \<in> A i) \<and> (\<forall>F. (\<forall>n. F n \<in> A n) \<longrightarrow> F ----> x)"
3.68 -    by (intro exI[of _ A]) (auto simp: tendsto_def)
3.69 -qed
3.70 -
3.71 -lemma sequentially_imp_eventually_nhds_within:
3.72 -  fixes a :: "'a::first_countable_topology"
3.73 -  assumes "\<forall>f. (\<forall>n. f n \<in> s) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially"
3.74 -  shows "eventually P (nhds a within s)"
3.75 -proof (rule ccontr)
3.76 -  from countable_basis[of a] guess A . note A = this
3.77 -  assume "\<not> eventually P (nhds a within s)"
3.78 -  with A have P: "\<exists>F. \<forall>n. F n \<in> s \<and> F n \<in> A n \<and> \<not> P (F n)"
3.79 -    unfolding Limits.eventually_within eventually_nhds by (intro choice) fastforce
3.80 -  then guess F ..
3.81 -  hence F0: "\<forall>n. F n \<in> s" and F2: "\<forall>n. F n \<in> A n" and F3: "\<forall>n. \<not> P (F n)"
3.82 -    by fast+
3.83 -  with A have "F ----> a" by auto
3.84 -  hence "eventually (\<lambda>n. P (F n)) sequentially"
3.85 -    using assms F0 by simp
3.86 -  thus "False" by (simp add: F3)
3.87 -qed
3.88 -
3.89 -lemma eventually_nhds_within_iff_sequentially:
3.90 -  fixes a :: "'a::first_countable_topology"
3.91 -  shows "eventually P (nhds a within s) \<longleftrightarrow>
3.92 -    (\<forall>f. (\<forall>n. f n \<in> s) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially)"
3.93 -proof (safe intro!: sequentially_imp_eventually_nhds_within)
3.94 -  assume "eventually P (nhds a within s)"
3.95 -  then obtain S where "open S" "a \<in> S" "\<forall>x\<in>S. x \<in> s \<longrightarrow> P x"
3.96 -    by (auto simp: Limits.eventually_within eventually_nhds)
3.97 -  moreover fix f assume "\<forall>n. f n \<in> s" "f ----> a"
3.98 -  ultimately show "eventually (\<lambda>n. P (f n)) sequentially"
3.99 -    by (auto dest!: topological_tendstoD elim: eventually_elim1)
3.100 -qed
3.101 -
3.102 -lemma eventually_nhds_iff_sequentially:
3.103 -  fixes a :: "'a::first_countable_topology"
3.104 -  shows "eventually P (nhds a) \<longleftrightarrow> (\<forall>f. f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially)"
3.105 -  using eventually_nhds_within_iff_sequentially[of P a UNIV] by simp
3.106 -
3.107 -lemma not_eventually_sequentiallyD:
3.108 -  assumes P: "\<not> eventually P sequentially"
3.109 -  shows "\<exists>r. subseq r \<and> (\<forall>n. \<not> P (r n))"
3.110 -proof -
3.111 -  from P have "\<forall>n. \<exists>m\<ge>n. \<not> P m"
3.112 -    unfolding eventually_sequentially by (simp add: not_less)
3.113 -  then obtain r where "\<And>n. r n \<ge> n" "\<And>n. \<not> P (r n)"
3.114 -    by (auto simp: choice_iff)
3.115 -  then show ?thesis
3.116 -    by (auto intro!: exI[of _ "\<lambda>n. r (((Suc \<circ> r) ^^ Suc n) 0)"]
3.117 -             simp: less_eq_Suc_le subseq_Suc_iff)
3.118 -qed
3.119 -
3.120 +lemma (in topological_space) first_countableI:
3.121 +  assumes "countable A" and 1: "\<And>a. a \<in> A \<Longrightarrow> x \<in> a" "\<And>a. a \<in> A \<Longrightarrow> open a"
3.122 +   and 2: "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> \<exists>a\<in>A. a \<subseteq> S"
3.123 +  shows "\<exists>A::nat \<Rightarrow> 'a 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))"
3.124 +proof (safe intro!: exI[of _ "from_nat_into A"])
3.125 +  have "A \<noteq> {}" using 2[of UNIV] by auto
3.126 +  { fix i show "x \<in> from_nat_into A i" "open (from_nat_into A i)"
3.127 +      using range_from_nat_into_subset[OF `A \<noteq> {}`] 1 by auto }
3.128 +  { fix S assume "open S" "x\<in>S" from 2[OF this] show "\<exists>i. from_nat_into A i \<subseteq> S"
3.129 +      using subset_range_from_nat_into[OF `countable A`] by auto }
3.130 +qed
3.131
3.132  instance prod :: (first_countable_topology, first_countable_topology) first_countable_topology
3.133  proof
3.134    fix x :: "'a \<times> 'b"
3.135    from first_countable_basisE[of "fst x"] guess A :: "'a set set" . note A = this
3.136    from first_countable_basisE[of "snd x"] guess B :: "'b set set" . note B = this
3.137 -  show "\<exists>A::('a\<times>'b) set set. countable A \<and> (\<forall>a\<in>A. x \<in> a \<and> open a) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S))"
3.138 -  proof (intro exI[of _ "(\<lambda>(a, b). a \<times> b) ` (A \<times> B)"], safe)
3.139 +  show "\<exists>A::nat \<Rightarrow> ('a \<times> '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))"
3.140 +  proof (rule first_countableI[of "(\<lambda>(a, b). a \<times> b) ` (A \<times> B)"], safe)
3.141      fix a b assume x: "a \<in> A" "b \<in> B"
3.142      with A(2, 3)[of a] B(2, 3)[of b] show "x \<in> a \<times> b" "open (a \<times> b)"
3.143        unfolding mem_Times_iff by (auto intro: open_Times)
3.144 @@ -329,23 +248,6 @@
3.145    qed (simp add: A B)
3.146  qed
3.147
3.148 -instance metric_space \<subseteq> first_countable_topology
3.149 -proof
3.150 -  fix x :: 'a
3.151 -  show "\<exists>A. countable A \<and> (\<forall>a\<in>A. x \<in> a \<and> open a) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S))"
3.152 -  proof (intro exI, safe)
3.153 -    fix S assume "open S" "x \<in> S"
3.154 -    then obtain r where "0 < r" "{y. dist x y < r} \<subseteq> S"
3.155 -      by (auto simp: open_dist dist_commute subset_eq)
3.156 -    moreover from reals_Archimedean[OF `0 < r`] guess n ..
3.157 -    moreover
3.158 -    then have "{y. dist x y < inverse (Suc n)} \<subseteq> {y. dist x y < r}"
3.159 -      by (auto simp: inverse_eq_divide)
3.160 -    ultimately show "\<exists>a\<in>range (\<lambda>n. {y. dist x y < inverse (Suc n)}). a \<subseteq> S"
3.161 -      by auto
3.162 -  qed (auto intro: open_ball)
3.163 -qed
3.164 -
3.165  class second_countable_topology = topological_space +
3.166    assumes ex_countable_subbasis: "\<exists>B::'a::topological_space set set. countable B \<and> open = generate_topology B"
3.167  begin
3.168 @@ -417,9 +319,9 @@
3.169    then have B: "countable B" "topological_basis B"
3.170      using countable_basis is_basis
3.171      by (auto simp: countable_basis is_basis)
3.172 -  then show "\<exists>A. countable A \<and> (\<forall>a\<in>A. x \<in> a \<and> open a) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S))"
3.173 -    by (intro exI[of _ "{b\<in>B. x \<in> b}"])
3.174 -       (fastforce simp: topological_space_class.topological_basis_def)
3.175 +  then show "\<exists>A::nat \<Rightarrow> 'a 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))"
3.176 +    by (intro first_countableI[of "{b\<in>B. x \<in> b}"])
3.177 +       (fastforce simp: topological_space_class.topological_basis_def)+
3.178  qed
3.179
3.180  subsection {* Polish spaces *}
3.181 @@ -2353,7 +2255,7 @@
3.182    apply (subgoal_tac "\<And>x (y::real). 0 < 1 + abs y \<and> (x <= y \<longrightarrow> x <= 1 + abs y)")
3.183    by metis arith
3.184
3.185 -lemma Bseq_eq_bounded: "Bseq f \<longleftrightarrow> bounded (range f)"
3.186 +lemma Bseq_eq_bounded: "Bseq f \<longleftrightarrow> bounded (range f::_::real_normed_vector set)"
3.187    unfolding Bseq_def bounded_pos by auto
3.188
3.189  lemma bounded_Int[intro]: "bounded S \<or> bounded T \<Longrightarrow> bounded (S \<inter> T)"
```
```     4.1 --- a/src/HOL/Probability/Fin_Map.thy	Fri Mar 22 10:41:43 2013 +0100
4.2 +++ b/src/HOL/Probability/Fin_Map.thy	Fri Mar 22 10:41:43 2013 +0100
4.3 @@ -222,8 +222,8 @@
4.4    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
4.5    have A_notempty: "\<And>i. i \<in> domain x \<Longrightarrow> A i \<noteq> {}" using open_sub[of _ "\<lambda>_. UNIV"] by auto
4.6    let ?A = "(\<lambda>f. Pi' (domain x) f) ` (Pi\<^isub>E (domain x) A)"
4.7 -  show "\<exists>A. countable A \<and> (\<forall>a\<in>A. x \<in> a \<and> open a) \<and> (\<forall>S. open S \<and> x \<in> S \<longrightarrow> (\<exists>a\<in>A. a \<subseteq> S))"
4.8 -  proof (rule exI[where x="?A"], safe)
4.9 +  show "\<exists>A::nat \<Rightarrow> ('a\<Rightarrow>\<^isub>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))"
4.10 +  proof (rule first_countableI[where A="?A"], safe)
4.11      show "countable ?A" using A by (simp add: countable_PiE)
4.12    next
4.13      fix S::"('a \<Rightarrow>\<^isub>F 'b) set" assume "open S" "x \<in> S"
```
```     5.1 --- a/src/HOL/Topological_Spaces.thy	Fri Mar 22 10:41:43 2013 +0100
5.2 +++ b/src/HOL/Topological_Spaces.thy	Fri Mar 22 10:41:43 2013 +0100
5.3 @@ -681,17 +681,17 @@
5.4  definition (in topological_space) at :: "'a \<Rightarrow> 'a filter"
5.5    where "at a = nhds a within - {a}"
5.6
5.7 -abbreviation at_right :: "'a\<Colon>{topological_space, order} \<Rightarrow> 'a filter" where
5.8 +abbreviation (in order_topology) at_right :: "'a \<Rightarrow> 'a filter" where
5.9    "at_right x \<equiv> at x within {x <..}"
5.10
5.11 -abbreviation at_left :: "'a\<Colon>{topological_space, order} \<Rightarrow> 'a filter" where
5.12 +abbreviation (in order_topology) at_left :: "'a \<Rightarrow> 'a filter" where
5.13    "at_left x \<equiv> at x within {..< x}"
5.14
5.15 -lemma eventually_nhds:
5.16 +lemma (in topological_space) eventually_nhds:
5.17    "eventually P (nhds a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))"
5.18    unfolding nhds_def
5.19  proof (rule eventually_Abs_filter, rule is_filter.intro)
5.20 -  have "open (UNIV :: 'a :: topological_space set) \<and> a \<in> UNIV \<and> (\<forall>x\<in>UNIV. True)" by simp
5.21 +  have "open UNIV \<and> a \<in> UNIV \<and> (\<forall>x\<in>UNIV. True)" by simp
5.22    thus "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. True)" ..
5.23  next
5.24    fix P Q
5.25 @@ -843,7 +843,8 @@
5.26      map (fn thm => @{thm tendsto_eq_rhs} OF [thm]) o Tendsto_Intros.get o Context.proof_of);
5.27  *}
5.28
5.29 -lemma tendsto_def: "(f ---> l) F \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F)"
5.30 +lemma (in topological_space) tendsto_def:
5.31 +   "(f ---> l) F \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F)"
5.32    unfolding filterlim_def
5.33  proof safe
5.34    fix S assume "open S" "l \<in> S" "filtermap f F \<le> nhds l"
5.35 @@ -859,12 +860,12 @@
5.36  lemma tendsto_mono: "F \<le> F' \<Longrightarrow> (f ---> l) F' \<Longrightarrow> (f ---> l) F"
5.37    unfolding tendsto_def le_filter_def by fast
5.38
5.39 -lemma topological_tendstoI:
5.40 +lemma (in topological_space) topological_tendstoI:
5.41    "(\<And>S. open S \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) F)
5.42      \<Longrightarrow> (f ---> l) F"
5.43    unfolding tendsto_def by auto
5.44
5.45 -lemma topological_tendstoD:
5.46 +lemma (in topological_space) topological_tendstoD:
5.47    "(f ---> l) F \<Longrightarrow> open S \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) F"
5.48    unfolding tendsto_def by auto
5.49
5.50 @@ -1290,6 +1291,19 @@
5.51    "subseq r \<Longrightarrow> eventually P sequentially \<Longrightarrow> eventually (\<lambda>n. P (r n)) sequentially"
5.52    unfolding eventually_sequentially by (metis seq_suble le_trans)
5.53
5.54 +lemma not_eventually_sequentiallyD:
5.55 +  assumes P: "\<not> eventually P sequentially"
5.56 +  shows "\<exists>r. subseq r \<and> (\<forall>n. \<not> P (r n))"
5.57 +proof -
5.58 +  from P have "\<forall>n. \<exists>m\<ge>n. \<not> P m"
5.59 +    unfolding eventually_sequentially by (simp add: not_less)
5.60 +  then obtain r where "\<And>n. r n \<ge> n" "\<And>n. \<not> P (r n)"
5.61 +    by (auto simp: choice_iff)
5.62 +  then show ?thesis
5.63 +    by (auto intro!: exI[of _ "\<lambda>n. r (((Suc \<circ> r) ^^ Suc n) 0)"]
5.64 +             simp: less_eq_Suc_le subseq_Suc_iff)
5.65 +qed
5.66 +
5.67  lemma filterlim_subseq: "subseq f \<Longrightarrow> filterlim f sequentially sequentially"
5.68    unfolding filterlim_iff by (metis eventually_subseq)
5.69
5.70 @@ -1427,6 +1441,83 @@
5.71  lemma decseq_le: "decseq X \<Longrightarrow> X ----> L \<Longrightarrow> (L::'a::linorder_topology) \<le> X n"
5.72    by (metis decseq_def LIMSEQ_le_const2)
5.73
5.74 +subsection {* First countable topologies *}
5.75 +
5.76 +class first_countable_topology = topological_space +
5.77 +  assumes first_countable_basis:
5.78 +    "\<exists>A::nat \<Rightarrow> 'a 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))"
5.79 +
5.80 +lemma (in first_countable_topology) countable_basis_at_decseq:
5.81 +  obtains A :: "nat \<Rightarrow> 'a set" where
5.82 +    "\<And>i. open (A i)" "\<And>i. x \<in> (A i)"
5.83 +    "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> eventually (\<lambda>i. A i \<subseteq> S) sequentially"
5.84 +proof atomize_elim
5.85 +  from first_countable_basis[of x] obtain A :: "nat \<Rightarrow> 'a set" where
5.86 +    nhds: "\<And>i. open (A i)" "\<And>i. x \<in> A i"
5.87 +    and incl: "\<And>S. open S \<Longrightarrow> x \<in> S \<Longrightarrow> \<exists>i. A i \<subseteq> S"  by auto
5.88 +  def F \<equiv> "\<lambda>n. \<Inter>i\<le>n. A i"
5.89 +  show "\<exists>A. (\<forall>i. open (A i)) \<and> (\<forall>i. x \<in> A i) \<and>
5.90 +      (\<forall>S. open S \<longrightarrow> x \<in> S \<longrightarrow> eventually (\<lambda>i. A i \<subseteq> S) sequentially)"
5.91 +  proof (safe intro!: exI[of _ F])
5.92 +    fix i
5.93 +    show "open (F i)" using nhds(1) by (auto simp: F_def intro!: open_INT)
5.94 +    show "x \<in> F i" using nhds(2) by (auto simp: F_def)
5.95 +  next
5.96 +    fix S assume "open S" "x \<in> S"
5.97 +    from incl[OF this] obtain i where "F i \<subseteq> S" unfolding F_def by auto
5.98 +    moreover have "\<And>j. i \<le> j \<Longrightarrow> F j \<subseteq> F i"
5.99 +      by (auto simp: F_def)
5.100 +    ultimately show "eventually (\<lambda>i. F i \<subseteq> S) sequentially"
5.101 +      by (auto simp: eventually_sequentially)
5.102 +  qed
5.103 +qed
5.104 +
5.105 +lemma (in first_countable_topology) countable_basis:
5.106 +  obtains A :: "nat \<Rightarrow> 'a set" where
5.107 +    "\<And>i. open (A i)" "\<And>i. x \<in> A i"
5.108 +    "\<And>F. (\<forall>n. F n \<in> A n) \<Longrightarrow> F ----> x"
5.109 +proof atomize_elim
5.110 +  from countable_basis_at_decseq[of x] guess A . note A = this
5.111 +  { fix F S assume "\<forall>n. F n \<in> A n" "open S" "x \<in> S"
5.112 +    with A(3)[of S] have "eventually (\<lambda>n. F n \<in> S) sequentially"
5.113 +      by (auto elim: eventually_elim1 simp: subset_eq) }
5.114 +  with A show "\<exists>A. (\<forall>i. open (A i)) \<and> (\<forall>i. x \<in> A i) \<and> (\<forall>F. (\<forall>n. F n \<in> A n) \<longrightarrow> F ----> x)"
5.115 +    by (intro exI[of _ A]) (auto simp: tendsto_def)
5.116 +qed
5.117 +
5.118 +lemma (in first_countable_topology) sequentially_imp_eventually_nhds_within:
5.119 +  assumes "\<forall>f. (\<forall>n. f n \<in> s) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially"
5.120 +  shows "eventually P (nhds a within s)"
5.121 +proof (rule ccontr)
5.122 +  from countable_basis[of a] guess A . note A = this
5.123 +  assume "\<not> eventually P (nhds a within s)"
5.124 +  with A have P: "\<exists>F. \<forall>n. F n \<in> s \<and> F n \<in> A n \<and> \<not> P (F n)"
5.125 +    unfolding eventually_within eventually_nhds by (intro choice) fastforce
5.126 +  then guess F ..
5.127 +  hence F0: "\<forall>n. F n \<in> s" and F2: "\<forall>n. F n \<in> A n" and F3: "\<forall>n. \<not> P (F n)"
5.128 +    by fast+
5.129 +  with A have "F ----> a" by auto
5.130 +  hence "eventually (\<lambda>n. P (F n)) sequentially"
5.131 +    using assms F0 by simp
5.132 +  thus "False" by (simp add: F3)
5.133 +qed
5.134 +
5.135 +lemma (in first_countable_topology) eventually_nhds_within_iff_sequentially:
5.136 +  "eventually P (nhds a within s) \<longleftrightarrow>
5.137 +    (\<forall>f. (\<forall>n. f n \<in> s) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially)"
5.138 +proof (safe intro!: sequentially_imp_eventually_nhds_within)
5.139 +  assume "eventually P (nhds a within s)"
5.140 +  then obtain S where "open S" "a \<in> S" "\<forall>x\<in>S. x \<in> s \<longrightarrow> P x"
5.141 +    by (auto simp: eventually_within eventually_nhds)
5.142 +  moreover fix f assume "\<forall>n. f n \<in> s" "f ----> a"
5.143 +  ultimately show "eventually (\<lambda>n. P (f n)) sequentially"
5.144 +    by (auto dest!: topological_tendstoD elim: eventually_elim1)
5.145 +qed
5.146 +
5.147 +lemma (in first_countable_topology) eventually_nhds_iff_sequentially:
5.148 +  "eventually P (nhds a) \<longleftrightarrow> (\<forall>f. f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially)"
5.149 +  using eventually_nhds_within_iff_sequentially[of P a UNIV] by simp
5.150 +
5.151  subsection {* Function limit at a point *}
5.152
5.153  abbreviation
5.154 @@ -1487,6 +1578,35 @@
5.155    shows "(\<lambda>x. g (f x)) -- a --> c"
5.156    using g f inj by (rule tendsto_compose_eventually)
5.157
5.158 +subsubsection {* Relation of LIM and LIMSEQ *}
5.159 +
5.160 +lemma (in first_countable_topology) sequentially_imp_eventually_within:
5.161 +  "(\<forall>f. (\<forall>n. f n \<in> s \<and> f n \<noteq> a) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially) \<Longrightarrow>
5.162 +    eventually P (at a within s)"
5.163 +  unfolding at_def within_within_eq
5.164 +  by (intro sequentially_imp_eventually_nhds_within) auto
5.165 +
5.166 +lemma (in first_countable_topology) sequentially_imp_eventually_at:
5.167 +  "(\<forall>f. (\<forall>n. f n \<noteq> a) \<and> f ----> a \<longrightarrow> eventually (\<lambda>n. P (f n)) sequentially) \<Longrightarrow> eventually P (at a)"
5.168 +  using assms sequentially_imp_eventually_within [where s=UNIV] by simp
5.169 +
5.170 +lemma LIMSEQ_SEQ_conv1:
5.171 +  fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space"
5.172 +  assumes f: "f -- a --> l"
5.173 +  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
5.174 +  using tendsto_compose_eventually [OF f, where F=sequentially] by simp
5.175 +
5.176 +lemma LIMSEQ_SEQ_conv2:
5.177 +  fixes f :: "'a::first_countable_topology \<Rightarrow> 'b::topological_space"
5.178 +  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
5.179 +  shows "f -- a --> l"
5.180 +  using assms unfolding tendsto_def [where l=l] by (simp add: sequentially_imp_eventually_at)
5.181 +
5.182 +lemma LIMSEQ_SEQ_conv:
5.183 +  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::'a::first_countable_topology) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
5.184 +   (X -- a --> (L::'b::topological_space))"
5.185 +  using LIMSEQ_SEQ_conv2 LIMSEQ_SEQ_conv1 ..
5.186 +
5.187  subsection {* Continuity *}
5.188
5.189  definition isCont :: "('a::topological_space \<Rightarrow> 'b::topological_space) \<Rightarrow> 'a \<Rightarrow> bool" where
```