author | paulson |
Tue, 29 Aug 2017 17:41:27 +0100 | |
changeset 66553 | 6ab32ffb2bdd |
parent 65955 | 0616ba637b14 |
child 67613 | ce654b0e6d69 |
permissions | -rw-r--r-- |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
1 |
(* Title: HOL/Hilbert_Choice.thy |
32988 | 2 |
Author: Lawrence C Paulson, Tobias Nipkow |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
3 |
Copyright 2001 University of Cambridge |
12023 | 4 |
*) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
5 |
|
60758 | 6 |
section \<open>Hilbert's Epsilon-Operator and the Axiom of Choice\<close> |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
7 |
|
15131 | 8 |
theory Hilbert_Choice |
63612 | 9 |
imports Wellfounded |
10 |
keywords "specification" :: thy_goal |
|
15131 | 11 |
begin |
12298 | 12 |
|
60758 | 13 |
subsection \<open>Hilbert's epsilon\<close> |
12298 | 14 |
|
63612 | 15 |
axiomatization Eps :: "('a \<Rightarrow> bool) \<Rightarrow> 'a" |
16 |
where someI: "P x \<Longrightarrow> P (Eps P)" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
17 |
|
14872
3f2144aebd76
improved symbolic syntax of Eps: \<some> for mode "epsilon";
wenzelm
parents:
14760
diff
changeset
|
18 |
syntax (epsilon) |
63612 | 19 |
"_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a" ("(3\<some>_./ _)" [0, 10] 10) |
62521 | 20 |
syntax (input) |
63612 | 21 |
"_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a" ("(3@ _./ _)" [0, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
22 |
syntax |
63612 | 23 |
"_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a" ("(3SOME _./ _)" [0, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
24 |
translations |
63612 | 25 |
"SOME x. P" \<rightleftharpoons> "CONST Eps (\<lambda>x. P)" |
13763
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13585
diff
changeset
|
26 |
|
60758 | 27 |
print_translation \<open> |
52143 | 28 |
[(@{const_syntax Eps}, fn _ => fn [Abs abs] => |
42284 | 29 |
let val (x, t) = Syntax_Trans.atomic_abs_tr' abs |
35115 | 30 |
in Syntax.const @{syntax_const "_Eps"} $ x $ t end)] |
61799 | 31 |
\<close> \<comment> \<open>to avoid eta-contraction of body\<close> |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
32 |
|
65815 | 33 |
definition inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where |
34 |
"inv_into A f = (\<lambda>x. SOME y. y \<in> A \<and> f y = x)" |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
35 |
|
65815 | 36 |
lemma inv_into_def2: "inv_into A f x = (SOME y. y \<in> A \<and> f y = x)" |
37 |
by(simp add: inv_into_def) |
|
38 |
||
39 |
abbreviation inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where |
|
40 |
"inv \<equiv> inv_into UNIV" |
|
14760 | 41 |
|
42 |
||
60758 | 43 |
subsection \<open>Hilbert's Epsilon-operator\<close> |
14760 | 44 |
|
63612 | 45 |
text \<open> |
46 |
Easier to apply than \<open>someI\<close> if the witness comes from an |
|
47 |
existential formula. |
|
48 |
\<close> |
|
49 |
lemma someI_ex [elim?]: "\<exists>x. P x \<Longrightarrow> P (SOME x. P x)" |
|
50 |
apply (erule exE) |
|
51 |
apply (erule someI) |
|
52 |
done |
|
14760 | 53 |
|
63612 | 54 |
text \<open> |
55 |
Easier to apply than \<open>someI\<close> because the conclusion has only one |
|
56 |
occurrence of @{term P}. |
|
57 |
\<close> |
|
58 |
lemma someI2: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. P x)" |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
59 |
by (blast intro: someI) |
14760 | 60 |
|
63612 | 61 |
text \<open> |
62 |
Easier to apply than \<open>someI2\<close> if the witness comes from an |
|
63 |
existential formula. |
|
64 |
\<close> |
|
65 |
lemma someI2_ex: "\<exists>a. P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. P x)" |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
66 |
by (blast intro: someI2) |
14760 | 67 |
|
63612 | 68 |
lemma someI2_bex: "\<exists>a\<in>A. P a \<Longrightarrow> (\<And>x. x \<in> A \<and> P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. x \<in> A \<and> P x)" |
69 |
by (blast intro: someI2) |
|
70 |
||
71 |
lemma some_equality [intro]: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> x = a) \<Longrightarrow> (SOME x. P x) = a" |
|
72 |
by (blast intro: someI2) |
|
14760 | 73 |
|
63629 | 74 |
lemma some1_equality: "\<exists>!x. P x \<Longrightarrow> P a \<Longrightarrow> (SOME x. P x) = a" |
63612 | 75 |
by blast |
14760 | 76 |
|
63612 | 77 |
lemma some_eq_ex: "P (SOME x. P x) \<longleftrightarrow> (\<exists>x. P x)" |
78 |
by (blast intro: someI) |
|
14760 | 79 |
|
59000 | 80 |
lemma some_in_eq: "(SOME x. x \<in> A) \<in> A \<longleftrightarrow> A \<noteq> {}" |
81 |
unfolding ex_in_conv[symmetric] by (rule some_eq_ex) |
|
82 |
||
63612 | 83 |
lemma some_eq_trivial [simp]: "(SOME y. y = x) = x" |
84 |
by (rule some_equality) (rule refl) |
|
14760 | 85 |
|
63612 | 86 |
lemma some_sym_eq_trivial [simp]: "(SOME y. x = y) = x" |
87 |
apply (rule some_equality) |
|
88 |
apply (rule refl) |
|
89 |
apply (erule sym) |
|
90 |
done |
|
14760 | 91 |
|
92 |
||
63612 | 93 |
subsection \<open>Axiom of Choice, Proved Using the Description Operator\<close> |
14760 | 94 |
|
63612 | 95 |
lemma choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" |
96 |
by (fast elim: someI) |
|
14760 | 97 |
|
63612 | 98 |
lemma bchoice: "\<forall>x\<in>S. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" |
99 |
by (fast elim: someI) |
|
14760 | 100 |
|
50105 | 101 |
lemma choice_iff: "(\<forall>x. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x. Q x (f x))" |
63612 | 102 |
by (fast elim: someI) |
50105 | 103 |
|
104 |
lemma choice_iff': "(\<forall>x. P x \<longrightarrow> (\<exists>y. Q x y)) \<longleftrightarrow> (\<exists>f. \<forall>x. P x \<longrightarrow> Q x (f x))" |
|
63612 | 105 |
by (fast elim: someI) |
50105 | 106 |
|
107 |
lemma bchoice_iff: "(\<forall>x\<in>S. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. Q x (f x))" |
|
63612 | 108 |
by (fast elim: someI) |
50105 | 109 |
|
110 |
lemma bchoice_iff': "(\<forall>x\<in>S. P x \<longrightarrow> (\<exists>y. Q x y)) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. P x \<longrightarrow> Q x (f x))" |
|
63612 | 111 |
by (fast elim: someI) |
14760 | 112 |
|
57275
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
113 |
lemma dependent_nat_choice: |
63612 | 114 |
assumes 1: "\<exists>x. P 0 x" |
115 |
and 2: "\<And>x n. P n x \<Longrightarrow> \<exists>y. P (Suc n) y \<and> Q n x y" |
|
57448
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
hoelzl
parents:
57275
diff
changeset
|
116 |
shows "\<exists>f. \<forall>n. P n (f n) \<and> Q n (f n) (f (Suc n))" |
57275
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
117 |
proof (intro exI allI conjI) |
63040 | 118 |
fix n |
119 |
define f where "f = rec_nat (SOME x. P 0 x) (\<lambda>n x. SOME y. P (Suc n) y \<and> Q n x y)" |
|
63612 | 120 |
then have "P 0 (f 0)" "\<And>n. P n (f n) \<Longrightarrow> P (Suc n) (f (Suc n)) \<and> Q n (f n) (f (Suc n))" |
121 |
using someI_ex[OF 1] someI_ex[OF 2] by simp_all |
|
57448
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
hoelzl
parents:
57275
diff
changeset
|
122 |
then show "P n (f n)" "Q n (f n) (f (Suc n))" |
57275
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
123 |
by (induct n) auto |
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
124 |
qed |
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
125 |
|
58074 | 126 |
|
60758 | 127 |
subsection \<open>Function Inverse\<close> |
14760 | 128 |
|
63612 | 129 |
lemma inv_def: "inv f = (\<lambda>y. SOME x. f x = y)" |
130 |
by (simp add: inv_into_def) |
|
33014 | 131 |
|
63612 | 132 |
lemma inv_into_into: "x \<in> f ` A \<Longrightarrow> inv_into A f x \<in> A" |
133 |
by (simp add: inv_into_def) (fast intro: someI2) |
|
14760 | 134 |
|
63612 | 135 |
lemma inv_identity [simp]: "inv (\<lambda>a. a) = (\<lambda>a. a)" |
63365 | 136 |
by (simp add: inv_def) |
137 |
||
63612 | 138 |
lemma inv_id [simp]: "inv id = id" |
63365 | 139 |
by (simp add: id_def) |
14760 | 140 |
|
63612 | 141 |
lemma inv_into_f_f [simp]: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> inv_into A f (f x) = x" |
142 |
by (simp add: inv_into_def inj_on_def) (blast intro: someI2) |
|
14760 | 143 |
|
63612 | 144 |
lemma inv_f_f: "inj f \<Longrightarrow> inv f (f x) = x" |
145 |
by simp |
|
32988 | 146 |
|
63612 | 147 |
lemma f_inv_into_f: "y : f`A \<Longrightarrow> f (inv_into A f y) = y" |
148 |
by (simp add: inv_into_def) (fast intro: someI2) |
|
32988 | 149 |
|
63612 | 150 |
lemma inv_into_f_eq: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> f x = y \<Longrightarrow> inv_into A f y = x" |
151 |
by (erule subst) (fast intro: inv_into_f_f) |
|
32988 | 152 |
|
63612 | 153 |
lemma inv_f_eq: "inj f \<Longrightarrow> f x = y \<Longrightarrow> inv f y = x" |
154 |
by (simp add:inv_into_f_eq) |
|
32988 | 155 |
|
63612 | 156 |
lemma inj_imp_inv_eq: "inj f \<Longrightarrow> \<forall>x. f (g x) = x \<Longrightarrow> inv f = g" |
44921 | 157 |
by (blast intro: inv_into_f_eq) |
14760 | 158 |
|
63612 | 159 |
text \<open>But is it useful?\<close> |
14760 | 160 |
lemma inj_transfer: |
63612 | 161 |
assumes inj: "inj f" |
162 |
and minor: "\<And>y. y \<in> range f \<Longrightarrow> P (inv f y)" |
|
14760 | 163 |
shows "P x" |
164 |
proof - |
|
165 |
have "f x \<in> range f" by auto |
|
63612 | 166 |
then have "P(inv f (f x))" by (rule minor) |
167 |
then show "P x" by (simp add: inv_into_f_f [OF inj]) |
|
14760 | 168 |
qed |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
169 |
|
63612 | 170 |
lemma inj_iff: "inj f \<longleftrightarrow> inv f \<circ> f = id" |
171 |
by (simp add: o_def fun_eq_iff) (blast intro: inj_on_inverseI inv_into_f_f) |
|
14760 | 172 |
|
63612 | 173 |
lemma inv_o_cancel[simp]: "inj f \<Longrightarrow> inv f \<circ> f = id" |
174 |
by (simp add: inj_iff) |
|
175 |
||
176 |
lemma o_inv_o_cancel[simp]: "inj f \<Longrightarrow> g \<circ> inv f \<circ> f = g" |
|
177 |
by (simp add: comp_assoc) |
|
23433 | 178 |
|
63612 | 179 |
lemma inv_into_image_cancel[simp]: "inj_on f A \<Longrightarrow> S \<subseteq> A \<Longrightarrow> inv_into A f ` f ` S = S" |
180 |
by (fastforce simp: image_def) |
|
23433 | 181 |
|
63612 | 182 |
lemma inj_imp_surj_inv: "inj f \<Longrightarrow> surj (inv f)" |
183 |
by (blast intro!: surjI inv_into_f_f) |
|
32988 | 184 |
|
63612 | 185 |
lemma surj_f_inv_f: "surj f \<Longrightarrow> f (inv f y) = y" |
186 |
by (simp add: f_inv_into_f) |
|
14760 | 187 |
|
33057 | 188 |
lemma inv_into_injective: |
189 |
assumes eq: "inv_into A f x = inv_into A f y" |
|
63612 | 190 |
and x: "x \<in> f`A" |
191 |
and y: "y \<in> f`A" |
|
192 |
shows "x = y" |
|
14760 | 193 |
proof - |
63612 | 194 |
from eq have "f (inv_into A f x) = f (inv_into A f y)" |
195 |
by simp |
|
196 |
with x y show ?thesis |
|
197 |
by (simp add: f_inv_into_f) |
|
14760 | 198 |
qed |
199 |
||
63612 | 200 |
lemma inj_on_inv_into: "B \<subseteq> f`A \<Longrightarrow> inj_on (inv_into A f) B" |
201 |
by (blast intro: inj_onI dest: inv_into_injective injD) |
|
32988 | 202 |
|
63612 | 203 |
lemma bij_betw_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (inv_into A f) B A" |
204 |
by (auto simp add: bij_betw_def inj_on_inv_into) |
|
14760 | 205 |
|
63612 | 206 |
lemma surj_imp_inj_inv: "surj f \<Longrightarrow> inj (inv f)" |
207 |
by (simp add: inj_on_inv_into) |
|
14760 | 208 |
|
63612 | 209 |
lemma surj_iff: "surj f \<longleftrightarrow> f \<circ> inv f = id" |
210 |
by (auto intro!: surjI simp: surj_f_inv_f fun_eq_iff[where 'b='a]) |
|
40702 | 211 |
|
212 |
lemma surj_iff_all: "surj f \<longleftrightarrow> (\<forall>x. f (inv f x) = x)" |
|
63612 | 213 |
by (simp add: o_def surj_iff fun_eq_iff) |
14760 | 214 |
|
63612 | 215 |
lemma surj_imp_inv_eq: "surj f \<Longrightarrow> \<forall>x. g (f x) = x \<Longrightarrow> inv f = g" |
216 |
apply (rule ext) |
|
217 |
apply (drule_tac x = "inv f x" in spec) |
|
218 |
apply (simp add: surj_f_inv_f) |
|
219 |
done |
|
14760 | 220 |
|
63612 | 221 |
lemma bij_imp_bij_inv: "bij f \<Longrightarrow> bij (inv f)" |
222 |
by (simp add: bij_def inj_imp_surj_inv surj_imp_inj_inv) |
|
12372 | 223 |
|
63612 | 224 |
lemma inv_equality: "(\<And>x. g (f x) = x) \<Longrightarrow> (\<And>y. f (g y) = y) \<Longrightarrow> inv f = g" |
225 |
by (rule ext) (auto simp add: inv_into_def) |
|
226 |
||
227 |
lemma inv_inv_eq: "bij f \<Longrightarrow> inv (inv f) = f" |
|
228 |
by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) |
|
14760 | 229 |
|
63612 | 230 |
text \<open> |
231 |
\<open>bij (inv f)\<close> implies little about \<open>f\<close>. Consider \<open>f :: bool \<Rightarrow> bool\<close> such |
|
232 |
that \<open>f True = f False = True\<close>. Then it ia consistent with axiom \<open>someI\<close> |
|
233 |
that \<open>inv f\<close> could be any function at all, including the identity function. |
|
234 |
If \<open>inv f = id\<close> then \<open>inv f\<close> is a bijection, but \<open>inj f\<close>, \<open>surj f\<close> and \<open>inv |
|
235 |
(inv f) = f\<close> all fail. |
|
236 |
\<close> |
|
14760 | 237 |
|
33057 | 238 |
lemma inv_into_comp: |
63612 | 239 |
"inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow> |
240 |
inv_into A (f \<circ> g) x = (inv_into A g \<circ> inv_into (g ` A) f) x" |
|
241 |
apply (rule inv_into_f_eq) |
|
242 |
apply (fast intro: comp_inj_on) |
|
243 |
apply (simp add: inv_into_into) |
|
244 |
apply (simp add: f_inv_into_f inv_into_into) |
|
245 |
done |
|
32988 | 246 |
|
63612 | 247 |
lemma o_inv_distrib: "bij f \<Longrightarrow> bij g \<Longrightarrow> inv (f \<circ> g) = inv g \<circ> inv f" |
248 |
by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) |
|
14760 | 249 |
|
63807 | 250 |
lemma image_f_inv_f: "surj f \<Longrightarrow> f ` (inv f ` A) = A" |
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61859
diff
changeset
|
251 |
by (simp add: surj_f_inv_f image_comp comp_def) |
14760 | 252 |
|
63612 | 253 |
lemma image_inv_f_f: "inj f \<Longrightarrow> inv f ` (f ` A) = A" |
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61859
diff
changeset
|
254 |
by simp |
14760 | 255 |
|
63612 | 256 |
lemma bij_image_Collect_eq: "bij f \<Longrightarrow> f ` Collect P = {y. P (inv f y)}" |
257 |
apply auto |
|
258 |
apply (force simp add: bij_is_inj) |
|
259 |
apply (blast intro: bij_is_surj [THEN surj_f_inv_f, symmetric]) |
|
260 |
done |
|
14760 | 261 |
|
63612 | 262 |
lemma bij_vimage_eq_inv_image: "bij f \<Longrightarrow> f -` A = inv f ` A" |
263 |
apply (auto simp add: bij_is_surj [THEN surj_f_inv_f]) |
|
264 |
apply (blast intro: bij_is_inj [THEN inv_into_f_f, symmetric]) |
|
265 |
done |
|
14760 | 266 |
|
31380 | 267 |
lemma finite_fun_UNIVD1: |
268 |
assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)" |
|
63612 | 269 |
and card: "card (UNIV :: 'b set) \<noteq> Suc 0" |
31380 | 270 |
shows "finite (UNIV :: 'a set)" |
271 |
proof - |
|
63630 | 272 |
let ?UNIV_b = "UNIV :: 'b set" |
273 |
from fin have "finite ?UNIV_b" |
|
63612 | 274 |
by (rule finite_fun_UNIVD2) |
63630 | 275 |
with card have "card ?UNIV_b \<ge> Suc (Suc 0)" |
276 |
by (cases "card ?UNIV_b") (auto simp: card_eq_0_iff) |
|
277 |
then have "card ?UNIV_b = Suc (Suc (card ?UNIV_b - Suc (Suc 0)))" |
|
278 |
by simp |
|
63629 | 279 |
then obtain b1 b2 :: 'b where b1b2: "b1 \<noteq> b2" |
280 |
by (auto simp: card_Suc_eq) |
|
63630 | 281 |
from fin have fin': "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1))" |
63612 | 282 |
by (rule finite_imageI) |
63630 | 283 |
have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1)" |
31380 | 284 |
proof (rule UNIV_eq_I) |
285 |
fix x :: 'a |
|
63612 | 286 |
from b1b2 have "x = inv (\<lambda>y. if y = x then b1 else b2) b1" |
287 |
by (simp add: inv_into_def) |
|
288 |
then show "x \<in> range (\<lambda>f::'a \<Rightarrow> 'b. inv f b1)" |
|
289 |
by blast |
|
31380 | 290 |
qed |
63630 | 291 |
with fin' show ?thesis |
63612 | 292 |
by simp |
31380 | 293 |
qed |
14760 | 294 |
|
60758 | 295 |
text \<open> |
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
296 |
Every infinite set contains a countable subset. More precisely we |
61799 | 297 |
show that a set \<open>S\<close> is infinite if and only if there exists an |
298 |
injective function from the naturals into \<open>S\<close>. |
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
299 |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
300 |
The ``only if'' direction is harder because it requires the |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
301 |
construction of a sequence of pairwise different elements of an |
61799 | 302 |
infinite set \<open>S\<close>. The idea is to construct a sequence of |
303 |
non-empty and infinite subsets of \<open>S\<close> obtained by successively |
|
304 |
removing elements of \<open>S\<close>. |
|
60758 | 305 |
\<close> |
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
306 |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
307 |
lemma infinite_countable_subset: |
63629 | 308 |
assumes inf: "\<not> finite S" |
309 |
shows "\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S" |
|
61799 | 310 |
\<comment> \<open>Courtesy of Stephan Merz\<close> |
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
311 |
proof - |
63040 | 312 |
define Sseq where "Sseq = rec_nat S (\<lambda>n T. T - {SOME e. e \<in> T})" |
313 |
define pick where "pick n = (SOME e. e \<in> Sseq n)" for n |
|
63540 | 314 |
have *: "Sseq n \<subseteq> S" "\<not> finite (Sseq n)" for n |
63612 | 315 |
by (induct n) (auto simp: Sseq_def inf) |
63540 | 316 |
then have **: "\<And>n. pick n \<in> Sseq n" |
55811 | 317 |
unfolding pick_def by (subst (asm) finite.simps) (auto simp add: ex_in_conv intro: someI_ex) |
63540 | 318 |
with * have "range pick \<subseteq> S" by auto |
63612 | 319 |
moreover have "pick n \<noteq> pick (n + Suc m)" for m n |
320 |
proof - |
|
63540 | 321 |
have "pick n \<notin> Sseq (n + Suc m)" |
322 |
by (induct m) (auto simp add: Sseq_def pick_def) |
|
63612 | 323 |
with ** show ?thesis by auto |
324 |
qed |
|
325 |
then have "inj pick" |
|
326 |
by (intro linorder_injI) (auto simp add: less_iff_Suc_add) |
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
327 |
ultimately show ?thesis by blast |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
328 |
qed |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
329 |
|
63629 | 330 |
lemma infinite_iff_countable_subset: "\<not> finite S \<longleftrightarrow> (\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S)" |
61799 | 331 |
\<comment> \<open>Courtesy of Stephan Merz\<close> |
55811 | 332 |
using finite_imageD finite_subset infinite_UNIV_char_0 infinite_countable_subset by auto |
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
333 |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
334 |
lemma image_inv_into_cancel: |
63612 | 335 |
assumes surj: "f`A = A'" |
336 |
and sub: "B' \<subseteq> A'" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
337 |
shows "f `((inv_into A f)`B') = B'" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
338 |
using assms |
63612 | 339 |
proof (auto simp: f_inv_into_f) |
340 |
let ?f' = "inv_into A f" |
|
341 |
fix a' |
|
342 |
assume *: "a' \<in> B'" |
|
343 |
with sub have "a' \<in> A'" by auto |
|
344 |
with surj have "a' = f (?f' a')" |
|
345 |
by (auto simp: f_inv_into_f) |
|
346 |
with * show "a' \<in> f ` (?f' ` B')" by blast |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
347 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
348 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
349 |
lemma inv_into_inv_into_eq: |
63612 | 350 |
assumes "bij_betw f A A'" |
351 |
and a: "a \<in> A" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
352 |
shows "inv_into A' (inv_into A f) a = f a" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
353 |
proof - |
63612 | 354 |
let ?f' = "inv_into A f" |
355 |
let ?f'' = "inv_into A' ?f'" |
|
356 |
from assms have *: "bij_betw ?f' A' A" |
|
357 |
by (auto simp: bij_betw_inv_into) |
|
358 |
with a obtain a' where a': "a' \<in> A'" "?f' a' = a" |
|
359 |
unfolding bij_betw_def by force |
|
360 |
with a * have "?f'' a = a'" |
|
361 |
by (auto simp: f_inv_into_f bij_betw_def) |
|
362 |
moreover from assms a' have "f a = a'" |
|
363 |
by (auto simp: bij_betw_def) |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
364 |
ultimately show "?f'' a = f a" by simp |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
365 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
366 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
367 |
lemma inj_on_iff_surj: |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
368 |
assumes "A \<noteq> {}" |
63629 | 369 |
shows "(\<exists>f. inj_on f A \<and> f ` A \<subseteq> A') \<longleftrightarrow> (\<exists>g. g ` A' = A)" |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
370 |
proof safe |
63612 | 371 |
fix f |
372 |
assume inj: "inj_on f A" and incl: "f ` A \<subseteq> A'" |
|
373 |
let ?phi = "\<lambda>a' a. a \<in> A \<and> f a = a'" |
|
374 |
let ?csi = "\<lambda>a. a \<in> A" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
375 |
let ?g = "\<lambda>a'. if a' \<in> f ` A then (SOME a. ?phi a' a) else (SOME a. ?csi a)" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
376 |
have "?g ` A' = A" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
377 |
proof |
63612 | 378 |
show "?g ` A' \<subseteq> A" |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
379 |
proof clarify |
63612 | 380 |
fix a' |
381 |
assume *: "a' \<in> A'" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
382 |
show "?g a' \<in> A" |
63612 | 383 |
proof (cases "a' \<in> f ` A") |
384 |
case True |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
385 |
then obtain a where "?phi a' a" by blast |
63612 | 386 |
then have "?phi a' (SOME a. ?phi a' a)" |
387 |
using someI[of "?phi a'" a] by blast |
|
388 |
with True show ?thesis by auto |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
389 |
next |
63612 | 390 |
case False |
391 |
with assms have "?csi (SOME a. ?csi a)" |
|
392 |
using someI_ex[of ?csi] by blast |
|
393 |
with False show ?thesis by auto |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
394 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
395 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
396 |
next |
63612 | 397 |
show "A \<subseteq> ?g ` A'" |
398 |
proof - |
|
399 |
have "?g (f a) = a \<and> f a \<in> A'" if a: "a \<in> A" for a |
|
400 |
proof - |
|
401 |
let ?b = "SOME aa. ?phi (f a) aa" |
|
402 |
from a have "?phi (f a) a" by auto |
|
403 |
then have *: "?phi (f a) ?b" |
|
404 |
using someI[of "?phi(f a)" a] by blast |
|
405 |
then have "?g (f a) = ?b" using a by auto |
|
406 |
moreover from inj * a have "a = ?b" |
|
407 |
by (auto simp add: inj_on_def) |
|
408 |
ultimately have "?g(f a) = a" by simp |
|
409 |
with incl a show ?thesis by auto |
|
410 |
qed |
|
411 |
then show ?thesis by force |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
412 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
413 |
qed |
63612 | 414 |
then show "\<exists>g. g ` A' = A" by blast |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
415 |
next |
63612 | 416 |
fix g |
417 |
let ?f = "inv_into A' g" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
418 |
have "inj_on ?f (g ` A')" |
63612 | 419 |
by (auto simp: inj_on_inv_into) |
420 |
moreover have "?f (g a') \<in> A'" if a': "a' \<in> A'" for a' |
|
421 |
proof - |
|
422 |
let ?phi = "\<lambda> b'. b' \<in> A' \<and> g b' = g a'" |
|
423 |
from a' have "?phi a'" by auto |
|
424 |
then have "?phi (SOME b'. ?phi b')" |
|
425 |
using someI[of ?phi] by blast |
|
426 |
then show ?thesis by (auto simp: inv_into_def) |
|
427 |
qed |
|
428 |
ultimately show "\<exists>f. inj_on f (g ` A') \<and> f ` g ` A' \<subseteq> A'" |
|
429 |
by auto |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
430 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
431 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
432 |
lemma Ex_inj_on_UNION_Sigma: |
63629 | 433 |
"\<exists>f. (inj_on f (\<Union>i \<in> I. A i) \<and> f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i))" |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
434 |
proof |
63612 | 435 |
let ?phi = "\<lambda>a i. i \<in> I \<and> a \<in> A i" |
436 |
let ?sm = "\<lambda>a. SOME i. ?phi a i" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
437 |
let ?f = "\<lambda>a. (?sm a, a)" |
63612 | 438 |
have "inj_on ?f (\<Union>i \<in> I. A i)" |
439 |
by (auto simp: inj_on_def) |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
440 |
moreover |
63612 | 441 |
have "?sm a \<in> I \<and> a \<in> A(?sm a)" if "i \<in> I" and "a \<in> A i" for i a |
442 |
using that someI[of "?phi a" i] by auto |
|
63629 | 443 |
then have "?f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i)" |
63612 | 444 |
by auto |
63629 | 445 |
ultimately show "inj_on ?f (\<Union>i \<in> I. A i) \<and> ?f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i)" |
63612 | 446 |
by auto |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
447 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
448 |
|
56608 | 449 |
lemma inv_unique_comp: |
450 |
assumes fg: "f \<circ> g = id" |
|
451 |
and gf: "g \<circ> f = id" |
|
452 |
shows "inv f = g" |
|
453 |
using fg gf inv_equality[of g f] by (auto simp add: fun_eq_iff) |
|
454 |
||
455 |
||
60758 | 456 |
subsection \<open>Other Consequences of Hilbert's Epsilon\<close> |
14760 | 457 |
|
60758 | 458 |
text \<open>Hilbert's Epsilon and the @{term split} Operator\<close> |
14760 | 459 |
|
63612 | 460 |
text \<open>Looping simprule!\<close> |
461 |
lemma split_paired_Eps: "(SOME x. P x) = (SOME (a, b). P (a, b))" |
|
26347 | 462 |
by simp |
14760 | 463 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61076
diff
changeset
|
464 |
lemma Eps_case_prod: "Eps (case_prod P) = (SOME xy. P (fst xy) (snd xy))" |
26347 | 465 |
by (simp add: split_def) |
14760 | 466 |
|
63612 | 467 |
lemma Eps_case_prod_eq [simp]: "(SOME (x', y'). x = x' \<and> y = y') = (x, y)" |
26347 | 468 |
by blast |
14760 | 469 |
|
470 |
||
63612 | 471 |
text \<open>A relation is wellfounded iff it has no infinite descending chain.\<close> |
63981 | 472 |
lemma wf_iff_no_infinite_down_chain: "wf r \<longleftrightarrow> (\<nexists>f. \<forall>i. (f (Suc i), f i) \<in> r)" |
473 |
(is "_ \<longleftrightarrow> \<not> ?ex") |
|
474 |
proof |
|
475 |
assume "wf r" |
|
476 |
show "\<not> ?ex" |
|
477 |
proof |
|
478 |
assume ?ex |
|
479 |
then obtain f where f: "(f (Suc i), f i) \<in> r" for i |
|
480 |
by blast |
|
481 |
from \<open>wf r\<close> have minimal: "x \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q" for x Q |
|
482 |
by (auto simp: wf_eq_minimal) |
|
483 |
let ?Q = "{w. \<exists>i. w = f i}" |
|
484 |
fix n |
|
485 |
have "f n \<in> ?Q" by blast |
|
486 |
from minimal [OF this] obtain j where "(y, f j) \<in> r \<Longrightarrow> y \<notin> ?Q" for y by blast |
|
487 |
with this [OF \<open>(f (Suc j), f j) \<in> r\<close>] have "f (Suc j) \<notin> ?Q" by simp |
|
488 |
then show False by blast |
|
489 |
qed |
|
490 |
next |
|
491 |
assume "\<not> ?ex" |
|
492 |
then show "wf r" |
|
493 |
proof (rule contrapos_np) |
|
494 |
assume "\<not> wf r" |
|
495 |
then obtain Q x where x: "x \<in> Q" and rec: "z \<in> Q \<Longrightarrow> \<exists>y. (y, z) \<in> r \<and> y \<in> Q" for z |
|
496 |
by (auto simp add: wf_eq_minimal) |
|
497 |
obtain descend :: "nat \<Rightarrow> 'a" |
|
498 |
where descend_0: "descend 0 = x" |
|
499 |
and descend_Suc: "descend (Suc n) = (SOME y. y \<in> Q \<and> (y, descend n) \<in> r)" for n |
|
500 |
by (rule that [of "rec_nat x (\<lambda>_ rec. (SOME y. y \<in> Q \<and> (y, rec) \<in> r))"]) simp_all |
|
501 |
have descend_Q: "descend n \<in> Q" for n |
|
502 |
proof (induct n) |
|
503 |
case 0 |
|
504 |
with x show ?case by (simp only: descend_0) |
|
505 |
next |
|
506 |
case Suc |
|
507 |
then show ?case by (simp only: descend_Suc) (rule someI2_ex; use rec in blast) |
|
508 |
qed |
|
509 |
have "(descend (Suc i), descend i) \<in> r" for i |
|
510 |
by (simp only: descend_Suc) (rule someI2_ex; use descend_Q rec in blast) |
|
511 |
then show "\<exists>f. \<forall>i. (f (Suc i), f i) \<in> r" by blast |
|
512 |
qed |
|
513 |
qed |
|
14760 | 514 |
|
27760 | 515 |
lemma wf_no_infinite_down_chainE: |
63612 | 516 |
assumes "wf r" |
517 |
obtains k where "(f (Suc k), f k) \<notin> r" |
|
518 |
using assms wf_iff_no_infinite_down_chain[of r] by blast |
|
27760 | 519 |
|
520 |
||
63612 | 521 |
text \<open>A dynamically-scoped fact for TFL\<close> |
522 |
lemma tfl_some: "\<forall>P x. P x \<longrightarrow> P (Eps P)" |
|
12298 | 523 |
by (blast intro: someI) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
524 |
|
12298 | 525 |
|
60758 | 526 |
subsection \<open>An aside: bounded accessible part\<close> |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
527 |
|
60758 | 528 |
text \<open>Finite monotone eventually stable sequences\<close> |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
529 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
530 |
lemma finite_mono_remains_stable_implies_strict_prefix: |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
531 |
fixes f :: "nat \<Rightarrow> 'a::order" |
63612 | 532 |
assumes S: "finite (range f)" "mono f" |
533 |
and eq: "\<forall>n. f n = f (Suc n) \<longrightarrow> f (Suc n) = f (Suc (Suc n))" |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
534 |
shows "\<exists>N. (\<forall>n\<le>N. \<forall>m\<le>N. m < n \<longrightarrow> f m < f n) \<and> (\<forall>n\<ge>N. f N = f n)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
535 |
using assms |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
536 |
proof - |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
537 |
have "\<exists>n. f n = f (Suc n)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
538 |
proof (rule ccontr) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
539 |
assume "\<not> ?thesis" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
540 |
then have "\<And>n. f n \<noteq> f (Suc n)" by auto |
63612 | 541 |
with \<open>mono f\<close> have "\<And>n. f n < f (Suc n)" |
542 |
by (auto simp: le_less mono_iff_le_Suc) |
|
543 |
with lift_Suc_mono_less_iff[of f] have *: "\<And>n m. n < m \<Longrightarrow> f n < f m" |
|
544 |
by auto |
|
55811 | 545 |
have "inj f" |
546 |
proof (intro injI) |
|
547 |
fix x y |
|
548 |
assume "f x = f y" |
|
63612 | 549 |
then show "x = y" |
550 |
by (cases x y rule: linorder_cases) (auto dest: *) |
|
55811 | 551 |
qed |
60758 | 552 |
with \<open>finite (range f)\<close> have "finite (UNIV::nat set)" |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
553 |
by (rule finite_imageD) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
554 |
then show False by simp |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
555 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
556 |
then obtain n where n: "f n = f (Suc n)" .. |
63040 | 557 |
define N where "N = (LEAST n. f n = f (Suc n))" |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
558 |
have N: "f N = f (Suc N)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
559 |
unfolding N_def using n by (rule LeastI) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
560 |
show ?thesis |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
561 |
proof (intro exI[of _ N] conjI allI impI) |
63612 | 562 |
fix n |
563 |
assume "N \<le> n" |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
564 |
then have "\<And>m. N \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m = f N" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
565 |
proof (induct rule: dec_induct) |
63612 | 566 |
case base |
567 |
then show ?case by simp |
|
568 |
next |
|
569 |
case (step n) |
|
570 |
then show ?case |
|
571 |
using eq [rule_format, of "n - 1"] N |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
572 |
by (cases n) (auto simp add: le_Suc_eq) |
63612 | 573 |
qed |
60758 | 574 |
from this[of n] \<open>N \<le> n\<close> show "f N = f n" by auto |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
575 |
next |
63612 | 576 |
fix n m :: nat |
577 |
assume "m < n" "n \<le> N" |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
578 |
then show "f m < f n" |
62683 | 579 |
proof (induct rule: less_Suc_induct) |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
580 |
case (1 i) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
581 |
then have "i < N" by simp |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
582 |
then have "f i \<noteq> f (Suc i)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
583 |
unfolding N_def by (rule not_less_Least) |
60758 | 584 |
with \<open>mono f\<close> show ?case by (simp add: mono_iff_le_Suc less_le) |
63612 | 585 |
next |
586 |
case 2 |
|
587 |
then show ?case by simp |
|
588 |
qed |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
589 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
590 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
591 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
592 |
lemma finite_mono_strict_prefix_implies_finite_fixpoint: |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
593 |
fixes f :: "nat \<Rightarrow> 'a set" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
594 |
assumes S: "\<And>i. f i \<subseteq> S" "finite S" |
63612 | 595 |
and ex: "\<exists>N. (\<forall>n\<le>N. \<forall>m\<le>N. m < n \<longrightarrow> f m \<subset> f n) \<and> (\<forall>n\<ge>N. f N = f n)" |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
596 |
shows "f (card S) = (\<Union>n. f n)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
597 |
proof - |
63612 | 598 |
from ex obtain N where inj: "\<And>n m. n \<le> N \<Longrightarrow> m \<le> N \<Longrightarrow> m < n \<Longrightarrow> f m \<subset> f n" |
599 |
and eq: "\<forall>n\<ge>N. f N = f n" |
|
600 |
by atomize auto |
|
601 |
have "i \<le> N \<Longrightarrow> i \<le> card (f i)" for i |
|
602 |
proof (induct i) |
|
603 |
case 0 |
|
604 |
then show ?case by simp |
|
605 |
next |
|
606 |
case (Suc i) |
|
607 |
with inj [of "Suc i" i] have "(f i) \<subset> (f (Suc i))" by auto |
|
608 |
moreover have "finite (f (Suc i))" using S by (rule finite_subset) |
|
609 |
ultimately have "card (f i) < card (f (Suc i))" by (intro psubset_card_mono) |
|
610 |
with Suc inj show ?case by auto |
|
611 |
qed |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
612 |
then have "N \<le> card (f N)" by simp |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
613 |
also have "\<dots> \<le> card S" using S by (intro card_mono) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
614 |
finally have "f (card S) = f N" using eq by auto |
63612 | 615 |
then show ?thesis |
616 |
using eq inj [of N] |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
617 |
apply auto |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
618 |
apply (case_tac "n < N") |
63612 | 619 |
apply (auto simp: not_less) |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
620 |
done |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
621 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
622 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
623 |
|
60758 | 624 |
subsection \<open>More on injections, bijections, and inverses\<close> |
55020 | 625 |
|
63374 | 626 |
locale bijection = |
627 |
fixes f :: "'a \<Rightarrow> 'a" |
|
628 |
assumes bij: "bij f" |
|
629 |
begin |
|
630 |
||
63612 | 631 |
lemma bij_inv: "bij (inv f)" |
63374 | 632 |
using bij by (rule bij_imp_bij_inv) |
633 |
||
63612 | 634 |
lemma surj [simp]: "surj f" |
63374 | 635 |
using bij by (rule bij_is_surj) |
636 |
||
63612 | 637 |
lemma inj: "inj f" |
63374 | 638 |
using bij by (rule bij_is_inj) |
639 |
||
63612 | 640 |
lemma surj_inv [simp]: "surj (inv f)" |
63374 | 641 |
using inj by (rule inj_imp_surj_inv) |
642 |
||
63612 | 643 |
lemma inj_inv: "inj (inv f)" |
63374 | 644 |
using surj by (rule surj_imp_inj_inv) |
645 |
||
63612 | 646 |
lemma eqI: "f a = f b \<Longrightarrow> a = b" |
63374 | 647 |
using inj by (rule injD) |
648 |
||
63612 | 649 |
lemma eq_iff [simp]: "f a = f b \<longleftrightarrow> a = b" |
63374 | 650 |
by (auto intro: eqI) |
651 |
||
63612 | 652 |
lemma eq_invI: "inv f a = inv f b \<Longrightarrow> a = b" |
63374 | 653 |
using inj_inv by (rule injD) |
654 |
||
63612 | 655 |
lemma eq_inv_iff [simp]: "inv f a = inv f b \<longleftrightarrow> a = b" |
63374 | 656 |
by (auto intro: eq_invI) |
657 |
||
63612 | 658 |
lemma inv_left [simp]: "inv f (f a) = a" |
63374 | 659 |
using inj by (simp add: inv_f_eq) |
660 |
||
63612 | 661 |
lemma inv_comp_left [simp]: "inv f \<circ> f = id" |
63374 | 662 |
by (simp add: fun_eq_iff) |
663 |
||
63612 | 664 |
lemma inv_right [simp]: "f (inv f a) = a" |
63374 | 665 |
using surj by (simp add: surj_f_inv_f) |
666 |
||
63612 | 667 |
lemma inv_comp_right [simp]: "f \<circ> inv f = id" |
63374 | 668 |
by (simp add: fun_eq_iff) |
669 |
||
63612 | 670 |
lemma inv_left_eq_iff [simp]: "inv f a = b \<longleftrightarrow> f b = a" |
63374 | 671 |
by auto |
672 |
||
63612 | 673 |
lemma inv_right_eq_iff [simp]: "b = inv f a \<longleftrightarrow> f b = a" |
63374 | 674 |
by auto |
675 |
||
676 |
end |
|
677 |
||
55020 | 678 |
lemma infinite_imp_bij_betw: |
63612 | 679 |
assumes infinite: "\<not> finite A" |
680 |
shows "\<exists>h. bij_betw h A (A - {a})" |
|
681 |
proof (cases "a \<in> A") |
|
682 |
case False |
|
683 |
then have "A - {a} = A" by blast |
|
684 |
then show ?thesis |
|
685 |
using bij_betw_id[of A] by auto |
|
55020 | 686 |
next |
63612 | 687 |
case True |
688 |
with infinite have "\<not> finite (A - {a})" by auto |
|
689 |
with infinite_iff_countable_subset[of "A - {a}"] |
|
690 |
obtain f :: "nat \<Rightarrow> 'a" where 1: "inj f" and 2: "f ` UNIV \<subseteq> A - {a}" by blast |
|
691 |
define g where "g n = (if n = 0 then a else f (Suc n))" for n |
|
692 |
define A' where "A' = g ` UNIV" |
|
693 |
have *: "\<forall>y. f y \<noteq> a" using 2 by blast |
|
694 |
have 3: "inj_on g UNIV \<and> g ` UNIV \<subseteq> A \<and> a \<in> g ` UNIV" |
|
695 |
apply (auto simp add: True g_def [abs_def]) |
|
696 |
apply (unfold inj_on_def) |
|
697 |
apply (intro ballI impI) |
|
698 |
apply (case_tac "x = 0") |
|
699 |
apply (auto simp add: 2) |
|
700 |
proof - |
|
701 |
fix y |
|
702 |
assume "a = (if y = 0 then a else f (Suc y))" |
|
703 |
then show "y = 0" by (cases "y = 0") (use * in auto) |
|
55020 | 704 |
next |
705 |
fix x y |
|
706 |
assume "f (Suc x) = (if y = 0 then a else f (Suc y))" |
|
63612 | 707 |
with 1 * show "x = y" by (cases "y = 0") (auto simp: inj_on_def) |
55020 | 708 |
next |
63612 | 709 |
fix n |
710 |
from 2 show "f (Suc n) \<in> A" by blast |
|
55020 | 711 |
qed |
63612 | 712 |
then have 4: "bij_betw g UNIV A' \<and> a \<in> A' \<and> A' \<subseteq> A" |
713 |
using inj_on_imp_bij_betw[of g] by (auto simp: A'_def) |
|
714 |
then have 5: "bij_betw (inv g) A' UNIV" |
|
715 |
by (auto simp add: bij_betw_inv_into) |
|
716 |
from 3 obtain n where n: "g n = a" by auto |
|
717 |
have 6: "bij_betw g (UNIV - {n}) (A' - {a})" |
|
718 |
by (rule bij_betw_subset) (use 3 4 n in \<open>auto simp: image_set_diff A'_def\<close>) |
|
719 |
define v where "v m = (if m < n then m else Suc m)" for m |
|
55020 | 720 |
have 7: "bij_betw v UNIV (UNIV - {n})" |
63612 | 721 |
proof (unfold bij_betw_def inj_on_def, intro conjI, clarify) |
722 |
fix m1 m2 |
|
723 |
assume "v m1 = v m2" |
|
724 |
then show "m1 = m2" |
|
725 |
apply (cases "m1 < n") |
|
726 |
apply (cases "m2 < n") |
|
727 |
apply (auto simp: inj_on_def v_def [abs_def]) |
|
728 |
apply (cases "m2 < n") |
|
729 |
apply auto |
|
730 |
done |
|
55020 | 731 |
next |
732 |
show "v ` UNIV = UNIV - {n}" |
|
63612 | 733 |
proof (auto simp: v_def [abs_def]) |
734 |
fix m |
|
735 |
assume "m \<noteq> n" |
|
736 |
assume *: "m \<notin> Suc ` {m'. \<not> m' < n}" |
|
737 |
have False if "n \<le> m" |
|
738 |
proof - |
|
739 |
from \<open>m \<noteq> n\<close> that have **: "Suc n \<le> m" by auto |
|
740 |
from Suc_le_D [OF this] obtain m' where m': "m = Suc m'" .. |
|
741 |
with ** have "n \<le> m'" by auto |
|
742 |
with m' * show ?thesis by auto |
|
743 |
qed |
|
744 |
then show "m < n" by force |
|
55020 | 745 |
qed |
746 |
qed |
|
63612 | 747 |
define h' where "h' = g \<circ> v \<circ> (inv g)" |
748 |
with 5 6 7 have 8: "bij_betw h' A' (A' - {a})" |
|
749 |
by (auto simp add: bij_betw_trans) |
|
750 |
define h where "h b = (if b \<in> A' then h' b else b)" for b |
|
751 |
then have "\<forall>b \<in> A'. h b = h' b" by simp |
|
752 |
with 8 have "bij_betw h A' (A' - {a})" |
|
753 |
using bij_betw_cong[of A' h] by auto |
|
55020 | 754 |
moreover |
63612 | 755 |
have "\<forall>b \<in> A - A'. h b = b" by (auto simp: h_def) |
756 |
then have "bij_betw h (A - A') (A - A')" |
|
757 |
using bij_betw_cong[of "A - A'" h id] bij_betw_id[of "A - A'"] by auto |
|
55020 | 758 |
moreover |
63612 | 759 |
from 4 have "(A' \<inter> (A - A') = {} \<and> A' \<union> (A - A') = A) \<and> |
760 |
((A' - {a}) \<inter> (A - A') = {} \<and> (A' - {a}) \<union> (A - A') = A - {a})" |
|
761 |
by blast |
|
55020 | 762 |
ultimately have "bij_betw h A (A - {a})" |
63612 | 763 |
using bij_betw_combine[of h A' "A' - {a}" "A - A'" "A - A'"] by simp |
764 |
then show ?thesis by blast |
|
55020 | 765 |
qed |
766 |
||
767 |
lemma infinite_imp_bij_betw2: |
|
63612 | 768 |
assumes "\<not> finite A" |
769 |
shows "\<exists>h. bij_betw h A (A \<union> {a})" |
|
770 |
proof (cases "a \<in> A") |
|
771 |
case True |
|
772 |
then have "A \<union> {a} = A" by blast |
|
773 |
then show ?thesis using bij_betw_id[of A] by auto |
|
55020 | 774 |
next |
63612 | 775 |
case False |
55020 | 776 |
let ?A' = "A \<union> {a}" |
63612 | 777 |
from False have "A = ?A' - {a}" by blast |
778 |
moreover from assms have "\<not> finite ?A'" by auto |
|
55020 | 779 |
ultimately obtain f where "bij_betw f ?A' A" |
63612 | 780 |
using infinite_imp_bij_betw[of ?A' a] by auto |
781 |
then have "bij_betw (inv_into ?A' f) A ?A'" by (rule bij_betw_inv_into) |
|
782 |
then show ?thesis by auto |
|
55020 | 783 |
qed |
784 |
||
63612 | 785 |
lemma bij_betw_inv_into_left: "bij_betw f A A' \<Longrightarrow> a \<in> A \<Longrightarrow> inv_into A f (f a) = a" |
786 |
unfolding bij_betw_def by clarify (rule inv_into_f_f) |
|
55020 | 787 |
|
63612 | 788 |
lemma bij_betw_inv_into_right: "bij_betw f A A' \<Longrightarrow> a' \<in> A' \<Longrightarrow> f (inv_into A f a') = a'" |
789 |
unfolding bij_betw_def using f_inv_into_f by force |
|
55020 | 790 |
|
791 |
lemma bij_betw_inv_into_subset: |
|
63612 | 792 |
"bij_betw f A A' \<Longrightarrow> B \<subseteq> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw (inv_into A f) B' B" |
793 |
by (auto simp: bij_betw_def intro: inj_on_inv_into) |
|
55020 | 794 |
|
795 |
||
60758 | 796 |
subsection \<open>Specification package -- Hilbertized version\<close> |
17893
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
wenzelm
parents:
17702
diff
changeset
|
797 |
|
63612 | 798 |
lemma exE_some: "Ex P \<Longrightarrow> c \<equiv> Eps P \<Longrightarrow> P c" |
17893
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
wenzelm
parents:
17702
diff
changeset
|
799 |
by (simp only: someI_ex) |
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
wenzelm
parents:
17702
diff
changeset
|
800 |
|
48891 | 801 |
ML_file "Tools/choice_specification.ML" |
14115 | 802 |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
803 |
end |