# HG changeset patch # User huffman # Date 1522261147 25200 # Node ID 79dbb9dccc99064b1950b779f9cfb8a3a1447256 # Parent f69ea1a88c1affb0901519270e9061e40538c4f3 tuned some proofs about filters diff -r f69ea1a88c1a -r 79dbb9dccc99 src/HOL/Filter.thy --- a/src/HOL/Filter.thy Wed Mar 28 13:46:21 2018 +0200 +++ b/src/HOL/Filter.thy Wed Mar 28 11:19:07 2018 -0700 @@ -522,30 +522,6 @@ lemma eventually_INF1: "i \ I \ eventually P (F i) \ eventually P (\i\I. F i)" using filter_leD[OF INF_lower] . -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 X: "finite X" "X \ I" "\\<^sub>F x in \i\X. F i. P x" - unfolding eventually_INF[of _ _ I] by auto - 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 - with X show "\\<^sub>F x in \i\I. F' i. T P x" - by (subst eventually_INF) auto -qed - - subsubsection \Map function for filters\ definition filtermap :: "('a \ 'b) \ 'a filter \ 'b filter" @@ -572,29 +548,20 @@ lemma filtermap_bot [simp]: "filtermap f bot = bot" by (simp add: filter_eq_iff eventually_filtermap) +lemma filtermap_bot_iff: "filtermap f F = bot \ F = bot" + by (simp add: trivial_limit_def eventually_filtermap) + lemma filtermap_sup: "filtermap f (sup F1 F2) = sup (filtermap f F1) (filtermap f F2)" - by (auto simp: filter_eq_iff eventually_filtermap eventually_sup) + by (simp add: filter_eq_iff eventually_filtermap eventually_sup) + +lemma filtermap_SUP: "filtermap f (\b\B. F b) = (\b\B. filtermap f (F b))" + by (simp add: filter_eq_iff eventually_Sup eventually_filtermap) lemma filtermap_inf: "filtermap f (inf F1 F2) \ inf (filtermap f F1) (filtermap f F2)" - by (auto simp: le_filter_def eventually_filtermap eventually_inf) + by (intro inf_greatest filtermap_mono inf_sup_ord) lemma filtermap_INF: "filtermap f (\b\B. F b) \ (\b\B. filtermap f (F b))" -proof - - { fix X :: "'c set" assume "finite X" - then have "filtermap f (INFIMUM X F) \ (\b\X. filtermap f (F b))" - proof induct - case (insert x X) - have "filtermap f (\a\insert x X. F a) \ inf (filtermap f (F x)) (filtermap f (\a\X. F a))" - by (rule order_trans[OF _ filtermap_inf]) simp - also have "\ \ inf (filtermap f (F x)) (\a\X. filtermap f (F a))" - by (intro inf_mono insert order_refl) - finally show ?case - by simp - qed simp } - then show ?thesis - unfolding le_filter_def eventually_filtermap - by (subst (1 2) eventually_INF) auto -qed + by (rule INF_greatest, rule filtermap_mono, erule INF_lower) subsubsection \Contravariant map function for filters\ @@ -661,13 +628,7 @@ qed lemma filtercomap_sup: "filtercomap f (sup F1 F2) \ sup (filtercomap f F1) (filtercomap f F2)" - unfolding le_filter_def -proof safe - fix P - assume "eventually P (filtercomap f (sup F1 F2))" - thus "eventually P (sup (filtercomap f F1) (filtercomap f F2))" - by (auto simp: filter_eq_iff eventually_filtercomap eventually_sup) -qed + by (intro sup_least filtercomap_mono inf_sup_ord) lemma filtercomap_INF: "filtercomap f (\b\B. F b) = (\b\B. filtercomap f (F b))" proof - @@ -688,11 +649,10 @@ qed qed -lemma filtercomap_SUP_finite: - "finite B \ filtercomap f (\b\B. F b) \ (\b\B. filtercomap f (F b))" - by (induction B rule: finite_induct) - (auto intro: order_trans[OF _ order_trans[OF _ filtercomap_sup]] filtercomap_mono) - +lemma filtercomap_SUP: + "filtercomap f (\b\B. F b) \ (\b\B. filtercomap f (F b))" + by (intro SUP_least filtercomap_mono SUP_upper) + lemma eventually_filtercomapI [intro]: assumes "eventually P F" shows "eventually (\x. P (f x)) (filtercomap f F)" @@ -700,7 +660,7 @@ lemma filtermap_filtercomap: "filtermap f (filtercomap f F) \ F" by (auto simp: le_filter_def eventually_filtermap eventually_filtercomap) - + lemma filtercomap_filtermap: "filtercomap f (filtermap f F) \ F" unfolding le_filter_def eventually_filtermap eventually_filtercomap by (auto elim!: eventually_mono) @@ -895,6 +855,8 @@ lemma eventually_sequentially_seg [simp]: "eventually (\n. P (n + k)) sequentially \ eventually P sequentially" using eventually_sequentially_Suc[of "\n. P (n + k)" for k] by (induction k) auto +lemma filtermap_sequentually_ne_bot: "filtermap f sequentially \ bot" + by (simp add: filtermap_bot_iff) subsection \The cofinite filter\ @@ -947,9 +909,6 @@ subsubsection \Product of filters\ -lemma filtermap_sequentually_ne_bot: "filtermap f sequentially \ bot" - by (auto simp add: filter_eq_iff eventually_filtermap eventually_sequentially) - definition prod_filter :: "'a filter \ 'b filter \ ('a \ 'b) filter" (infixr "\\<^sub>F" 80) where "prod_filter F G = (\(P, Q)\{(P, Q). eventually P F \ eventually Q G}. principal {(x, y). P x \ Q y})" @@ -1046,15 +1005,19 @@ 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) + unfolding trivial_limit_def +proof + assume "\\<^sub>F x in A \\<^sub>F B. False" + then obtain Pf Pg + where Pf: "eventually (\x. Pf x) A" and Pg: "eventually (\y. Pg y) B" + and *: "\x y. Pf x \ Pg y \ False" + unfolding eventually_prod_filter by fast + from * have "(\x. \ Pf x) \ (\y. \ Pg y)" by fast + with Pf Pg show "(\\<^sub>F x in A. False) \ (\\<^sub>F x in B. False)" by auto 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) + assume "(\\<^sub>F x in A. False) \ (\\<^sub>F x in B. False)" + then show "\\<^sub>F x in A \\<^sub>F B. False" + unfolding eventually_prod_filter by (force intro: eventually_True) qed lemma prod_filter_mono: "F \ F' \ G \ G' \ F \\<^sub>F G \ F' \\<^sub>F G'" @@ -1098,62 +1061,42 @@ unfolding eventually_prod_same eventually_sequentially by auto lemma principal_prod_principal: "principal A \\<^sub>F principal B = principal (A \ B)" - apply (simp add: filter_eq_iff eventually_prod_filter eventually_principal) - apply safe - apply blast - apply (intro conjI exI[of _ "\x. x \ A"] exI[of _ "\x. x \ B"]) - apply auto - done + unfolding filter_eq_iff eventually_prod_filter eventually_principal + by (fast intro: exI[of _ "\x. x \ A"] exI[of _ "\x. x \ B"]) + +lemma le_prod_filterI: + "filtermap fst F \ A \ filtermap snd F \ B \ F \ A \\<^sub>F B" + unfolding le_filter_def eventually_filtermap eventually_prod_filter + by (force elim: eventually_elim2) + +lemma filtermap_fst_prod_filter: "filtermap fst (A \\<^sub>F B) \ A" + unfolding le_filter_def eventually_filtermap eventually_prod_filter + by (force intro: eventually_True) + +lemma filtermap_snd_prod_filter: "filtermap snd (A \\<^sub>F B) \ B" + unfolding le_filter_def eventually_filtermap eventually_prod_filter + by (force intro: eventually_True) lemma prod_filter_INF: - assumes "I \ {}" "J \ {}" + assumes "I \ {}" and "J \ {}" shows "(\i\I. A i) \\<^sub>F (\j\J. B j) = (\i\I. \j\J. A i \\<^sub>F B j)" -proof (safe intro!: antisym INF_greatest) +proof (rule antisym) 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) + by (fast intro: le_prod_filterI INF_greatest INF_lower2 + order_trans[OF filtermap_INF] `i \ I` `j \ J` + filtermap_fst_prod_filter filtermap_snd_prod_filter) + show "(\i\I. A i) \\<^sub>F (\j\J. B j) \ (\i\I. \j\J. A i \\<^sub>F B j)" + by (intro INF_greatest prod_filter_mono INF_lower) +qed 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) + by (rule le_prod_filterI, simp_all add: filtermap_filtermap) lemma eventually_prodI: "eventually P F \ eventually Q G \ eventually (\x. P (fst x) \ Q (snd x)) (F \\<^sub>F G)" - unfolding prod_filter_def - by (intro eventually_INF1[of "(P, Q)"]) (auto simp: eventually_principal) + unfolding eventually_prod_filter by auto lemma prod_filter_INF1: "I \ {} \ (\i\I. A i) \\<^sub>F B = (\i\I. A i \\<^sub>F B)" using prod_filter_INF[of I "{B}" A "\x. x"] by simp @@ -1204,7 +1147,7 @@ done lemma filtermap_mono_strong: "inj f \ filtermap f F \ filtermap f G \ F \ G" - apply (auto intro!: filtermap_mono) [] + apply (safe intro!: filtermap_mono) apply (auto simp: le_filter_def eventually_filtermap) apply (erule_tac x="\x. P (inv f x)" in allE) apply auto @@ -1644,51 +1587,11 @@ lemma frequently_parametric [transfer_rule]: "((A ===> (=)) ===> rel_filter A ===> (=)) frequently frequently" unfolding frequently_def[abs_def] by transfer_prover -lemma is_filter_parametric_aux: - assumes "is_filter F" - assumes [transfer_rule]: "bi_total A" "bi_unique A" - and [transfer_rule]: "((A ===> (=)) ===> (=)) F G" - shows "is_filter G" -proof - - interpret is_filter F by fact - show ?thesis - proof - have "F (\_. True) = G (\x. True)" by transfer_prover - thus "G (\x. True)" by(simp add: True) - next - fix P' Q' - assume "G P'" "G Q'" - moreover - from bi_total_fun[OF \bi_unique A\ bi_total_eq, unfolded bi_total_def] - obtain P Q where [transfer_rule]: "(A ===> (=)) P P'" "(A ===> (=)) Q Q'" by blast - have "F P = G P'" "F Q = G Q'" by transfer_prover+ - ultimately have "F (\x. P x \ Q x)" by(simp add: conj) - moreover have "F (\x. P x \ Q x) = G (\x. P' x \ Q' x)" by transfer_prover - ultimately show "G (\x. P' x \ Q' x)" by simp - next - fix P' Q' - assume "\x. P' x \ Q' x" "G P'" - moreover - from bi_total_fun[OF \bi_unique A\ bi_total_eq, unfolded bi_total_def] - obtain P Q where [transfer_rule]: "(A ===> (=)) P P'" "(A ===> (=)) Q Q'" by blast - have "F P = G P'" by transfer_prover - moreover have "(\x. P x \ Q x) \ (\x. P' x \ Q' x)" by transfer_prover - ultimately have "F Q" by(simp add: mono) - moreover have "F Q = G Q'" by transfer_prover - ultimately show "G Q'" by simp - qed -qed - lemma is_filter_parametric [transfer_rule]: - "\ bi_total A; bi_unique A \ - \ (((A ===> (=)) ===> (=)) ===> (=)) is_filter is_filter" -apply(rule rel_funI) -apply(rule iffI) - apply(erule (3) is_filter_parametric_aux) -apply(erule is_filter_parametric_aux[where A="conversep A"]) -apply (simp_all add: rel_fun_def) -apply metis -done + assumes [transfer_rule]: "bi_total A" + assumes [transfer_rule]: "bi_unique A" + shows "(((A ===> (=)) ===> (=)) ===> (=)) is_filter is_filter" + unfolding is_filter_def by transfer_prover lemma top_filter_parametric [transfer_rule]: "rel_filter A top top" if "bi_total A" proof