src/HOL/Limits.thy
changeset 36654 7c8eb32724ce
parent 36630 aa1f8acdcc1c
child 36655 88f0125c3bd2
equal deleted inserted replaced
36632:f96aa31b739d 36654:7c8eb32724ce
   239 lemma eventually_False:
   239 lemma eventually_False:
   240   "eventually (\<lambda>x. False) net \<longleftrightarrow> net = bot"
   240   "eventually (\<lambda>x. False) net \<longleftrightarrow> net = bot"
   241 unfolding expand_net_eq by (auto elim: eventually_rev_mp)
   241 unfolding expand_net_eq by (auto elim: eventually_rev_mp)
   242 
   242 
   243 
   243 
       
   244 subsection {* Map function for nets *}
       
   245 
       
   246 definition
       
   247   netmap :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a net \<Rightarrow> 'b net"
       
   248 where [code del]:
       
   249   "netmap f net = Abs_net (\<lambda>P. eventually (\<lambda>x. P (f x)) net)"
       
   250 
       
   251 lemma eventually_netmap:
       
   252   "eventually P (netmap f net) = eventually (\<lambda>x. P (f x)) net"
       
   253 unfolding netmap_def
       
   254 apply (rule eventually_Abs_net)
       
   255 apply (rule is_filter.intro)
       
   256 apply (auto elim!: eventually_rev_mp)
       
   257 done
       
   258 
       
   259 lemma netmap_ident: "netmap (\<lambda>x. x) net = net"
       
   260 by (simp add: expand_net_eq eventually_netmap)
       
   261 
       
   262 lemma netmap_netmap: "netmap f (netmap g net) = netmap (\<lambda>x. f (g x)) net"
       
   263 by (simp add: expand_net_eq eventually_netmap)
       
   264 
       
   265 lemma netmap_mono: "net \<le> net' \<Longrightarrow> netmap f net \<le> netmap f net'"
       
   266 unfolding le_net_def eventually_netmap by simp
       
   267 
       
   268 lemma netmap_bot [simp]: "netmap f bot = bot"
       
   269 by (simp add: expand_net_eq eventually_netmap)
       
   270 
       
   271 
   244 subsection {* Standard Nets *}
   272 subsection {* Standard Nets *}
   245 
   273 
   246 definition
   274 definition
   247   sequentially :: "nat net"
   275   sequentially :: "nat net"
   248 where [code del]:
   276 where [code del]:
   252   within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70)
   280   within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70)
   253 where [code del]:
   281 where [code del]:
   254   "net within S = Abs_net (\<lambda>P. eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net)"
   282   "net within S = Abs_net (\<lambda>P. eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net)"
   255 
   283 
   256 definition
   284 definition
       
   285   nhds :: "'a::topological_space \<Rightarrow> 'a net"
       
   286 where [code del]:
       
   287   "nhds a = Abs_net (\<lambda>P. \<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))"
       
   288 
       
   289 definition
   257   at :: "'a::topological_space \<Rightarrow> 'a net"
   290   at :: "'a::topological_space \<Rightarrow> 'a net"
   258 where [code del]:
   291 where [code del]:
   259   "at a = Abs_net (\<lambda>P. \<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x))"
   292   "at a = nhds a within - {a}"
   260 
   293 
   261 lemma eventually_sequentially:
   294 lemma eventually_sequentially:
   262   "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)"
   295   "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)"
   263 unfolding sequentially_def
   296 unfolding sequentially_def
   264 proof (rule eventually_Abs_net, rule is_filter.intro)
   297 proof (rule eventually_Abs_net, rule is_filter.intro)
   276    (auto elim!: eventually_rev_mp)
   309    (auto elim!: eventually_rev_mp)
   277 
   310 
   278 lemma within_UNIV: "net within UNIV = net"
   311 lemma within_UNIV: "net within UNIV = net"
   279   unfolding expand_net_eq eventually_within by simp
   312   unfolding expand_net_eq eventually_within by simp
   280 
   313 
       
   314 lemma eventually_nhds:
       
   315   "eventually P (nhds a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))"
       
   316 unfolding nhds_def
       
   317 proof (rule eventually_Abs_net, rule is_filter.intro)
       
   318   have "open UNIV \<and> a \<in> UNIV \<and> (\<forall>x\<in>UNIV. True)" by simp
       
   319   thus "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. True)" by - rule
       
   320 next
       
   321   fix P Q
       
   322   assume "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x)"
       
   323      and "\<exists>T. open T \<and> a \<in> T \<and> (\<forall>x\<in>T. Q x)"
       
   324   then obtain S T where
       
   325     "open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x)"
       
   326     "open T \<and> a \<in> T \<and> (\<forall>x\<in>T. Q x)" by auto
       
   327   hence "open (S \<inter> T) \<and> a \<in> S \<inter> T \<and> (\<forall>x\<in>(S \<inter> T). P x \<and> Q x)"
       
   328     by (simp add: open_Int)
       
   329   thus "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x \<and> Q x)" by - rule
       
   330 qed auto
       
   331 
   281 lemma eventually_at_topological:
   332 lemma eventually_at_topological:
   282   "eventually P (at a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x))"
   333   "eventually P (at a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x))"
   283 unfolding at_def
   334 unfolding at_def eventually_within eventually_nhds by simp
   284 proof (rule eventually_Abs_net, rule is_filter.intro)
       
   285   have "open UNIV \<and> a \<in> UNIV \<and> (\<forall>x\<in>UNIV. x \<noteq> a \<longrightarrow> True)" by simp
       
   286   thus "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> True)" by - rule
       
   287 next
       
   288   fix P Q
       
   289   assume "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x)"
       
   290      and "\<exists>T. open T \<and> a \<in> T \<and> (\<forall>x\<in>T. x \<noteq> a \<longrightarrow> Q x)"
       
   291   then obtain S T where
       
   292     "open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x)"
       
   293     "open T \<and> a \<in> T \<and> (\<forall>x\<in>T. x \<noteq> a \<longrightarrow> Q x)" by auto
       
   294   hence "open (S \<inter> T) \<and> a \<in> S \<inter> T \<and> (\<forall>x\<in>(S \<inter> T). x \<noteq> a \<longrightarrow> P x \<and> Q x)"
       
   295     by (simp add: open_Int)
       
   296   thus "\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> P x \<and> Q x)" by - rule
       
   297 qed auto
       
   298 
   335 
   299 lemma eventually_at:
   336 lemma eventually_at:
   300   fixes a :: "'a::metric_space"
   337   fixes a :: "'a::metric_space"
   301   shows "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> P x)"
   338   shows "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> P x)"
   302 unfolding eventually_at_topological open_dist
   339 unfolding eventually_at_topological open_dist