src/HOL/Limits.thy
changeset 37767 a2b7a20d6ea3
parent 36822 38a480e0346f
child 39198 f967a16dfcdd
equal deleted inserted replaced
37766:a779f463bae4 37767:a2b7a20d6ea3
    35 using assms by (simp add: Abs_net_inverse)
    35 using assms by (simp add: Abs_net_inverse)
    36 
    36 
    37 
    37 
    38 subsection {* Eventually *}
    38 subsection {* Eventually *}
    39 
    39 
    40 definition
    40 definition eventually :: "('a \<Rightarrow> bool) \<Rightarrow> 'a net \<Rightarrow> bool" where
    41   eventually :: "('a \<Rightarrow> bool) \<Rightarrow> 'a net \<Rightarrow> bool" where
    41   "eventually P net \<longleftrightarrow> Rep_net net P"
    42   [code del]: "eventually P net \<longleftrightarrow> Rep_net net P"
       
    43 
    42 
    44 lemma eventually_Abs_net:
    43 lemma eventually_Abs_net:
    45   assumes "is_filter net" shows "eventually P (Abs_net net) = net P"
    44   assumes "is_filter net" shows "eventually P (Abs_net net) = net P"
    46 unfolding eventually_def using assms by (simp add: Abs_net_inverse)
    45 unfolding eventually_def using assms by (simp add: Abs_net_inverse)
    47 
    46 
   112 
   111 
   113 instantiation net :: (type) complete_lattice
   112 instantiation net :: (type) complete_lattice
   114 begin
   113 begin
   115 
   114 
   116 definition
   115 definition
   117   le_net_def [code del]:
   116   le_net_def: "net \<le> net' \<longleftrightarrow> (\<forall>P. eventually P net' \<longrightarrow> eventually P net)"
   118     "net \<le> net' \<longleftrightarrow> (\<forall>P. eventually P net' \<longrightarrow> eventually P net)"
       
   119 
   117 
   120 definition
   118 definition
   121   less_net_def [code del]:
   119   less_net_def: "(net :: 'a net) < net' \<longleftrightarrow> net \<le> net' \<and> \<not> net' \<le> net"
   122     "(net :: 'a net) < net' \<longleftrightarrow> net \<le> net' \<and> \<not> net' \<le> net"
       
   123 
   120 
   124 definition
   121 definition
   125   top_net_def [code del]:
   122   top_net_def: "top = Abs_net (\<lambda>P. \<forall>x. P x)"
   126     "top = Abs_net (\<lambda>P. \<forall>x. P x)"
       
   127 
   123 
   128 definition
   124 definition
   129   bot_net_def [code del]:
   125   bot_net_def: "bot = Abs_net (\<lambda>P. True)"
   130     "bot = Abs_net (\<lambda>P. True)"
       
   131 
   126 
   132 definition
   127 definition
   133   sup_net_def [code del]:
   128   sup_net_def: "sup net net' = Abs_net (\<lambda>P. eventually P net \<and> eventually P net')"
   134     "sup net net' = Abs_net (\<lambda>P. eventually P net \<and> eventually P net')"
       
   135 
   129 
   136 definition
   130 definition
   137   inf_net_def [code del]:
   131   inf_net_def: "inf a b = Abs_net
   138     "inf a b = Abs_net
       
   139       (\<lambda>P. \<exists>Q R. eventually Q a \<and> eventually R b \<and> (\<forall>x. Q x \<and> R x \<longrightarrow> P x))"
   132       (\<lambda>P. \<exists>Q R. eventually Q a \<and> eventually R b \<and> (\<forall>x. Q x \<and> R x \<longrightarrow> P x))"
   140 
   133 
   141 definition
   134 definition
   142   Sup_net_def [code del]:
   135   Sup_net_def: "Sup A = Abs_net (\<lambda>P. \<forall>net\<in>A. eventually P net)"
   143     "Sup A = Abs_net (\<lambda>P. \<forall>net\<in>A. eventually P net)"
       
   144 
   136 
   145 definition
   137 definition
   146   Inf_net_def [code del]:
   138   Inf_net_def: "Inf A = Sup {x::'a net. \<forall>y\<in>A. x \<le> y}"
   147     "Inf A = Sup {x::'a net. \<forall>y\<in>A. x \<le> y}"
       
   148 
   139 
   149 lemma eventually_top [simp]: "eventually P top \<longleftrightarrow> (\<forall>x. P x)"
   140 lemma eventually_top [simp]: "eventually P top \<longleftrightarrow> (\<forall>x. P x)"
   150 unfolding top_net_def
   141 unfolding top_net_def
   151 by (rule eventually_Abs_net, rule is_filter.intro, auto)
   142 by (rule eventually_Abs_net, rule is_filter.intro, auto)
   152 
   143 
   241 unfolding expand_net_eq by (auto elim: eventually_rev_mp)
   232 unfolding expand_net_eq by (auto elim: eventually_rev_mp)
   242 
   233 
   243 
   234 
   244 subsection {* Map function for nets *}
   235 subsection {* Map function for nets *}
   245 
   236 
   246 definition
   237 definition netmap :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a net \<Rightarrow> 'b net" where
   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)"
   238   "netmap f net = Abs_net (\<lambda>P. eventually (\<lambda>x. P (f x)) net)"
   250 
   239 
   251 lemma eventually_netmap:
   240 lemma eventually_netmap:
   252   "eventually P (netmap f net) = eventually (\<lambda>x. P (f x)) net"
   241   "eventually P (netmap f net) = eventually (\<lambda>x. P (f x)) net"
   253 unfolding netmap_def
   242 unfolding netmap_def
   269 by (simp add: expand_net_eq eventually_netmap)
   258 by (simp add: expand_net_eq eventually_netmap)
   270 
   259 
   271 
   260 
   272 subsection {* Sequentially *}
   261 subsection {* Sequentially *}
   273 
   262 
   274 definition
   263 definition sequentially :: "nat net" where
   275   sequentially :: "nat net"
       
   276 where [code del]:
       
   277   "sequentially = Abs_net (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)"
   264   "sequentially = Abs_net (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)"
   278 
   265 
   279 lemma eventually_sequentially:
   266 lemma eventually_sequentially:
   280   "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)"
   267   "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)"
   281 unfolding sequentially_def
   268 unfolding sequentially_def
   300 by (safe, fast, drule_tac x=N in spec, auto elim: eventually_rev_mp)
   287 by (safe, fast, drule_tac x=N in spec, auto elim: eventually_rev_mp)
   301 
   288 
   302 
   289 
   303 subsection {* Standard Nets *}
   290 subsection {* Standard Nets *}
   304 
   291 
   305 definition
   292 definition within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70) where
   306   within :: "'a net \<Rightarrow> 'a set \<Rightarrow> 'a net" (infixr "within" 70)
       
   307 where [code del]:
       
   308   "net within S = Abs_net (\<lambda>P. eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net)"
   293   "net within S = Abs_net (\<lambda>P. eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net)"
   309 
   294 
   310 definition
   295 definition nhds :: "'a::topological_space \<Rightarrow> 'a net" where
   311   nhds :: "'a::topological_space \<Rightarrow> 'a net"
       
   312 where [code del]:
       
   313   "nhds a = Abs_net (\<lambda>P. \<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))"
   296   "nhds a = Abs_net (\<lambda>P. \<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))"
   314 
   297 
   315 definition
   298 definition at :: "'a::topological_space \<Rightarrow> 'a net" where
   316   at :: "'a::topological_space \<Rightarrow> 'a net"
       
   317 where [code del]:
       
   318   "at a = nhds a within - {a}"
   299   "at a = nhds a within - {a}"
   319 
   300 
   320 lemma eventually_within:
   301 lemma eventually_within:
   321   "eventually P (net within S) = eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net"
   302   "eventually P (net within S) = eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) net"
   322 unfolding within_def
   303 unfolding within_def
   366 unfolding at_def eventually_within eventually_nhds_metric by auto
   347 unfolding at_def eventually_within eventually_nhds_metric by auto
   367 
   348 
   368 
   349 
   369 subsection {* Boundedness *}
   350 subsection {* Boundedness *}
   370 
   351 
   371 definition
   352 definition Bfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a net \<Rightarrow> bool" where
   372   Bfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a net \<Rightarrow> bool" where
   353   "Bfun f net = (\<exists>K>0. eventually (\<lambda>x. norm (f x) \<le> K) net)"
   373   [code del]: "Bfun f net = (\<exists>K>0. eventually (\<lambda>x. norm (f x) \<le> K) net)"
       
   374 
   354 
   375 lemma BfunI:
   355 lemma BfunI:
   376   assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) net" shows "Bfun f net"
   356   assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) net" shows "Bfun f net"
   377 unfolding Bfun_def
   357 unfolding Bfun_def
   378 proof (intro exI conjI allI)
   358 proof (intro exI conjI allI)
   388 using assms unfolding Bfun_def by fast
   368 using assms unfolding Bfun_def by fast
   389 
   369 
   390 
   370 
   391 subsection {* Convergence to Zero *}
   371 subsection {* Convergence to Zero *}
   392 
   372 
   393 definition
   373 definition Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a net \<Rightarrow> bool" where
   394   Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a net \<Rightarrow> bool" where
   374   "Zfun f net = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) net)"
   395   [code del]: "Zfun f net = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) net)"
       
   396 
   375 
   397 lemma ZfunI:
   376 lemma ZfunI:
   398   "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) net) \<Longrightarrow> Zfun f net"
   377   "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) net) \<Longrightarrow> Zfun f net"
   399 unfolding Zfun_def by simp
   378 unfolding Zfun_def by simp
   400 
   379 
   545 lemmas Zfun_mult_left = mult.Zfun_left
   524 lemmas Zfun_mult_left = mult.Zfun_left
   546 
   525 
   547 
   526 
   548 subsection {* Limits *}
   527 subsection {* Limits *}
   549 
   528 
   550 definition
   529 definition tendsto :: "('a \<Rightarrow> 'b::topological_space) \<Rightarrow> 'b \<Rightarrow> 'a net \<Rightarrow> bool"
   551   tendsto :: "('a \<Rightarrow> 'b::topological_space) \<Rightarrow> 'b \<Rightarrow> 'a net \<Rightarrow> bool"
   530     (infixr "--->" 55) where
   552     (infixr "--->" 55)
       
   553 where [code del]:
       
   554   "(f ---> l) net \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net)"
   531   "(f ---> l) net \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net)"
   555 
   532 
   556 ML {*
   533 ML {*
   557 structure Tendsto_Intros = Named_Thms
   534 structure Tendsto_Intros = Named_Thms
   558 (
   535 (