src/HOL/Filter.thy
changeset 71743 0239bee6bffd
parent 70927 cc204e10385c
child 74325 8d0c2d74ad63
equal deleted inserted replaced
71721:df68b82c818d 71743:0239bee6bffd
   298 
   298 
   299 lemma eventually_inf:
   299 lemma eventually_inf:
   300   "eventually P (inf F F') \<longleftrightarrow>
   300   "eventually P (inf F F') \<longleftrightarrow>
   301    (\<exists>Q R. eventually Q F \<and> eventually R F' \<and> (\<forall>x. Q x \<and> R x \<longrightarrow> P x))"
   301    (\<exists>Q R. eventually Q F \<and> eventually R F' \<and> (\<forall>x. Q x \<and> R x \<longrightarrow> P x))"
   302   unfolding inf_filter_def
   302   unfolding inf_filter_def
   303   apply (rule eventually_Abs_filter, rule is_filter.intro)
   303   apply (rule eventually_Abs_filter [OF is_filter.intro])
   304   apply (fast intro: eventually_True)
   304   apply (blast intro: eventually_True)
   305   apply clarify
   305    apply (force elim!: eventually_conj)+
   306   apply (intro exI conjI)
       
   307   apply (erule (1) eventually_conj)
       
   308   apply (erule (1) eventually_conj)
       
   309   apply simp
       
   310   apply auto
       
   311   done
   306   done
   312 
   307 
   313 lemma eventually_Sup:
   308 lemma eventually_Sup:
   314   "eventually P (Sup S) \<longleftrightarrow> (\<forall>F\<in>S. eventually P F)"
   309   "eventually P (Sup S) \<longleftrightarrow> (\<forall>F\<in>S. eventually P F)"
   315   unfolding Sup_filter_def
   310   unfolding Sup_filter_def
   316   apply (rule eventually_Abs_filter, rule is_filter.intro)
   311   apply (rule eventually_Abs_filter [OF is_filter.intro])
   317   apply (auto intro: eventually_conj elim!: eventually_rev_mp)
   312   apply (auto intro: eventually_conj elim!: eventually_rev_mp)
   318   done
   313   done
   319 
   314 
   320 instance proof
   315 instance proof
   321   fix F F' F'' :: "'a filter" and S :: "'a filter set"
   316   fix F F' F'' :: "'a filter" and S :: "'a filter set"
   555   where "filtermap f F = Abs_filter (\<lambda>P. eventually (\<lambda>x. P (f x)) F)"
   550   where "filtermap f F = Abs_filter (\<lambda>P. eventually (\<lambda>x. P (f x)) F)"
   556 
   551 
   557 lemma eventually_filtermap:
   552 lemma eventually_filtermap:
   558   "eventually P (filtermap f F) = eventually (\<lambda>x. P (f x)) F"
   553   "eventually P (filtermap f F) = eventually (\<lambda>x. P (f x)) F"
   559   unfolding filtermap_def
   554   unfolding filtermap_def
   560   apply (rule eventually_Abs_filter)
   555   apply (rule eventually_Abs_filter [OF is_filter.intro])
   561   apply (rule is_filter.intro)
       
   562   apply (auto elim!: eventually_rev_mp)
   556   apply (auto elim!: eventually_rev_mp)
   563   done
   557   done
   564 
   558 
   565 lemma filtermap_ident: "filtermap (\<lambda>x. x) F = F"
   559 lemma filtermap_ident: "filtermap (\<lambda>x. x) F = F"
   566   by (simp add: filter_eq_iff eventually_filtermap)
   560   by (simp add: filter_eq_iff eventually_filtermap)
   744 lemma principal_le_iff[iff]: "principal A \<le> principal B \<longleftrightarrow> A \<subseteq> B"
   738 lemma principal_le_iff[iff]: "principal A \<le> principal B \<longleftrightarrow> A \<subseteq> B"
   745   by (auto simp: le_filter_def eventually_principal)
   739   by (auto simp: le_filter_def eventually_principal)
   746 
   740 
   747 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F"
   741 lemma le_principal: "F \<le> principal A \<longleftrightarrow> eventually (\<lambda>x. x \<in> A) F"
   748   unfolding le_filter_def eventually_principal
   742   unfolding le_filter_def eventually_principal
   749   apply safe
   743   by (force elim: eventually_mono)
   750   apply (erule_tac x="\<lambda>x. x \<in> A" in allE)
       
   751   apply (auto elim: eventually_mono)
       
   752   done
       
   753 
   744 
   754 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B"
   745 lemma principal_inject[iff]: "principal A = principal B \<longleftrightarrow> A = B"
   755   unfolding eq_iff by simp
   746   unfolding eq_iff by simp
   756 
   747 
   757 lemma sup_principal[simp]: "sup (principal A) (principal B) = principal (A \<union> B)"
   748 lemma sup_principal[simp]: "sup (principal A) (principal B) = principal (A \<union> B)"
  1170   qed
  1161   qed
  1171 qed (intro prod_filter_mono)
  1162 qed (intro prod_filter_mono)
  1172 
  1163 
  1173 lemma eventually_prod_same: "eventually P (F \<times>\<^sub>F F) \<longleftrightarrow>
  1164 lemma eventually_prod_same: "eventually P (F \<times>\<^sub>F F) \<longleftrightarrow>
  1174     (\<exists>Q. eventually Q F \<and> (\<forall>x y. Q x \<longrightarrow> Q y \<longrightarrow> P (x, y)))"
  1165     (\<exists>Q. eventually Q F \<and> (\<forall>x y. Q x \<longrightarrow> Q y \<longrightarrow> P (x, y)))"
  1175   unfolding eventually_prod_filter
  1166   unfolding eventually_prod_filter by (blast intro!: eventually_conj)
  1176   apply safe
       
  1177   apply (rule_tac x="inf Pf Pg" in exI)
       
  1178   apply (auto simp: inf_fun_def intro!: eventually_conj)
       
  1179   done
       
  1180 
  1167 
  1181 lemma eventually_prod_sequentially:
  1168 lemma eventually_prod_sequentially:
  1182   "eventually P (sequentially \<times>\<^sub>F sequentially) \<longleftrightarrow> (\<exists>N. \<forall>m \<ge> N. \<forall>n \<ge> N. P (n, m))"
  1169   "eventually P (sequentially \<times>\<^sub>F sequentially) \<longleftrightarrow> (\<exists>N. \<forall>m \<ge> N. \<forall>n \<ge> N. P (n, m))"
  1183   unfolding eventually_prod_same eventually_sequentially by auto
  1170   unfolding eventually_prod_same eventually_sequentially by auto
  1184 
  1171 
  1225 
  1212 
  1226 lemma prod_filter_INF2: "J \<noteq> {} \<Longrightarrow> A \<times>\<^sub>F (\<Sqinter>i\<in>J. B i) = (\<Sqinter>i\<in>J. A \<times>\<^sub>F B i)"
  1213 lemma prod_filter_INF2: "J \<noteq> {} \<Longrightarrow> A \<times>\<^sub>F (\<Sqinter>i\<in>J. B i) = (\<Sqinter>i\<in>J. A \<times>\<^sub>F B i)"
  1227   using prod_filter_INF[of "{A}" J "\<lambda>x. x" B] by simp
  1214   using prod_filter_INF[of "{A}" J "\<lambda>x. x" B] by simp
  1228 
  1215 
  1229 lemma prod_filtermap1: "prod_filter (filtermap f F) G = filtermap (apfst f) (prod_filter F G)"
  1216 lemma prod_filtermap1: "prod_filter (filtermap f F) G = filtermap (apfst f) (prod_filter F G)"
  1230   apply(clarsimp simp add: filter_eq_iff eventually_filtermap eventually_prod_filter; safe)
  1217   unfolding filter_eq_iff eventually_filtermap eventually_prod_filter
       
  1218   apply safe
  1231   subgoal by auto
  1219   subgoal by auto
  1232   subgoal for P Q R by(rule exI[where x="\<lambda>y. \<exists>x. y = f x \<and> Q x"])(auto intro: eventually_mono)
  1220   subgoal for P Q R by(rule exI[where x="\<lambda>y. \<exists>x. y = f x \<and> Q x"])(auto intro: eventually_mono)
  1233   done
  1221   done
  1234 
  1222 
  1235 lemma prod_filtermap2: "prod_filter F (filtermap g G) = filtermap (apsnd g) (prod_filter F G)"
  1223 lemma prod_filtermap2: "prod_filter F (filtermap g G) = filtermap (apsnd g) (prod_filter F G)"
  1236   apply(clarsimp simp add: filter_eq_iff eventually_filtermap eventually_prod_filter; safe)
  1224   unfolding filter_eq_iff eventually_filtermap eventually_prod_filter
       
  1225   apply safe
  1237   subgoal by auto
  1226   subgoal by auto
  1238   subgoal for P Q R  by(auto intro: exI[where x="\<lambda>y. \<exists>x. y = g x \<and> R x"] eventually_mono)
  1227   subgoal for P Q R  by(auto intro: exI[where x="\<lambda>y. \<exists>x. y = g x \<and> R x"] eventually_mono)
  1239   done
  1228   done
  1240 
  1229 
  1241 lemma prod_filter_assoc:
  1230 lemma prod_filter_assoc:
  1289 
  1278 
  1290 lemma filterlim_mono_eventually:
  1279 lemma filterlim_mono_eventually:
  1291   assumes "filterlim f F G" and ord: "F \<le> F'" "G' \<le> G"
  1280   assumes "filterlim f F G" and ord: "F \<le> F'" "G' \<le> G"
  1292   assumes eq: "eventually (\<lambda>x. f x = f' x) G'"
  1281   assumes eq: "eventually (\<lambda>x. f x = f' x) G'"
  1293   shows "filterlim f' F' G'"
  1282   shows "filterlim f' F' G'"
  1294   apply (rule filterlim_cong[OF refl refl eq, THEN iffD1])
  1283 proof -
  1295   apply (rule filterlim_mono[OF _ ord])
  1284   have "filterlim f F' G'"
  1296   apply fact
  1285     by (simp add: filterlim_mono[OF _ ord] assms)
  1297   done
  1286   then show ?thesis
       
  1287     by (rule filterlim_cong[OF refl refl eq, THEN iffD1])
       
  1288 qed
  1298 
  1289 
  1299 lemma filtermap_mono_strong: "inj f \<Longrightarrow> filtermap f F \<le> filtermap f G \<longleftrightarrow> F \<le> G"
  1290 lemma filtermap_mono_strong: "inj f \<Longrightarrow> filtermap f F \<le> filtermap f G \<longleftrightarrow> F \<le> G"
  1300   apply (safe intro!: filtermap_mono)
  1291   apply (safe intro!: filtermap_mono)
  1301   apply (auto simp: le_filter_def eventually_filtermap)
  1292   apply (auto simp: le_filter_def eventually_filtermap)
  1302   apply (erule_tac x="\<lambda>x. P (inv f x)" in allE)
  1293   apply (erule_tac x="\<lambda>x. P (inv f x)" in allE)
  1456   fix Z :: 'b
  1447   fix Z :: 'b
  1457   from lt_ex [of Z] obtain Z' where 1: "Z' < Z" ..
  1448   from lt_ex [of Z] obtain Z' where 1: "Z' < Z" ..
  1458   assume "\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F"
  1449   assume "\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F"
  1459   hence "eventually (\<lambda>x. f x \<le> Z') F" by auto
  1450   hence "eventually (\<lambda>x. f x \<le> Z') F" by auto
  1460   thus "eventually (\<lambda>x. f x < Z) F"
  1451   thus "eventually (\<lambda>x. f x < Z) F"
  1461     apply (rule eventually_mono)
  1452     by (rule eventually_mono) (use 1 in auto)
  1462     using 1 by auto
       
  1463   next
  1453   next
  1464     fix Z :: 'b
  1454     fix Z :: 'b
  1465     show "\<forall>Z. eventually (\<lambda>x. f x < Z) F \<Longrightarrow> eventually (\<lambda>x. f x \<le> Z) F"
  1455     show "\<forall>Z. eventually (\<lambda>x. f x < Z) F \<Longrightarrow> eventually (\<lambda>x. f x \<le> Z) F"
  1466       by (drule spec [of _ Z], erule eventually_mono, auto simp add: less_imp_le)
  1456       by (drule spec [of _ Z], erule eventually_mono, auto simp add: less_imp_le)
  1467 qed
  1457 qed