src/HOL/Filter.thy
changeset 61810 3c5040d5694a
parent 61806 d2e62ae01cd8
child 61841 4d3527b94f2a
equal deleted inserted replaced
61809:81d34cf268d8 61810:3c5040d5694a
    65 
    65 
    66 lemma eventuallyI: "(\<And>x. P x) \<Longrightarrow> eventually P F"
    66 lemma eventuallyI: "(\<And>x. P x) \<Longrightarrow> eventually P F"
    67   by (auto intro: always_eventually)
    67   by (auto intro: always_eventually)
    68 
    68 
    69 lemma eventually_mono:
    69 lemma eventually_mono:
    70   "(\<forall>x. P x \<longrightarrow> Q x) \<Longrightarrow> eventually P F \<Longrightarrow> eventually Q F"
       
    71   unfolding eventually_def
       
    72   by (rule is_filter.mono [OF is_filter_Rep_filter])
       
    73 
       
    74 lemma eventually_mono':
       
    75   "\<lbrakk>eventually P F; \<And>x. P x \<Longrightarrow> Q x\<rbrakk> \<Longrightarrow> eventually Q F"
    70   "\<lbrakk>eventually P F; \<And>x. P x \<Longrightarrow> Q x\<rbrakk> \<Longrightarrow> eventually Q F"
    76   unfolding eventually_def
    71   unfolding eventually_def
    77   by (blast intro: is_filter.mono [OF is_filter_Rep_filter])
    72   by (blast intro: is_filter.mono [OF is_filter_Rep_filter])
    78 
    73 
    79 lemma eventually_conj:
    74 lemma eventually_conj:
    89   shows "eventually (\<lambda>x. Q x) F"
    84   shows "eventually (\<lambda>x. Q x) F"
    90 proof -
    85 proof -
    91   have "eventually (\<lambda>x. (P x \<longrightarrow> Q x) \<and> P x) F"
    86   have "eventually (\<lambda>x. (P x \<longrightarrow> Q x) \<and> P x) F"
    92     using assms by (rule eventually_conj)
    87     using assms by (rule eventually_conj)
    93   then show ?thesis
    88   then show ?thesis
    94     by (blast intro: eventually_mono')
    89     by (blast intro: eventually_mono)
    95 qed
    90 qed
    96 
    91 
    97 lemma eventually_rev_mp:
    92 lemma eventually_rev_mp:
    98   assumes "eventually (\<lambda>x. P x) F"
    93   assumes "eventually (\<lambda>x. P x) F"
    99   assumes "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
    94   assumes "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
   101 using assms(2) assms(1) by (rule eventually_mp)
    96 using assms(2) assms(1) by (rule eventually_mp)
   102 
    97 
   103 lemma eventually_conj_iff:
    98 lemma eventually_conj_iff:
   104   "eventually (\<lambda>x. P x \<and> Q x) F \<longleftrightarrow> eventually P F \<and> eventually Q F"
    99   "eventually (\<lambda>x. P x \<and> Q x) F \<longleftrightarrow> eventually P F \<and> eventually Q F"
   105   by (auto intro: eventually_conj elim: eventually_rev_mp)
   100   by (auto intro: eventually_conj elim: eventually_rev_mp)
   106 
       
   107 lemma eventually_elim1:
       
   108   assumes "eventually (\<lambda>i. P i) F"
       
   109   assumes "\<And>i. P i \<Longrightarrow> Q i"
       
   110   shows "eventually (\<lambda>i. Q i) F"
       
   111   using assms by (auto elim!: eventually_rev_mp)
       
   112 
   101 
   113 lemma eventually_elim2:
   102 lemma eventually_elim2:
   114   assumes "eventually (\<lambda>i. P i) F"
   103   assumes "eventually (\<lambda>i. P i) F"
   115   assumes "eventually (\<lambda>i. Q i) F"
   104   assumes "eventually (\<lambda>i. Q i) F"
   116   assumes "\<And>i. P i \<Longrightarrow> Q i \<Longrightarrow> R i"
   105   assumes "\<And>i. P i \<Longrightarrow> Q i \<Longrightarrow> R i"
   133 
   122 
   134 lemma eventually_ex: "(\<forall>\<^sub>Fx in F. \<exists>y. P x y) \<longleftrightarrow> (\<exists>Y. \<forall>\<^sub>Fx in F. P x (Y x))"
   123 lemma eventually_ex: "(\<forall>\<^sub>Fx in F. \<exists>y. P x y) \<longleftrightarrow> (\<exists>Y. \<forall>\<^sub>Fx in F. P x (Y x))"
   135 proof
   124 proof
   136   assume "\<forall>\<^sub>Fx in F. \<exists>y. P x y"
   125   assume "\<forall>\<^sub>Fx in F. \<exists>y. P x y"
   137   then have "\<forall>\<^sub>Fx in F. P x (SOME y. P x y)"
   126   then have "\<forall>\<^sub>Fx in F. P x (SOME y. P x y)"
   138     by (auto intro: someI_ex eventually_elim1)
   127     by (auto intro: someI_ex eventually_mono)
   139   then show "\<exists>Y. \<forall>\<^sub>Fx in F. P x (Y x)"
   128   then show "\<exists>Y. \<forall>\<^sub>Fx in F. P x (Y x)"
   140     by auto
   129     by auto
   141 qed (auto intro: eventually_elim1)
   130 qed (auto intro: eventually_mono)
   142 
   131 
   143 lemma not_eventually_impI: "eventually P F \<Longrightarrow> \<not> eventually Q F \<Longrightarrow> \<not> eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
   132 lemma not_eventually_impI: "eventually P F \<Longrightarrow> \<not> eventually Q F \<Longrightarrow> \<not> eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
   144   by (auto intro: eventually_mp)
   133   by (auto intro: eventually_mp)
   145 
   134 
   146 lemma not_eventuallyD: "\<not> eventually P F \<Longrightarrow> \<exists>x. \<not> P x"
   135 lemma not_eventuallyD: "\<not> eventually P F \<Longrightarrow> \<exists>x. \<not> P x"
   150   assumes "eventually (\<lambda>n. P n = Q n) F"
   139   assumes "eventually (\<lambda>n. P n = Q n) F"
   151   shows "eventually P F = eventually Q F" (is "?L = ?R")
   140   shows "eventually P F = eventually Q F" (is "?L = ?R")
   152 proof -
   141 proof -
   153   from assms have "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
   142   from assms have "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
   154       and "eventually (\<lambda>x. Q x \<longrightarrow> P x) F"
   143       and "eventually (\<lambda>x. Q x \<longrightarrow> P x) F"
   155     by (auto elim: eventually_elim1)
   144     by (auto elim: eventually_mono)
   156   then show ?thesis by (auto elim: eventually_elim2)
   145   then show ?thesis by (auto elim: eventually_elim2)
   157 qed
   146 qed
   158 
   147 
   159 subsection \<open> Frequently as dual to eventually \<close>
   148 subsection \<open> Frequently as dual to eventually \<close>
   160 
   149 
   344     unfolding le_filter_def filter_eq_iff by fast }
   333     unfolding le_filter_def filter_eq_iff by fast }
   345   { show "inf F F' \<le> F" and "inf F F' \<le> F'"
   334   { show "inf F F' \<le> F" and "inf F F' \<le> F'"
   346     unfolding le_filter_def eventually_inf by (auto intro: eventually_True) }
   335     unfolding le_filter_def eventually_inf by (auto intro: eventually_True) }
   347   { assume "F \<le> F'" and "F \<le> F''" thus "F \<le> inf F' F''"
   336   { assume "F \<le> F'" and "F \<le> F''" thus "F \<le> inf F' F''"
   348     unfolding le_filter_def eventually_inf
   337     unfolding le_filter_def eventually_inf
   349     by (auto intro: eventually_mono' [OF eventually_conj]) }
   338     by (auto intro: eventually_mono [OF eventually_conj]) }
   350   { show "F \<le> sup F F'" and "F' \<le> sup F F'"
   339   { show "F \<le> sup F F'" and "F' \<le> sup F F'"
   351     unfolding le_filter_def eventually_sup by simp_all }
   340     unfolding le_filter_def eventually_sup by simp_all }
   352   { assume "F \<le> F''" and "F' \<le> F''" thus "sup F F' \<le> F''"
   341   { assume "F \<le> F''" and "F' \<le> F''" thus "sup F F' \<le> F''"
   353     unfolding le_filter_def eventually_sup by simp }
   342     unfolding le_filter_def eventually_sup by simp }
   354   { assume "F'' \<in> S" thus "Inf S \<le> F''"
   343   { assume "F'' \<in> S" thus "Inf S \<le> F''"
   432     next
   421     next
   433       fix P Q
   422       fix P Q
   434       assume "?F P" then guess X ..
   423       assume "?F P" then guess X ..
   435       moreover assume "\<forall>x. P x \<longrightarrow> Q x"
   424       moreover assume "\<forall>x. P x \<longrightarrow> Q x"
   436       ultimately show "?F Q"
   425       ultimately show "?F Q"
   437         by (intro exI[of _ X]) (auto elim: eventually_elim1)
   426         by (intro exI[of _ X]) (auto elim: eventually_mono)
   438     qed }
   427     qed }
   439   note eventually_F = this
   428   note eventually_F = this
   440 
   429 
   441   have "Inf B = Abs_filter ?F"
   430   have "Inf B = Abs_filter ?F"
   442   proof (intro antisym Inf_greatest)
   431   proof (intro antisym Inf_greatest)
   551 lemma eventually_principal: "eventually P (principal S) \<longleftrightarrow> (\<forall>x\<in>S. P x)"
   540 lemma eventually_principal: "eventually P (principal S) \<longleftrightarrow> (\<forall>x\<in>S. P x)"
   552   unfolding principal_def
   541   unfolding principal_def
   553   by (rule eventually_Abs_filter, rule is_filter.intro) auto
   542   by (rule eventually_Abs_filter, rule is_filter.intro) auto
   554 
   543 
   555 lemma eventually_inf_principal: "eventually P (inf F (principal s)) \<longleftrightarrow> eventually (\<lambda>x. x \<in> s \<longrightarrow> P x) F"
   544 lemma eventually_inf_principal: "eventually P (inf F (principal s)) \<longleftrightarrow> eventually (\<lambda>x. x \<in> s \<longrightarrow> P x) F"
   556   unfolding eventually_inf eventually_principal by (auto elim: eventually_elim1)
   545   unfolding eventually_inf eventually_principal by (auto elim: eventually_mono)
   557 
   546 
   558 lemma principal_UNIV[simp]: "principal UNIV = top"
   547 lemma principal_UNIV[simp]: "principal UNIV = top"
   559   by (auto simp: filter_eq_iff eventually_principal)
   548   by (auto simp: filter_eq_iff eventually_principal)
   560 
   549 
   561 lemma principal_empty[simp]: "principal {} = bot"
   550 lemma principal_empty[simp]: "principal {} = bot"
   569 
   558 
   570 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F"
   559 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F"
   571   unfolding le_filter_def eventually_principal
   560   unfolding le_filter_def eventually_principal
   572   apply safe
   561   apply safe
   573   apply (erule_tac x="\<lambda>x. x \<in> A" in allE)
   562   apply (erule_tac x="\<lambda>x. x \<in> A" in allE)
   574   apply (auto elim: eventually_elim1)
   563   apply (auto elim: eventually_mono)
   575   done
   564   done
   576 
   565 
   577 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B"
   566 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B"
   578   unfolding eq_iff by simp
   567   unfolding eq_iff by simp
   579 
   568 
   875 subsection \<open>Limits to @{const at_top} and @{const at_bot}\<close>
   864 subsection \<open>Limits to @{const at_top} and @{const at_bot}\<close>
   876 
   865 
   877 lemma filterlim_at_top:
   866 lemma filterlim_at_top:
   878   fixes f :: "'a \<Rightarrow> ('b::linorder)"
   867   fixes f :: "'a \<Rightarrow> ('b::linorder)"
   879   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z \<le> f x) F)"
   868   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z \<le> f x) F)"
   880   by (auto simp: filterlim_iff eventually_at_top_linorder elim!: eventually_elim1)
   869   by (auto simp: filterlim_iff eventually_at_top_linorder elim!: eventually_mono)
   881 
   870 
   882 lemma filterlim_at_top_mono:
   871 lemma filterlim_at_top_mono:
   883   "LIM x F. f x :> at_top \<Longrightarrow> eventually (\<lambda>x. f x \<le> (g x::'a::linorder)) F \<Longrightarrow>
   872   "LIM x F. f x :> at_top \<Longrightarrow> eventually (\<lambda>x. f x \<le> (g x::'a::linorder)) F \<Longrightarrow>
   884     LIM x F. g x :> at_top"
   873     LIM x F. g x :> at_top"
   885   by (auto simp: filterlim_at_top elim: eventually_elim2 intro: order_trans)
   874   by (auto simp: filterlim_at_top elim: eventually_elim2 intro: order_trans)
   886 
   875 
   887 lemma filterlim_at_top_dense:
   876 lemma filterlim_at_top_dense:
   888   fixes f :: "'a \<Rightarrow> ('b::unbounded_dense_linorder)"
   877   fixes f :: "'a \<Rightarrow> ('b::unbounded_dense_linorder)"
   889   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z < f x) F)"
   878   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z < f x) F)"
   890   by (metis eventually_elim1[of _ F] eventually_gt_at_top order_less_imp_le
   879   by (metis eventually_mono[of _ F] eventually_gt_at_top order_less_imp_le
   891             filterlim_at_top[of f F] filterlim_iff[of f at_top F])
   880             filterlim_at_top[of f F] filterlim_iff[of f at_top F])
   892 
   881 
   893 lemma filterlim_at_top_ge:
   882 lemma filterlim_at_top_ge:
   894   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
   883   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
   895   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z\<ge>c. eventually (\<lambda>x. Z \<le> f x) F)"
   884   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z\<ge>c. eventually (\<lambda>x. Z \<le> f x) F)"
   922   by (metis filterlim_at_top order_less_le_trans gt_ex filterlim_at_top_ge)
   911   by (metis filterlim_at_top order_less_le_trans gt_ex filterlim_at_top_ge)
   923 
   912 
   924 lemma filterlim_at_bot:
   913 lemma filterlim_at_bot:
   925   fixes f :: "'a \<Rightarrow> ('b::linorder)"
   914   fixes f :: "'a \<Rightarrow> ('b::linorder)"
   926   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F)"
   915   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F)"
   927   by (auto simp: filterlim_iff eventually_at_bot_linorder elim!: eventually_elim1)
   916   by (auto simp: filterlim_iff eventually_at_bot_linorder elim!: eventually_mono)
   928 
   917 
   929 lemma filterlim_at_bot_dense:
   918 lemma filterlim_at_bot_dense:
   930   fixes f :: "'a \<Rightarrow> ('b::{dense_linorder, no_bot})"
   919   fixes f :: "'a \<Rightarrow> ('b::{dense_linorder, no_bot})"
   931   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x < Z) F)"
   920   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x < Z) F)"
   932 proof (auto simp add: filterlim_at_bot[of f F])
   921 proof (auto simp add: filterlim_at_bot[of f F])
   933   fix Z :: 'b
   922   fix Z :: 'b
   934   from lt_ex [of Z] obtain Z' where 1: "Z' < Z" ..
   923   from lt_ex [of Z] obtain Z' where 1: "Z' < Z" ..
   935   assume "\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F"
   924   assume "\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F"
   936   hence "eventually (\<lambda>x. f x \<le> Z') F" by auto
   925   hence "eventually (\<lambda>x. f x \<le> Z') F" by auto
   937   thus "eventually (\<lambda>x. f x < Z) F"
   926   thus "eventually (\<lambda>x. f x < Z) F"
   938     apply (rule eventually_mono')
   927     apply (rule eventually_mono)
   939     using 1 by auto
   928     using 1 by auto
   940   next
   929   next
   941     fix Z :: 'b
   930     fix Z :: 'b
   942     show "\<forall>Z. eventually (\<lambda>x. f x < Z) F \<Longrightarrow> eventually (\<lambda>x. f x \<le> Z) F"
   931     show "\<forall>Z. eventually (\<lambda>x. f x < Z) F \<Longrightarrow> eventually (\<lambda>x. f x \<le> Z) F"
   943       by (drule spec [of _ Z], erule eventually_mono', auto simp add: less_imp_le)
   932       by (drule spec [of _ Z], erule eventually_mono, auto simp add: less_imp_le)
   944 qed
   933 qed
   945 
   934 
   946 lemma filterlim_at_bot_le:
   935 lemma filterlim_at_bot_le:
   947   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
   936   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
   948   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F)"
   937   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F)"
   949   unfolding filterlim_at_bot
   938   unfolding filterlim_at_bot
   950 proof safe
   939 proof safe
   951   fix Z assume *: "\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F"
   940   fix Z assume *: "\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F"
   952   with *[THEN spec, of "min Z c"] show "eventually (\<lambda>x. Z \<ge> f x) F"
   941   with *[THEN spec, of "min Z c"] show "eventually (\<lambda>x. Z \<ge> f x) F"
   953     by (auto elim!: eventually_elim1)
   942     by (auto elim!: eventually_mono)
   954 qed simp
   943 qed simp
   955 
   944 
   956 lemma filterlim_at_bot_lt:
   945 lemma filterlim_at_bot_lt:
   957   fixes f :: "'a \<Rightarrow> ('b::unbounded_dense_linorder)" and c :: "'b"
   946   fixes f :: "'a \<Rightarrow> ('b::unbounded_dense_linorder)" and c :: "'b"
   958   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z<c. eventually (\<lambda>x. Z \<ge> f x) F)"
   947   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z<c. eventually (\<lambda>x. Z \<ge> f x) F)"