author | paulson <lp15@cam.ac.uk> |
Wed, 17 Apr 2019 17:48:28 +0100 | |
changeset 70178 | 4900351361b0 |
parent 69661 | a03a63b81f44 |
child 70179 | 269dcea7426c |
permissions | -rw-r--r-- |
27407
68e111812b83
rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents:
27368
diff
changeset
|
1 |
(* Title: HOL/Library/Infinite_Set.thy |
20809 | 2 |
Author: Stephan Merz |
3 |
*) |
|
4 |
||
60500 | 5 |
section \<open>Infinite Sets and Related Concepts\<close> |
20809 | 6 |
|
7 |
theory Infinite_Set |
|
64967 | 8 |
imports Main |
20809 | 9 |
begin |
10 |
||
70178
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
11 |
lemma subset_image_inj: |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
12 |
"S \<subseteq> f ` T \<longleftrightarrow> (\<exists>U. U \<subseteq> T \<and> inj_on f U \<and> S = f ` U)" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
13 |
proof safe |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
14 |
show "\<exists>U\<subseteq>T. inj_on f U \<and> S = f ` U" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
15 |
if "S \<subseteq> f ` T" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
16 |
proof - |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
17 |
from that [unfolded subset_image_iff subset_iff] |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
18 |
obtain g where g: "\<And>x. x \<in> S \<Longrightarrow> g x \<in> T \<and> x = f (g x)" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
19 |
unfolding image_iff by metis |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
20 |
show ?thesis |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
21 |
proof (intro exI conjI) |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
22 |
show "g ` S \<subseteq> T" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
23 |
by (simp add: g image_subsetI) |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
24 |
show "inj_on f (g ` S)" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
25 |
using g by (auto simp: inj_on_def) |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
26 |
show "S = f ` (g ` S)" |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
27 |
using g image_subset_iff by auto |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
28 |
qed |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
29 |
qed |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
30 |
qed blast |
4900351361b0
Lindelöf spaces and supporting material
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
31 |
|
64967 | 32 |
subsection \<open>The set of natural numbers is infinite\<close> |
20809 | 33 |
|
64967 | 34 |
lemma infinite_nat_iff_unbounded_le: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n\<ge>m. n \<in> S)" |
35 |
for S :: "nat set" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
36 |
using frequently_cofinite[of "\<lambda>x. x \<in> S"] |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
37 |
by (simp add: cofinite_eq_sequentially frequently_def eventually_sequentially) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
38 |
|
64967 | 39 |
lemma infinite_nat_iff_unbounded: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n>m. n \<in> S)" |
40 |
for S :: "nat set" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
41 |
using frequently_cofinite[of "\<lambda>x. x \<in> S"] |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
42 |
by (simp add: cofinite_eq_sequentially frequently_def eventually_at_top_dense) |
20809 | 43 |
|
64967 | 44 |
lemma finite_nat_iff_bounded: "finite S \<longleftrightarrow> (\<exists>k. S \<subseteq> {..<k})" |
45 |
for S :: "nat set" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
46 |
using infinite_nat_iff_unbounded_le[of S] by (simp add: subset_eq) (metis not_le) |
20809 | 47 |
|
64967 | 48 |
lemma finite_nat_iff_bounded_le: "finite S \<longleftrightarrow> (\<exists>k. S \<subseteq> {.. k})" |
49 |
for S :: "nat set" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
50 |
using infinite_nat_iff_unbounded[of S] by (simp add: subset_eq) (metis not_le) |
20809 | 51 |
|
64967 | 52 |
lemma finite_nat_bounded: "finite S \<Longrightarrow> \<exists>k. S \<subseteq> {..<k}" |
53 |
for S :: "nat set" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
54 |
by (simp add: finite_nat_iff_bounded) |
20809 | 55 |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
56 |
|
60500 | 57 |
text \<open> |
20809 | 58 |
For a set of natural numbers to be infinite, it is enough to know |
61585 | 59 |
that for any number larger than some \<open>k\<close>, there is some larger |
20809 | 60 |
number that is an element of the set. |
60500 | 61 |
\<close> |
20809 | 62 |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
63 |
lemma unbounded_k_infinite: "\<forall>m>k. \<exists>n>m. n \<in> S \<Longrightarrow> infinite (S::nat set)" |
64967 | 64 |
apply (clarsimp simp add: finite_nat_set_iff_bounded) |
65 |
apply (drule_tac x="Suc (max m k)" in spec) |
|
66 |
using less_Suc_eq apply fastforce |
|
67 |
done |
|
20809 | 68 |
|
35056 | 69 |
lemma nat_not_finite: "finite (UNIV::nat set) \<Longrightarrow> R" |
20809 | 70 |
by simp |
71 |
||
72 |
lemma range_inj_infinite: |
|
64967 | 73 |
fixes f :: "nat \<Rightarrow> 'a" |
74 |
assumes "inj f" |
|
75 |
shows "infinite (range f)" |
|
20809 | 76 |
proof |
64967 | 77 |
assume "finite (range f)" |
78 |
from this assms have "finite (UNIV::nat set)" |
|
27407
68e111812b83
rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents:
27368
diff
changeset
|
79 |
by (rule finite_imageD) |
20809 | 80 |
then show False by simp |
81 |
qed |
|
82 |
||
64967 | 83 |
|
84 |
subsection \<open>The set of integers is also infinite\<close> |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
85 |
|
64967 | 86 |
lemma infinite_int_iff_infinite_nat_abs: "infinite S \<longleftrightarrow> infinite ((nat \<circ> abs) ` S)" |
87 |
for S :: "int set" |
|
69661 | 88 |
proof (unfold Not_eq_iff, rule iffI) |
89 |
assume "finite ((nat \<circ> abs) ` S)" |
|
90 |
then have "finite (nat ` (abs ` S))" |
|
91 |
by (simp add: image_image cong: image_cong) |
|
92 |
moreover have "inj_on nat (abs ` S)" |
|
66837 | 93 |
by (rule inj_onI) auto |
69661 | 94 |
ultimately have "finite (abs ` S)" |
95 |
by (rule finite_imageD) |
|
96 |
then show "finite S" |
|
97 |
by (rule finite_image_absD) |
|
98 |
qed simp |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
99 |
|
64967 | 100 |
proposition infinite_int_iff_unbounded_le: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n. \<bar>n\<bar> \<ge> m \<and> n \<in> S)" |
101 |
for S :: "int set" |
|
102 |
by (simp add: infinite_int_iff_infinite_nat_abs infinite_nat_iff_unbounded_le o_def image_def) |
|
103 |
(metis abs_ge_zero nat_le_eq_zle le_nat_iff) |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
104 |
|
64967 | 105 |
proposition infinite_int_iff_unbounded: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n. \<bar>n\<bar> > m \<and> n \<in> S)" |
106 |
for S :: "int set" |
|
107 |
by (simp add: infinite_int_iff_infinite_nat_abs infinite_nat_iff_unbounded o_def image_def) |
|
108 |
(metis (full_types) nat_le_iff nat_mono not_le) |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
109 |
|
64967 | 110 |
proposition finite_int_iff_bounded: "finite S \<longleftrightarrow> (\<exists>k. abs ` S \<subseteq> {..<k})" |
111 |
for S :: "int set" |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
112 |
using infinite_int_iff_unbounded_le[of S] by (simp add: subset_eq) (metis not_le) |
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
113 |
|
64967 | 114 |
proposition finite_int_iff_bounded_le: "finite S \<longleftrightarrow> (\<exists>k. abs ` S \<subseteq> {.. k})" |
115 |
for S :: "int set" |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
116 |
using infinite_int_iff_unbounded[of S] by (simp add: subset_eq) (metis not_le) |
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61585
diff
changeset
|
117 |
|
64967 | 118 |
|
119 |
subsection \<open>Infinitely Many and Almost All\<close> |
|
20809 | 120 |
|
60500 | 121 |
text \<open> |
20809 | 122 |
We often need to reason about the existence of infinitely many |
123 |
(resp., all but finitely many) objects satisfying some predicate, so |
|
124 |
we introduce corresponding binders and their proof rules. |
|
60500 | 125 |
\<close> |
20809 | 126 |
|
64967 | 127 |
lemma not_INFM [simp]: "\<not> (INFM x. P x) \<longleftrightarrow> (MOST x. \<not> P x)" |
128 |
by (rule not_frequently) |
|
129 |
||
130 |
lemma not_MOST [simp]: "\<not> (MOST x. P x) \<longleftrightarrow> (INFM x. \<not> P x)" |
|
131 |
by (rule not_eventually) |
|
34112 | 132 |
|
133 |
lemma INFM_const [simp]: "(INFM x::'a. P) \<longleftrightarrow> P \<and> infinite (UNIV::'a set)" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
134 |
by (simp add: frequently_const_iff) |
34112 | 135 |
|
136 |
lemma MOST_const [simp]: "(MOST x::'a. P) \<longleftrightarrow> P \<or> finite (UNIV::'a set)" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
137 |
by (simp add: eventually_const_iff) |
20809 | 138 |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
139 |
lemma INFM_imp_distrib: "(INFM x. P x \<longrightarrow> Q x) \<longleftrightarrow> ((MOST x. P x) \<longrightarrow> (INFM x. Q x))" |
64967 | 140 |
by (rule frequently_imp_iff) |
34112 | 141 |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
142 |
lemma MOST_imp_iff: "MOST x. P x \<Longrightarrow> (MOST x. P x \<longrightarrow> Q x) \<longleftrightarrow> (MOST x. Q x)" |
61810 | 143 |
by (auto intro: eventually_rev_mp eventually_mono) |
34113 | 144 |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
145 |
lemma INFM_conjI: "INFM x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> INFM x. P x \<and> Q x" |
61810 | 146 |
by (rule frequently_rev_mp[of P]) (auto elim: eventually_mono) |
34112 | 147 |
|
64967 | 148 |
|
60500 | 149 |
text \<open>Properties of quantifiers with injective functions.\<close> |
34112 | 150 |
|
53239 | 151 |
lemma INFM_inj: "INFM x. P (f x) \<Longrightarrow> inj f \<Longrightarrow> INFM x. P x" |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
152 |
using finite_vimageI[of "{x. P x}" f] by (auto simp: frequently_cofinite) |
27407
68e111812b83
rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents:
27368
diff
changeset
|
153 |
|
53239 | 154 |
lemma MOST_inj: "MOST x. P x \<Longrightarrow> inj f \<Longrightarrow> MOST x. P (f x)" |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
155 |
using finite_vimageI[of "{x. \<not> P x}" f] by (auto simp: eventually_cofinite) |
34112 | 156 |
|
64967 | 157 |
|
60500 | 158 |
text \<open>Properties of quantifiers with singletons.\<close> |
34112 | 159 |
|
160 |
lemma not_INFM_eq [simp]: |
|
161 |
"\<not> (INFM x. x = a)" |
|
162 |
"\<not> (INFM x. a = x)" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
163 |
unfolding frequently_cofinite by simp_all |
34112 | 164 |
|
165 |
lemma MOST_neq [simp]: |
|
166 |
"MOST x. x \<noteq> a" |
|
167 |
"MOST x. a \<noteq> x" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
168 |
unfolding eventually_cofinite by simp_all |
27407
68e111812b83
rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents:
27368
diff
changeset
|
169 |
|
34112 | 170 |
lemma INFM_neq [simp]: |
171 |
"(INFM x::'a. x \<noteq> a) \<longleftrightarrow> infinite (UNIV::'a set)" |
|
172 |
"(INFM x::'a. a \<noteq> x) \<longleftrightarrow> infinite (UNIV::'a set)" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
173 |
unfolding frequently_cofinite by simp_all |
34112 | 174 |
|
175 |
lemma MOST_eq [simp]: |
|
176 |
"(MOST x::'a. x = a) \<longleftrightarrow> finite (UNIV::'a set)" |
|
177 |
"(MOST x::'a. a = x) \<longleftrightarrow> finite (UNIV::'a set)" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
178 |
unfolding eventually_cofinite by simp_all |
34112 | 179 |
|
180 |
lemma MOST_eq_imp: |
|
181 |
"MOST x. x = a \<longrightarrow> P x" |
|
182 |
"MOST x. a = x \<longrightarrow> P x" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
183 |
unfolding eventually_cofinite by simp_all |
34112 | 184 |
|
64967 | 185 |
|
60500 | 186 |
text \<open>Properties of quantifiers over the naturals.\<close> |
27407
68e111812b83
rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents:
27368
diff
changeset
|
187 |
|
64967 | 188 |
lemma MOST_nat: "(\<forall>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<exists>m. \<forall>n>m. P n)" |
189 |
for P :: "nat \<Rightarrow> bool" |
|
68406 | 190 |
by (auto simp add: eventually_cofinite finite_nat_iff_bounded_le subset_eq simp flip: not_le) |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
191 |
|
64967 | 192 |
lemma MOST_nat_le: "(\<forall>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<exists>m. \<forall>n\<ge>m. P n)" |
193 |
for P :: "nat \<Rightarrow> bool" |
|
68406 | 194 |
by (auto simp add: eventually_cofinite finite_nat_iff_bounded subset_eq simp flip: not_le) |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
195 |
|
64967 | 196 |
lemma INFM_nat: "(\<exists>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<forall>m. \<exists>n>m. P n)" |
197 |
for P :: "nat \<Rightarrow> bool" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
198 |
by (simp add: frequently_cofinite infinite_nat_iff_unbounded) |
20809 | 199 |
|
64967 | 200 |
lemma INFM_nat_le: "(\<exists>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<forall>m. \<exists>n\<ge>m. P n)" |
201 |
for P :: "nat \<Rightarrow> bool" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
202 |
by (simp add: frequently_cofinite infinite_nat_iff_unbounded_le) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
203 |
|
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
204 |
lemma MOST_INFM: "infinite (UNIV::'a set) \<Longrightarrow> MOST x::'a. P x \<Longrightarrow> INFM x::'a. P x" |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
205 |
by (simp add: eventually_frequently) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
206 |
|
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
207 |
lemma MOST_Suc_iff: "(MOST n. P (Suc n)) \<longleftrightarrow> (MOST n. P n)" |
64697 | 208 |
by (simp add: cofinite_eq_sequentially) |
20809 | 209 |
|
64967 | 210 |
lemma MOST_SucI: "MOST n. P n \<Longrightarrow> MOST n. P (Suc n)" |
211 |
and MOST_SucD: "MOST n. P (Suc n) \<Longrightarrow> MOST n. P n" |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
212 |
by (simp_all add: MOST_Suc_iff) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
213 |
|
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
214 |
lemma MOST_ge_nat: "MOST n::nat. m \<le> n" |
66837 | 215 |
by (simp add: cofinite_eq_sequentially) |
20809 | 216 |
|
67408 | 217 |
\<comment> \<open>legacy names\<close> |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
218 |
lemma Inf_many_def: "Inf_many P \<longleftrightarrow> infinite {x. P x}" by (fact frequently_cofinite) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
219 |
lemma Alm_all_def: "Alm_all P \<longleftrightarrow> \<not> (INFM x. \<not> P x)" by simp |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
220 |
lemma INFM_iff_infinite: "(INFM x. P x) \<longleftrightarrow> infinite {x. P x}" by (fact frequently_cofinite) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
221 |
lemma MOST_iff_cofinite: "(MOST x. P x) \<longleftrightarrow> finite {x. \<not> P x}" by (fact eventually_cofinite) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
222 |
lemma INFM_EX: "(\<exists>\<^sub>\<infinity>x. P x) \<Longrightarrow> (\<exists>x. P x)" by (fact frequently_ex) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
223 |
lemma ALL_MOST: "\<forall>x. P x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. P x" by (fact always_eventually) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
224 |
lemma INFM_mono: "\<exists>\<^sub>\<infinity>x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> \<exists>\<^sub>\<infinity>x. Q x" by (fact frequently_elim1) |
61810 | 225 |
lemma MOST_mono: "\<forall>\<^sub>\<infinity>x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> \<forall>\<^sub>\<infinity>x. Q x" by (fact eventually_mono) |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
226 |
lemma INFM_disj_distrib: "(\<exists>\<^sub>\<infinity>x. P x \<or> Q x) \<longleftrightarrow> (\<exists>\<^sub>\<infinity>x. P x) \<or> (\<exists>\<^sub>\<infinity>x. Q x)" by (fact frequently_disj_iff) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
227 |
lemma MOST_rev_mp: "\<forall>\<^sub>\<infinity>x. P x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. P x \<longrightarrow> Q x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. Q x" by (fact eventually_rev_mp) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
228 |
lemma MOST_conj_distrib: "(\<forall>\<^sub>\<infinity>x. P x \<and> Q x) \<longleftrightarrow> (\<forall>\<^sub>\<infinity>x. P x) \<and> (\<forall>\<^sub>\<infinity>x. Q x)" by (fact eventually_conj_iff) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
229 |
lemma MOST_conjI: "MOST x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> MOST x. P x \<and> Q x" by (fact eventually_conj) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
230 |
lemma INFM_finite_Bex_distrib: "finite A \<Longrightarrow> (INFM y. \<exists>x\<in>A. P x y) \<longleftrightarrow> (\<exists>x\<in>A. INFM y. P x y)" by (fact frequently_bex_finite_distrib) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
231 |
lemma MOST_finite_Ball_distrib: "finite A \<Longrightarrow> (MOST y. \<forall>x\<in>A. P x y) \<longleftrightarrow> (\<forall>x\<in>A. MOST y. P x y)" by (fact eventually_ball_finite_distrib) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
232 |
lemma INFM_E: "INFM x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> thesis) \<Longrightarrow> thesis" by (fact frequentlyE) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
233 |
lemma MOST_I: "(\<And>x. P x) \<Longrightarrow> MOST x. P x" by (rule eventuallyI) |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
234 |
lemmas MOST_iff_finiteNeg = MOST_iff_cofinite |
20809 | 235 |
|
236 |
||
64967 | 237 |
subsection \<open>Enumeration of an Infinite Set\<close> |
238 |
||
239 |
text \<open>The set's element type must be wellordered (e.g. the natural numbers).\<close> |
|
20809 | 240 |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
241 |
text \<open> |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
242 |
Could be generalized to |
69593 | 243 |
\<^prop>\<open>enumerate' S n = (SOME t. t \<in> s \<and> finite {s\<in>S. s < t} \<and> card {s\<in>S. s < t} = n)\<close>. |
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
244 |
\<close> |
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
245 |
|
53239 | 246 |
primrec (in wellorder) enumerate :: "'a set \<Rightarrow> nat \<Rightarrow> 'a" |
64967 | 247 |
where |
248 |
enumerate_0: "enumerate S 0 = (LEAST n. n \<in> S)" |
|
249 |
| enumerate_Suc: "enumerate S (Suc n) = enumerate (S - {LEAST n. n \<in> S}) n" |
|
20809 | 250 |
|
53239 | 251 |
lemma enumerate_Suc': "enumerate S (Suc n) = enumerate (S - {enumerate S 0}) n" |
20809 | 252 |
by simp |
253 |
||
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
254 |
lemma enumerate_in_set: "infinite S \<Longrightarrow> enumerate S n \<in> S" |
64967 | 255 |
proof (induct n arbitrary: S) |
256 |
case 0 |
|
257 |
then show ?case |
|
258 |
by (fastforce intro: LeastI dest!: infinite_imp_nonempty) |
|
259 |
next |
|
260 |
case (Suc n) |
|
261 |
then show ?case |
|
262 |
by simp (metis DiffE infinite_remove) |
|
263 |
qed |
|
20809 | 264 |
|
265 |
declare enumerate_0 [simp del] enumerate_Suc [simp del] |
|
266 |
||
267 |
lemma enumerate_step: "infinite S \<Longrightarrow> enumerate S n < enumerate S (Suc n)" |
|
268 |
apply (induct n arbitrary: S) |
|
269 |
apply (rule order_le_neq_trans) |
|
270 |
apply (simp add: enumerate_0 Least_le enumerate_in_set) |
|
271 |
apply (simp only: enumerate_Suc') |
|
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
272 |
apply (subgoal_tac "enumerate (S - {enumerate S 0}) 0 \<in> S - {enumerate S 0}") |
20809 | 273 |
apply (blast intro: sym) |
274 |
apply (simp add: enumerate_in_set del: Diff_iff) |
|
275 |
apply (simp add: enumerate_Suc') |
|
276 |
done |
|
277 |
||
60040
1fa1023b13b9
move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents:
59506
diff
changeset
|
278 |
lemma enumerate_mono: "m < n \<Longrightarrow> infinite S \<Longrightarrow> enumerate S m < enumerate S n" |
64967 | 279 |
by (induct m n rule: less_Suc_induct) (auto intro: enumerate_step) |
20809 | 280 |
|
50134 | 281 |
lemma le_enumerate: |
282 |
assumes S: "infinite S" |
|
283 |
shows "n \<le> enumerate S n" |
|
61810 | 284 |
using S |
50134 | 285 |
proof (induct n) |
53239 | 286 |
case 0 |
287 |
then show ?case by simp |
|
288 |
next |
|
50134 | 289 |
case (Suc n) |
290 |
then have "n \<le> enumerate S n" by simp |
|
60500 | 291 |
also note enumerate_mono[of n "Suc n", OF _ \<open>infinite S\<close>] |
50134 | 292 |
finally show ?case by simp |
53239 | 293 |
qed |
50134 | 294 |
|
69516
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
295 |
lemma infinite_enumerate: |
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
296 |
assumes fS: "infinite S" |
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
297 |
shows "\<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (\<forall>n. r n \<in> S)" |
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
298 |
unfolding strict_mono_def |
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
299 |
using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto |
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents:
68406
diff
changeset
|
300 |
|
50134 | 301 |
lemma enumerate_Suc'': |
302 |
fixes S :: "'a::wellorder set" |
|
53239 | 303 |
assumes "infinite S" |
304 |
shows "enumerate S (Suc n) = (LEAST s. s \<in> S \<and> enumerate S n < s)" |
|
305 |
using assms |
|
50134 | 306 |
proof (induct n arbitrary: S) |
307 |
case 0 |
|
53239 | 308 |
then have "\<forall>s \<in> S. enumerate S 0 \<le> s" |
50134 | 309 |
by (auto simp: enumerate.simps intro: Least_le) |
310 |
then show ?case |
|
311 |
unfolding enumerate_Suc' enumerate_0[of "S - {enumerate S 0}"] |
|
53239 | 312 |
by (intro arg_cong[where f = Least] ext) auto |
50134 | 313 |
next |
314 |
case (Suc n S) |
|
315 |
show ?case |
|
60500 | 316 |
using enumerate_mono[OF zero_less_Suc \<open>infinite S\<close>, of n] \<open>infinite S\<close> |
50134 | 317 |
apply (subst (1 2) enumerate_Suc') |
318 |
apply (subst Suc) |
|
64967 | 319 |
apply (use \<open>infinite S\<close> in simp) |
53239 | 320 |
apply (intro arg_cong[where f = Least] ext) |
68406 | 321 |
apply (auto simp flip: enumerate_Suc') |
53239 | 322 |
done |
50134 | 323 |
qed |
324 |
||
325 |
lemma enumerate_Ex: |
|
64967 | 326 |
fixes S :: "nat set" |
327 |
assumes S: "infinite S" |
|
328 |
and s: "s \<in> S" |
|
329 |
shows "\<exists>n. enumerate S n = s" |
|
330 |
using s |
|
50134 | 331 |
proof (induct s rule: less_induct) |
332 |
case (less s) |
|
333 |
show ?case |
|
64967 | 334 |
proof (cases "\<exists>y\<in>S. y < s") |
335 |
case True |
|
50134 | 336 |
let ?y = "Max {s'\<in>S. s' < s}" |
64967 | 337 |
from True have y: "\<And>x. ?y < x \<longleftrightarrow> (\<forall>s'\<in>S. s' < s \<longrightarrow> s' < x)" |
53239 | 338 |
by (subst Max_less_iff) auto |
339 |
then have y_in: "?y \<in> {s'\<in>S. s' < s}" |
|
340 |
by (intro Max_in) auto |
|
341 |
with less.hyps[of ?y] obtain n where "enumerate S n = ?y" |
|
342 |
by auto |
|
50134 | 343 |
with S have "enumerate S (Suc n) = s" |
344 |
by (auto simp: y less enumerate_Suc'' intro!: Least_equality) |
|
64967 | 345 |
then show ?thesis by auto |
50134 | 346 |
next |
64967 | 347 |
case False |
50134 | 348 |
then have "\<forall>t\<in>S. s \<le> t" by auto |
60500 | 349 |
with \<open>s \<in> S\<close> show ?thesis |
50134 | 350 |
by (auto intro!: exI[of _ 0] Least_equality simp: enumerate_0) |
351 |
qed |
|
352 |
qed |
|
353 |
||
354 |
lemma bij_enumerate: |
|
355 |
fixes S :: "nat set" |
|
356 |
assumes S: "infinite S" |
|
357 |
shows "bij_betw (enumerate S) UNIV S" |
|
358 |
proof - |
|
359 |
have "\<And>n m. n \<noteq> m \<Longrightarrow> enumerate S n \<noteq> enumerate S m" |
|
60500 | 360 |
using enumerate_mono[OF _ \<open>infinite S\<close>] by (auto simp: neq_iff) |
50134 | 361 |
then have "inj (enumerate S)" |
362 |
by (auto simp: inj_on_def) |
|
53239 | 363 |
moreover have "\<forall>s \<in> S. \<exists>i. enumerate S i = s" |
50134 | 364 |
using enumerate_Ex[OF S] by auto |
60500 | 365 |
moreover note \<open>infinite S\<close> |
50134 | 366 |
ultimately show ?thesis |
367 |
unfolding bij_betw_def by (auto intro: enumerate_in_set) |
|
368 |
qed |
|
369 |
||
64967 | 370 |
text \<open>A pair of weird and wonderful lemmas from HOL Light.\<close> |
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
371 |
lemma finite_transitivity_chain: |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
372 |
assumes "finite A" |
64967 | 373 |
and R: "\<And>x. \<not> R x x" "\<And>x y z. \<lbrakk>R x y; R y z\<rbrakk> \<Longrightarrow> R x z" |
374 |
and A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y. y \<in> A \<and> R x y" |
|
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
375 |
shows "A = {}" |
64967 | 376 |
using \<open>finite A\<close> A |
377 |
proof (induct A) |
|
378 |
case empty |
|
379 |
then show ?case by simp |
|
380 |
next |
|
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
381 |
case (insert a A) |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
382 |
with R show ?case |
64967 | 383 |
by (metis empty_iff insert_iff) (* somewhat slow *) |
384 |
qed |
|
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
385 |
|
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
386 |
corollary Union_maximal_sets: |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
387 |
assumes "finite \<F>" |
64967 | 388 |
shows "\<Union>{T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} = \<Union>\<F>" |
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
389 |
(is "?lhs = ?rhs") |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
390 |
proof |
64967 | 391 |
show "?lhs \<subseteq> ?rhs" by force |
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
392 |
show "?rhs \<subseteq> ?lhs" |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
393 |
proof (rule Union_subsetI) |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
394 |
fix S |
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
395 |
assume "S \<in> \<F>" |
64967 | 396 |
have "{T \<in> \<F>. S \<subseteq> T} = {}" |
397 |
if "\<not> (\<exists>y. y \<in> {T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} \<and> S \<subseteq> y)" |
|
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
398 |
apply (rule finite_transitivity_chain [of _ "\<lambda>T U. S \<subseteq> T \<and> T \<subset> U"]) |
64967 | 399 |
apply (use assms that in auto) |
400 |
apply (blast intro: dual_order.trans psubset_imp_subset) |
|
401 |
done |
|
402 |
with \<open>S \<in> \<F>\<close> show "\<exists>y. y \<in> {T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} \<and> S \<subseteq> y" |
|
403 |
by blast |
|
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
404 |
qed |
64967 | 405 |
qed |
63492
a662e8139804
More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents:
61945
diff
changeset
|
406 |
|
20809 | 407 |
end |