528 by (rule eventually_False [symmetric]) |
528 by (rule eventually_False [symmetric]) |
529 |
529 |
530 lemma eventually_const: "\<not> trivial_limit net \<Longrightarrow> eventually (\<lambda>x. P) net \<longleftrightarrow> P" |
530 lemma eventually_const: "\<not> trivial_limit net \<Longrightarrow> eventually (\<lambda>x. P) net \<longleftrightarrow> P" |
531 by (cases P) (simp_all add: eventually_False) |
531 by (cases P) (simp_all add: eventually_False) |
532 |
532 |
|
533 lemma eventually_Inf: "eventually P (Inf B) \<longleftrightarrow> (\<exists>X\<subseteq>B. finite X \<and> eventually P (Inf X))" |
|
534 proof - |
|
535 let ?F = "\<lambda>P. \<exists>X\<subseteq>B. finite X \<and> eventually P (Inf X)" |
|
536 |
|
537 { fix P have "eventually P (Abs_filter ?F) \<longleftrightarrow> ?F P" |
|
538 proof (rule eventually_Abs_filter is_filter.intro)+ |
|
539 show "?F (\<lambda>x. True)" |
|
540 by (rule exI[of _ "{}"]) (simp add: le_fun_def) |
|
541 next |
|
542 fix P Q |
|
543 assume "?F P" then guess X .. |
|
544 moreover |
|
545 assume "?F Q" then guess Y .. |
|
546 ultimately show "?F (\<lambda>x. P x \<and> Q x)" |
|
547 by (intro exI[of _ "X \<union> Y"]) |
|
548 (auto simp: Inf_union_distrib eventually_inf) |
|
549 next |
|
550 fix P Q |
|
551 assume "?F P" then guess X .. |
|
552 moreover assume "\<forall>x. P x \<longrightarrow> Q x" |
|
553 ultimately show "?F Q" |
|
554 by (intro exI[of _ X]) (auto elim: eventually_elim1) |
|
555 qed } |
|
556 note eventually_F = this |
|
557 |
|
558 have "Inf B = Abs_filter ?F" |
|
559 proof (intro antisym Inf_greatest) |
|
560 show "Inf B \<le> Abs_filter ?F" |
|
561 by (auto simp: le_filter_def eventually_F dest: Inf_superset_mono) |
|
562 next |
|
563 fix F assume "F \<in> B" then show "Abs_filter ?F \<le> F" |
|
564 by (auto simp add: le_filter_def eventually_F intro!: exI[of _ "{F}"]) |
|
565 qed |
|
566 then show ?thesis |
|
567 by (simp add: eventually_F) |
|
568 qed |
|
569 |
|
570 lemma eventually_INF: "eventually P (INF b:B. F b) \<longleftrightarrow> (\<exists>X\<subseteq>B. finite X \<and> eventually P (INF b:X. F b))" |
|
571 unfolding INF_def[of B] eventually_Inf[of P "F`B"] |
|
572 by (metis Inf_image_eq finite_imageI image_mono finite_subset_image) |
|
573 |
|
574 lemma Inf_filter_not_bot: |
|
575 fixes B :: "'a filter set" |
|
576 shows "(\<And>X. X \<subseteq> B \<Longrightarrow> finite X \<Longrightarrow> Inf X \<noteq> bot) \<Longrightarrow> Inf B \<noteq> bot" |
|
577 unfolding trivial_limit_def eventually_Inf[of _ B] |
|
578 bot_bool_def [symmetric] bot_fun_def [symmetric] bot_unique by simp |
|
579 |
|
580 lemma INF_filter_not_bot: |
|
581 fixes F :: "'i \<Rightarrow> 'a filter" |
|
582 shows "(\<And>X. X \<subseteq> B \<Longrightarrow> finite X \<Longrightarrow> (INF b:X. F b) \<noteq> bot) \<Longrightarrow> (INF b:B. F b) \<noteq> bot" |
|
583 unfolding trivial_limit_def eventually_INF[of _ B] |
|
584 bot_bool_def [symmetric] bot_fun_def [symmetric] bot_unique by simp |
|
585 |
|
586 lemma eventually_Inf_base: |
|
587 assumes "B \<noteq> {}" and base: "\<And>F G. F \<in> B \<Longrightarrow> G \<in> B \<Longrightarrow> \<exists>x\<in>B. x \<le> inf F G" |
|
588 shows "eventually P (Inf B) \<longleftrightarrow> (\<exists>b\<in>B. eventually P b)" |
|
589 proof (subst eventually_Inf, safe) |
|
590 fix X assume "finite X" "X \<subseteq> B" |
|
591 then have "\<exists>b\<in>B. \<forall>x\<in>X. b \<le> x" |
|
592 proof induct |
|
593 case empty then show ?case |
|
594 using `B \<noteq> {}` by auto |
|
595 next |
|
596 case (insert x X) |
|
597 then obtain b where "b \<in> B" "\<And>x. x \<in> X \<Longrightarrow> b \<le> x" |
|
598 by auto |
|
599 with `insert x X \<subseteq> B` base[of b x] show ?case |
|
600 by (auto intro: order_trans) |
|
601 qed |
|
602 then obtain b where "b \<in> B" "b \<le> Inf X" |
|
603 by (auto simp: le_Inf_iff) |
|
604 then show "eventually P (Inf X) \<Longrightarrow> Bex B (eventually P)" |
|
605 by (intro bexI[of _ b]) (auto simp: le_filter_def) |
|
606 qed (auto intro!: exI[of _ "{x}" for x]) |
|
607 |
|
608 lemma eventually_INF_base: |
|
609 "B \<noteq> {} \<Longrightarrow> (\<And>a b. a \<in> B \<Longrightarrow> b \<in> B \<Longrightarrow> \<exists>x\<in>B. F x \<le> inf (F a) (F b)) \<Longrightarrow> |
|
610 eventually P (INF b:B. F b) \<longleftrightarrow> (\<exists>b\<in>B. eventually P (F b))" |
|
611 unfolding INF_def by (subst eventually_Inf_base) auto |
|
612 |
533 |
613 |
534 subsubsection {* Map function for filters *} |
614 subsubsection {* Map function for filters *} |
535 |
615 |
536 definition filtermap :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a filter \<Rightarrow> 'b filter" |
616 definition filtermap :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a filter \<Rightarrow> 'b filter" |
537 where "filtermap f F = Abs_filter (\<lambda>P. eventually (\<lambda>x. P (f x)) F)" |
617 where "filtermap f F = Abs_filter (\<lambda>P. eventually (\<lambda>x. P (f x)) F)" |
558 by (simp add: filter_eq_iff eventually_filtermap) |
638 by (simp add: filter_eq_iff eventually_filtermap) |
559 |
639 |
560 lemma filtermap_sup: "filtermap f (sup F1 F2) = sup (filtermap f F1) (filtermap f F2)" |
640 lemma filtermap_sup: "filtermap f (sup F1 F2) = sup (filtermap f F1) (filtermap f F2)" |
561 by (auto simp: filter_eq_iff eventually_filtermap eventually_sup) |
641 by (auto simp: filter_eq_iff eventually_filtermap eventually_sup) |
562 |
642 |
|
643 lemma filtermap_inf: "filtermap f (inf F1 F2) \<le> inf (filtermap f F1) (filtermap f F2)" |
|
644 by (auto simp: le_filter_def eventually_filtermap eventually_inf) |
|
645 |
|
646 lemma filtermap_INF: "filtermap f (INF b:B. F b) \<le> (INF b:B. filtermap f (F b))" |
|
647 proof - |
|
648 { fix X :: "'c set" assume "finite X" |
|
649 then have "filtermap f (INFIMUM X F) \<le> (INF b:X. filtermap f (F b))" |
|
650 proof induct |
|
651 case (insert x X) |
|
652 have "filtermap f (INF a:insert x X. F a) \<le> inf (filtermap f (F x)) (filtermap f (INF a:X. F a))" |
|
653 by (rule order_trans[OF _ filtermap_inf]) simp |
|
654 also have "\<dots> \<le> inf (filtermap f (F x)) (INF a:X. filtermap f (F a))" |
|
655 by (intro inf_mono insert order_refl) |
|
656 finally show ?case |
|
657 by simp |
|
658 qed simp } |
|
659 then show ?thesis |
|
660 unfolding le_filter_def eventually_filtermap |
|
661 by (subst (1 2) eventually_INF) auto |
|
662 qed |
|
663 subsubsection {* Standard filters *} |
|
664 |
|
665 definition principal :: "'a set \<Rightarrow> 'a filter" where |
|
666 "principal S = Abs_filter (\<lambda>P. \<forall>x\<in>S. P x)" |
|
667 |
|
668 lemma eventually_principal: "eventually P (principal S) \<longleftrightarrow> (\<forall>x\<in>S. P x)" |
|
669 unfolding principal_def |
|
670 by (rule eventually_Abs_filter, rule is_filter.intro) auto |
|
671 |
|
672 lemma eventually_inf_principal: "eventually P (inf F (principal s)) \<longleftrightarrow> eventually (\<lambda>x. x \<in> s \<longrightarrow> P x) F" |
|
673 unfolding eventually_inf eventually_principal by (auto elim: eventually_elim1) |
|
674 |
|
675 lemma principal_UNIV[simp]: "principal UNIV = top" |
|
676 by (auto simp: filter_eq_iff eventually_principal) |
|
677 |
|
678 lemma principal_empty[simp]: "principal {} = bot" |
|
679 by (auto simp: filter_eq_iff eventually_principal) |
|
680 |
|
681 lemma principal_eq_bot_iff: "principal X = bot \<longleftrightarrow> X = {}" |
|
682 by (auto simp add: filter_eq_iff eventually_principal) |
|
683 |
|
684 lemma principal_le_iff[iff]: "principal A \<le> principal B \<longleftrightarrow> A \<subseteq> B" |
|
685 by (auto simp: le_filter_def eventually_principal) |
|
686 |
|
687 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F" |
|
688 unfolding le_filter_def eventually_principal |
|
689 apply safe |
|
690 apply (erule_tac x="\<lambda>x. x \<in> A" in allE) |
|
691 apply (auto elim: eventually_elim1) |
|
692 done |
|
693 |
|
694 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B" |
|
695 unfolding eq_iff by simp |
|
696 |
|
697 lemma sup_principal[simp]: "sup (principal A) (principal B) = principal (A \<union> B)" |
|
698 unfolding filter_eq_iff eventually_sup eventually_principal by auto |
|
699 |
|
700 lemma inf_principal[simp]: "inf (principal A) (principal B) = principal (A \<inter> B)" |
|
701 unfolding filter_eq_iff eventually_inf eventually_principal |
|
702 by (auto intro: exI[of _ "\<lambda>x. x \<in> A"] exI[of _ "\<lambda>x. x \<in> B"]) |
|
703 |
|
704 lemma SUP_principal[simp]: "(SUP i : I. principal (A i)) = principal (\<Union>i\<in>I. A i)" |
|
705 unfolding filter_eq_iff eventually_Sup SUP_def by (auto simp: eventually_principal) |
|
706 |
|
707 lemma INF_principal_finite: "finite X \<Longrightarrow> (INF x:X. principal (f x)) = principal (\<Inter>x\<in>X. f x)" |
|
708 by (induct X rule: finite_induct) auto |
|
709 |
|
710 lemma filtermap_principal[simp]: "filtermap f (principal A) = principal (f ` A)" |
|
711 unfolding filter_eq_iff eventually_filtermap eventually_principal by simp |
|
712 |
563 subsubsection {* Order filters *} |
713 subsubsection {* Order filters *} |
564 |
714 |
565 definition at_top :: "('a::order) filter" |
715 definition at_top :: "('a::order) filter" |
566 where "at_top = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<ge>k. P n)" |
716 where "at_top = (INF k. principal {k ..})" |
567 |
717 |
568 lemma eventually_at_top_linorder: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::linorder. \<forall>n\<ge>N. P n)" |
718 lemma eventually_at_top_linorder: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::linorder. \<forall>n\<ge>N. P n)" |
569 unfolding at_top_def |
719 unfolding at_top_def |
570 proof (rule eventually_Abs_filter, rule is_filter.intro) |
720 by (subst eventually_INF_base) (auto simp: eventually_principal intro: max.cobounded1 max.cobounded2) |
571 fix P Q :: "'a \<Rightarrow> bool" |
|
572 assume "\<exists>i. \<forall>n\<ge>i. P n" and "\<exists>j. \<forall>n\<ge>j. Q n" |
|
573 then obtain i j where "\<forall>n\<ge>i. P n" and "\<forall>n\<ge>j. Q n" by auto |
|
574 then have "\<forall>n\<ge>max i j. P n \<and> Q n" by simp |
|
575 then show "\<exists>k. \<forall>n\<ge>k. P n \<and> Q n" .. |
|
576 qed auto |
|
577 |
721 |
578 lemma eventually_ge_at_top: |
722 lemma eventually_ge_at_top: |
579 "eventually (\<lambda>x. (c::_::linorder) \<le> x) at_top" |
723 "eventually (\<lambda>x. (c::_::linorder) \<le> x) at_top" |
580 unfolding eventually_at_top_linorder by auto |
724 unfolding eventually_at_top_linorder by auto |
581 |
725 |
582 lemma eventually_at_top_dense: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::unbounded_dense_linorder. \<forall>n>N. P n)" |
726 lemma (in linorder) Ici_subset_Ioi_iff: "{a ..} \<subseteq> {b <..} \<longleftrightarrow> b < a" |
583 unfolding eventually_at_top_linorder |
727 by auto |
584 proof safe |
728 |
585 fix N assume "\<forall>n\<ge>N. P n" |
729 lemma (in linorder) Iic_subset_Iio_iff: "{.. a} \<subseteq> {..< b} \<longleftrightarrow> a < b" |
586 then show "\<exists>N. \<forall>n>N. P n" by (auto intro!: exI[of _ N]) |
730 by auto |
587 next |
731 |
588 fix N assume "\<forall>n>N. P n" |
732 lemma eventually_at_top_dense: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::{no_top, linorder}. \<forall>n>N. P n)" |
589 moreover obtain y where "N < y" using gt_ex[of N] .. |
733 proof - |
590 ultimately show "\<exists>N. \<forall>n\<ge>N. P n" by (auto intro!: exI[of _ y]) |
734 have "eventually P (INF k. principal {k <..}) \<longleftrightarrow> (\<exists>N::'a. \<forall>n>N. P n)" |
|
735 by (subst eventually_INF_base) (auto simp: eventually_principal intro: max.cobounded1 max.cobounded2) |
|
736 also have "(INF k. principal {k::'a <..}) = at_top" |
|
737 unfolding at_top_def |
|
738 by (intro INF_eq) (auto intro: less_imp_le simp: Ici_subset_Ioi_iff gt_ex) |
|
739 finally show ?thesis . |
591 qed |
740 qed |
592 |
741 |
593 lemma eventually_gt_at_top: |
742 lemma eventually_gt_at_top: |
594 "eventually (\<lambda>x. (c::_::unbounded_dense_linorder) < x) at_top" |
743 "eventually (\<lambda>x. (c::_::unbounded_dense_linorder) < x) at_top" |
595 unfolding eventually_at_top_dense by auto |
744 unfolding eventually_at_top_dense by auto |
596 |
745 |
597 definition at_bot :: "('a::order) filter" |
746 definition at_bot :: "('a::order) filter" |
598 where "at_bot = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<le>k. P n)" |
747 where "at_bot = (INF k. principal {.. k})" |
599 |
748 |
600 lemma eventually_at_bot_linorder: |
749 lemma eventually_at_bot_linorder: |
601 fixes P :: "'a::linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n\<le>N. P n)" |
750 fixes P :: "'a::linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n\<le>N. P n)" |
602 unfolding at_bot_def |
751 unfolding at_bot_def |
603 proof (rule eventually_Abs_filter, rule is_filter.intro) |
752 by (subst eventually_INF_base) (auto simp: eventually_principal intro: min.cobounded1 min.cobounded2) |
604 fix P Q :: "'a \<Rightarrow> bool" |
|
605 assume "\<exists>i. \<forall>n\<le>i. P n" and "\<exists>j. \<forall>n\<le>j. Q n" |
|
606 then obtain i j where "\<forall>n\<le>i. P n" and "\<forall>n\<le>j. Q n" by auto |
|
607 then have "\<forall>n\<le>min i j. P n \<and> Q n" by simp |
|
608 then show "\<exists>k. \<forall>n\<le>k. P n \<and> Q n" .. |
|
609 qed auto |
|
610 |
753 |
611 lemma eventually_le_at_bot: |
754 lemma eventually_le_at_bot: |
612 "eventually (\<lambda>x. x \<le> (c::_::linorder)) at_bot" |
755 "eventually (\<lambda>x. x \<le> (c::_::linorder)) at_bot" |
613 unfolding eventually_at_bot_linorder by auto |
756 unfolding eventually_at_bot_linorder by auto |
614 |
757 |
615 lemma eventually_at_bot_dense: |
758 lemma eventually_at_bot_dense: "eventually P at_bot \<longleftrightarrow> (\<exists>N::'a::{no_bot, linorder}. \<forall>n<N. P n)" |
616 fixes P :: "'a::unbounded_dense_linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n<N. P n)" |
759 proof - |
617 unfolding eventually_at_bot_linorder |
760 have "eventually P (INF k. principal {..< k}) \<longleftrightarrow> (\<exists>N::'a. \<forall>n<N. P n)" |
618 proof safe |
761 by (subst eventually_INF_base) (auto simp: eventually_principal intro: min.cobounded1 min.cobounded2) |
619 fix N assume "\<forall>n\<le>N. P n" then show "\<exists>N. \<forall>n<N. P n" by (auto intro!: exI[of _ N]) |
762 also have "(INF k. principal {..< k::'a}) = at_bot" |
620 next |
763 unfolding at_bot_def |
621 fix N assume "\<forall>n<N. P n" |
764 by (intro INF_eq) (auto intro: less_imp_le simp: Iic_subset_Iio_iff lt_ex) |
622 moreover obtain y where "y < N" using lt_ex[of N] .. |
765 finally show ?thesis . |
623 ultimately show "\<exists>N. \<forall>n\<le>N. P n" by (auto intro!: exI[of _ y]) |
|
624 qed |
766 qed |
625 |
767 |
626 lemma eventually_gt_at_bot: |
768 lemma eventually_gt_at_bot: |
627 "eventually (\<lambda>x. x < (c::_::unbounded_dense_linorder)) at_bot" |
769 "eventually (\<lambda>x. x < (c::_::unbounded_dense_linorder)) at_bot" |
628 unfolding eventually_at_bot_dense by auto |
770 unfolding eventually_at_bot_dense by auto |
676 apply auto [] |
814 apply auto [] |
677 apply (rule_tac x=N in exI) |
815 apply (rule_tac x=N in exI) |
678 apply auto [] |
816 apply auto [] |
679 done |
817 done |
680 |
818 |
681 subsubsection {* Standard filters *} |
|
682 |
|
683 definition principal :: "'a set \<Rightarrow> 'a filter" where |
|
684 "principal S = Abs_filter (\<lambda>P. \<forall>x\<in>S. P x)" |
|
685 |
|
686 lemma eventually_principal: "eventually P (principal S) \<longleftrightarrow> (\<forall>x\<in>S. P x)" |
|
687 unfolding principal_def |
|
688 by (rule eventually_Abs_filter, rule is_filter.intro) auto |
|
689 |
|
690 lemma eventually_inf_principal: "eventually P (inf F (principal s)) \<longleftrightarrow> eventually (\<lambda>x. x \<in> s \<longrightarrow> P x) F" |
|
691 unfolding eventually_inf eventually_principal by (auto elim: eventually_elim1) |
|
692 |
|
693 lemma principal_UNIV[simp]: "principal UNIV = top" |
|
694 by (auto simp: filter_eq_iff eventually_principal) |
|
695 |
|
696 lemma principal_empty[simp]: "principal {} = bot" |
|
697 by (auto simp: filter_eq_iff eventually_principal) |
|
698 |
|
699 lemma principal_le_iff[iff]: "principal A \<le> principal B \<longleftrightarrow> A \<subseteq> B" |
|
700 by (auto simp: le_filter_def eventually_principal) |
|
701 |
|
702 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F" |
|
703 unfolding le_filter_def eventually_principal |
|
704 apply safe |
|
705 apply (erule_tac x="\<lambda>x. x \<in> A" in allE) |
|
706 apply (auto elim: eventually_elim1) |
|
707 done |
|
708 |
|
709 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B" |
|
710 unfolding eq_iff by simp |
|
711 |
|
712 lemma sup_principal[simp]: "sup (principal A) (principal B) = principal (A \<union> B)" |
|
713 unfolding filter_eq_iff eventually_sup eventually_principal by auto |
|
714 |
|
715 lemma inf_principal[simp]: "inf (principal A) (principal B) = principal (A \<inter> B)" |
|
716 unfolding filter_eq_iff eventually_inf eventually_principal |
|
717 by (auto intro: exI[of _ "\<lambda>x. x \<in> A"] exI[of _ "\<lambda>x. x \<in> B"]) |
|
718 |
|
719 lemma SUP_principal[simp]: "(SUP i : I. principal (A i)) = principal (\<Union>i\<in>I. A i)" |
|
720 unfolding filter_eq_iff eventually_Sup SUP_def by (auto simp: eventually_principal) |
|
721 |
|
722 lemma filtermap_principal[simp]: "filtermap f (principal A) = principal (f ` A)" |
|
723 unfolding filter_eq_iff eventually_filtermap eventually_principal by simp |
|
724 |
|
725 subsubsection {* Topological filters *} |
819 subsubsection {* Topological filters *} |
726 |
820 |
727 definition (in topological_space) nhds :: "'a \<Rightarrow> 'a filter" |
821 definition (in topological_space) nhds :: "'a \<Rightarrow> 'a filter" |
728 where "nhds a = Abs_filter (\<lambda>P. \<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. P x))" |
822 where "nhds a = (INF S:{S. open S \<and> a \<in> S}. principal S)" |
729 |
823 |
730 definition (in topological_space) at_within :: "'a \<Rightarrow> 'a set \<Rightarrow> 'a filter" ("at (_) within (_)" [1000, 60] 60) |
824 definition (in topological_space) at_within :: "'a \<Rightarrow> 'a set \<Rightarrow> 'a filter" ("at (_) within (_)" [1000, 60] 60) |
731 where "at a within s = inf (nhds a) (principal (s - {a}))" |
825 where "at a within s = inf (nhds a) (principal (s - {a}))" |
732 |
826 |
733 abbreviation (in topological_space) at :: "'a \<Rightarrow> 'a filter" ("at") where |
827 abbreviation (in topological_space) at :: "'a \<Rightarrow> 'a filter" ("at") where |