diff -r 95c6cf433c91 -r d2bc8a7e5fec src/HOL/Filter.thy --- a/src/HOL/Filter.thy Thu Feb 18 17:53:09 2016 +0100 +++ b/src/HOL/Filter.thy Mon Feb 08 17:18:13 2016 +0100 @@ -479,6 +479,29 @@ eventually P (INF b:B. F b) \ (\b\B. eventually P (F b))" by (subst eventually_Inf_base) auto +lemma eventually_INF_mono: + assumes *: "\\<^sub>F x in \i\I. F i. P x" + assumes T1: "\Q R P. (\x. Q x \ R x \ P x) \ (\x. T Q x \ T R x \ T P x)" + assumes T2: "\P. (\x. P x) \ (\x. T P x)" + assumes **: "\i P. i \ I \ \\<^sub>F x in F i. P x \ \\<^sub>F x in F' i. T P x" + shows "\\<^sub>F x in \i\I. F' i. T P x" +proof - + from * obtain X where "finite X" "X \ I" "\\<^sub>F x in \i\X. F i. P x" + unfolding eventually_INF[of _ I] by auto + moreover then have "eventually (T P) (INFIMUM X F')" + apply (induction X arbitrary: P) + apply (auto simp: eventually_inf T2) + subgoal for x S P Q R + apply (intro exI[of _ "T Q"]) + apply (auto intro!: **) [] + apply (intro exI[of _ "T R"]) + apply (auto intro: T1) [] + done + done + ultimately show "\\<^sub>F x in \i\I. F' i. T P x" + by (subst eventually_INF) auto +qed + subsubsection \Map function for filters\ @@ -530,7 +553,6 @@ by (subst (1 2) eventually_INF) auto qed - subsubsection \Standard filters\ definition principal :: "'a set \ 'a filter" where @@ -768,9 +790,116 @@ by auto qed (auto simp: eventually_principal intro: eventually_True) +lemma eventually_prod1: + assumes "B \ bot" + shows "(\\<^sub>F (x, y) in A \\<^sub>F B. P x) \ (\\<^sub>F x in A. P x)" + unfolding eventually_prod_filter +proof safe + fix R Q assume "\\<^sub>F x in A. R x" "\\<^sub>F x in B. Q x" "\x y. R x \ Q y \ P x" + moreover with \B \ bot\ obtain y where "Q y" by (auto dest: eventually_happens) + ultimately show "eventually P A" + by (force elim: eventually_mono) +next + assume "eventually P A" + then show "\Pf Pg. eventually Pf A \ eventually Pg B \ (\x y. Pf x \ Pg y \ P x)" + by (intro exI[of _ P] exI[of _ "\x. True"]) auto +qed + +lemma eventually_prod2: + assumes "A \ bot" + shows "(\\<^sub>F (x, y) in A \\<^sub>F B. P y) \ (\\<^sub>F y in B. P y)" + unfolding eventually_prod_filter +proof safe + fix R Q assume "\\<^sub>F x in A. R x" "\\<^sub>F x in B. Q x" "\x y. R x \ Q y \ P y" + moreover with \A \ bot\ obtain x where "R x" by (auto dest: eventually_happens) + ultimately show "eventually P B" + by (force elim: eventually_mono) +next + assume "eventually P B" + then show "\Pf Pg. eventually Pf A \ eventually Pg B \ (\x y. Pf x \ Pg y \ P y)" + by (intro exI[of _ P] exI[of _ "\x. True"]) auto +qed + +lemma INF_filter_bot_base: + fixes F :: "'a \ 'b filter" + assumes *: "\i j. i \ I \ j \ I \ \k\I. F k \ F i \ F j" + shows "(INF i:I. F i) = bot \ (\i\I. F i = bot)" +proof cases + assume "\i\I. F i = bot" + moreover then have "(INF i:I. F i) \ bot" + by (auto intro: INF_lower2) + ultimately show ?thesis + by (auto simp: bot_unique) +next + assume **: "\ (\i\I. F i = bot)" + moreover have "(INF i:I. F i) \ bot" + proof cases + assume "I \ {}" + show ?thesis + proof (rule INF_filter_not_bot) + fix J assume "finite J" "J \ I" + then have "\k\I. F k \ (\i\J. F i)" + proof (induction J) + case empty then show ?case + using \I \ {}\ by auto + next + case (insert i J) + moreover then obtain k where "k \ I" "F k \ (\i\J. F i)" by auto + moreover note *[of i k] + ultimately show ?case + by auto + qed + with ** show "(\i\J. F i) \ \" + by (auto simp: bot_unique) + qed + qed (auto simp add: filter_eq_iff) + ultimately show ?thesis + by auto +qed + +lemma Collect_empty_eq_bot: "Collect P = {} \ P = \" + by auto + +lemma prod_filter_eq_bot: "A \\<^sub>F B = bot \ A = bot \ B = bot" + unfolding prod_filter_def +proof (subst INF_filter_bot_base; clarsimp simp: principal_eq_bot_iff Collect_empty_eq_bot bot_fun_def simp del: Collect_empty_eq) + fix A1 A2 B1 B2 assume "\\<^sub>F x in A. A1 x" "\\<^sub>F x in A. A2 x" "\\<^sub>F x in B. B1 x" "\\<^sub>F x in B. B2 x" + then show "\x. eventually x A \ (\y. eventually y B \ Collect x \ Collect y \ Collect A1 \ Collect B1 \ Collect x \ Collect y \ Collect A2 \ Collect B2)" + by (intro exI[of _ "\x. A1 x \ A2 x"] exI[of _ "\x. B1 x \ B2 x"] conjI) + (auto simp: eventually_conj_iff) +next + show "(\x. eventually x A \ (\y. eventually y B \ (x = (\x. False) \ y = (\x. False)))) = (A = \ \ B = \)" + by (auto simp: trivial_limit_def intro: eventually_True) +qed + lemma prod_filter_mono: "F \ F' \ G \ G' \ F \\<^sub>F G \ F' \\<^sub>F G'" by (auto simp: le_filter_def eventually_prod_filter) +lemma prod_filter_mono_iff: + assumes nAB: "A \ bot" "B \ bot" + shows "A \\<^sub>F B \ C \\<^sub>F D \ A \ C \ B \ D" +proof safe + assume *: "A \\<^sub>F B \ C \\<^sub>F D" + moreover with assms have "A \\<^sub>F B \ bot" + by (auto simp: bot_unique prod_filter_eq_bot) + ultimately have "C \\<^sub>F D \ bot" + by (auto simp: bot_unique) + then have nCD: "C \ bot" "D \ bot" + by (auto simp: prod_filter_eq_bot) + + show "A \ C" + proof (rule filter_leI) + fix P assume "eventually P C" with *[THEN filter_leD, of "\(x, y). P x"] show "eventually P A" + using nAB nCD by (simp add: eventually_prod1 eventually_prod2) + qed + + show "B \ D" + proof (rule filter_leI) + fix P assume "eventually P D" with *[THEN filter_leD, of "\(x, y). P y"] show "eventually P B" + using nAB nCD by (simp add: eventually_prod1 eventually_prod2) + qed +qed (intro prod_filter_mono) + lemma eventually_prod_same: "eventually P (F \\<^sub>F F) \ (\Q. eventually Q F \ (\x y. Q x \ Q y \ P (x, y)))" unfolding eventually_prod_filter @@ -791,6 +920,52 @@ apply auto done +lemma prod_filter_INF: + assumes "I \ {}" "J \ {}" + shows "(INF i:I. A i) \\<^sub>F (INF j:J. B j) = (INF i:I. INF j:J. A i \\<^sub>F B j)" +proof (safe intro!: antisym INF_greatest) + from \I \ {}\ obtain i where "i \ I" by auto + from \J \ {}\ obtain j where "j \ J" by auto + + show "(\i\I. \j\J. A i \\<^sub>F B j) \ (\i\I. A i) \\<^sub>F (\j\J. B j)" + unfolding prod_filter_def + proof (safe intro!: INF_greatest) + fix P Q assume P: "\\<^sub>F x in \i\I. A i. P x" and Q: "\\<^sub>F x in \j\J. B j. Q x" + let ?X = "(\i\I. \j\J. \(P, Q)\{(P, Q). (\\<^sub>F x in A i. P x) \ (\\<^sub>F x in B j. Q x)}. principal {(x, y). P x \ Q y})" + have "?X \ principal {x. P (fst x)} \ principal {x. Q (snd x)}" + proof (intro inf_greatest) + have "?X \ (\i\I. \P\{P. eventually P (A i)}. principal {x. P (fst x)})" + by (auto intro!: INF_greatest INF_lower2[of j] INF_lower2 \j\J\ INF_lower2[of "(_, \x. True)"]) + also have "\ \ principal {x. P (fst x)}" + unfolding le_principal + proof (rule eventually_INF_mono[OF P]) + fix i P assume "i \ I" "eventually P (A i)" + then show "\\<^sub>F x in \P\{P. eventually P (A i)}. principal {x. P (fst x)}. x \ {x. P (fst x)}" + unfolding le_principal[symmetric] by (auto intro!: INF_lower) + qed auto + finally show "?X \ principal {x. P (fst x)}" . + + have "?X \ (\i\J. \P\{P. eventually P (B i)}. principal {x. P (snd x)})" + by (auto intro!: INF_greatest INF_lower2[of i] INF_lower2 \i\I\ INF_lower2[of "(\x. True, _)"]) + also have "\ \ principal {x. Q (snd x)}" + unfolding le_principal + proof (rule eventually_INF_mono[OF Q]) + fix j Q assume "j \ J" "eventually Q (B j)" + then show "\\<^sub>F x in \P\{P. eventually P (B j)}. principal {x. P (snd x)}. x \ {x. Q (snd x)}" + unfolding le_principal[symmetric] by (auto intro!: INF_lower) + qed auto + finally show "?X \ principal {x. Q (snd x)}" . + qed + also have "\ = principal {(x, y). P x \ Q y}" + by auto + finally show "?X \ principal {(x, y). P x \ Q y}" . + qed +qed (intro prod_filter_mono INF_lower) + +lemma filtermap_Pair: "filtermap (\x. (f x, g x)) F \ filtermap f F \\<^sub>F filtermap g F" + by (simp add: le_filter_def eventually_filtermap eventually_prod_filter) + (auto elim: eventually_elim2) + subsection \Limits\ definition filterlim :: "('a \ 'b) \ 'b filter \ 'a filter \ bool" where @@ -800,7 +975,7 @@ "_LIM" :: "pttrns \ 'a \ 'b \ 'a \ bool" ("(3LIM (_)/ (_)./ (_) :> (_))" [1000, 10, 0, 10] 10) translations - "LIM x F1. f :> F2" == "CONST filterlim (%x. f) F2 F1" + "LIM x F1. f :> F2" == "CONST filterlim (\x. f) F2 F1" lemma filterlim_iff: "(LIM x F1. f x :> F2) \ (\P. eventually P F2 \ eventually (\x. P (f x)) F1)" @@ -907,6 +1082,11 @@ LIM x F. if P x then f x else g x :> G" unfolding filterlim_iff eventually_inf_principal by (auto simp: eventually_conj_iff) +lemma filterlim_Pair: + "LIM x F. f x :> G \ LIM x F. g x :> H \ LIM x F. (f x, g x) :> G \\<^sub>F H" + unfolding filterlim_def + by (rule order_trans[OF filtermap_Pair prod_filter_mono]) + subsection \Limits to @{const at_top} and @{const at_bot}\ lemma filterlim_at_top: