author | wenzelm |
Fri, 05 Aug 2016 18:14:28 +0200 | |
changeset 63612 | 7195acc2fe93 |
parent 63540 | f8652d0534fa |
child 63629 | 3b3ab4674274 |
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 |
|
63612 | 33 |
definition inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" |
34 |
where "inv_into A f \<equiv> \<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 |
|
63612 | 36 |
abbreviation inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" |
37 |
where "inv \<equiv> inv_into UNIV" |
|
14760 | 38 |
|
39 |
||
60758 | 40 |
subsection \<open>Hilbert's Epsilon-operator\<close> |
14760 | 41 |
|
63612 | 42 |
text \<open> |
43 |
Easier to apply than \<open>someI\<close> if the witness comes from an |
|
44 |
existential formula. |
|
45 |
\<close> |
|
46 |
lemma someI_ex [elim?]: "\<exists>x. P x \<Longrightarrow> P (SOME x. P x)" |
|
47 |
apply (erule exE) |
|
48 |
apply (erule someI) |
|
49 |
done |
|
14760 | 50 |
|
63612 | 51 |
text \<open> |
52 |
Easier to apply than \<open>someI\<close> because the conclusion has only one |
|
53 |
occurrence of @{term P}. |
|
54 |
\<close> |
|
55 |
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
|
56 |
by (blast intro: someI) |
14760 | 57 |
|
63612 | 58 |
text \<open> |
59 |
Easier to apply than \<open>someI2\<close> if the witness comes from an |
|
60 |
existential formula. |
|
61 |
\<close> |
|
62 |
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
|
63 |
by (blast intro: someI2) |
14760 | 64 |
|
63612 | 65 |
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)" |
66 |
by (blast intro: someI2) |
|
67 |
||
68 |
lemma some_equality [intro]: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> x = a) \<Longrightarrow> (SOME x. P x) = a" |
|
69 |
by (blast intro: someI2) |
|
14760 | 70 |
|
63612 | 71 |
lemma some1_equality: "EX!x. P x \<Longrightarrow> P a \<Longrightarrow> (SOME x. P x) = a" |
72 |
by blast |
|
14760 | 73 |
|
63612 | 74 |
lemma some_eq_ex: "P (SOME x. P x) \<longleftrightarrow> (\<exists>x. P x)" |
75 |
by (blast intro: someI) |
|
14760 | 76 |
|
59000 | 77 |
lemma some_in_eq: "(SOME x. x \<in> A) \<in> A \<longleftrightarrow> A \<noteq> {}" |
78 |
unfolding ex_in_conv[symmetric] by (rule some_eq_ex) |
|
79 |
||
63612 | 80 |
lemma some_eq_trivial [simp]: "(SOME y. y = x) = x" |
81 |
by (rule some_equality) (rule refl) |
|
14760 | 82 |
|
63612 | 83 |
lemma some_sym_eq_trivial [simp]: "(SOME y. x = y) = x" |
84 |
apply (rule some_equality) |
|
85 |
apply (rule refl) |
|
86 |
apply (erule sym) |
|
87 |
done |
|
14760 | 88 |
|
89 |
||
63612 | 90 |
subsection \<open>Axiom of Choice, Proved Using the Description Operator\<close> |
14760 | 91 |
|
63612 | 92 |
lemma choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" |
93 |
by (fast elim: someI) |
|
14760 | 94 |
|
63612 | 95 |
lemma bchoice: "\<forall>x\<in>S. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" |
96 |
by (fast elim: someI) |
|
14760 | 97 |
|
50105 | 98 |
lemma choice_iff: "(\<forall>x. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x. Q x (f x))" |
63612 | 99 |
by (fast elim: someI) |
50105 | 100 |
|
101 |
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 | 102 |
by (fast elim: someI) |
50105 | 103 |
|
104 |
lemma bchoice_iff: "(\<forall>x\<in>S. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. Q x (f x))" |
|
63612 | 105 |
by (fast elim: someI) |
50105 | 106 |
|
107 |
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 | 108 |
by (fast elim: someI) |
14760 | 109 |
|
57275
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
110 |
lemma dependent_nat_choice: |
63612 | 111 |
assumes 1: "\<exists>x. P 0 x" |
112 |
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
|
113 |
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
|
114 |
proof (intro exI allI conjI) |
63040 | 115 |
fix n |
116 |
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 | 117 |
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))" |
118 |
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
|
119 |
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
|
120 |
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
|
121 |
qed |
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56740
diff
changeset
|
122 |
|
58074 | 123 |
|
60758 | 124 |
subsection \<open>Function Inverse\<close> |
14760 | 125 |
|
63612 | 126 |
lemma inv_def: "inv f = (\<lambda>y. SOME x. f x = y)" |
127 |
by (simp add: inv_into_def) |
|
33014 | 128 |
|
63612 | 129 |
lemma inv_into_into: "x \<in> f ` A \<Longrightarrow> inv_into A f x \<in> A" |
130 |
by (simp add: inv_into_def) (fast intro: someI2) |
|
14760 | 131 |
|
63612 | 132 |
lemma inv_identity [simp]: "inv (\<lambda>a. a) = (\<lambda>a. a)" |
63365 | 133 |
by (simp add: inv_def) |
134 |
||
63612 | 135 |
lemma inv_id [simp]: "inv id = id" |
63365 | 136 |
by (simp add: id_def) |
14760 | 137 |
|
63612 | 138 |
lemma inv_into_f_f [simp]: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> inv_into A f (f x) = x" |
139 |
by (simp add: inv_into_def inj_on_def) (blast intro: someI2) |
|
14760 | 140 |
|
63612 | 141 |
lemma inv_f_f: "inj f \<Longrightarrow> inv f (f x) = x" |
142 |
by simp |
|
32988 | 143 |
|
63612 | 144 |
lemma f_inv_into_f: "y : f`A \<Longrightarrow> f (inv_into A f y) = y" |
145 |
by (simp add: inv_into_def) (fast intro: someI2) |
|
32988 | 146 |
|
63612 | 147 |
lemma inv_into_f_eq: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> f x = y \<Longrightarrow> inv_into A f y = x" |
148 |
by (erule subst) (fast intro: inv_into_f_f) |
|
32988 | 149 |
|
63612 | 150 |
lemma inv_f_eq: "inj f \<Longrightarrow> f x = y \<Longrightarrow> inv f y = x" |
151 |
by (simp add:inv_into_f_eq) |
|
32988 | 152 |
|
63612 | 153 |
lemma inj_imp_inv_eq: "inj f \<Longrightarrow> \<forall>x. f (g x) = x \<Longrightarrow> inv f = g" |
44921 | 154 |
by (blast intro: inv_into_f_eq) |
14760 | 155 |
|
63612 | 156 |
text \<open>But is it useful?\<close> |
14760 | 157 |
lemma inj_transfer: |
63612 | 158 |
assumes inj: "inj f" |
159 |
and minor: "\<And>y. y \<in> range f \<Longrightarrow> P (inv f y)" |
|
14760 | 160 |
shows "P x" |
161 |
proof - |
|
162 |
have "f x \<in> range f" by auto |
|
63612 | 163 |
then have "P(inv f (f x))" by (rule minor) |
164 |
then show "P x" by (simp add: inv_into_f_f [OF inj]) |
|
14760 | 165 |
qed |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
166 |
|
63612 | 167 |
lemma inj_iff: "inj f \<longleftrightarrow> inv f \<circ> f = id" |
168 |
by (simp add: o_def fun_eq_iff) (blast intro: inj_on_inverseI inv_into_f_f) |
|
14760 | 169 |
|
63612 | 170 |
lemma inv_o_cancel[simp]: "inj f \<Longrightarrow> inv f \<circ> f = id" |
171 |
by (simp add: inj_iff) |
|
172 |
||
173 |
lemma o_inv_o_cancel[simp]: "inj f \<Longrightarrow> g \<circ> inv f \<circ> f = g" |
|
174 |
by (simp add: comp_assoc) |
|
23433 | 175 |
|
63612 | 176 |
lemma inv_into_image_cancel[simp]: "inj_on f A \<Longrightarrow> S \<subseteq> A \<Longrightarrow> inv_into A f ` f ` S = S" |
177 |
by (fastforce simp: image_def) |
|
23433 | 178 |
|
63612 | 179 |
lemma inj_imp_surj_inv: "inj f \<Longrightarrow> surj (inv f)" |
180 |
by (blast intro!: surjI inv_into_f_f) |
|
32988 | 181 |
|
63612 | 182 |
lemma surj_f_inv_f: "surj f \<Longrightarrow> f (inv f y) = y" |
183 |
by (simp add: f_inv_into_f) |
|
14760 | 184 |
|
33057 | 185 |
lemma inv_into_injective: |
186 |
assumes eq: "inv_into A f x = inv_into A f y" |
|
63612 | 187 |
and x: "x \<in> f`A" |
188 |
and y: "y \<in> f`A" |
|
189 |
shows "x = y" |
|
14760 | 190 |
proof - |
63612 | 191 |
from eq have "f (inv_into A f x) = f (inv_into A f y)" |
192 |
by simp |
|
193 |
with x y show ?thesis |
|
194 |
by (simp add: f_inv_into_f) |
|
14760 | 195 |
qed |
196 |
||
63612 | 197 |
lemma inj_on_inv_into: "B \<subseteq> f`A \<Longrightarrow> inj_on (inv_into A f) B" |
198 |
by (blast intro: inj_onI dest: inv_into_injective injD) |
|
32988 | 199 |
|
63612 | 200 |
lemma bij_betw_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (inv_into A f) B A" |
201 |
by (auto simp add: bij_betw_def inj_on_inv_into) |
|
14760 | 202 |
|
63612 | 203 |
lemma surj_imp_inj_inv: "surj f \<Longrightarrow> inj (inv f)" |
204 |
by (simp add: inj_on_inv_into) |
|
14760 | 205 |
|
63612 | 206 |
lemma surj_iff: "surj f \<longleftrightarrow> f \<circ> inv f = id" |
207 |
by (auto intro!: surjI simp: surj_f_inv_f fun_eq_iff[where 'b='a]) |
|
40702 | 208 |
|
209 |
lemma surj_iff_all: "surj f \<longleftrightarrow> (\<forall>x. f (inv f x) = x)" |
|
63612 | 210 |
by (simp add: o_def surj_iff fun_eq_iff) |
14760 | 211 |
|
63612 | 212 |
lemma surj_imp_inv_eq: "surj f \<Longrightarrow> \<forall>x. g (f x) = x \<Longrightarrow> inv f = g" |
213 |
apply (rule ext) |
|
214 |
apply (drule_tac x = "inv f x" in spec) |
|
215 |
apply (simp add: surj_f_inv_f) |
|
216 |
done |
|
14760 | 217 |
|
63612 | 218 |
lemma bij_imp_bij_inv: "bij f \<Longrightarrow> bij (inv f)" |
219 |
by (simp add: bij_def inj_imp_surj_inv surj_imp_inj_inv) |
|
12372 | 220 |
|
63612 | 221 |
lemma inv_equality: "(\<And>x. g (f x) = x) \<Longrightarrow> (\<And>y. f (g y) = y) \<Longrightarrow> inv f = g" |
222 |
by (rule ext) (auto simp add: inv_into_def) |
|
223 |
||
224 |
lemma inv_inv_eq: "bij f \<Longrightarrow> inv (inv f) = f" |
|
225 |
by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) |
|
14760 | 226 |
|
63612 | 227 |
text \<open> |
228 |
\<open>bij (inv f)\<close> implies little about \<open>f\<close>. Consider \<open>f :: bool \<Rightarrow> bool\<close> such |
|
229 |
that \<open>f True = f False = True\<close>. Then it ia consistent with axiom \<open>someI\<close> |
|
230 |
that \<open>inv f\<close> could be any function at all, including the identity function. |
|
231 |
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 |
|
232 |
(inv f) = f\<close> all fail. |
|
233 |
\<close> |
|
14760 | 234 |
|
33057 | 235 |
lemma inv_into_comp: |
63612 | 236 |
"inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow> |
237 |
inv_into A (f \<circ> g) x = (inv_into A g \<circ> inv_into (g ` A) f) x" |
|
238 |
apply (rule inv_into_f_eq) |
|
239 |
apply (fast intro: comp_inj_on) |
|
240 |
apply (simp add: inv_into_into) |
|
241 |
apply (simp add: f_inv_into_f inv_into_into) |
|
242 |
done |
|
32988 | 243 |
|
63612 | 244 |
lemma o_inv_distrib: "bij f \<Longrightarrow> bij g \<Longrightarrow> inv (f \<circ> g) = inv g \<circ> inv f" |
245 |
by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) |
|
14760 | 246 |
|
63612 | 247 |
lemma image_surj_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
|
248 |
by (simp add: surj_f_inv_f image_comp comp_def) |
14760 | 249 |
|
63612 | 250 |
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
|
251 |
by simp |
14760 | 252 |
|
63612 | 253 |
lemma inv_image_comp: "inj f \<Longrightarrow> inv f ` (f ` X) = X" |
56740 | 254 |
by (fact image_inv_f_f) |
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 - |
|
63612 | 272 |
from fin have finb: "finite (UNIV :: 'b set)" |
273 |
by (rule finite_fun_UNIVD2) |
|
31380 | 274 |
with card have "card (UNIV :: 'b set) \<ge> Suc (Suc 0)" |
275 |
by (cases "card (UNIV :: 'b set)") (auto simp add: card_eq_0_iff) |
|
63612 | 276 |
then obtain n where "card (UNIV :: 'b set) = Suc (Suc n)" "n = card (UNIV :: 'b set) - Suc (Suc 0)" |
277 |
by auto |
|
278 |
then obtain b1 b2 where b1b2: "(b1 :: 'b) \<noteq> (b2 :: 'b)" |
|
279 |
by (auto simp add: card_Suc_eq) |
|
280 |
from fin have "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1))" |
|
281 |
by (rule finite_imageI) |
|
31380 | 282 |
moreover have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1)" |
283 |
proof (rule UNIV_eq_I) |
|
284 |
fix x :: 'a |
|
63612 | 285 |
from b1b2 have "x = inv (\<lambda>y. if y = x then b1 else b2) b1" |
286 |
by (simp add: inv_into_def) |
|
287 |
then show "x \<in> range (\<lambda>f::'a \<Rightarrow> 'b. inv f b1)" |
|
288 |
by blast |
|
31380 | 289 |
qed |
63612 | 290 |
ultimately show "finite (UNIV :: 'a set)" |
291 |
by simp |
|
31380 | 292 |
qed |
14760 | 293 |
|
60758 | 294 |
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
|
295 |
Every infinite set contains a countable subset. More precisely we |
61799 | 296 |
show that a set \<open>S\<close> is infinite if and only if there exists an |
297 |
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
|
298 |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
299 |
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
|
300 |
construction of a sequence of pairwise different elements of an |
61799 | 301 |
infinite set \<open>S\<close>. The idea is to construct a sequence of |
302 |
non-empty and infinite subsets of \<open>S\<close> obtained by successively |
|
303 |
removing elements of \<open>S\<close>. |
|
60758 | 304 |
\<close> |
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
305 |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
306 |
lemma infinite_countable_subset: |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
307 |
assumes inf: "\<not> finite (S::'a set)" |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
308 |
shows "\<exists>f. inj (f::nat \<Rightarrow> 'a) \<and> range f \<subseteq> S" |
61799 | 309 |
\<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
|
310 |
proof - |
63040 | 311 |
define Sseq where "Sseq = rec_nat S (\<lambda>n T. T - {SOME e. e \<in> T})" |
312 |
define pick where "pick n = (SOME e. e \<in> Sseq n)" for n |
|
63540 | 313 |
have *: "Sseq n \<subseteq> S" "\<not> finite (Sseq n)" for n |
63612 | 314 |
by (induct n) (auto simp: Sseq_def inf) |
63540 | 315 |
then have **: "\<And>n. pick n \<in> Sseq n" |
55811 | 316 |
unfolding pick_def by (subst (asm) finite.simps) (auto simp add: ex_in_conv intro: someI_ex) |
63540 | 317 |
with * have "range pick \<subseteq> S" by auto |
63612 | 318 |
moreover have "pick n \<noteq> pick (n + Suc m)" for m n |
319 |
proof - |
|
63540 | 320 |
have "pick n \<notin> Sseq (n + Suc m)" |
321 |
by (induct m) (auto simp add: Sseq_def pick_def) |
|
63612 | 322 |
with ** show ?thesis by auto |
323 |
qed |
|
324 |
then have "inj pick" |
|
325 |
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
|
326 |
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
|
327 |
qed |
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
328 |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54295
diff
changeset
|
329 |
lemma infinite_iff_countable_subset: "\<not> finite S \<longleftrightarrow> (\<exists>f. inj (f::nat \<Rightarrow> 'a) \<and> range f \<subseteq> S)" |
61799 | 330 |
\<comment> \<open>Courtesy of Stephan Merz\<close> |
55811 | 331 |
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
|
332 |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
333 |
lemma image_inv_into_cancel: |
63612 | 334 |
assumes surj: "f`A = A'" |
335 |
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
|
336 |
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
|
337 |
using assms |
63612 | 338 |
proof (auto simp: f_inv_into_f) |
339 |
let ?f' = "inv_into A f" |
|
340 |
fix a' |
|
341 |
assume *: "a' \<in> B'" |
|
342 |
with sub have "a' \<in> A'" by auto |
|
343 |
with surj have "a' = f (?f' a')" |
|
344 |
by (auto simp: f_inv_into_f) |
|
345 |
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
|
346 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
347 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
348 |
lemma inv_into_inv_into_eq: |
63612 | 349 |
assumes "bij_betw f A A'" |
350 |
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
|
351 |
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
|
352 |
proof - |
63612 | 353 |
let ?f' = "inv_into A f" |
354 |
let ?f'' = "inv_into A' ?f'" |
|
355 |
from assms have *: "bij_betw ?f' A' A" |
|
356 |
by (auto simp: bij_betw_inv_into) |
|
357 |
with a obtain a' where a': "a' \<in> A'" "?f' a' = a" |
|
358 |
unfolding bij_betw_def by force |
|
359 |
with a * have "?f'' a = a'" |
|
360 |
by (auto simp: f_inv_into_f bij_betw_def) |
|
361 |
moreover from assms a' have "f a = a'" |
|
362 |
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
|
363 |
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
|
364 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
365 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
366 |
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
|
367 |
assumes "A \<noteq> {}" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
368 |
shows "(\<exists>f. inj_on f A \<and> f ` A \<le> A') \<longleftrightarrow> (\<exists>g. 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
|
369 |
proof safe |
63612 | 370 |
fix f |
371 |
assume inj: "inj_on f A" and incl: "f ` A \<subseteq> A'" |
|
372 |
let ?phi = "\<lambda>a' a. a \<in> A \<and> f a = a'" |
|
373 |
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
|
374 |
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
|
375 |
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
|
376 |
proof |
63612 | 377 |
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
|
378 |
proof clarify |
63612 | 379 |
fix a' |
380 |
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
|
381 |
show "?g a' \<in> A" |
63612 | 382 |
proof (cases "a' \<in> f ` A") |
383 |
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
|
384 |
then obtain a where "?phi a' a" by blast |
63612 | 385 |
then have "?phi a' (SOME a. ?phi a' a)" |
386 |
using someI[of "?phi a'" a] by blast |
|
387 |
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
|
388 |
next |
63612 | 389 |
case False |
390 |
with assms have "?csi (SOME a. ?csi a)" |
|
391 |
using someI_ex[of ?csi] by blast |
|
392 |
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
|
393 |
qed |
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 |
next |
63612 | 396 |
show "A \<subseteq> ?g ` A'" |
397 |
proof - |
|
398 |
have "?g (f a) = a \<and> f a \<in> A'" if a: "a \<in> A" for a |
|
399 |
proof - |
|
400 |
let ?b = "SOME aa. ?phi (f a) aa" |
|
401 |
from a have "?phi (f a) a" by auto |
|
402 |
then have *: "?phi (f a) ?b" |
|
403 |
using someI[of "?phi(f a)" a] by blast |
|
404 |
then have "?g (f a) = ?b" using a by auto |
|
405 |
moreover from inj * a have "a = ?b" |
|
406 |
by (auto simp add: inj_on_def) |
|
407 |
ultimately have "?g(f a) = a" by simp |
|
408 |
with incl a show ?thesis by auto |
|
409 |
qed |
|
410 |
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
|
411 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
412 |
qed |
63612 | 413 |
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
|
414 |
next |
63612 | 415 |
fix g |
416 |
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
|
417 |
have "inj_on ?f (g ` A')" |
63612 | 418 |
by (auto simp: inj_on_inv_into) |
419 |
moreover have "?f (g a') \<in> A'" if a': "a' \<in> A'" for a' |
|
420 |
proof - |
|
421 |
let ?phi = "\<lambda> b'. b' \<in> A' \<and> g b' = g a'" |
|
422 |
from a' have "?phi a'" by auto |
|
423 |
then have "?phi (SOME b'. ?phi b')" |
|
424 |
using someI[of ?phi] by blast |
|
425 |
then show ?thesis by (auto simp: inv_into_def) |
|
426 |
qed |
|
427 |
ultimately show "\<exists>f. inj_on f (g ` A') \<and> f ` g ` A' \<subseteq> A'" |
|
428 |
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
|
429 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
430 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
431 |
lemma Ex_inj_on_UNION_Sigma: |
60585 | 432 |
"\<exists>f. (inj_on f (\<Union>i \<in> I. A i) \<and> f ` (\<Union>i \<in> I. A i) \<le> (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
|
433 |
proof |
63612 | 434 |
let ?phi = "\<lambda>a i. i \<in> I \<and> a \<in> A i" |
435 |
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
|
436 |
let ?f = "\<lambda>a. (?sm a, a)" |
63612 | 437 |
have "inj_on ?f (\<Union>i \<in> I. A i)" |
438 |
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
|
439 |
moreover |
63612 | 440 |
have "?sm a \<in> I \<and> a \<in> A(?sm a)" if "i \<in> I" and "a \<in> A i" for i a |
441 |
using that someI[of "?phi a" i] by auto |
|
442 |
then have "?f ` (\<Union>i \<in> I. A i) \<le> (SIGMA i : I. A i)" |
|
443 |
by auto |
|
444 |
ultimately show "inj_on ?f (\<Union>i \<in> I. A i) \<and> ?f ` (\<Union>i \<in> I. A i) \<le> (SIGMA i : I. A i)" |
|
445 |
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
|
446 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
447 |
|
56608 | 448 |
lemma inv_unique_comp: |
449 |
assumes fg: "f \<circ> g = id" |
|
450 |
and gf: "g \<circ> f = id" |
|
451 |
shows "inv f = g" |
|
452 |
using fg gf inv_equality[of g f] by (auto simp add: fun_eq_iff) |
|
453 |
||
454 |
||
60758 | 455 |
subsection \<open>The Cantor-Bernstein Theorem\<close> |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
456 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
457 |
lemma Cantor_Bernstein_aux: |
63612 | 458 |
"\<exists>A' h. A' \<subseteq> A \<and> |
459 |
(\<forall>a \<in> A'. a \<notin> g ` (B - f ` A')) \<and> |
|
460 |
(\<forall>a \<in> A'. h a = f a) \<and> |
|
461 |
(\<forall>a \<in> A - A'. h a \<in> B - (f ` A') \<and> a = g (h a))" |
|
462 |
proof - |
|
463 |
define H where "H A' = A - (g ` (B - (f ` A')))" for A' |
|
464 |
have "mono H" unfolding mono_def H_def by blast |
|
465 |
from lfp_unfold [OF this] obtain A' where "H A' = A'" by blast |
|
466 |
then have "A' = A - (g ` (B - (f ` A')))" by (simp add: H_def) |
|
467 |
then have 1: "A' \<subseteq> A" |
|
468 |
and 2: "\<forall>a \<in> A'. a \<notin> g ` (B - f ` A')" |
|
469 |
and 3: "\<forall>a \<in> A - A'. \<exists>b \<in> B - (f ` A'). a = g b" |
|
470 |
by blast+ |
|
471 |
define h where "h a = (if a \<in> A' then f a else (SOME b. b \<in> B - (f ` A') \<and> a = g b))" for a |
|
472 |
then have 4: "\<forall>a \<in> A'. h a = f a" by simp |
|
473 |
have "\<forall>a \<in> A - A'. h a \<in> B - (f ` A') \<and> a = g (h a)" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
474 |
proof |
63612 | 475 |
fix a |
476 |
let ?phi = "\<lambda>b. b \<in> B - (f ` A') \<and> a = g b" |
|
477 |
assume *: "a \<in> A - A'" |
|
478 |
from * have "h a = (SOME b. ?phi b)" by (auto simp: h_def) |
|
479 |
moreover from 3 * have "\<exists>b. ?phi b" by auto |
|
480 |
ultimately show "?phi (h a)" |
|
481 |
using someI_ex[of ?phi] 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
|
482 |
qed |
63612 | 483 |
with 1 2 4 show ?thesis 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
|
484 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
485 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
486 |
theorem Cantor_Bernstein: |
63612 | 487 |
assumes inj1: "inj_on f A" and sub1: "f ` A \<subseteq> B" |
488 |
and inj2: "inj_on g B" and sub2: "g ` 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
|
489 |
shows "\<exists>h. bij_betw h A B" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
490 |
proof- |
63612 | 491 |
obtain A' and h where "A' \<subseteq> A" |
492 |
and 1: "\<forall>a \<in> A'. a \<notin> g ` (B - f ` A')" |
|
493 |
and 2: "\<forall>a \<in> A'. h a = f a" |
|
494 |
and 3: "\<forall>a \<in> A - A'. h a \<in> B - (f ` A') \<and> a = g (h a)" |
|
495 |
using Cantor_Bernstein_aux [of A g B f] 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
|
496 |
have "inj_on h A" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
497 |
proof (intro inj_onI) |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
498 |
fix a1 a2 |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
499 |
assume 4: "a1 \<in> A" and 5: "a2 \<in> A" and 6: "h a1 = h a2" |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
500 |
show "a1 = a2" |
63612 | 501 |
proof (cases "a1 \<in> A'") |
502 |
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
|
503 |
show ?thesis |
63612 | 504 |
proof (cases "a2 \<in> A'") |
505 |
case True': True |
|
506 |
with True 2 6 have "f a1 = f a2" by auto |
|
507 |
with inj1 \<open>A' \<subseteq> A\<close> True True' show ?thesis |
|
508 |
unfolding inj_on_def 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
|
509 |
next |
63612 | 510 |
case False |
511 |
with 2 3 5 6 True have False by force |
|
512 |
then show ?thesis .. |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
513 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
514 |
next |
63612 | 515 |
case False |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
516 |
show ?thesis |
63612 | 517 |
proof (cases "a2 \<in> A'") |
518 |
case True |
|
519 |
with 2 3 4 6 False have False by auto |
|
520 |
then show ?thesis .. |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
521 |
next |
63612 | 522 |
case False': False |
523 |
with False 3 4 5 have "a1 = g (h a1)" "a2 = g (h a2)" by auto |
|
524 |
with 6 show ?thesis by simp |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
525 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
526 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
527 |
qed |
63612 | 528 |
moreover have "h ` A = B" |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
529 |
proof safe |
63612 | 530 |
fix a |
531 |
assume "a \<in> A" |
|
532 |
with sub1 2 3 show "h a \<in> B" by (cases "a \<in> A'") auto |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
533 |
next |
63612 | 534 |
fix b |
535 |
assume *: "b \<in> B" |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
536 |
show "b \<in> h ` A" |
63612 | 537 |
proof (cases "b \<in> f ` A'") |
538 |
case True |
|
539 |
then obtain a where "a \<in> A'" "b = f a" by blast |
|
540 |
with \<open>A' \<subseteq> A\<close> 2 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
|
541 |
next |
63612 | 542 |
case False |
543 |
with 1 * have "g b \<notin> A'" by auto |
|
544 |
with sub2 * have 4: "g b \<in> A - A'" by auto |
|
545 |
with 3 have "h (g b) \<in> B" "g (h (g b)) = g b" by auto |
|
546 |
with inj2 * have "h (g b) = b" by (auto simp: inj_on_def) |
|
547 |
with 4 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
|
548 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
549 |
qed |
63612 | 550 |
ultimately show ?thesis |
551 |
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
|
552 |
qed |
14760 | 553 |
|
63612 | 554 |
|
60758 | 555 |
subsection \<open>Other Consequences of Hilbert's Epsilon\<close> |
14760 | 556 |
|
60758 | 557 |
text \<open>Hilbert's Epsilon and the @{term split} Operator\<close> |
14760 | 558 |
|
63612 | 559 |
text \<open>Looping simprule!\<close> |
560 |
lemma split_paired_Eps: "(SOME x. P x) = (SOME (a, b). P (a, b))" |
|
26347 | 561 |
by simp |
14760 | 562 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61076
diff
changeset
|
563 |
lemma Eps_case_prod: "Eps (case_prod P) = (SOME xy. P (fst xy) (snd xy))" |
26347 | 564 |
by (simp add: split_def) |
14760 | 565 |
|
63612 | 566 |
lemma Eps_case_prod_eq [simp]: "(SOME (x', y'). x = x' \<and> y = y') = (x, y)" |
26347 | 567 |
by blast |
14760 | 568 |
|
569 |
||
63612 | 570 |
text \<open>A relation is wellfounded iff it has no infinite descending chain.\<close> |
571 |
lemma wf_iff_no_infinite_down_chain: "wf r \<longleftrightarrow> (\<not> (\<exists>f. \<forall>i. (f (Suc i), f i) \<in> r))" |
|
572 |
apply (simp only: wf_eq_minimal) |
|
573 |
apply (rule iffI) |
|
574 |
apply (rule notI) |
|
575 |
apply (erule exE) |
|
576 |
apply (erule_tac x = "{w. \<exists>i. w = f i}" in allE) |
|
577 |
apply blast |
|
578 |
apply (erule contrapos_np) |
|
579 |
apply simp |
|
580 |
apply clarify |
|
581 |
apply (subgoal_tac "\<forall>n. rec_nat x (\<lambda>i y. SOME z. z \<in> Q \<and> (z, y) \<in> r) n \<in> Q") |
|
582 |
apply (rule_tac x = "rec_nat x (\<lambda>i y. SOME z. z \<in> Q \<and> (z, y) \<in> r)" in exI) |
|
583 |
apply (rule allI) |
|
584 |
apply simp |
|
585 |
apply (rule someI2_ex) |
|
586 |
apply blast |
|
587 |
apply blast |
|
588 |
apply (rule allI) |
|
589 |
apply (induct_tac n) |
|
590 |
apply simp_all |
|
591 |
apply (rule someI2_ex) |
|
592 |
apply blast |
|
593 |
apply blast |
|
594 |
done |
|
14760 | 595 |
|
27760 | 596 |
lemma wf_no_infinite_down_chainE: |
63612 | 597 |
assumes "wf r" |
598 |
obtains k where "(f (Suc k), f k) \<notin> r" |
|
599 |
using assms wf_iff_no_infinite_down_chain[of r] by blast |
|
27760 | 600 |
|
601 |
||
63612 | 602 |
text \<open>A dynamically-scoped fact for TFL\<close> |
603 |
lemma tfl_some: "\<forall>P x. P x \<longrightarrow> P (Eps P)" |
|
12298 | 604 |
by (blast intro: someI) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
605 |
|
12298 | 606 |
|
60758 | 607 |
subsection \<open>Least value operator\<close> |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
608 |
|
63612 | 609 |
definition LeastM :: "('a \<Rightarrow> 'b::ord) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a" |
610 |
where "LeastM m P \<equiv> (SOME x. P x \<and> (\<forall>y. P y \<longrightarrow> m x \<le> m y))" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
611 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
612 |
syntax |
63612 | 613 |
"_LeastM" :: "pttrn \<Rightarrow> ('a \<Rightarrow> 'b::ord) \<Rightarrow> bool \<Rightarrow> 'a" ("LEAST _ WRT _. _" [0, 4, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
614 |
translations |
63612 | 615 |
"LEAST x WRT m. P" \<rightleftharpoons> "CONST LeastM m (\<lambda>x. P)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
616 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
617 |
lemma LeastMI2: |
63612 | 618 |
"P x \<Longrightarrow> |
619 |
(\<And>y. P y \<Longrightarrow> m x \<le> m y) \<Longrightarrow> |
|
620 |
(\<And>x. P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> m x \<le> m y \<Longrightarrow> Q x) \<Longrightarrow> |
|
621 |
Q (LeastM m P)" |
|
14760 | 622 |
apply (simp add: LeastM_def) |
63612 | 623 |
apply (rule someI2_ex) |
624 |
apply blast |
|
625 |
apply blast |
|
12298 | 626 |
done |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
627 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
628 |
lemma LeastM_equality: |
63612 | 629 |
"P k \<Longrightarrow> (\<And>x. P x \<Longrightarrow> m k \<le> m x) \<Longrightarrow> m (LEAST x WRT m. P x) = (m k :: 'a::order)" |
630 |
apply (rule LeastMI2) |
|
631 |
apply assumption |
|
632 |
apply blast |
|
12298 | 633 |
apply (blast intro!: order_antisym) |
634 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
635 |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
636 |
lemma wf_linord_ex_has_least: |
63612 | 637 |
"wf r \<Longrightarrow> \<forall>x y. (x, y) \<in> r\<^sup>+ \<longleftrightarrow> (y, x) \<notin> r\<^sup>* \<Longrightarrow> P k \<Longrightarrow> \<exists>x. P x \<and> (\<forall>y. P y \<longrightarrow> (m x, m y) \<in> r\<^sup>*)" |
12298 | 638 |
apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]]) |
63612 | 639 |
apply (drule_tac x = "m ` Collect P" in spec) |
640 |
apply force |
|
12298 | 641 |
done |
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
642 |
|
63612 | 643 |
lemma ex_has_least_nat: "P k \<Longrightarrow> \<exists>x. P x \<and> (\<forall>y. P y \<longrightarrow> m x \<le> (m y :: nat))" |
12298 | 644 |
apply (simp only: pred_nat_trancl_eq_le [symmetric]) |
645 |
apply (rule wf_pred_nat [THEN wf_linord_ex_has_least]) |
|
63612 | 646 |
apply (simp add: less_eq linorder_not_le pred_nat_trancl_eq_le) |
647 |
apply assumption |
|
12298 | 648 |
done |
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
649 |
|
63612 | 650 |
lemma LeastM_nat_lemma: "P k \<Longrightarrow> P (LeastM m P) \<and> (\<forall>y. P y \<longrightarrow> m (LeastM m P) \<le> (m y :: nat))" |
14760 | 651 |
apply (simp add: LeastM_def) |
12298 | 652 |
apply (rule someI_ex) |
653 |
apply (erule ex_has_least_nat) |
|
654 |
done |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
655 |
|
45607 | 656 |
lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1] |
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
657 |
|
63612 | 658 |
lemma LeastM_nat_le: "P x \<Longrightarrow> m (LeastM m P) \<le> (m x :: nat)" |
659 |
by (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp]) |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
660 |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
661 |
|
60758 | 662 |
subsection \<open>Greatest value operator\<close> |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
663 |
|
63612 | 664 |
definition GreatestM :: "('a \<Rightarrow> 'b::ord) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a" |
665 |
where "GreatestM m P \<equiv> SOME x. P x \<and> (\<forall>y. P y \<longrightarrow> m y \<le> m x)" |
|
12298 | 666 |
|
63612 | 667 |
definition Greatest :: "('a::ord \<Rightarrow> bool) \<Rightarrow> 'a" (binder "GREATEST " 10) |
668 |
where "Greatest \<equiv> GreatestM (\<lambda>x. x)" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
669 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
670 |
syntax |
63612 | 671 |
"_GreatestM" :: "pttrn \<Rightarrow> ('a \<Rightarrow> 'b::ord) \<Rightarrow> bool \<Rightarrow> 'a" ("GREATEST _ WRT _. _" [0, 4, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
672 |
translations |
63612 | 673 |
"GREATEST x WRT m. P" \<rightleftharpoons> "CONST GreatestM m (\<lambda>x. P)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
674 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
675 |
lemma GreatestMI2: |
63612 | 676 |
"P x \<Longrightarrow> |
677 |
(\<And>y. P y \<Longrightarrow> m y \<le> m x) \<Longrightarrow> |
|
678 |
(\<And>x. P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> m y \<le> m x \<Longrightarrow> Q x) \<Longrightarrow> |
|
679 |
Q (GreatestM m P)" |
|
14760 | 680 |
apply (simp add: GreatestM_def) |
63612 | 681 |
apply (rule someI2_ex) |
682 |
apply blast |
|
683 |
apply blast |
|
12298 | 684 |
done |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
685 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
686 |
lemma GreatestM_equality: |
63612 | 687 |
"P k \<Longrightarrow> |
688 |
(\<And>x. P x \<Longrightarrow> m x \<le> m k) \<Longrightarrow> |
|
689 |
m (GREATEST x WRT m. P x) = (m k :: 'a::order)" |
|
690 |
apply (rule GreatestMI2 [where m = m]) |
|
691 |
apply assumption |
|
692 |
apply blast |
|
12298 | 693 |
apply (blast intro!: order_antisym) |
694 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
695 |
|
63612 | 696 |
lemma Greatest_equality: "P k \<Longrightarrow> (\<And>x. P x \<Longrightarrow> x \<le> k) \<Longrightarrow> (GREATEST x. P x) = k" |
697 |
for k :: "'a::order" |
|
14760 | 698 |
apply (simp add: Greatest_def) |
63612 | 699 |
apply (erule GreatestM_equality) |
700 |
apply blast |
|
12298 | 701 |
done |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
702 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
703 |
lemma ex_has_greatest_nat_lemma: |
63612 | 704 |
"P k \<Longrightarrow> \<forall>x. P x \<longrightarrow> (\<exists>y. P y \<and> \<not> m y \<le> (m x :: nat)) \<Longrightarrow> \<exists>y. P y \<and> \<not> m y < m k + n" |
705 |
by (induct n) (force simp: le_Suc_eq)+ |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
706 |
|
12298 | 707 |
lemma ex_has_greatest_nat: |
63612 | 708 |
"P k \<Longrightarrow> \<forall>y. P y \<longrightarrow> m y < b \<Longrightarrow> \<exists>x. P x \<and> (\<forall>y. P y \<longrightarrow> m y \<le> (m x :: nat))" |
12298 | 709 |
apply (rule ccontr) |
710 |
apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma) |
|
63612 | 711 |
apply (subgoal_tac [3] "m k \<le> b") |
712 |
apply auto |
|
12298 | 713 |
done |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
714 |
|
12298 | 715 |
lemma GreatestM_nat_lemma: |
63612 | 716 |
"P k \<Longrightarrow> \<forall>y. P y \<longrightarrow> m y < b \<Longrightarrow> |
717 |
P (GreatestM m P) \<and> (\<forall>y. P y \<longrightarrow> (m y :: nat) \<le> m (GreatestM m P))" |
|
14760 | 718 |
apply (simp add: GreatestM_def) |
12298 | 719 |
apply (rule someI_ex) |
63612 | 720 |
apply (erule ex_has_greatest_nat) |
721 |
apply assumption |
|
12298 | 722 |
done |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
723 |
|
45607 | 724 |
lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1] |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
725 |
|
63612 | 726 |
lemma GreatestM_nat_le: "P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> m y < b \<Longrightarrow> (m x :: nat) \<le> m (GreatestM m P)" |
727 |
by (blast dest: GreatestM_nat_lemma [THEN conjunct2, THEN spec, of P]) |
|
12298 | 728 |
|
729 |
||
63612 | 730 |
text \<open>\<^medskip> Specialization to \<open>GREATEST\<close>.\<close> |
12298 | 731 |
|
63612 | 732 |
lemma GreatestI: "P k \<Longrightarrow> \<forall>y. P y \<longrightarrow> y < b \<Longrightarrow> P (GREATEST x. P x)" |
733 |
for k :: nat |
|
734 |
unfolding Greatest_def by (rule GreatestM_natI) auto |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
735 |
|
63612 | 736 |
lemma Greatest_le: "P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> y < b \<Longrightarrow> x \<le> (GREATEST x. P x)" |
737 |
for x :: nat |
|
738 |
unfolding Greatest_def by (rule GreatestM_nat_le) auto |
|
12298 | 739 |
|
740 |
||
60758 | 741 |
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
|
742 |
|
60758 | 743 |
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
|
744 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
745 |
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
|
746 |
fixes f :: "nat \<Rightarrow> 'a::order" |
63612 | 747 |
assumes S: "finite (range f)" "mono f" |
748 |
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
|
749 |
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
|
750 |
using assms |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
751 |
proof - |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
752 |
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
|
753 |
proof (rule ccontr) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
754 |
assume "\<not> ?thesis" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
755 |
then have "\<And>n. f n \<noteq> f (Suc n)" by auto |
63612 | 756 |
with \<open>mono f\<close> have "\<And>n. f n < f (Suc n)" |
757 |
by (auto simp: le_less mono_iff_le_Suc) |
|
758 |
with lift_Suc_mono_less_iff[of f] have *: "\<And>n m. n < m \<Longrightarrow> f n < f m" |
|
759 |
by auto |
|
55811 | 760 |
have "inj f" |
761 |
proof (intro injI) |
|
762 |
fix x y |
|
763 |
assume "f x = f y" |
|
63612 | 764 |
then show "x = y" |
765 |
by (cases x y rule: linorder_cases) (auto dest: *) |
|
55811 | 766 |
qed |
60758 | 767 |
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
|
768 |
by (rule finite_imageD) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
769 |
then show False by simp |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
770 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
771 |
then obtain n where n: "f n = f (Suc n)" .. |
63040 | 772 |
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
|
773 |
have N: "f N = f (Suc N)" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
774 |
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
|
775 |
show ?thesis |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
776 |
proof (intro exI[of _ N] conjI allI impI) |
63612 | 777 |
fix n |
778 |
assume "N \<le> n" |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
779 |
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
|
780 |
proof (induct rule: dec_induct) |
63612 | 781 |
case base |
782 |
then show ?case by simp |
|
783 |
next |
|
784 |
case (step n) |
|
785 |
then show ?case |
|
786 |
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
|
787 |
by (cases n) (auto simp add: le_Suc_eq) |
63612 | 788 |
qed |
60758 | 789 |
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
|
790 |
next |
63612 | 791 |
fix n m :: nat |
792 |
assume "m < n" "n \<le> N" |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
793 |
then show "f m < f n" |
62683 | 794 |
proof (induct rule: less_Suc_induct) |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
795 |
case (1 i) |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
796 |
then have "i < N" by simp |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
797 |
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
|
798 |
unfolding N_def by (rule not_less_Least) |
60758 | 799 |
with \<open>mono f\<close> show ?case by (simp add: mono_iff_le_Suc less_le) |
63612 | 800 |
next |
801 |
case 2 |
|
802 |
then show ?case by simp |
|
803 |
qed |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
804 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
805 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
806 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
807 |
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
|
808 |
fixes f :: "nat \<Rightarrow> 'a set" |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
809 |
assumes S: "\<And>i. f i \<subseteq> S" "finite S" |
63612 | 810 |
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
|
811 |
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
|
812 |
proof - |
63612 | 813 |
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" |
814 |
and eq: "\<forall>n\<ge>N. f N = f n" |
|
815 |
by atomize auto |
|
816 |
have "i \<le> N \<Longrightarrow> i \<le> card (f i)" for i |
|
817 |
proof (induct i) |
|
818 |
case 0 |
|
819 |
then show ?case by simp |
|
820 |
next |
|
821 |
case (Suc i) |
|
822 |
with inj [of "Suc i" i] have "(f i) \<subset> (f (Suc i))" by auto |
|
823 |
moreover have "finite (f (Suc i))" using S by (rule finite_subset) |
|
824 |
ultimately have "card (f i) < card (f (Suc i))" by (intro psubset_card_mono) |
|
825 |
with Suc inj show ?case by auto |
|
826 |
qed |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
827 |
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
|
828 |
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
|
829 |
finally have "f (card S) = f N" using eq by auto |
63612 | 830 |
then show ?thesis |
831 |
using eq inj [of N] |
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
832 |
apply auto |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
833 |
apply (case_tac "n < N") |
63612 | 834 |
apply (auto simp: not_less) |
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
835 |
done |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
836 |
qed |
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
837 |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49739
diff
changeset
|
838 |
|
60758 | 839 |
subsection \<open>More on injections, bijections, and inverses\<close> |
55020 | 840 |
|
63374 | 841 |
locale bijection = |
842 |
fixes f :: "'a \<Rightarrow> 'a" |
|
843 |
assumes bij: "bij f" |
|
844 |
begin |
|
845 |
||
63612 | 846 |
lemma bij_inv: "bij (inv f)" |
63374 | 847 |
using bij by (rule bij_imp_bij_inv) |
848 |
||
63612 | 849 |
lemma surj [simp]: "surj f" |
63374 | 850 |
using bij by (rule bij_is_surj) |
851 |
||
63612 | 852 |
lemma inj: "inj f" |
63374 | 853 |
using bij by (rule bij_is_inj) |
854 |
||
63612 | 855 |
lemma surj_inv [simp]: "surj (inv f)" |
63374 | 856 |
using inj by (rule inj_imp_surj_inv) |
857 |
||
63612 | 858 |
lemma inj_inv: "inj (inv f)" |
63374 | 859 |
using surj by (rule surj_imp_inj_inv) |
860 |
||
63612 | 861 |
lemma eqI: "f a = f b \<Longrightarrow> a = b" |
63374 | 862 |
using inj by (rule injD) |
863 |
||
63612 | 864 |
lemma eq_iff [simp]: "f a = f b \<longleftrightarrow> a = b" |
63374 | 865 |
by (auto intro: eqI) |
866 |
||
63612 | 867 |
lemma eq_invI: "inv f a = inv f b \<Longrightarrow> a = b" |
63374 | 868 |
using inj_inv by (rule injD) |
869 |
||
63612 | 870 |
lemma eq_inv_iff [simp]: "inv f a = inv f b \<longleftrightarrow> a = b" |
63374 | 871 |
by (auto intro: eq_invI) |
872 |
||
63612 | 873 |
lemma inv_left [simp]: "inv f (f a) = a" |
63374 | 874 |
using inj by (simp add: inv_f_eq) |
875 |
||
63612 | 876 |
lemma inv_comp_left [simp]: "inv f \<circ> f = id" |
63374 | 877 |
by (simp add: fun_eq_iff) |
878 |
||
63612 | 879 |
lemma inv_right [simp]: "f (inv f a) = a" |
63374 | 880 |
using surj by (simp add: surj_f_inv_f) |
881 |
||
63612 | 882 |
lemma inv_comp_right [simp]: "f \<circ> inv f = id" |
63374 | 883 |
by (simp add: fun_eq_iff) |
884 |
||
63612 | 885 |
lemma inv_left_eq_iff [simp]: "inv f a = b \<longleftrightarrow> f b = a" |
63374 | 886 |
by auto |
887 |
||
63612 | 888 |
lemma inv_right_eq_iff [simp]: "b = inv f a \<longleftrightarrow> f b = a" |
63374 | 889 |
by auto |
890 |
||
891 |
end |
|
892 |
||
55020 | 893 |
lemma infinite_imp_bij_betw: |
63612 | 894 |
assumes infinite: "\<not> finite A" |
895 |
shows "\<exists>h. bij_betw h A (A - {a})" |
|
896 |
proof (cases "a \<in> A") |
|
897 |
case False |
|
898 |
then have "A - {a} = A" by blast |
|
899 |
then show ?thesis |
|
900 |
using bij_betw_id[of A] by auto |
|
55020 | 901 |
next |
63612 | 902 |
case True |
903 |
with infinite have "\<not> finite (A - {a})" by auto |
|
904 |
with infinite_iff_countable_subset[of "A - {a}"] |
|
905 |
obtain f :: "nat \<Rightarrow> 'a" where 1: "inj f" and 2: "f ` UNIV \<subseteq> A - {a}" by blast |
|
906 |
define g where "g n = (if n = 0 then a else f (Suc n))" for n |
|
907 |
define A' where "A' = g ` UNIV" |
|
908 |
have *: "\<forall>y. f y \<noteq> a" using 2 by blast |
|
909 |
have 3: "inj_on g UNIV \<and> g ` UNIV \<subseteq> A \<and> a \<in> g ` UNIV" |
|
910 |
apply (auto simp add: True g_def [abs_def]) |
|
911 |
apply (unfold inj_on_def) |
|
912 |
apply (intro ballI impI) |
|
913 |
apply (case_tac "x = 0") |
|
914 |
apply (auto simp add: 2) |
|
915 |
proof - |
|
916 |
fix y |
|
917 |
assume "a = (if y = 0 then a else f (Suc y))" |
|
918 |
then show "y = 0" by (cases "y = 0") (use * in auto) |
|
55020 | 919 |
next |
920 |
fix x y |
|
921 |
assume "f (Suc x) = (if y = 0 then a else f (Suc y))" |
|
63612 | 922 |
with 1 * show "x = y" by (cases "y = 0") (auto simp: inj_on_def) |
55020 | 923 |
next |
63612 | 924 |
fix n |
925 |
from 2 show "f (Suc n) \<in> A" by blast |
|
55020 | 926 |
qed |
63612 | 927 |
then have 4: "bij_betw g UNIV A' \<and> a \<in> A' \<and> A' \<subseteq> A" |
928 |
using inj_on_imp_bij_betw[of g] by (auto simp: A'_def) |
|
929 |
then have 5: "bij_betw (inv g) A' UNIV" |
|
930 |
by (auto simp add: bij_betw_inv_into) |
|
931 |
from 3 obtain n where n: "g n = a" by auto |
|
932 |
have 6: "bij_betw g (UNIV - {n}) (A' - {a})" |
|
933 |
by (rule bij_betw_subset) (use 3 4 n in \<open>auto simp: image_set_diff A'_def\<close>) |
|
934 |
define v where "v m = (if m < n then m else Suc m)" for m |
|
55020 | 935 |
have 7: "bij_betw v UNIV (UNIV - {n})" |
63612 | 936 |
proof (unfold bij_betw_def inj_on_def, intro conjI, clarify) |
937 |
fix m1 m2 |
|
938 |
assume "v m1 = v m2" |
|
939 |
then show "m1 = m2" |
|
940 |
apply (cases "m1 < n") |
|
941 |
apply (cases "m2 < n") |
|
942 |
apply (auto simp: inj_on_def v_def [abs_def]) |
|
943 |
apply (cases "m2 < n") |
|
944 |
apply auto |
|
945 |
done |
|
55020 | 946 |
next |
947 |
show "v ` UNIV = UNIV - {n}" |
|
63612 | 948 |
proof (auto simp: v_def [abs_def]) |
949 |
fix m |
|
950 |
assume "m \<noteq> n" |
|
951 |
assume *: "m \<notin> Suc ` {m'. \<not> m' < n}" |
|
952 |
have False if "n \<le> m" |
|
953 |
proof - |
|
954 |
from \<open>m \<noteq> n\<close> that have **: "Suc n \<le> m" by auto |
|
955 |
from Suc_le_D [OF this] obtain m' where m': "m = Suc m'" .. |
|
956 |
with ** have "n \<le> m'" by auto |
|
957 |
with m' * show ?thesis by auto |
|
958 |
qed |
|
959 |
then show "m < n" by force |
|
55020 | 960 |
qed |
961 |
qed |
|
63612 | 962 |
define h' where "h' = g \<circ> v \<circ> (inv g)" |
963 |
with 5 6 7 have 8: "bij_betw h' A' (A' - {a})" |
|
964 |
by (auto simp add: bij_betw_trans) |
|
965 |
define h where "h b = (if b \<in> A' then h' b else b)" for b |
|
966 |
then have "\<forall>b \<in> A'. h b = h' b" by simp |
|
967 |
with 8 have "bij_betw h A' (A' - {a})" |
|
968 |
using bij_betw_cong[of A' h] by auto |
|
55020 | 969 |
moreover |
63612 | 970 |
have "\<forall>b \<in> A - A'. h b = b" by (auto simp: h_def) |
971 |
then have "bij_betw h (A - A') (A - A')" |
|
972 |
using bij_betw_cong[of "A - A'" h id] bij_betw_id[of "A - A'"] by auto |
|
55020 | 973 |
moreover |
63612 | 974 |
from 4 have "(A' \<inter> (A - A') = {} \<and> A' \<union> (A - A') = A) \<and> |
975 |
((A' - {a}) \<inter> (A - A') = {} \<and> (A' - {a}) \<union> (A - A') = A - {a})" |
|
976 |
by blast |
|
55020 | 977 |
ultimately have "bij_betw h A (A - {a})" |
63612 | 978 |
using bij_betw_combine[of h A' "A' - {a}" "A - A'" "A - A'"] by simp |
979 |
then show ?thesis by blast |
|
55020 | 980 |
qed |
981 |
||
982 |
lemma infinite_imp_bij_betw2: |
|
63612 | 983 |
assumes "\<not> finite A" |
984 |
shows "\<exists>h. bij_betw h A (A \<union> {a})" |
|
985 |
proof (cases "a \<in> A") |
|
986 |
case True |
|
987 |
then have "A \<union> {a} = A" by blast |
|
988 |
then show ?thesis using bij_betw_id[of A] by auto |
|
55020 | 989 |
next |
63612 | 990 |
case False |
55020 | 991 |
let ?A' = "A \<union> {a}" |
63612 | 992 |
from False have "A = ?A' - {a}" by blast |
993 |
moreover from assms have "\<not> finite ?A'" by auto |
|
55020 | 994 |
ultimately obtain f where "bij_betw f ?A' A" |
63612 | 995 |
using infinite_imp_bij_betw[of ?A' a] by auto |
996 |
then have "bij_betw (inv_into ?A' f) A ?A'" by (rule bij_betw_inv_into) |
|
997 |
then show ?thesis by auto |
|
55020 | 998 |
qed |
999 |
||
63612 | 1000 |
lemma bij_betw_inv_into_left: "bij_betw f A A' \<Longrightarrow> a \<in> A \<Longrightarrow> inv_into A f (f a) = a" |
1001 |
unfolding bij_betw_def by clarify (rule inv_into_f_f) |
|
55020 | 1002 |
|
63612 | 1003 |
lemma bij_betw_inv_into_right: "bij_betw f A A' \<Longrightarrow> a' \<in> A' \<Longrightarrow> f (inv_into A f a') = a'" |
1004 |
unfolding bij_betw_def using f_inv_into_f by force |
|
55020 | 1005 |
|
1006 |
lemma bij_betw_inv_into_subset: |
|
63612 | 1007 |
"bij_betw f A A' \<Longrightarrow> B \<subseteq> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw (inv_into A f) B' B" |
1008 |
by (auto simp: bij_betw_def intro: inj_on_inv_into) |
|
55020 | 1009 |
|
1010 |
||
60758 | 1011 |
subsection \<open>Specification package -- Hilbertized version\<close> |
17893
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
wenzelm
parents:
17702
diff
changeset
|
1012 |
|
63612 | 1013 |
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
|
1014 |
by (simp only: someI_ex) |
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
wenzelm
parents:
17702
diff
changeset
|
1015 |
|
48891 | 1016 |
ML_file "Tools/choice_specification.ML" |
14115 | 1017 |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
1018 |
end |