112 within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70) where |
112 within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70) where |
113 [code del]: "net within S = Abs_net ((\<lambda>A. A \<inter> S) ` Rep_net net)" |
113 [code del]: "net within S = Abs_net ((\<lambda>A. A \<inter> S) ` Rep_net net)" |
114 |
114 |
115 definition |
115 definition |
116 at :: "'a::topological_space \<Rightarrow> 'a net" where |
116 at :: "'a::topological_space \<Rightarrow> 'a net" where |
117 [code del]: "at a = Abs_net ((\<lambda>S. S - {a}) ` {S\<in>topo. a \<in> S})" |
117 [code del]: "at a = Abs_net ((\<lambda>S. S - {a}) ` {S. open S \<and> a \<in> S})" |
118 |
118 |
119 lemma Rep_net_sequentially: |
119 lemma Rep_net_sequentially: |
120 "Rep_net sequentially = range (\<lambda>n. {n..})" |
120 "Rep_net sequentially = range (\<lambda>n. {n..})" |
121 unfolding sequentially_def |
121 unfolding sequentially_def |
122 apply (rule Abs_net_inverse') |
122 apply (rule Abs_net_inverse') |
134 apply (drule (1) Rep_net_directed) |
134 apply (drule (1) Rep_net_directed) |
135 apply (clarify, rule_tac x=C in bexI, auto) |
135 apply (clarify, rule_tac x=C in bexI, auto) |
136 done |
136 done |
137 |
137 |
138 lemma Rep_net_at: |
138 lemma Rep_net_at: |
139 "Rep_net (at a) = ((\<lambda>S. S - {a}) ` {S\<in>topo. a \<in> S})" |
139 "Rep_net (at a) = ((\<lambda>S. S - {a}) ` {S. open S \<and> a \<in> S})" |
140 unfolding at_def |
140 unfolding at_def |
141 apply (rule Abs_net_inverse') |
141 apply (rule Abs_net_inverse') |
142 apply (rule image_nonempty) |
142 apply (rule image_nonempty) |
143 apply (rule_tac x="UNIV" in exI, simp add: topo_UNIV) |
143 apply (rule_tac x="UNIV" in exI, simp) |
144 apply (clarsimp, rename_tac S T) |
144 apply (clarsimp, rename_tac S T) |
145 apply (rule_tac x="S \<inter> T" in exI, auto simp add: topo_Int) |
145 apply (rule_tac x="S \<inter> T" in exI, auto simp add: open_Int) |
146 done |
146 done |
147 |
147 |
148 lemma eventually_sequentially: |
148 lemma eventually_sequentially: |
149 "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)" |
149 "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)" |
150 unfolding eventually_def Rep_net_sequentially by auto |
150 unfolding eventually_def Rep_net_sequentially by auto |
152 lemma eventually_within: |
152 lemma eventually_within: |
153 "eventually P (net within S) = eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net" |
153 "eventually P (net within S) = eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net" |
154 unfolding eventually_def Rep_net_within by auto |
154 unfolding eventually_def Rep_net_within by auto |
155 |
155 |
156 lemma eventually_at_topological: |
156 lemma eventually_at_topological: |
157 "eventually P (at a) \<longleftrightarrow> (\<exists>S\<in>topo. a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x))" |
157 "eventually P (at a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x))" |
158 unfolding eventually_def Rep_net_at by auto |
158 unfolding eventually_def Rep_net_at by auto |
159 |
159 |
160 lemma eventually_at: |
160 lemma eventually_at: |
161 fixes a :: "'a::metric_space" |
161 fixes a :: "'a::metric_space" |
162 shows "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> P x)" |
162 shows "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> P x)" |
163 unfolding eventually_at_topological topo_dist |
163 unfolding eventually_at_topological open_dist |
164 apply safe |
164 apply safe |
165 apply fast |
165 apply fast |
166 apply (rule_tac x="{x. dist x a < d}" in bexI, simp) |
166 apply (rule_tac x="{x. dist x a < d}" in exI, simp) |
167 apply clarsimp |
167 apply clarsimp |
168 apply (rule_tac x="d - dist x a" in exI, clarsimp) |
168 apply (rule_tac x="d - dist x a" in exI, clarsimp) |
169 apply (simp only: less_diff_eq) |
169 apply (simp only: less_diff_eq) |
170 apply (erule le_less_trans [OF dist_triangle]) |
170 apply (erule le_less_trans [OF dist_triangle]) |
171 done |
171 done |
354 |
354 |
355 definition |
355 definition |
356 tendsto :: "('a \<Rightarrow> 'b::topological_space) \<Rightarrow> 'b \<Rightarrow> 'a net \<Rightarrow> bool" |
356 tendsto :: "('a \<Rightarrow> 'b::topological_space) \<Rightarrow> 'b \<Rightarrow> 'a net \<Rightarrow> bool" |
357 (infixr "--->" 55) |
357 (infixr "--->" 55) |
358 where [code del]: |
358 where [code del]: |
359 "(f ---> l) net \<longleftrightarrow> (\<forall>S\<in>topo. l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net)" |
359 "(f ---> l) net \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net)" |
360 |
360 |
361 lemma topological_tendstoI: |
361 lemma topological_tendstoI: |
362 "(\<And>S. S \<in> topo \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) net) |
362 "(\<And>S. open S \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) net) |
363 \<Longrightarrow> (f ---> l) net" |
363 \<Longrightarrow> (f ---> l) net" |
364 unfolding tendsto_def by auto |
364 unfolding tendsto_def by auto |
365 |
365 |
366 lemma topological_tendstoD: |
366 lemma topological_tendstoD: |
367 "(f ---> l) net \<Longrightarrow> S \<in> topo \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) net" |
367 "(f ---> l) net \<Longrightarrow> open S \<Longrightarrow> l \<in> S \<Longrightarrow> eventually (\<lambda>x. f x \<in> S) net" |
368 unfolding tendsto_def by auto |
368 unfolding tendsto_def by auto |
369 |
369 |
370 lemma tendstoI: |
370 lemma tendstoI: |
371 assumes "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net" |
371 assumes "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net" |
372 shows "(f ---> l) net" |
372 shows "(f ---> l) net" |
373 apply (rule topological_tendstoI) |
373 apply (rule topological_tendstoI) |
374 apply (simp add: topo_dist) |
374 apply (simp add: open_dist) |
375 apply (drule (1) bspec, clarify) |
375 apply (drule (1) bspec, clarify) |
376 apply (drule assms) |
376 apply (drule assms) |
377 apply (erule eventually_elim1, simp) |
377 apply (erule eventually_elim1, simp) |
378 done |
378 done |
379 |
379 |
380 lemma tendstoD: |
380 lemma tendstoD: |
381 "(f ---> l) net \<Longrightarrow> 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net" |
381 "(f ---> l) net \<Longrightarrow> 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net" |
382 apply (drule_tac S="{x. dist x l < e}" in topological_tendstoD) |
382 apply (drule_tac S="{x. dist x l < e}" in topological_tendstoD) |
383 apply (clarsimp simp add: topo_dist) |
383 apply (clarsimp simp add: open_dist) |
384 apply (rule_tac x="e - dist x l" in exI, clarsimp) |
384 apply (rule_tac x="e - dist x l" in exI, clarsimp) |
385 apply (simp only: less_diff_eq) |
385 apply (simp only: less_diff_eq) |
386 apply (erule le_less_trans [OF dist_triangle]) |
386 apply (erule le_less_trans [OF dist_triangle]) |
387 apply simp |
387 apply simp |
388 apply simp |
388 apply simp |