author | paulson |
Fri, 18 Apr 1997 11:47:36 +0200 | |
changeset 2982 | 85c81d524655 |
parent 2949 | 58039791af82 |
child 3421 | be777156c7e9 |
permissions | -rw-r--r-- |
2935 | 1 |
(* Title: HOL/Univ |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
6 |
For univ.thy |
|
7 |
*) |
|
8 |
||
9 |
open Univ; |
|
10 |
||
11 |
(** apfst -- can be used in similar type definitions **) |
|
12 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
13 |
goalw Univ.thy [apfst_def] "apfst f (a,b) = (f(a),b)"; |
923 | 14 |
by (rtac split 1); |
976
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
15 |
qed "apfst_conv"; |
923 | 16 |
|
17 |
val [major,minor] = goal Univ.thy |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
18 |
"[| q = apfst f p; !!x y. [| p = (x,y); q = (f(x),y) |] ==> R \ |
923 | 19 |
\ |] ==> R"; |
20 |
by (rtac PairE 1); |
|
21 |
by (rtac minor 1); |
|
22 |
by (assume_tac 1); |
|
23 |
by (rtac (major RS trans) 1); |
|
24 |
by (etac ssubst 1); |
|
976
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
25 |
by (rtac apfst_conv 1); |
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
26 |
qed "apfst_convE"; |
923 | 27 |
|
28 |
(** Push -- an injection, analogous to Cons on lists **) |
|
29 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
30 |
val [major] = goalw Univ.thy [Push_def] "Push i f = Push j g ==> i=j"; |
923 | 31 |
by (rtac (major RS fun_cong RS box_equals RS Suc_inject) 1); |
32 |
by (rtac nat_case_0 1); |
|
33 |
by (rtac nat_case_0 1); |
|
34 |
qed "Push_inject1"; |
|
35 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
36 |
val [major] = goalw Univ.thy [Push_def] "Push i f = Push j g ==> f=g"; |
923 | 37 |
by (rtac (major RS fun_cong RS ext RS box_equals) 1); |
38 |
by (rtac (nat_case_Suc RS ext) 1); |
|
39 |
by (rtac (nat_case_Suc RS ext) 1); |
|
40 |
qed "Push_inject2"; |
|
41 |
||
42 |
val [major,minor] = goal Univ.thy |
|
43 |
"[| Push i f =Push j g; [| i=j; f=g |] ==> P \ |
|
44 |
\ |] ==> P"; |
|
45 |
by (rtac ((major RS Push_inject2) RS ((major RS Push_inject1) RS minor)) 1); |
|
46 |
qed "Push_inject"; |
|
47 |
||
48 |
val [major] = goalw Univ.thy [Push_def] "Push k f =(%z.0) ==> P"; |
|
49 |
by (rtac (major RS fun_cong RS box_equals RS Suc_neq_Zero) 1); |
|
50 |
by (rtac nat_case_0 1); |
|
51 |
by (rtac refl 1); |
|
52 |
qed "Push_neq_K0"; |
|
53 |
||
54 |
(*** Isomorphisms ***) |
|
55 |
||
56 |
goal Univ.thy "inj(Rep_Node)"; |
|
1465 | 57 |
by (rtac inj_inverseI 1); (*cannot combine by RS: multiple unifiers*) |
923 | 58 |
by (rtac Rep_Node_inverse 1); |
59 |
qed "inj_Rep_Node"; |
|
60 |
||
61 |
goal Univ.thy "inj_onto Abs_Node Node"; |
|
62 |
by (rtac inj_onto_inverseI 1); |
|
63 |
by (etac Abs_Node_inverse 1); |
|
64 |
qed "inj_onto_Abs_Node"; |
|
65 |
||
66 |
val Abs_Node_inject = inj_onto_Abs_Node RS inj_ontoD; |
|
67 |
||
68 |
||
69 |
(*** Introduction rules for Node ***) |
|
70 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
71 |
goalw Univ.thy [Node_def] "(%k. 0,a) : Node"; |
2891 | 72 |
by (Blast_tac 1); |
923 | 73 |
qed "Node_K0_I"; |
74 |
||
75 |
goalw Univ.thy [Node_def,Push_def] |
|
76 |
"!!p. p: Node ==> apfst (Push i) p : Node"; |
|
2891 | 77 |
by (blast_tac (!claset addSIs [apfst_conv, nat_case_Suc RS trans]) 1); |
923 | 78 |
qed "Node_Push_I"; |
79 |
||
80 |
||
81 |
(*** Distinctness of constructors ***) |
|
82 |
||
83 |
(** Scons vs Atom **) |
|
84 |
||
85 |
goalw Univ.thy [Atom_def,Scons_def,Push_Node_def] "(M$N) ~= Atom(a)"; |
|
86 |
by (rtac notI 1); |
|
87 |
by (etac (equalityD2 RS subsetD RS UnE) 1); |
|
88 |
by (rtac singletonI 1); |
|
976
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
89 |
by (REPEAT (eresolve_tac [imageE, Abs_Node_inject RS apfst_convE, |
1465 | 90 |
Pair_inject, sym RS Push_neq_K0] 1 |
923 | 91 |
ORELSE resolve_tac [Node_K0_I, Rep_Node RS Node_Push_I] 1)); |
92 |
qed "Scons_not_Atom"; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
93 |
bind_thm ("Atom_not_Scons", Scons_not_Atom RS not_sym); |
923 | 94 |
|
95 |
||
96 |
(*** Injectiveness ***) |
|
97 |
||
98 |
(** Atomic nodes **) |
|
99 |
||
1563 | 100 |
goalw Univ.thy [Atom_def, inj_def] "inj(Atom)"; |
2891 | 101 |
by (blast_tac (!claset addSIs [Node_K0_I] addSDs [Abs_Node_inject]) 1); |
923 | 102 |
qed "inj_Atom"; |
103 |
val Atom_inject = inj_Atom RS injD; |
|
104 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
105 |
goal Univ.thy "(Atom(a)=Atom(b)) = (a=b)"; |
2891 | 106 |
by (blast_tac (!claset addSDs [Atom_inject]) 1); |
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
107 |
qed "Atom_Atom_eq"; |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
108 |
AddIffs [Atom_Atom_eq]; |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
109 |
|
923 | 110 |
goalw Univ.thy [Leaf_def,o_def] "inj(Leaf)"; |
111 |
by (rtac injI 1); |
|
112 |
by (etac (Atom_inject RS Inl_inject) 1); |
|
113 |
qed "inj_Leaf"; |
|
114 |
||
115 |
val Leaf_inject = inj_Leaf RS injD; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
116 |
AddSDs [Leaf_inject]; |
923 | 117 |
|
118 |
goalw Univ.thy [Numb_def,o_def] "inj(Numb)"; |
|
119 |
by (rtac injI 1); |
|
120 |
by (etac (Atom_inject RS Inr_inject) 1); |
|
121 |
qed "inj_Numb"; |
|
122 |
||
123 |
val Numb_inject = inj_Numb RS injD; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
124 |
AddSDs [Numb_inject]; |
923 | 125 |
|
126 |
(** Injectiveness of Push_Node **) |
|
127 |
||
128 |
val [major,minor] = goalw Univ.thy [Push_Node_def] |
|
129 |
"[| Push_Node i m =Push_Node j n; [| i=j; m=n |] ==> P \ |
|
130 |
\ |] ==> P"; |
|
976
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
131 |
by (rtac (major RS Abs_Node_inject RS apfst_convE) 1); |
923 | 132 |
by (REPEAT (resolve_tac [Rep_Node RS Node_Push_I] 1)); |
976
14b55f7fbf15
renamed theorem "apfst" to "apfst_conv" to avoid conflict with function
clasohm
parents:
972
diff
changeset
|
133 |
by (etac (sym RS apfst_convE) 1); |
923 | 134 |
by (rtac minor 1); |
135 |
by (etac Pair_inject 1); |
|
136 |
by (etac (Push_inject1 RS sym) 1); |
|
137 |
by (rtac (inj_Rep_Node RS injD) 1); |
|
138 |
by (etac trans 1); |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
139 |
by (safe_tac (!claset addSEs [Push_inject,sym])); |
923 | 140 |
qed "Push_Node_inject"; |
141 |
||
142 |
||
143 |
(** Injectiveness of Scons **) |
|
144 |
||
2891 | 145 |
goalw Univ.thy [Scons_def] "!!M. M$N <= M'$N' ==> M<=M'"; |
146 |
by (blast_tac (!claset addSDs [Push_Node_inject]) 1); |
|
923 | 147 |
qed "Scons_inject_lemma1"; |
148 |
||
2891 | 149 |
goalw Univ.thy [Scons_def] "!!M. M$N <= M'$N' ==> N<=N'"; |
2935 | 150 |
by (blast_tac (!claset addSDs [Push_Node_inject]) 1); |
923 | 151 |
qed "Scons_inject_lemma2"; |
152 |
||
153 |
val [major] = goal Univ.thy "M$N = M'$N' ==> M=M'"; |
|
154 |
by (rtac (major RS equalityE) 1); |
|
155 |
by (REPEAT (ares_tac [equalityI, Scons_inject_lemma1] 1)); |
|
156 |
qed "Scons_inject1"; |
|
157 |
||
158 |
val [major] = goal Univ.thy "M$N = M'$N' ==> N=N'"; |
|
159 |
by (rtac (major RS equalityE) 1); |
|
160 |
by (REPEAT (ares_tac [equalityI, Scons_inject_lemma2] 1)); |
|
161 |
qed "Scons_inject2"; |
|
162 |
||
163 |
val [major,minor] = goal Univ.thy |
|
164 |
"[| M$N = M'$N'; [| M=M'; N=N' |] ==> P \ |
|
165 |
\ |] ==> P"; |
|
166 |
by (rtac ((major RS Scons_inject2) RS ((major RS Scons_inject1) RS minor)) 1); |
|
167 |
qed "Scons_inject"; |
|
168 |
||
169 |
goal Univ.thy "(M$N = M'$N') = (M=M' & N=N')"; |
|
2891 | 170 |
by (blast_tac (!claset addSEs [Scons_inject]) 1); |
923 | 171 |
qed "Scons_Scons_eq"; |
172 |
||
173 |
(*** Distinctness involving Leaf and Numb ***) |
|
174 |
||
175 |
(** Scons vs Leaf **) |
|
176 |
||
177 |
goalw Univ.thy [Leaf_def,o_def] "(M$N) ~= Leaf(a)"; |
|
178 |
by (rtac Scons_not_Atom 1); |
|
179 |
qed "Scons_not_Leaf"; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
180 |
bind_thm ("Leaf_not_Scons", Scons_not_Leaf RS not_sym); |
923 | 181 |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
182 |
AddIffs [Scons_not_Leaf, Leaf_not_Scons]; |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
183 |
|
923 | 184 |
|
185 |
(** Scons vs Numb **) |
|
186 |
||
187 |
goalw Univ.thy [Numb_def,o_def] "(M$N) ~= Numb(k)"; |
|
188 |
by (rtac Scons_not_Atom 1); |
|
189 |
qed "Scons_not_Numb"; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
190 |
bind_thm ("Numb_not_Scons", Scons_not_Numb RS not_sym); |
923 | 191 |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
192 |
AddIffs [Scons_not_Numb, Numb_not_Scons]; |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
193 |
|
923 | 194 |
|
195 |
(** Leaf vs Numb **) |
|
196 |
||
197 |
goalw Univ.thy [Leaf_def,Numb_def] "Leaf(a) ~= Numb(k)"; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
198 |
by (simp_tac (!simpset addsimps [Inl_not_Inr]) 1); |
923 | 199 |
qed "Leaf_not_Numb"; |
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
200 |
bind_thm ("Numb_not_Leaf", Leaf_not_Numb RS not_sym); |
923 | 201 |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
202 |
AddIffs [Leaf_not_Numb, Numb_not_Leaf]; |
923 | 203 |
|
204 |
||
205 |
(*** ndepth -- the depth of a node ***) |
|
206 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
207 |
Addsimps [apfst_conv]; |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
208 |
AddIffs [Scons_not_Atom, Atom_not_Scons, Scons_Scons_eq]; |
923 | 209 |
|
210 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
211 |
goalw Univ.thy [ndepth_def] "ndepth (Abs_Node((%k.0, x))) = 0"; |
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1465
diff
changeset
|
212 |
by (EVERY1[stac (Node_K0_I RS Abs_Node_inverse), stac split]); |
923 | 213 |
by (rtac Least_equality 1); |
214 |
by (rtac refl 1); |
|
215 |
by (etac less_zeroE 1); |
|
216 |
qed "ndepth_K0"; |
|
217 |
||
218 |
goal Univ.thy "k < Suc(LEAST x. f(x)=0) --> nat_case (Suc i) f k ~= 0"; |
|
219 |
by (nat_ind_tac "k" 1); |
|
1264 | 220 |
by (ALLGOALS Simp_tac); |
923 | 221 |
by (rtac impI 1); |
222 |
by (etac not_less_Least 1); |
|
223 |
qed "ndepth_Push_lemma"; |
|
224 |
||
225 |
goalw Univ.thy [ndepth_def,Push_Node_def] |
|
226 |
"ndepth (Push_Node i n) = Suc(ndepth(n))"; |
|
227 |
by (stac (Rep_Node RS Node_Push_I RS Abs_Node_inverse) 1); |
|
228 |
by (cut_facts_tac [rewrite_rule [Node_def] Rep_Node] 1); |
|
1786
8a31d85d27b8
best_tac, deepen_tac and safe_tac now also use default claset.
berghofe
parents:
1761
diff
changeset
|
229 |
by (safe_tac (!claset)); |
1465 | 230 |
by (etac ssubst 1); (*instantiates type variables!*) |
1264 | 231 |
by (Simp_tac 1); |
923 | 232 |
by (rtac Least_equality 1); |
233 |
by (rewtac Push_def); |
|
234 |
by (rtac (nat_case_Suc RS trans) 1); |
|
235 |
by (etac LeastI 1); |
|
236 |
by (etac (ndepth_Push_lemma RS mp) 1); |
|
237 |
qed "ndepth_Push_Node"; |
|
238 |
||
239 |
||
240 |
(*** ntrunc applied to the various node sets ***) |
|
241 |
||
242 |
goalw Univ.thy [ntrunc_def] "ntrunc 0 M = {}"; |
|
2891 | 243 |
by (Blast_tac 1); |
923 | 244 |
qed "ntrunc_0"; |
245 |
||
246 |
goalw Univ.thy [Atom_def,ntrunc_def] "ntrunc (Suc k) (Atom a) = Atom(a)"; |
|
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
247 |
by (fast_tac (!claset addss (!simpset addsimps [ndepth_K0])) 1); |
923 | 248 |
qed "ntrunc_Atom"; |
249 |
||
250 |
goalw Univ.thy [Leaf_def,o_def] "ntrunc (Suc k) (Leaf a) = Leaf(a)"; |
|
251 |
by (rtac ntrunc_Atom 1); |
|
252 |
qed "ntrunc_Leaf"; |
|
253 |
||
254 |
goalw Univ.thy [Numb_def,o_def] "ntrunc (Suc k) (Numb i) = Numb(i)"; |
|
255 |
by (rtac ntrunc_Atom 1); |
|
256 |
qed "ntrunc_Numb"; |
|
257 |
||
258 |
goalw Univ.thy [Scons_def,ntrunc_def] |
|
259 |
"ntrunc (Suc k) (M$N) = ntrunc k M $ ntrunc k N"; |
|
2891 | 260 |
by (safe_tac (!claset addSIs [equalityI, imageI])); |
923 | 261 |
by (REPEAT (stac ndepth_Push_Node 3 THEN etac Suc_mono 3)); |
262 |
by (REPEAT (rtac Suc_less_SucD 1 THEN |
|
1465 | 263 |
rtac (ndepth_Push_Node RS subst) 1 THEN |
264 |
assume_tac 1)); |
|
923 | 265 |
qed "ntrunc_Scons"; |
266 |
||
267 |
(** Injection nodes **) |
|
268 |
||
269 |
goalw Univ.thy [In0_def] "ntrunc (Suc 0) (In0 M) = {}"; |
|
1264 | 270 |
by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
923 | 271 |
by (rewtac Scons_def); |
2891 | 272 |
by (Blast_tac 1); |
923 | 273 |
qed "ntrunc_one_In0"; |
274 |
||
275 |
goalw Univ.thy [In0_def] |
|
276 |
"ntrunc (Suc (Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"; |
|
1264 | 277 |
by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
923 | 278 |
qed "ntrunc_In0"; |
279 |
||
280 |
goalw Univ.thy [In1_def] "ntrunc (Suc 0) (In1 M) = {}"; |
|
1264 | 281 |
by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
923 | 282 |
by (rewtac Scons_def); |
2891 | 283 |
by (Blast_tac 1); |
923 | 284 |
qed "ntrunc_one_In1"; |
285 |
||
286 |
goalw Univ.thy [In1_def] |
|
287 |
"ntrunc (Suc (Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"; |
|
1264 | 288 |
by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
923 | 289 |
qed "ntrunc_In1"; |
290 |
||
291 |
||
292 |
(*** Cartesian Product ***) |
|
293 |
||
294 |
goalw Univ.thy [uprod_def] "!!M N. [| M:A; N:B |] ==> (M$N) : A<*>B"; |
|
295 |
by (REPEAT (ares_tac [singletonI,UN_I] 1)); |
|
296 |
qed "uprodI"; |
|
297 |
||
298 |
(*The general elimination rule*) |
|
299 |
val major::prems = goalw Univ.thy [uprod_def] |
|
300 |
"[| c : A<*>B; \ |
|
301 |
\ !!x y. [| x:A; y:B; c=x$y |] ==> P \ |
|
302 |
\ |] ==> P"; |
|
303 |
by (cut_facts_tac [major] 1); |
|
304 |
by (REPEAT (eresolve_tac [asm_rl,singletonE,UN_E] 1 |
|
305 |
ORELSE resolve_tac prems 1)); |
|
306 |
qed "uprodE"; |
|
307 |
||
308 |
(*Elimination of a pair -- introduces no eigenvariables*) |
|
309 |
val prems = goal Univ.thy |
|
310 |
"[| (M$N) : A<*>B; [| M:A; N:B |] ==> P \ |
|
311 |
\ |] ==> P"; |
|
312 |
by (rtac uprodE 1); |
|
313 |
by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Scons_inject,ssubst] 1)); |
|
314 |
qed "uprodE2"; |
|
315 |
||
316 |
||
317 |
(*** Disjoint Sum ***) |
|
318 |
||
319 |
goalw Univ.thy [usum_def] "!!M. M:A ==> In0(M) : A<+>B"; |
|
2891 | 320 |
by (Blast_tac 1); |
923 | 321 |
qed "usum_In0I"; |
322 |
||
323 |
goalw Univ.thy [usum_def] "!!N. N:B ==> In1(N) : A<+>B"; |
|
2891 | 324 |
by (Blast_tac 1); |
923 | 325 |
qed "usum_In1I"; |
326 |
||
327 |
val major::prems = goalw Univ.thy [usum_def] |
|
328 |
"[| u : A<+>B; \ |
|
329 |
\ !!x. [| x:A; u=In0(x) |] ==> P; \ |
|
330 |
\ !!y. [| y:B; u=In1(y) |] ==> P \ |
|
331 |
\ |] ==> P"; |
|
332 |
by (rtac (major RS UnE) 1); |
|
333 |
by (REPEAT (rtac refl 1 |
|
334 |
ORELSE eresolve_tac (prems@[imageE,ssubst]) 1)); |
|
335 |
qed "usumE"; |
|
336 |
||
337 |
||
338 |
(** Injection **) |
|
339 |
||
340 |
goalw Univ.thy [In0_def,In1_def] "In0(M) ~= In1(N)"; |
|
341 |
by (rtac notI 1); |
|
342 |
by (etac (Scons_inject1 RS Numb_inject RS Zero_neq_Suc) 1); |
|
343 |
qed "In0_not_In1"; |
|
344 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
345 |
bind_thm ("In1_not_In0", In0_not_In1 RS not_sym); |
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
346 |
|
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
347 |
AddIffs [In0_not_In1, In1_not_In0]; |
923 | 348 |
|
349 |
val [major] = goalw Univ.thy [In0_def] "In0(M) = In0(N) ==> M=N"; |
|
350 |
by (rtac (major RS Scons_inject2) 1); |
|
351 |
qed "In0_inject"; |
|
352 |
||
353 |
val [major] = goalw Univ.thy [In1_def] "In1(M) = In1(N) ==> M=N"; |
|
354 |
by (rtac (major RS Scons_inject2) 1); |
|
355 |
qed "In1_inject"; |
|
356 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1786
diff
changeset
|
357 |
AddSDs [In0_inject, In1_inject]; |
923 | 358 |
|
359 |
(*** proving equality of sets and functions using ntrunc ***) |
|
360 |
||
361 |
goalw Univ.thy [ntrunc_def] "ntrunc k M <= M"; |
|
2891 | 362 |
by (Blast_tac 1); |
923 | 363 |
qed "ntrunc_subsetI"; |
364 |
||
365 |
val [major] = goalw Univ.thy [ntrunc_def] |
|
366 |
"(!!k. ntrunc k M <= N) ==> M<=N"; |
|
2891 | 367 |
by (blast_tac (!claset addIs [less_add_Suc1, less_add_Suc2, |
1465 | 368 |
major RS subsetD]) 1); |
923 | 369 |
qed "ntrunc_subsetD"; |
370 |
||
371 |
(*A generalized form of the take-lemma*) |
|
372 |
val [major] = goal Univ.thy "(!!k. ntrunc k M = ntrunc k N) ==> M=N"; |
|
373 |
by (rtac equalityI 1); |
|
374 |
by (ALLGOALS (rtac ntrunc_subsetD)); |
|
375 |
by (ALLGOALS (rtac (ntrunc_subsetI RSN (2, subset_trans)))); |
|
376 |
by (rtac (major RS equalityD1) 1); |
|
377 |
by (rtac (major RS equalityD2) 1); |
|
378 |
qed "ntrunc_equality"; |
|
379 |
||
380 |
val [major] = goalw Univ.thy [o_def] |
|
381 |
"[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2"; |
|
382 |
by (rtac (ntrunc_equality RS ext) 1); |
|
383 |
by (rtac (major RS fun_cong) 1); |
|
384 |
qed "ntrunc_o_equality"; |
|
385 |
||
386 |
(*** Monotonicity ***) |
|
387 |
||
388 |
goalw Univ.thy [uprod_def] "!!A B. [| A<=A'; B<=B' |] ==> A<*>B <= A'<*>B'"; |
|
2891 | 389 |
by (Blast_tac 1); |
923 | 390 |
qed "uprod_mono"; |
391 |
||
392 |
goalw Univ.thy [usum_def] "!!A B. [| A<=A'; B<=B' |] ==> A<+>B <= A'<+>B'"; |
|
2891 | 393 |
by (Blast_tac 1); |
923 | 394 |
qed "usum_mono"; |
395 |
||
396 |
goalw Univ.thy [Scons_def] "!!M N. [| M<=M'; N<=N' |] ==> M$N <= M'$N'"; |
|
2891 | 397 |
by (Blast_tac 1); |
923 | 398 |
qed "Scons_mono"; |
399 |
||
400 |
goalw Univ.thy [In0_def] "!!M N. M<=N ==> In0(M) <= In0(N)"; |
|
401 |
by (REPEAT (ares_tac [subset_refl,Scons_mono] 1)); |
|
402 |
qed "In0_mono"; |
|
403 |
||
404 |
goalw Univ.thy [In1_def] "!!M N. M<=N ==> In1(M) <= In1(N)"; |
|
405 |
by (REPEAT (ares_tac [subset_refl,Scons_mono] 1)); |
|
406 |
qed "In1_mono"; |
|
407 |
||
408 |
||
409 |
(*** Split and Case ***) |
|
410 |
||
411 |
goalw Univ.thy [Split_def] "Split c (M$N) = c M N"; |
|
2891 | 412 |
by (blast_tac (!claset addIs [select_equality]) 1); |
923 | 413 |
qed "Split"; |
414 |
||
415 |
goalw Univ.thy [Case_def] "Case c d (In0 M) = c(M)"; |
|
2891 | 416 |
by (blast_tac (!claset addIs [select_equality]) 1); |
923 | 417 |
qed "Case_In0"; |
418 |
||
419 |
goalw Univ.thy [Case_def] "Case c d (In1 N) = d(N)"; |
|
2891 | 420 |
by (blast_tac (!claset addIs [select_equality]) 1); |
923 | 421 |
qed "Case_In1"; |
422 |
||
423 |
(**** UN x. B(x) rules ****) |
|
424 |
||
425 |
goalw Univ.thy [ntrunc_def] "ntrunc k (UN x.f(x)) = (UN x. ntrunc k (f x))"; |
|
2891 | 426 |
by (Blast_tac 1); |
923 | 427 |
qed "ntrunc_UN1"; |
428 |
||
429 |
goalw Univ.thy [Scons_def] "(UN x.f(x)) $ M = (UN x. f(x) $ M)"; |
|
2891 | 430 |
by (Blast_tac 1); |
923 | 431 |
qed "Scons_UN1_x"; |
432 |
||
433 |
goalw Univ.thy [Scons_def] "M $ (UN x.f(x)) = (UN x. M $ f(x))"; |
|
2891 | 434 |
by (Blast_tac 1); |
923 | 435 |
qed "Scons_UN1_y"; |
436 |
||
437 |
goalw Univ.thy [In0_def] "In0(UN x.f(x)) = (UN x. In0(f(x)))"; |
|
1465 | 438 |
by (rtac Scons_UN1_y 1); |
923 | 439 |
qed "In0_UN1"; |
440 |
||
441 |
goalw Univ.thy [In1_def] "In1(UN x.f(x)) = (UN x. In1(f(x)))"; |
|
1465 | 442 |
by (rtac Scons_UN1_y 1); |
923 | 443 |
qed "In1_UN1"; |
444 |
||
445 |
||
446 |
(*** Equality : the diagonal relation ***) |
|
447 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
448 |
goalw Univ.thy [diag_def] "!!a A. [| a=b; a:A |] ==> (a,b) : diag(A)"; |
2891 | 449 |
by (Blast_tac 1); |
923 | 450 |
qed "diag_eqI"; |
451 |
||
452 |
val diagI = refl RS diag_eqI |> standard; |
|
453 |
||
454 |
(*The general elimination rule*) |
|
455 |
val major::prems = goalw Univ.thy [diag_def] |
|
456 |
"[| c : diag(A); \ |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
457 |
\ !!x y. [| x:A; c = (x,x) |] ==> P \ |
923 | 458 |
\ |] ==> P"; |
459 |
by (rtac (major RS UN_E) 1); |
|
460 |
by (REPEAT (eresolve_tac [asm_rl,singletonE] 1 ORELSE resolve_tac prems 1)); |
|
461 |
qed "diagE"; |
|
462 |
||
463 |
(*** Equality for Cartesian Product ***) |
|
464 |
||
465 |
goalw Univ.thy [dprod_def] |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
466 |
"!!r s. [| (M,M'):r; (N,N'):s |] ==> (M$N, M'$N') : r<**>s"; |
2891 | 467 |
by (Blast_tac 1); |
923 | 468 |
qed "dprodI"; |
469 |
||
470 |
(*The general elimination rule*) |
|
471 |
val major::prems = goalw Univ.thy [dprod_def] |
|
472 |
"[| c : r<**>s; \ |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
473 |
\ !!x y x' y'. [| (x,x') : r; (y,y') : s; c = (x$y,x'$y') |] ==> P \ |
923 | 474 |
\ |] ==> P"; |
475 |
by (cut_facts_tac [major] 1); |
|
476 |
by (REPEAT_FIRST (eresolve_tac [asm_rl, UN_E, mem_splitE, singletonE])); |
|
477 |
by (REPEAT (ares_tac prems 1 ORELSE hyp_subst_tac 1)); |
|
478 |
qed "dprodE"; |
|
479 |
||
480 |
||
481 |
(*** Equality for Disjoint Sum ***) |
|
482 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
483 |
goalw Univ.thy [dsum_def] "!!r. (M,M'):r ==> (In0(M), In0(M')) : r<++>s"; |
2891 | 484 |
by (Blast_tac 1); |
923 | 485 |
qed "dsum_In0I"; |
486 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
487 |
goalw Univ.thy [dsum_def] "!!r. (N,N'):s ==> (In1(N), In1(N')) : r<++>s"; |
2891 | 488 |
by (Blast_tac 1); |
923 | 489 |
qed "dsum_In1I"; |
490 |
||
491 |
val major::prems = goalw Univ.thy [dsum_def] |
|
492 |
"[| w : r<++>s; \ |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
493 |
\ !!x x'. [| (x,x') : r; w = (In0(x), In0(x')) |] ==> P; \ |
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
494 |
\ !!y y'. [| (y,y') : s; w = (In1(y), In1(y')) |] ==> P \ |
923 | 495 |
\ |] ==> P"; |
496 |
by (cut_facts_tac [major] 1); |
|
497 |
by (REPEAT_FIRST (eresolve_tac [asm_rl, UN_E, UnE, mem_splitE, singletonE])); |
|
498 |
by (DEPTH_SOLVE (ares_tac prems 1 ORELSE hyp_subst_tac 1)); |
|
499 |
qed "dsumE"; |
|
500 |
||
501 |
||
1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1642
diff
changeset
|
502 |
AddSIs [diagI, uprodI, dprodI]; |
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1642
diff
changeset
|
503 |
AddIs [usum_In0I, usum_In1I, dsum_In0I, dsum_In1I]; |
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1642
diff
changeset
|
504 |
AddSEs [diagE, uprodE, dprodE, usumE, dsumE]; |
923 | 505 |
|
506 |
(*** Monotonicity ***) |
|
507 |
||
508 |
goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<**>s <= r'<**>s'"; |
|
2891 | 509 |
by (Blast_tac 1); |
923 | 510 |
qed "dprod_mono"; |
511 |
||
512 |
goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<++>s <= r'<++>s'"; |
|
2891 | 513 |
by (Blast_tac 1); |
923 | 514 |
qed "dsum_mono"; |
515 |
||
516 |
||
517 |
(*** Bounding theorems ***) |
|
518 |
||
1642 | 519 |
goal Univ.thy "diag(A) <= A Times A"; |
2891 | 520 |
by (Blast_tac 1); |
923 | 521 |
qed "diag_subset_Sigma"; |
522 |
||
1642 | 523 |
goal Univ.thy "((A Times B) <**> (C Times D)) <= (A<*>C) Times (B<*>D)"; |
2891 | 524 |
by (Blast_tac 1); |
923 | 525 |
qed "dprod_Sigma"; |
526 |
||
527 |
val dprod_subset_Sigma = [dprod_mono, dprod_Sigma] MRS subset_trans |>standard; |
|
528 |
||
529 |
(*Dependent version*) |
|
530 |
goal Univ.thy |
|
531 |
"(Sigma A B <**> Sigma C D) <= Sigma (A<*>C) (Split(%x y. B(x)<*>D(y)))"; |
|
1786
8a31d85d27b8
best_tac, deepen_tac and safe_tac now also use default claset.
berghofe
parents:
1761
diff
changeset
|
532 |
by (safe_tac (!claset)); |
923 | 533 |
by (stac Split 1); |
2891 | 534 |
by (Blast_tac 1); |
923 | 535 |
qed "dprod_subset_Sigma2"; |
536 |
||
1642 | 537 |
goal Univ.thy "(A Times B <++> C Times D) <= (A<+>C) Times (B<+>D)"; |
2891 | 538 |
by (Blast_tac 1); |
923 | 539 |
qed "dsum_Sigma"; |
540 |
||
541 |
val dsum_subset_Sigma = [dsum_mono, dsum_Sigma] MRS subset_trans |> standard; |
|
542 |
||
543 |
||
544 |
(*** Domain ***) |
|
545 |
||
546 |
goal Univ.thy "fst `` diag(A) = A"; |
|
2891 | 547 |
by (Blast_tac 1); |
923 | 548 |
qed "fst_image_diag"; |
549 |
||
550 |
goal Univ.thy "fst `` (r<**>s) = (fst``r) <*> (fst``s)"; |
|
2891 | 551 |
by (Blast_tac 1); |
923 | 552 |
qed "fst_image_dprod"; |
553 |
||
554 |
goal Univ.thy "fst `` (r<++>s) = (fst``r) <+> (fst``s)"; |
|
2891 | 555 |
by (Blast_tac 1); |
923 | 556 |
qed "fst_image_dsum"; |
557 |
||
1264 | 558 |
Addsimps [fst_image_diag, fst_image_dprod, fst_image_dsum]; |