278 unfolding le_filter_def eventually_filtermap by simp |
278 unfolding le_filter_def eventually_filtermap by simp |
279 |
279 |
280 lemma filtermap_bot [simp]: "filtermap f bot = bot" |
280 lemma filtermap_bot [simp]: "filtermap f bot = bot" |
281 by (simp add: filter_eq_iff eventually_filtermap) |
281 by (simp add: filter_eq_iff eventually_filtermap) |
282 |
282 |
283 |
283 subsection {* Order filters *} |
284 subsection {* Sequentially *} |
284 |
285 |
285 definition at_top :: "('a::order) filter" |
286 definition sequentially :: "nat filter" |
286 where "at_top = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)" |
287 where "sequentially = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)" |
287 |
288 |
288 lemma eventually_at_top_linorder: |
289 lemma eventually_sequentially: |
289 fixes P :: "'a::linorder \<Rightarrow> bool" shows "eventually P at_top \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)" |
290 "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)" |
290 unfolding at_top_def |
291 unfolding sequentially_def |
|
292 proof (rule eventually_Abs_filter, rule is_filter.intro) |
291 proof (rule eventually_Abs_filter, rule is_filter.intro) |
293 fix P Q :: "nat \<Rightarrow> bool" |
292 fix P Q :: "'a \<Rightarrow> bool" |
294 assume "\<exists>i. \<forall>n\<ge>i. P n" and "\<exists>j. \<forall>n\<ge>j. Q n" |
293 assume "\<exists>i. \<forall>n\<ge>i. P n" and "\<exists>j. \<forall>n\<ge>j. Q n" |
295 then obtain i j where "\<forall>n\<ge>i. P n" and "\<forall>n\<ge>j. Q n" by auto |
294 then obtain i j where "\<forall>n\<ge>i. P n" and "\<forall>n\<ge>j. Q n" by auto |
296 then have "\<forall>n\<ge>max i j. P n \<and> Q n" by simp |
295 then have "\<forall>n\<ge>max i j. P n \<and> Q n" by simp |
297 then show "\<exists>k. \<forall>n\<ge>k. P n \<and> Q n" .. |
296 then show "\<exists>k. \<forall>n\<ge>k. P n \<and> Q n" .. |
298 qed auto |
297 qed auto |
299 |
298 |
|
299 lemma eventually_at_top_dense: |
|
300 fixes P :: "'a::dense_linorder \<Rightarrow> bool" shows "eventually P at_top \<longleftrightarrow> (\<exists>N. \<forall>n>N. P n)" |
|
301 unfolding eventually_at_top_linorder |
|
302 proof safe |
|
303 fix N assume "\<forall>n\<ge>N. P n" then show "\<exists>N. \<forall>n>N. P n" by (auto intro!: exI[of _ N]) |
|
304 next |
|
305 fix N assume "\<forall>n>N. P n" |
|
306 moreover from gt_ex[of N] guess y .. |
|
307 ultimately show "\<exists>N. \<forall>n\<ge>N. P n" by (auto intro!: exI[of _ y]) |
|
308 qed |
|
309 |
|
310 definition at_bot :: "('a::order) filter" |
|
311 where "at_bot = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<le>k. P n)" |
|
312 |
|
313 lemma eventually_at_bot_linorder: |
|
314 fixes P :: "'a::linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n\<le>N. P n)" |
|
315 unfolding at_bot_def |
|
316 proof (rule eventually_Abs_filter, rule is_filter.intro) |
|
317 fix P Q :: "'a \<Rightarrow> bool" |
|
318 assume "\<exists>i. \<forall>n\<le>i. P n" and "\<exists>j. \<forall>n\<le>j. Q n" |
|
319 then obtain i j where "\<forall>n\<le>i. P n" and "\<forall>n\<le>j. Q n" by auto |
|
320 then have "\<forall>n\<le>min i j. P n \<and> Q n" by simp |
|
321 then show "\<exists>k. \<forall>n\<le>k. P n \<and> Q n" .. |
|
322 qed auto |
|
323 |
|
324 lemma eventually_at_bot_dense: |
|
325 fixes P :: "'a::dense_linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n<N. P n)" |
|
326 unfolding eventually_at_bot_linorder |
|
327 proof safe |
|
328 fix N assume "\<forall>n\<le>N. P n" then show "\<exists>N. \<forall>n<N. P n" by (auto intro!: exI[of _ N]) |
|
329 next |
|
330 fix N assume "\<forall>n<N. P n" |
|
331 moreover from lt_ex[of N] guess y .. |
|
332 ultimately show "\<exists>N. \<forall>n\<le>N. P n" by (auto intro!: exI[of _ y]) |
|
333 qed |
|
334 |
|
335 subsection {* Sequentially *} |
|
336 |
|
337 abbreviation sequentially :: "nat filter" |
|
338 where "sequentially == at_top" |
|
339 |
|
340 lemma sequentially_def: "sequentially = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)" |
|
341 unfolding at_top_def by simp |
|
342 |
|
343 lemma eventually_sequentially: |
|
344 "eventually P sequentially \<longleftrightarrow> (\<exists>N. \<forall>n\<ge>N. P n)" |
|
345 by (rule eventually_at_top_linorder) |
|
346 |
300 lemma sequentially_bot [simp, intro]: "sequentially \<noteq> bot" |
347 lemma sequentially_bot [simp, intro]: "sequentially \<noteq> bot" |
301 unfolding filter_eq_iff eventually_sequentially by auto |
348 unfolding filter_eq_iff eventually_sequentially by auto |
302 |
349 |
303 lemmas trivial_limit_sequentially = sequentially_bot |
350 lemmas trivial_limit_sequentially = sequentially_bot |
304 |
351 |
337 lemma within_UNIV [simp]: "F within UNIV = F" |
384 lemma within_UNIV [simp]: "F within UNIV = F" |
338 unfolding filter_eq_iff eventually_within by simp |
385 unfolding filter_eq_iff eventually_within by simp |
339 |
386 |
340 lemma within_empty [simp]: "F within {} = bot" |
387 lemma within_empty [simp]: "F within {} = bot" |
341 unfolding filter_eq_iff eventually_within by simp |
388 unfolding filter_eq_iff eventually_within by simp |
|
389 |
|
390 lemma within_le: "F within S \<le> F" |
|
391 unfolding le_filter_def eventually_within by (auto elim: eventually_elim1) |
342 |
392 |
343 lemma eventually_nhds: |
393 lemma eventually_nhds: |
344 "eventually P (nhds a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))" |
394 "eventually P (nhds a) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))" |
345 unfolding nhds_def |
395 unfolding nhds_def |
346 proof (rule eventually_Abs_filter, rule is_filter.intro) |
396 proof (rule eventually_Abs_filter, rule is_filter.intro) |
562 lemmas Zfun_mult_left = bounded_bilinear.Zfun_left [OF bounded_bilinear_mult] |
612 lemmas Zfun_mult_left = bounded_bilinear.Zfun_left [OF bounded_bilinear_mult] |
563 |
613 |
564 |
614 |
565 subsection {* Limits *} |
615 subsection {* Limits *} |
566 |
616 |
567 definition (in topological_space) |
617 definition filter_lim :: "('a \<Rightarrow> 'b) \<Rightarrow> 'b filter \<Rightarrow> 'a filter \<Rightarrow> bool" where |
|
618 "filter_lim f F2 F1 \<longleftrightarrow> filtermap f F1 \<le> F2" |
|
619 |
|
620 syntax |
|
621 "_LIM" :: "pttrns \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> bool" ("(3LIM (_)/ (_)./ (_) :> (_))" [1000, 10, 0, 10] 10) |
|
622 |
|
623 translations |
|
624 "LIM x F1. f :> F2" == "CONST filter_lim (%x. f) F2 F1" |
|
625 |
|
626 lemma filter_limE: "(LIM x F1. f x :> F2) \<Longrightarrow> eventually P F2 \<Longrightarrow> eventually (\<lambda>x. P (f x)) F1" |
|
627 by (auto simp: filter_lim_def eventually_filtermap le_filter_def) |
|
628 |
|
629 lemma filter_limI: "(\<And>P. eventually P F2 \<Longrightarrow> eventually (\<lambda>x. P (f x)) F1) \<Longrightarrow> (LIM x F1. f x :> F2)" |
|
630 by (auto simp: filter_lim_def eventually_filtermap le_filter_def) |
|
631 |
|
632 abbreviation (in topological_space) |
568 tendsto :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'b filter \<Rightarrow> bool" (infixr "--->" 55) where |
633 tendsto :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'b filter \<Rightarrow> bool" (infixr "--->" 55) where |
569 "(f ---> l) F \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F)" |
634 "(f ---> l) F \<equiv> filter_lim f (nhds l) F" |
570 |
|
571 definition real_tendsto_inf :: "('a \<Rightarrow> real) \<Rightarrow> 'a filter \<Rightarrow> bool" where |
|
572 "real_tendsto_inf f F \<equiv> \<forall>x. eventually (\<lambda>y. x < f y) F" |
|
573 |
635 |
574 ML {* |
636 ML {* |
575 structure Tendsto_Intros = Named_Thms |
637 structure Tendsto_Intros = Named_Thms |
576 ( |
638 ( |
577 val name = @{binding tendsto_intros} |
639 val name = @{binding tendsto_intros} |
578 val description = "introduction rules for tendsto" |
640 val description = "introduction rules for tendsto" |
579 ) |
641 ) |
580 *} |
642 *} |
581 |
643 |
582 setup Tendsto_Intros.setup |
644 setup Tendsto_Intros.setup |
|
645 |
|
646 lemma tendsto_def: "(f ---> l) F \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F)" |
|
647 unfolding filter_lim_def |
|
648 proof safe |
|
649 fix S assume "open S" "l \<in> S" "filtermap f F \<le> nhds l" |
|
650 then show "eventually (\<lambda>x. f x \<in> S) F" |
|
651 unfolding eventually_nhds eventually_filtermap le_filter_def |
|
652 by (auto elim!: allE[of _ "\<lambda>x. x \<in> S"] eventually_rev_mp) |
|
653 qed (auto elim!: eventually_rev_mp simp: eventually_nhds eventually_filtermap le_filter_def) |
583 |
654 |
584 lemma tendsto_mono: "F \<le> F' \<Longrightarrow> (f ---> l) F' \<Longrightarrow> (f ---> l) F" |
655 lemma tendsto_mono: "F \<le> F' \<Longrightarrow> (f ---> l) F' \<Longrightarrow> (f ---> l) F" |
585 unfolding tendsto_def le_filter_def by fast |
656 unfolding tendsto_def le_filter_def by fast |
586 |
657 |
587 lemma topological_tendstoI: |
658 lemma topological_tendstoI: |
703 fix e :: real assume "0 < e" |
774 fix e :: real assume "0 < e" |
704 with f have "eventually (\<lambda>x. dist (f x) a < e) F" by (rule tendstoD) |
775 with f have "eventually (\<lambda>x. dist (f x) a < e) F" by (rule tendstoD) |
705 with le show "eventually (\<lambda>x. dist (g x) b < e) F" |
776 with le show "eventually (\<lambda>x. dist (g x) b < e) F" |
706 using le_less_trans by (rule eventually_elim2) |
777 using le_less_trans by (rule eventually_elim2) |
707 qed |
778 qed |
708 |
|
709 lemma real_tendsto_inf_real: "real_tendsto_inf real sequentially" |
|
710 proof (unfold real_tendsto_inf_def, rule allI) |
|
711 fix x show "eventually (\<lambda>y. x < real y) sequentially" |
|
712 by (rule eventually_sequentiallyI[of "natceiling (x + 1)"]) |
|
713 (simp add: natceiling_le_eq) |
|
714 qed |
|
715 |
|
716 |
|
717 |
779 |
718 subsubsection {* Distance and norms *} |
780 subsubsection {* Distance and norms *} |
719 |
781 |
720 lemma tendsto_dist [tendsto_intros]: |
782 lemma tendsto_dist [tendsto_intros]: |
721 assumes f: "(f ---> l) F" and g: "(g ---> m) F" |
783 assumes f: "(f ---> l) F" and g: "(g ---> m) F" |
1009 lemma tendsto_sgn [tendsto_intros]: |
1071 lemma tendsto_sgn [tendsto_intros]: |
1010 fixes l :: "'a::real_normed_vector" |
1072 fixes l :: "'a::real_normed_vector" |
1011 shows "\<lbrakk>(f ---> l) F; l \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. sgn (f x)) ---> sgn l) F" |
1073 shows "\<lbrakk>(f ---> l) F; l \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. sgn (f x)) ---> sgn l) F" |
1012 unfolding sgn_div_norm by (simp add: tendsto_intros) |
1074 unfolding sgn_div_norm by (simp add: tendsto_intros) |
1013 |
1075 |
|
1076 subsection {* Limits to @{const at_top} and @{const at_bot} *} |
|
1077 |
|
1078 lemma filter_lim_at_top: |
|
1079 fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" |
|
1080 shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z < f x) F)" |
|
1081 by (safe elim!: filter_limE intro!: filter_limI) |
|
1082 (auto simp: eventually_at_top_dense elim!: eventually_elim1) |
|
1083 |
|
1084 lemma filter_lim_at_bot: |
|
1085 fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" |
|
1086 shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x < Z) F)" |
|
1087 by (safe elim!: filter_limE intro!: filter_limI) |
|
1088 (auto simp: eventually_at_bot_dense elim!: eventually_elim1) |
|
1089 |
|
1090 lemma filter_lim_real_sequentially: "LIM x sequentially. real x :> at_top" |
|
1091 unfolding filter_lim_at_top |
|
1092 apply (intro allI) |
|
1093 apply (rule_tac c="natceiling (Z + 1)" in eventually_sequentiallyI) |
|
1094 apply (auto simp: natceiling_le_eq) |
|
1095 done |
|
1096 |
1014 end |
1097 end |