# HG changeset patch # User hoelzl # Date 1428831249 -7200 # Node ID 1fa1023b13b9cb1fcf810859213afffd2a506162 # Parent d55937a8f97e9a0158eabdf149a4e3eeaab6121b move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/Filter.thy --- a/src/HOL/Filter.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/Filter.thy Sun Apr 12 11:34:09 2015 +0200 @@ -63,6 +63,9 @@ thus "eventually P F" by simp qed +lemma eventuallyI: "(\x. P x) \ eventually P F" + by (auto intro: always_eventually) + lemma eventually_mono: "(\x. P x \ Q x) \ eventually P F \ eventually Q F" unfolding eventually_def @@ -75,17 +78,6 @@ using assms unfolding eventually_def by (rule is_filter.conj [OF is_filter_Rep_filter]) -lemma eventually_Ball_finite: - assumes "finite A" and "\y\A. eventually (\x. P x y) net" - shows "eventually (\x. \y\A. P x y) net" -using assms by (induct set: finite, simp, simp add: eventually_conj) - -lemma eventually_all_finite: - fixes P :: "'a \ 'b::finite \ bool" - assumes "\y. eventually (\x. P x y) net" - shows "eventually (\x. \y. P x y) net" -using eventually_Ball_finite [of UNIV P] assms by simp - lemma eventually_mp: assumes "eventually (\x. P x \ Q x) F" assumes "eventually (\x. P x) F" @@ -119,6 +111,29 @@ shows "eventually (\i. R i) F" using assms by (auto elim!: eventually_rev_mp) +lemma eventually_ball_finite_distrib: + "finite A \ (eventually (\x. \y\A. P x y) net) \ (\y\A. eventually (\x. P x y) net)" + by (induction A rule: finite_induct) (auto simp: eventually_conj_iff) + +lemma eventually_ball_finite: + "finite A \ \y\A. eventually (\x. P x y) net \ eventually (\x. \y\A. P x y) net" + by (auto simp: eventually_ball_finite_distrib) + +lemma eventually_all_finite: + fixes P :: "'a \ 'b::finite \ bool" + assumes "\y. eventually (\x. P x y) net" + shows "eventually (\x. \y. P x y) net" +using eventually_ball_finite [of UNIV P] assms by simp + +lemma eventually_ex: "(\\<^sub>Fx in F. \y. P x y) \ (\Y. \\<^sub>Fx in F. P x (Y x))" +proof + assume "\\<^sub>Fx in F. \y. P x y" + then have "\\<^sub>Fx in F. P x (SOME y. P x y)" + by (auto intro: someI_ex eventually_elim1) + then show "\Y. \\<^sub>Fx in F. P x (Y x)" + by auto +qed (auto intro: eventually_elim1) + lemma not_eventually_impI: "eventually P F \ \ eventually Q F \ \ eventually (\x. P x \ Q x) F" by (auto intro: eventually_mp) @@ -135,6 +150,93 @@ then show ?thesis by (auto elim: eventually_elim2) qed +subsection \ Frequently as dual to eventually \ + +definition frequently :: "('a \ bool) \ 'a filter \ bool" + where "frequently P F \ \ eventually (\x. \ P x) F" + +syntax (xsymbols) + "_frequently" :: "pttrn \ 'a filter \ bool \ bool" ("(3\\<^sub>F _ in _./ _)" [0, 0, 10] 10) + +translations + "\\<^sub>Fx in F. P" == "CONST frequently (\x. P) F" + +lemma not_frequently_False [simp]: "\ (\\<^sub>Fx in F. False)" + by (simp add: frequently_def) + +lemma frequently_ex: "\\<^sub>Fx in F. P x \ \x. P x" + by (auto simp: frequently_def dest: not_eventuallyD) + +lemma frequentlyE: assumes "frequently P F" obtains x where "P x" + using frequently_ex[OF assms] by auto + +lemma frequently_mp: + assumes ev: "\\<^sub>Fx in F. P x \ Q x" and P: "\\<^sub>Fx in F. P x" shows "\\<^sub>Fx in F. Q x" +proof - + from ev have "eventually (\x. \ Q x \ \ P x) F" + by (rule eventually_rev_mp) (auto intro!: always_eventually) + from eventually_mp[OF this] P show ?thesis + by (auto simp: frequently_def) +qed + +lemma frequently_rev_mp: + assumes "\\<^sub>Fx in F. P x" + assumes "\\<^sub>Fx in F. P x \ Q x" + shows "\\<^sub>Fx in F. Q x" +using assms(2) assms(1) by (rule frequently_mp) + +lemma frequently_mono: "(\x. P x \ Q x) \ frequently P F \ frequently Q F" + using frequently_mp[of P Q] by (simp add: always_eventually) + +lemma frequently_elim1: "\\<^sub>Fx in F. P x \ (\i. P i \ Q i) \ \\<^sub>Fx in F. Q x" + by (metis frequently_mono) + +lemma frequently_disj_iff: "(\\<^sub>Fx in F. P x \ Q x) \ (\\<^sub>Fx in F. P x) \ (\\<^sub>Fx in F. Q x)" + by (simp add: frequently_def eventually_conj_iff) + +lemma frequently_disj: "\\<^sub>Fx in F. P x \ \\<^sub>Fx in F. Q x \ \\<^sub>Fx in F. P x \ Q x" + by (simp add: frequently_disj_iff) + +lemma frequently_bex_finite_distrib: + assumes "finite A" shows "(\\<^sub>Fx in F. \y\A. P x y) \ (\y\A. \\<^sub>Fx in F. P x y)" + using assms by induction (auto simp: frequently_disj_iff) + +lemma frequently_bex_finite: "finite A \ \\<^sub>Fx in F. \y\A. P x y \ \y\A. \\<^sub>Fx in F. P x y" + by (simp add: frequently_bex_finite_distrib) + +lemma frequently_all: "(\\<^sub>Fx in F. \y. P x y) \ (\Y. \\<^sub>Fx in F. P x (Y x))" + using eventually_ex[of "\x y. \ P x y" F] by (simp add: frequently_def) + +lemma + shows not_eventually: "\ eventually P F \ (\\<^sub>Fx in F. \ P x)" + and not_frequently: "\ frequently P F \ (\\<^sub>Fx in F. \ P x)" + by (auto simp: frequently_def) + +lemma frequently_imp_iff: + "(\\<^sub>Fx in F. P x \ Q x) \ (eventually P F \ frequently Q F)" + unfolding imp_conv_disj frequently_disj_iff not_eventually[symmetric] .. + +lemma eventually_frequently_const_simps: + "(\\<^sub>Fx in F. P x \ C) \ (\\<^sub>Fx in F. P x) \ C" + "(\\<^sub>Fx in F. C \ P x) \ C \ (\\<^sub>Fx in F. P x)" + "(\\<^sub>Fx in F. P x \ C) \ (\\<^sub>Fx in F. P x) \ C" + "(\\<^sub>Fx in F. C \ P x) \ C \ (\\<^sub>Fx in F. P x)" + "(\\<^sub>Fx in F. P x \ C) \ ((\\<^sub>Fx in F. P x) \ C)" + "(\\<^sub>Fx in F. C \ P x) \ (C \ (\\<^sub>Fx in F. P x))" + by (cases C; simp add: not_frequently)+ + +lemmas eventually_frequently_simps = + eventually_frequently_const_simps + not_eventually + eventually_conj_iff + eventually_ball_finite_distrib + eventually_ex + not_frequently + frequently_disj_iff + frequently_bex_finite_distrib + frequently_all + frequently_imp_iff + ML {* fun eventually_elim_tac ctxt facts = SUBGOAL_CASES (fn (goal, i) => let @@ -154,54 +256,6 @@ Scan.succeed (fn ctxt => METHOD_CASES (HEADGOAL o eventually_elim_tac ctxt)) *} "elimination of eventually quantifiers" -subsection \ Frequently as dual to eventually \ - -definition frequently :: "('a \ bool) \ 'a filter \ bool" - where "frequently P F \ \ eventually (\x. \ P x) F" - -syntax (xsymbols) - "_frequently" :: "pttrn \ 'a filter \ bool \ bool" ("(3\\<^sub>F _ in _./ _)" [0, 0, 10] 10) - -translations - "\\<^sub>Fx in F. P" == "CONST frequently (\x. P) F" - -lemma not_frequently_False [simp]: "\ frequently (\x. False) F" - by (simp add: frequently_def) - -lemma frequently_ex: "frequently P F \ \x. P x" - by (auto simp: frequently_def dest: not_eventuallyD) - -lemma frequently_mp: - assumes ev: "eventually (\x. P x \ Q x) F" and P: "frequently (\x. P x) F" - shows "frequently (\x. Q x) F" -proof - - from ev have "eventually (\x. \ Q x \ \ P x) F" - by (rule eventually_rev_mp) (auto intro!: always_eventually) - from eventually_mp[OF this] P show ?thesis - by (auto simp: frequently_def) -qed - -lemma frequently_rev_mp: - assumes "frequently (\x. P x) F" - assumes "eventually (\x. P x \ Q x) F" - shows "frequently (\x. Q x) F" -using assms(2) assms(1) by (rule frequently_mp) - -lemma frequently_mono: "(\x. P x \ Q x) \ frequently P F \ frequently Q F" - using frequently_mp[of P Q] by (simp add: always_eventually) - -lemma frequently_disj_iff: - "frequently (\x. P x \ Q x) F \ frequently (\x. P x) F \ frequently (\x. Q x) F" - by (simp add: frequently_def eventually_conj_iff) - -lemma frequently_disj: - "frequently (\x. P x) F \ frequently (\x. Q x) F \ frequently (\x. P x \ Q x) F" - by (simp add: frequently_disj_iff) - -lemma frequently_Bex_finite: - assumes "finite A" shows "frequently (\x. \y\A. P x y) net \ (\y\A. frequently (\x. P x y) net)" - using assms by induction (auto simp: frequently_disj_iff) - subsubsection {* Finer-than relation *} text {* @{term "F \ F'"} means that filter @{term F} is finer than @@ -318,15 +372,28 @@ "eventually (\x. False) F \ F = bot" unfolding filter_eq_iff by (auto elim: eventually_rev_mp) +lemma eventually_frequently: "F \ bot \ eventually P F \ frequently P F" + using eventually_conj[of P F "\x. \ P x"] + by (auto simp add: frequently_def eventually_False) + +lemma eventually_const_iff: "eventually (\x. P) F \ P \ F = bot" + by (cases P) (auto simp: eventually_False) + +lemma eventually_const[simp]: "F \ bot \ eventually (\x. P) F \ P" + by (simp add: eventually_const_iff) + +lemma frequently_const_iff: "frequently (\x. P) F \ P \ F \ bot" + by (simp add: frequently_def eventually_const_iff) + +lemma frequently_const[simp]: "F \ bot \ frequently (\x. P) F \ P" + by (simp add: frequently_const_iff) + abbreviation (input) trivial_limit :: "'a filter \ bool" where "trivial_limit F \ F = bot" lemma trivial_limit_def: "trivial_limit F \ eventually (\x. False) F" by (rule eventually_False [symmetric]) -lemma eventually_const: "\ trivial_limit net \ eventually (\x. P) net \ P" - by (cases P) (simp_all add: eventually_False) - lemma eventually_Inf: "eventually P (Inf B) \ (\X\B. finite X \ eventually P (Inf X))" proof - let ?F = "\P. \X\B. finite X \ eventually P (Inf X)" @@ -601,22 +668,30 @@ shows "eventually P sequentially" using assms by (auto simp: eventually_sequentially) -lemma eventually_sequentially_seg: - "eventually (\n. P (n + k)) sequentially \ eventually P sequentially" - unfolding eventually_sequentially - apply safe - apply (rule_tac x="N + k" in exI) - apply rule - apply (erule_tac x="n - k" in allE) - apply auto [] - apply (rule_tac x=N in exI) - apply auto [] - done +lemma eventually_sequentially_Suc: "eventually (\i. P (Suc i)) sequentially \ eventually P sequentially" + unfolding eventually_sequentially by (metis Suc_le_D Suc_le_mono le_Suc_eq) + +lemma eventually_sequentially_seg: "eventually (\n. P (n + k)) sequentially \ eventually P sequentially" + using eventually_sequentially_Suc[of "\n. P (n + k)" for k] by (induction k) auto subsection \ The cofinite filter \ definition "cofinite = Abs_filter (\P. finite {x. \ P x})" +abbreviation Inf_many :: "('a \ bool) \ bool" (binder "INFM " 10) where + "Inf_many P \ frequently P cofinite" + +abbreviation Alm_all :: "('a \ bool) \ bool" (binder "MOST " 10) where + "Alm_all P \ eventually P cofinite" + +notation (xsymbols) + Inf_many (binder "\\<^sub>\" 10) and + Alm_all (binder "\\<^sub>\" 10) + +notation (HTML output) + Inf_many (binder "\\<^sub>\" 10) and + Alm_all (binder "\\<^sub>\" 10) + lemma eventually_cofinite: "eventually P cofinite \ finite {x. \ P x}" unfolding cofinite_def proof (rule eventually_Abs_filter, rule is_filter.intro) @@ -629,6 +704,9 @@ by (intro finite_subset[OF _ P]) auto qed simp +lemma frequently_cofinite: "frequently P cofinite \ \ finite {x. P x}" + by (simp add: frequently_def eventually_cofinite) + lemma cofinite_bot[simp]: "cofinite = (bot::'a filter) \ finite (UNIV :: 'a set)" unfolding trivial_limit_def eventually_cofinite by simp @@ -737,9 +815,6 @@ "filterlim f F F1 \ filterlim f F F2 \ filterlim f F (sup F1 F2)" unfolding filterlim_def filtermap_sup by auto -lemma eventually_sequentially_Suc: "eventually (\i. P (Suc i)) sequentially \ eventually P sequentially" - unfolding eventually_sequentially by (metis Suc_le_D Suc_le_mono le_Suc_eq) - lemma filterlim_sequentially_Suc: "(LIM x sequentially. f (Suc x) :> F) \ (LIM x sequentially. f x :> F)" unfolding filterlim_iff by (subst eventually_sequentially_Suc) simp diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/HOLCF/Library/Defl_Bifinite.thy --- a/src/HOL/HOLCF/Library/Defl_Bifinite.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/HOLCF/Library/Defl_Bifinite.thy Sun Apr 12 11:34:09 2015 +0200 @@ -12,38 +12,6 @@ default_sort type -lemma MOST_INFM: - assumes inf: "infinite (UNIV::'a set)" - shows "MOST x::'a. P x \ INFM x::'a. P x" - unfolding Alm_all_def Inf_many_def - apply (auto simp add: Collect_neg_eq) - apply (drule (1) finite_UnI) - apply (simp add: Compl_partition2 inf) - done - -lemma MOST_SucI: "MOST n. P n \ MOST n. P (Suc n)" -by (rule MOST_inj [OF _ inj_Suc]) - -lemma MOST_SucD: "MOST n. P (Suc n) \ MOST n. P n" -unfolding MOST_nat -apply (clarify, rule_tac x="Suc m" in exI, clarify) -apply (erule Suc_lessE, simp) -done - -lemma MOST_Suc_iff: "(MOST n. P (Suc n)) \ (MOST n. P n)" -by (rule iffI [OF MOST_SucD MOST_SucI]) - -lemma INFM_finite_Bex_distrib: - "finite A \ (INFM y. \x\A. P x y) \ (\x\A. INFM y. P x y)" -by (induct set: finite, simp, simp add: INFM_disj_distrib) - -lemma MOST_finite_Ball_distrib: - "finite A \ (MOST y. \x\A. P x y) \ (\x\A. MOST y. P x y)" -by (induct set: finite, simp, simp add: MOST_conj_distrib) - -lemma MOST_ge_nat: "MOST n::nat. m \ n" -unfolding MOST_nat_le by fast - subsection {* Eventually constant sequences *} definition diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/HOLCF/Plain_HOLCF.thy --- a/src/HOL/HOLCF/Plain_HOLCF.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/HOLCF/Plain_HOLCF.thy Sun Apr 12 11:34:09 2015 +0200 @@ -12,4 +12,6 @@ Basic HOLCF concepts and types; does not include definition packages. *} +hide_const (open) Filter.principal + end diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/Library/Infinite_Set.thy --- a/src/HOL/Library/Infinite_Set.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/Library/Infinite_Set.thy Sun Apr 12 11:34:09 2015 +0200 @@ -67,36 +67,22 @@ infinite. *} -lemma finite_nat_bounded: assumes S: "finite (S::nat set)" shows "\k. S \ {.. {}" with Max_less_iff[OF S this] show ?thesis - by auto -qed simp +lemma infinite_nat_iff_unbounded_le: "infinite (S::nat set) \ (\m. \n\m. n \ S)" + using frequently_cofinite[of "\x. x \ S"] + by (simp add: cofinite_eq_sequentially frequently_def eventually_sequentially) + +lemma infinite_nat_iff_unbounded: "infinite (S::nat set) \ (\m. \n>m. n \ S)" + using frequently_cofinite[of "\x. x \ S"] + by (simp add: cofinite_eq_sequentially frequently_def eventually_at_top_dense) lemma finite_nat_iff_bounded: "finite (S::nat set) \ (\k. S \ {.. (\k. S \ {..k})" (is "?lhs \ ?rhs") -proof - assume ?lhs - then obtain k where "S \ {.. {..k}" by auto - then show ?rhs .. -next - assume ?rhs - then obtain k where "S \ {..k}" .. - then show "finite S" - by (rule finite_subset) simp -qed +lemma finite_nat_iff_bounded_le: "finite (S::nat set) \ (\k. S \ {.. k})" + using infinite_nat_iff_unbounded[of S] by (simp add: subset_eq) (metis not_le) -lemma infinite_nat_iff_unbounded: "infinite (S::nat set) \ (\m. \n. m < n \ n \ S)" - unfolding finite_nat_iff_bounded_le by (auto simp: subset_eq not_le) - -lemma infinite_nat_iff_unbounded_le: - "infinite (S::nat set) \ (\m. \n. m \ n \ n \ S)" - unfolding finite_nat_iff_bounded by (auto simp: subset_eq not_less) +lemma finite_nat_bounded: "finite (S::nat set) \ \k. S \ {..m. k < m \ (\n. m < n \ n \ S)" - shows "infinite (S::nat set)" -proof - - { - fix m have "\n. m < n \ n \ S" - proof (cases "k < m") - case True - with k show ?thesis by blast - next - case False - from k obtain n where "Suc k < n \ n \ S" by auto - with False have "m < n \ n \ S" by auto - then show ?thesis .. - qed - } - then show ?thesis - by (auto simp add: infinite_nat_iff_unbounded) -qed +lemma unbounded_k_infinite: "\m>k. \n>m. n \ S \ infinite (S::nat set)" + by (metis (full_types) infinite_nat_iff_unbounded_le le_imp_less_Suc not_less + not_less_iff_gr_or_eq sup.bounded_iff) lemma nat_not_finite: "finite (UNIV::nat set) \ R" by simp @@ -178,181 +148,106 @@ we introduce corresponding binders and their proof rules. *} -definition Inf_many :: "('a \ bool) \ bool" (binder "INFM " 10) - where "Inf_many P \ infinite {x. P x}" - -definition Alm_all :: "('a \ bool) \ bool" (binder "MOST " 10) - where "Alm_all P \ \ (INFM x. \ P x)" - -notation (xsymbols) - Inf_many (binder "\\<^sub>\" 10) and - Alm_all (binder "\\<^sub>\" 10) - -notation (HTML output) - Inf_many (binder "\\<^sub>\" 10) and - Alm_all (binder "\\<^sub>\" 10) - -lemma INFM_iff_infinite: "(INFM x. P x) \ infinite {x. P x}" - unfolding Inf_many_def .. - -lemma MOST_iff_cofinite: "(MOST x. P x) \ finite {x. \ P x}" - unfolding Alm_all_def Inf_many_def by simp - -(* legacy name *) -lemmas MOST_iff_finiteNeg = MOST_iff_cofinite - -lemma not_INFM [simp]: "\ (INFM x. P x) \ (MOST x. \ P x)" - unfolding Alm_all_def not_not .. - -lemma not_MOST [simp]: "\ (MOST x. P x) \ (INFM x. \ P x)" - unfolding Alm_all_def not_not .. +(* The following two lemmas are available as filter-rules, but not in the simp-set *) +lemma not_INFM [simp]: "\ (INFM x. P x) \ (MOST x. \ P x)" by (fact not_frequently) +lemma not_MOST [simp]: "\ (MOST x. P x) \ (INFM x. \ P x)" by (fact not_eventually) lemma INFM_const [simp]: "(INFM x::'a. P) \ P \ infinite (UNIV::'a set)" - unfolding Inf_many_def by simp + by (simp add: frequently_const_iff) lemma MOST_const [simp]: "(MOST x::'a. P) \ P \ finite (UNIV::'a set)" - unfolding Alm_all_def by simp - -lemma INFM_EX: "(\\<^sub>\x. P x) \ (\x. P x)" - apply (erule contrapos_pp) - apply simp - done - -lemma ALL_MOST: "\x. P x \ \\<^sub>\x. P x" - by simp - -lemma INFM_E: - assumes "INFM x. P x" - obtains x where "P x" - using INFM_EX [OF assms] by (rule exE) - -lemma MOST_I: - assumes "\x. P x" - shows "MOST x. P x" - using assms by simp + by (simp add: eventually_const_iff) -lemma INFM_mono: - assumes inf: "\\<^sub>\x. P x" and q: "\x. P x \ Q x" - shows "\\<^sub>\x. Q x" -proof - - from inf have "infinite {x. P x}" unfolding Inf_many_def . - moreover from q have "{x. P x} \ {x. Q x}" by auto - ultimately show ?thesis - using Inf_many_def infinite_super by blast -qed - -lemma MOST_mono: "\\<^sub>\x. P x \ (\x. P x \ Q x) \ \\<^sub>\x. Q x" - unfolding Alm_all_def by (blast intro: INFM_mono) - -lemma INFM_disj_distrib: - "(\\<^sub>\x. P x \ Q x) \ (\\<^sub>\x. P x) \ (\\<^sub>\x. Q x)" - unfolding Inf_many_def by (simp add: Collect_disj_eq) - -lemma INFM_imp_distrib: - "(INFM x. P x \ Q x) \ ((MOST x. P x) \ (INFM x. Q x))" - by (simp only: imp_conv_disj INFM_disj_distrib not_MOST) +lemma INFM_imp_distrib: "(INFM x. P x \ Q x) \ ((MOST x. P x) \ (INFM x. Q x))" + by (simp only: imp_conv_disj frequently_disj_iff not_eventually) -lemma MOST_conj_distrib: - "(\\<^sub>\x. P x \ Q x) \ (\\<^sub>\x. P x) \ (\\<^sub>\x. Q x)" - unfolding Alm_all_def by (simp add: INFM_disj_distrib del: disj_not1) - -lemma MOST_conjI: - "MOST x. P x \ MOST x. Q x \ MOST x. P x \ Q x" - by (simp add: MOST_conj_distrib) - -lemma INFM_conjI: - "INFM x. P x \ MOST x. Q x \ INFM x. P x \ Q x" - unfolding MOST_iff_cofinite INFM_iff_infinite - apply (drule (1) Diff_infinite_finite) - apply (simp add: Collect_conj_eq Collect_neg_eq) - done +lemma MOST_imp_iff: "MOST x. P x \ (MOST x. P x \ Q x) \ (MOST x. Q x)" + by (auto intro: eventually_rev_mp eventually_elim1) -lemma MOST_rev_mp: - assumes "\\<^sub>\x. P x" and "\\<^sub>\x. P x \ Q x" - shows "\\<^sub>\x. Q x" -proof - - have "\\<^sub>\x. P x \ (P x \ Q x)" - using assms by (rule MOST_conjI) - thus ?thesis by (rule MOST_mono) simp -qed - -lemma MOST_imp_iff: - assumes "MOST x. P x" - shows "(MOST x. P x \ Q x) \ (MOST x. Q x)" -proof - assume "MOST x. P x \ Q x" - with assms show "MOST x. Q x" by (rule MOST_rev_mp) -next - assume "MOST x. Q x" - then show "MOST x. P x \ Q x" by (rule MOST_mono) simp -qed - -lemma INFM_MOST_simps [simp]: - "\P Q. (INFM x. P x \ Q) \ (INFM x. P x) \ Q" - "\P Q. (INFM x. P \ Q x) \ P \ (INFM x. Q x)" - "\P Q. (MOST x. P x \ Q) \ (MOST x. P x) \ Q" - "\P Q. (MOST x. P \ Q x) \ P \ (MOST x. Q x)" - "\P Q. (MOST x. P x \ Q) \ ((INFM x. P x) \ Q)" - "\P Q. (MOST x. P \ Q x) \ (P \ (MOST x. Q x))" - unfolding Alm_all_def Inf_many_def - by (simp_all add: Collect_conj_eq) +lemma INFM_conjI: "INFM x. P x \ MOST x. Q x \ INFM x. P x \ Q x" + by (rule frequently_rev_mp[of P]) (auto elim: eventually_elim1) text {* Properties of quantifiers with injective functions. *} lemma INFM_inj: "INFM x. P (f x) \ inj f \ INFM x. P x" - unfolding INFM_iff_infinite - apply clarify - apply (drule (1) finite_vimageI) - apply simp - done + using finite_vimageI[of "{x. P x}" f] by (auto simp: frequently_cofinite) lemma MOST_inj: "MOST x. P x \ inj f \ MOST x. P (f x)" - unfolding MOST_iff_cofinite - apply (drule (1) finite_vimageI) - apply simp - done + using finite_vimageI[of "{x. \ P x}" f] by (auto simp: eventually_cofinite) text {* Properties of quantifiers with singletons. *} lemma not_INFM_eq [simp]: "\ (INFM x. x = a)" "\ (INFM x. a = x)" - unfolding INFM_iff_infinite by simp_all + unfolding frequently_cofinite by simp_all lemma MOST_neq [simp]: "MOST x. x \ a" "MOST x. a \ x" - unfolding MOST_iff_cofinite by simp_all + unfolding eventually_cofinite by simp_all lemma INFM_neq [simp]: "(INFM x::'a. x \ a) \ infinite (UNIV::'a set)" "(INFM x::'a. a \ x) \ infinite (UNIV::'a set)" - unfolding INFM_iff_infinite by simp_all + unfolding frequently_cofinite by simp_all lemma MOST_eq [simp]: "(MOST x::'a. x = a) \ finite (UNIV::'a set)" "(MOST x::'a. a = x) \ finite (UNIV::'a set)" - unfolding MOST_iff_cofinite by simp_all + unfolding eventually_cofinite by simp_all lemma MOST_eq_imp: "MOST x. x = a \ P x" "MOST x. a = x \ P x" - unfolding MOST_iff_cofinite by simp_all + unfolding eventually_cofinite by simp_all text {* Properties of quantifiers over the naturals. *} -lemma INFM_nat: "(\\<^sub>\n. P (n::nat)) \ (\m. \n. m < n \ P n)" - by (simp add: Inf_many_def infinite_nat_iff_unbounded) +lemma MOST_nat: "(\\<^sub>\n. P (n::nat)) \ (\m. \n>m. P n)" + by (auto simp add: eventually_cofinite finite_nat_iff_bounded_le subset_eq not_le[symmetric]) + +lemma MOST_nat_le: "(\\<^sub>\n. P (n::nat)) \ (\m. \n\m. P n)" + by (auto simp add: eventually_cofinite finite_nat_iff_bounded subset_eq not_le[symmetric]) + +lemma INFM_nat: "(\\<^sub>\n. P (n::nat)) \ (\m. \n>m. P n)" + by (simp add: frequently_cofinite infinite_nat_iff_unbounded) -lemma INFM_nat_le: "(\\<^sub>\n. P (n::nat)) \ (\m. \n. m \ n \ P n)" - by (simp add: Inf_many_def infinite_nat_iff_unbounded_le) +lemma INFM_nat_le: "(\\<^sub>\n. P (n::nat)) \ (\m. \n\m. P n)" + by (simp add: frequently_cofinite infinite_nat_iff_unbounded_le) + +lemma MOST_INFM: "infinite (UNIV::'a set) \ MOST x::'a. P x \ INFM x::'a. P x" + by (simp add: eventually_frequently) + +lemma MOST_Suc_iff: "(MOST n. P (Suc n)) \ (MOST n. P n)" + by (simp add: cofinite_eq_sequentially eventually_sequentially_Suc) -lemma MOST_nat: "(\\<^sub>\n. P (n::nat)) \ (\m. \n. m < n \ P n)" - by (simp add: Alm_all_def INFM_nat) +lemma + shows MOST_SucI: "MOST n. P n \ MOST n. P (Suc n)" + and MOST_SucD: "MOST n. P (Suc n) \ MOST n. P n" + by (simp_all add: MOST_Suc_iff) + +lemma MOST_ge_nat: "MOST n::nat. m \ n" + by (simp add: cofinite_eq_sequentially eventually_ge_at_top) -lemma MOST_nat_le: "(\\<^sub>\n. P (n::nat)) \ (\m. \n. m \ n \ P n)" - by (simp add: Alm_all_def INFM_nat_le) - +(* legacy names *) +lemma Inf_many_def: "Inf_many P \ infinite {x. P x}" by (fact frequently_cofinite) +lemma Alm_all_def: "Alm_all P \ \ (INFM x. \ P x)" by simp +lemma INFM_iff_infinite: "(INFM x. P x) \ infinite {x. P x}" by (fact frequently_cofinite) +lemma MOST_iff_cofinite: "(MOST x. P x) \ finite {x. \ P x}" by (fact eventually_cofinite) +lemma INFM_EX: "(\\<^sub>\x. P x) \ (\x. P x)" by (fact frequently_ex) +lemma ALL_MOST: "\x. P x \ \\<^sub>\x. P x" by (fact always_eventually) +lemma INFM_mono: "\\<^sub>\x. P x \ (\x. P x \ Q x) \ \\<^sub>\x. Q x" by (fact frequently_elim1) +lemma MOST_mono: "\\<^sub>\x. P x \ (\x. P x \ Q x) \ \\<^sub>\x. Q x" by (fact eventually_elim1) +lemma INFM_disj_distrib: "(\\<^sub>\x. P x \ Q x) \ (\\<^sub>\x. P x) \ (\\<^sub>\x. Q x)" by (fact frequently_disj_iff) +lemma MOST_rev_mp: "\\<^sub>\x. P x \ \\<^sub>\x. P x \ Q x \ \\<^sub>\x. Q x" by (fact eventually_rev_mp) +lemma MOST_conj_distrib: "(\\<^sub>\x. P x \ Q x) \ (\\<^sub>\x. P x) \ (\\<^sub>\x. Q x)" by (fact eventually_conj_iff) +lemma MOST_conjI: "MOST x. P x \ MOST x. Q x \ MOST x. P x \ Q x" by (fact eventually_conj) +lemma INFM_finite_Bex_distrib: "finite A \ (INFM y. \x\A. P x y) \ (\x\A. INFM y. P x y)" by (fact frequently_bex_finite_distrib) +lemma MOST_finite_Ball_distrib: "finite A \ (MOST y. \x\A. P x y) \ (\x\A. MOST y. P x y)" by (fact eventually_ball_finite_distrib) +lemma INFM_E: "INFM x. P x \ (\x. P x \ thesis) \ thesis" by (fact frequentlyE) +lemma MOST_I: "(\x. P x) \ MOST x. P x" by (rule eventuallyI) +lemmas MOST_iff_finiteNeg = MOST_iff_cofinite subsection "Enumeration of an Infinite Set" @@ -360,6 +255,11 @@ The set's element type must be wellordered (e.g. the natural numbers). *} +text \ + Could be generalized to + @{term "enumerate' S n = (SOME t. t \ s \ finite {s\S. s < t} \ card {s\S. s < t} = n)"}. +\ + primrec (in wellorder) enumerate :: "'a set \ nat \ 'a" where enumerate_0: "enumerate S 0 = (LEAST n. n \ S)" @@ -368,7 +268,7 @@ lemma enumerate_Suc': "enumerate S (Suc n) = enumerate (S - {enumerate S 0}) n" by simp -lemma enumerate_in_set: "infinite S \ enumerate S n : S" +lemma enumerate_in_set: "infinite S \ enumerate S n \ S" apply (induct n arbitrary: S) apply (fastforce intro: LeastI dest!: infinite_imp_nonempty) apply simp @@ -382,13 +282,13 @@ apply (rule order_le_neq_trans) apply (simp add: enumerate_0 Least_le enumerate_in_set) apply (simp only: enumerate_Suc') - apply (subgoal_tac "enumerate (S - {enumerate S 0}) 0 : S - {enumerate S 0}") + apply (subgoal_tac "enumerate (S - {enumerate S 0}) 0 \ S - {enumerate S 0}") apply (blast intro: sym) apply (simp add: enumerate_in_set del: Diff_iff) apply (simp add: enumerate_Suc') done -lemma enumerate_mono: "m infinite S \ enumerate S m < enumerate S n" +lemma enumerate_mono: "m < n \ infinite S \ enumerate S m < enumerate S n" apply (erule less_Suc_induct) apply (auto intro: enumerate_step) done diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/Library/Polynomial.thy --- a/src/HOL/Library/Polynomial.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/Library/Polynomial.thy Sun Apr 12 11:34:09 2015 +0200 @@ -50,9 +50,6 @@ "tl (x ## xs) = xs" by (simp add: cCons_def) -lemma MOST_SucD: "(\\<^sub>\ n. P (Suc n)) \ (\\<^sub>\ n. P n)" - by (auto simp: MOST_nat) (metis Suc_lessE) - subsection {* Definition of type @{text poly} *} typedef 'a poly = "{f :: nat \ 'a::zero. \\<^sub>\ n. f n = 0}" @@ -501,9 +498,9 @@ lift_definition plus_poly :: "'a poly \ 'a poly \ 'a poly" is "\p q n. coeff p n + coeff q n" -proof (rule MOST_rev_mp[OF MOST_coeff_eq_0 MOST_rev_mp[OF MOST_coeff_eq_0]]) - fix q p :: "'a poly" show "\\<^sub>\n. coeff p n = 0 \ coeff q n = 0 \ coeff p n + coeff q n = 0" - by simp +proof - + fix q p :: "'a poly" show "\\<^sub>\n. coeff p n + coeff q n = 0" + using MOST_coeff_eq_0[of p] MOST_coeff_eq_0[of q] by eventually_elim simp qed lemma coeff_add [simp]: @@ -527,9 +524,9 @@ lift_definition minus_poly :: "'a poly \ 'a poly \ 'a poly" is "\p q n. coeff p n - coeff q n" -proof (rule MOST_rev_mp[OF MOST_coeff_eq_0 MOST_rev_mp[OF MOST_coeff_eq_0]]) - fix q p :: "'a poly" show "\\<^sub>\n. coeff p n = 0 \ coeff q n = 0 \ coeff p n - coeff q n = 0" - by simp +proof - + fix q p :: "'a poly" show "\\<^sub>\n. coeff p n - coeff q n = 0" + using MOST_coeff_eq_0[of p] MOST_coeff_eq_0[of q] by eventually_elim simp qed lemma coeff_diff [simp]: @@ -551,9 +548,9 @@ lift_definition uminus_poly :: "'a poly \ 'a poly" is "\p n. - coeff p n" -proof (rule MOST_rev_mp[OF MOST_coeff_eq_0]) - fix p :: "'a poly" show "\\<^sub>\n. coeff p n = 0 \ - coeff p n = 0" - by simp +proof - + fix p :: "'a poly" show "\\<^sub>\n. - coeff p n = 0" + using MOST_coeff_eq_0 by simp qed lemma coeff_minus [simp]: "coeff (- p) n = - coeff p n" @@ -707,11 +704,9 @@ lift_definition smult :: "'a::comm_semiring_0 \ 'a poly \ 'a poly" is "\a p n. a * coeff p n" -proof (intro MOST_nat[THEN iffD2] exI allI impI) - fix a :: 'a and p :: "'a poly" and i - assume "degree p < i" - then show "a * coeff p i = 0" - by (simp add: coeff_eq_0) +proof - + fix a :: 'a and p :: "'a poly" show "\\<^sub>\ i. a * coeff p i = 0" + using MOST_coeff_eq_0[of p] by eventually_elim simp qed lemma coeff_smult [simp]: diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Sun Apr 12 11:34:09 2015 +0200 @@ -3331,10 +3331,8 @@ have "(\B \ Z. finite B \ U \ \B \ {})" proof (intro allI impI) fix B assume "finite B" "B \ Z" - with `finite B` ev_Z have "eventually (\x. \b\B. x \ b) F" - by (auto intro!: eventually_Ball_finite) - with F(2) have "eventually (\x. x \ U \ (\B)) F" - by eventually_elim auto + with `finite B` ev_Z F(2) have "eventually (\x. x \ U \ (\B)) F" + by (auto simp: eventually_ball_finite_distrib eventually_conj_iff) with F show "U \ \B \ {}" by (intro notI) (simp add: eventually_False) qed @@ -7506,7 +7504,7 @@ then have cont: "continuous_on ?D (\x. dist ((g \ fst) x) (snd x))" unfolding continuous_on_eq_continuous_within by (intro continuous_dist ballI continuous_within_compose) - (auto intro!: continuous_fst continuous_snd continuous_within_id simp: image_image) + (auto intro!: continuous_fst continuous_snd continuous_within_id simp: image_image) obtain a where "a \ s" and le: "\x. x \ s \ dist (g a) a \ dist (g x) x" using continuous_attains_inf[OF D cont] by auto diff -r d55937a8f97e -r 1fa1023b13b9 src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Sun Apr 12 11:33:50 2015 +0200 +++ b/src/HOL/Topological_Spaces.thy Sun Apr 12 11:34:09 2015 +0200 @@ -1636,7 +1636,7 @@ by (rule compactE) from `D \ ?C` have "\x\D. eventually (\y. y \ x) (nhds y)" by auto with `finite D` have "eventually (\y. y \ \D) (nhds y)" - by (simp add: eventually_Ball_finite) + by (simp add: eventually_ball_finite) with `s \ \D` have "eventually (\y. y \ s) (nhds y)" by (auto elim!: eventually_mono [rotated]) thus "\t. open t \ y \ t \ t \ - s"