1465
|
1 |
(* Title: HOL/ex/set.ML
|
969
|
2 |
ID: $Id$
|
1465
|
3 |
Author: Tobias Nipkow, Cambridge University Computer Laboratory
|
969
|
4 |
Copyright 1991 University of Cambridge
|
|
5 |
|
|
6 |
Cantor's Theorem; the Schroeder-Berstein Theorem.
|
|
7 |
*)
|
|
8 |
|
|
9 |
|
|
10 |
writeln"File HOL/ex/set.";
|
|
11 |
|
4153
|
12 |
context Lfp.thy;
|
2998
|
13 |
|
5432
|
14 |
(*trivial example of term synthesis: apparently hard for some provers!*)
|
|
15 |
Goal "a ~= b ==> a:?X & b ~: ?X";
|
|
16 |
by (Blast_tac 1);
|
|
17 |
result();
|
|
18 |
|
4153
|
19 |
(*Nice demonstration of blast_tac--and its limitations*)
|
5432
|
20 |
Goal "!!S::'a set set. ALL x:S. ALL y:S. x<=y ==> EX z. S <= {z}";
|
4153
|
21 |
(*for some unfathomable reason, UNIV_I increases the search space greatly*)
|
|
22 |
by (blast_tac (claset() delrules [UNIV_I]) 1);
|
|
23 |
result();
|
|
24 |
|
4324
|
25 |
(*variant of the benchmark above*)
|
5432
|
26 |
Goal "ALL x:S. Union(S) <= x ==> EX z. S <= {z}";
|
4324
|
27 |
by (blast_tac (claset() delrules [UNIV_I]) 1);
|
5432
|
28 |
(*just Blast_tac takes 5 seconds instead of 1*)
|
4324
|
29 |
result();
|
2998
|
30 |
|
969
|
31 |
(*** A unique fixpoint theorem --- fast/best/meson all fail ***)
|
|
32 |
|
5432
|
33 |
Goal "?!x. f(g(x))=x ==> ?!y. g(f(y))=y";
|
|
34 |
by (EVERY1[etac ex1E, rtac ex1I, etac arg_cong,
|
969
|
35 |
rtac subst, atac, etac allE, rtac arg_cong, etac mp, etac arg_cong]);
|
|
36 |
result();
|
|
37 |
|
|
38 |
(*** Cantor's Theorem: There is no surjection from a set to its powerset. ***)
|
|
39 |
|
|
40 |
goal Set.thy "~ (? f:: 'a=>'a set. ! S. ? x. f(x) = S)";
|
|
41 |
(*requires best-first search because it is undirectional*)
|
4089
|
42 |
by (best_tac (claset() addSEs [equalityCE]) 1);
|
969
|
43 |
qed "cantor1";
|
|
44 |
|
|
45 |
(*This form displays the diagonal term*)
|
|
46 |
goal Set.thy "! f:: 'a=>'a set. ! x. f(x) ~= ?S(f)";
|
4089
|
47 |
by (best_tac (claset() addSEs [equalityCE]) 1);
|
969
|
48 |
uresult();
|
|
49 |
|
|
50 |
(*This form exploits the set constructs*)
|
|
51 |
goal Set.thy "?S ~: range(f :: 'a=>'a set)";
|
|
52 |
by (rtac notI 1);
|
|
53 |
by (etac rangeE 1);
|
|
54 |
by (etac equalityCE 1);
|
|
55 |
by (dtac CollectD 1);
|
|
56 |
by (contr_tac 1);
|
|
57 |
by (swap_res_tac [CollectI] 1);
|
|
58 |
by (assume_tac 1);
|
|
59 |
|
|
60 |
choplev 0;
|
4089
|
61 |
by (best_tac (claset() addSEs [equalityCE]) 1);
|
969
|
62 |
|
|
63 |
(*** The Schroder-Berstein Theorem ***)
|
|
64 |
|
5432
|
65 |
Goalw [image_def] "inj(f) ==> inv(f)``(f``X) = X";
|
969
|
66 |
by (rtac equalityI 1);
|
4089
|
67 |
by (fast_tac (claset() addEs [inv_f_f RS ssubst]) 1);
|
|
68 |
by (fast_tac (claset() addEs [inv_f_f RS ssubst]) 1);
|
969
|
69 |
qed "inv_image_comp";
|
|
70 |
|
5432
|
71 |
Goal "f(a) ~: (f``X) ==> a~:X";
|
2935
|
72 |
by (Blast_tac 1);
|
969
|
73 |
qed "contra_imageI";
|
|
74 |
|
5432
|
75 |
Goal "(a ~: Compl(X)) = (a:X)";
|
2935
|
76 |
by (Blast_tac 1);
|
969
|
77 |
qed "not_Compl";
|
|
78 |
|
|
79 |
(*Lots of backtracking in this proof...*)
|
|
80 |
val [compl,fg,Xa] = goal Lfp.thy
|
|
81 |
"[| Compl(f``X) = g``Compl(X); f(a)=g(b); a:X |] ==> b:X";
|
|
82 |
by (EVERY1 [rtac (not_Compl RS subst), rtac contra_imageI,
|
1465
|
83 |
rtac (compl RS subst), rtac (fg RS subst), stac not_Compl,
|
|
84 |
rtac imageI, rtac Xa]);
|
969
|
85 |
qed "disj_lemma";
|
|
86 |
|
5432
|
87 |
Goalw [image_def]
|
|
88 |
"range(%z. if z:X then f(z) else g(z)) = f``X Un g``Compl(X)";
|
4686
|
89 |
by (Simp_tac 1);
|
2935
|
90 |
by (Blast_tac 1);
|
969
|
91 |
qed "range_if_then_else";
|
|
92 |
|
5432
|
93 |
Goal "a : X Un Compl(X)";
|
2935
|
94 |
by (Blast_tac 1);
|
969
|
95 |
qed "X_Un_Compl";
|
|
96 |
|
5432
|
97 |
Goalw [surj_def] "surj(f) = (!a. a : range(f))";
|
4089
|
98 |
by (fast_tac (claset() addEs [ssubst]) 1);
|
969
|
99 |
qed "surj_iff_full_range";
|
|
100 |
|
5432
|
101 |
Goal "Compl(f``X) = g``Compl(X) ==> surj(%z. if z:X then f(z) else g(z))";
|
1487
|
102 |
by (EVERY1[stac surj_iff_full_range, stac range_if_then_else,
|
5432
|
103 |
etac subst]);
|
969
|
104 |
by (rtac (X_Un_Compl RS allI) 1);
|
|
105 |
qed "surj_if_then_else";
|
|
106 |
|
5432
|
107 |
val [injf,injg,compl,bij] =
|
|
108 |
goal Lfp.thy
|
4831
|
109 |
"[| inj_on f X; inj_on g (Compl X); Compl(f``X) = g``Compl(X); \
|
969
|
110 |
\ bij = (%z. if z:X then f(z) else g(z)) |] ==> \
|
|
111 |
\ inj(bij) & surj(bij)";
|
|
112 |
val f_eq_gE = make_elim (compl RS disj_lemma);
|
2031
|
113 |
by (stac bij 1);
|
969
|
114 |
by (rtac conjI 1);
|
|
115 |
by (rtac (compl RS surj_if_then_else) 2);
|
|
116 |
by (rewtac inj_def);
|
|
117 |
by (cut_facts_tac [injf,injg] 1);
|
4831
|
118 |
by (EVERY1 [rtac allI, rtac allI, stac split_if, rtac conjI, stac split_if]);
|
|
119 |
by (fast_tac (claset() addEs [inj_onD, sym RS f_eq_gE]) 1);
|
|
120 |
by (stac split_if 1);
|
|
121 |
by (fast_tac (claset() addEs [inj_onD, f_eq_gE]) 1);
|
969
|
122 |
qed "bij_if_then_else";
|
|
123 |
|
5432
|
124 |
Goal "? X. X = Compl(g``Compl((f:: 'a=>'b)``X))";
|
969
|
125 |
by (rtac exI 1);
|
|
126 |
by (rtac lfp_Tarski 1);
|
|
127 |
by (REPEAT (ares_tac [monoI, image_mono, Compl_anti_mono] 1));
|
|
128 |
qed "decomposition";
|
|
129 |
|
5432
|
130 |
val [injf,injg] = goal Lfp.thy
|
969
|
131 |
"[| inj(f:: 'a=>'b); inj(g:: 'b=>'a) |] ==> \
|
|
132 |
\ ? h:: 'a=>'b. inj(h) & surj(h)";
|
|
133 |
by (rtac (decomposition RS exE) 1);
|
|
134 |
by (rtac exI 1);
|
|
135 |
by (rtac bij_if_then_else 1);
|
|
136 |
by (EVERY [rtac refl 4, rtac (injf RS inj_imp) 1,
|
4831
|
137 |
rtac (injg RS inj_on_inv) 1]);
|
969
|
138 |
by (EVERY1 [etac ssubst, stac double_complement, rtac subsetI,
|
1465
|
139 |
etac imageE, etac ssubst, rtac rangeI]);
|
969
|
140 |
by (EVERY1 [etac ssubst, stac double_complement,
|
1465
|
141 |
rtac (injg RS inv_image_comp RS sym)]);
|
969
|
142 |
qed "schroeder_bernstein";
|
|
143 |
|
|
144 |
writeln"Reached end of file.";
|