67 |
67 |
68 |
68 |
69 (*** Introduction rules for Node ***) |
69 (*** Introduction rules for Node ***) |
70 |
70 |
71 goalw Univ.thy [Node_def] "(%k. 0,a) : Node"; |
71 goalw Univ.thy [Node_def] "(%k. 0,a) : Node"; |
72 by (Fast_tac 1); |
72 by (Blast_tac 1); |
73 qed "Node_K0_I"; |
73 qed "Node_K0_I"; |
74 |
74 |
75 goalw Univ.thy [Node_def,Push_def] |
75 goalw Univ.thy [Node_def,Push_def] |
76 "!!p. p: Node ==> apfst (Push i) p : Node"; |
76 "!!p. p: Node ==> apfst (Push i) p : Node"; |
77 by (fast_tac (!claset addSIs [apfst_conv, nat_case_Suc RS trans]) 1); |
77 by (blast_tac (!claset addSIs [apfst_conv, nat_case_Suc RS trans]) 1); |
78 qed "Node_Push_I"; |
78 qed "Node_Push_I"; |
79 |
79 |
80 |
80 |
81 (*** Distinctness of constructors ***) |
81 (*** Distinctness of constructors ***) |
82 |
82 |
96 (*** Injectiveness ***) |
96 (*** Injectiveness ***) |
97 |
97 |
98 (** Atomic nodes **) |
98 (** Atomic nodes **) |
99 |
99 |
100 goalw Univ.thy [Atom_def, inj_def] "inj(Atom)"; |
100 goalw Univ.thy [Atom_def, inj_def] "inj(Atom)"; |
101 by (fast_tac (!claset addSIs [Node_K0_I] addSDs [Abs_Node_inject]) 1); |
101 by (blast_tac (!claset addSIs [Node_K0_I] addSDs [Abs_Node_inject]) 1); |
102 qed "inj_Atom"; |
102 qed "inj_Atom"; |
103 val Atom_inject = inj_Atom RS injD; |
103 val Atom_inject = inj_Atom RS injD; |
104 |
104 |
105 goal Univ.thy "(Atom(a)=Atom(b)) = (a=b)"; |
105 goal Univ.thy "(Atom(a)=Atom(b)) = (a=b)"; |
106 by (fast_tac (!claset addSEs [Atom_inject]) 1); |
106 by (blast_tac (!claset addSDs [Atom_inject]) 1); |
107 qed "Atom_Atom_eq"; |
107 qed "Atom_Atom_eq"; |
108 AddIffs [Atom_Atom_eq]; |
108 AddIffs [Atom_Atom_eq]; |
109 |
109 |
110 goalw Univ.thy [Leaf_def,o_def] "inj(Leaf)"; |
110 goalw Univ.thy [Leaf_def,o_def] "inj(Leaf)"; |
111 by (rtac injI 1); |
111 by (rtac injI 1); |
140 qed "Push_Node_inject"; |
140 qed "Push_Node_inject"; |
141 |
141 |
142 |
142 |
143 (** Injectiveness of Scons **) |
143 (** Injectiveness of Scons **) |
144 |
144 |
145 val [major] = goalw Univ.thy [Scons_def] "M$N <= M'$N' ==> M<=M'"; |
145 goalw Univ.thy [Scons_def] "!!M. M$N <= M'$N' ==> M<=M'"; |
146 by (cut_facts_tac [major] 1); |
146 by (blast_tac (!claset addSDs [Push_Node_inject]) 1); |
147 by (fast_tac (!claset addSEs [Push_Node_inject]) 1); |
|
148 qed "Scons_inject_lemma1"; |
147 qed "Scons_inject_lemma1"; |
149 |
148 |
150 val [major] = goalw Univ.thy [Scons_def] "M$N <= M'$N' ==> N<=N'"; |
149 goalw Univ.thy [Scons_def] "!!M. M$N <= M'$N' ==> N<=N'"; |
151 by (cut_facts_tac [major] 1); |
150 by (fast_tac (!claset addSDs [Push_Node_inject]) 1); |
152 by (fast_tac (!claset addSEs [Push_Node_inject]) 1); |
|
153 qed "Scons_inject_lemma2"; |
151 qed "Scons_inject_lemma2"; |
154 |
152 |
155 val [major] = goal Univ.thy "M$N = M'$N' ==> M=M'"; |
153 val [major] = goal Univ.thy "M$N = M'$N' ==> M=M'"; |
156 by (rtac (major RS equalityE) 1); |
154 by (rtac (major RS equalityE) 1); |
157 by (REPEAT (ares_tac [equalityI, Scons_inject_lemma1] 1)); |
155 by (REPEAT (ares_tac [equalityI, Scons_inject_lemma1] 1)); |
169 qed "Scons_inject"; |
167 qed "Scons_inject"; |
170 |
168 |
171 AddSDs [Scons_inject]; |
169 AddSDs [Scons_inject]; |
172 |
170 |
173 goal Univ.thy "(M$N = M'$N') = (M=M' & N=N')"; |
171 goal Univ.thy "(M$N = M'$N') = (M=M' & N=N')"; |
174 by (fast_tac (!claset addSEs [Scons_inject]) 1); |
172 by (blast_tac (!claset addSEs [Scons_inject]) 1); |
175 qed "Scons_Scons_eq"; |
173 qed "Scons_Scons_eq"; |
176 |
174 |
177 (*** Distinctness involving Leaf and Numb ***) |
175 (*** Distinctness involving Leaf and Numb ***) |
178 |
176 |
179 (** Scons vs Leaf **) |
177 (** Scons vs Leaf **) |
259 by (rtac ntrunc_Atom 1); |
257 by (rtac ntrunc_Atom 1); |
260 qed "ntrunc_Numb"; |
258 qed "ntrunc_Numb"; |
261 |
259 |
262 goalw Univ.thy [Scons_def,ntrunc_def] |
260 goalw Univ.thy [Scons_def,ntrunc_def] |
263 "ntrunc (Suc k) (M$N) = ntrunc k M $ ntrunc k N"; |
261 "ntrunc (Suc k) (M$N) = ntrunc k M $ ntrunc k N"; |
264 by (safe_tac ((claset_of "Fun") addSIs [equalityI,imageI])); |
262 by (safe_tac (!claset addSIs [equalityI, imageI])); |
265 by (REPEAT (stac ndepth_Push_Node 3 THEN etac Suc_mono 3)); |
263 by (REPEAT (stac ndepth_Push_Node 3 THEN etac Suc_mono 3)); |
266 by (REPEAT (rtac Suc_less_SucD 1 THEN |
264 by (REPEAT (rtac Suc_less_SucD 1 THEN |
267 rtac (ndepth_Push_Node RS subst) 1 THEN |
265 rtac (ndepth_Push_Node RS subst) 1 THEN |
268 assume_tac 1)); |
266 assume_tac 1)); |
269 qed "ntrunc_Scons"; |
267 qed "ntrunc_Scons"; |
271 (** Injection nodes **) |
269 (** Injection nodes **) |
272 |
270 |
273 goalw Univ.thy [In0_def] "ntrunc (Suc 0) (In0 M) = {}"; |
271 goalw Univ.thy [In0_def] "ntrunc (Suc 0) (In0 M) = {}"; |
274 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
272 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
275 by (rewtac Scons_def); |
273 by (rewtac Scons_def); |
276 by (Fast_tac 1); |
274 by (Blast_tac 1); |
277 qed "ntrunc_one_In0"; |
275 qed "ntrunc_one_In0"; |
278 |
276 |
279 goalw Univ.thy [In0_def] |
277 goalw Univ.thy [In0_def] |
280 "ntrunc (Suc (Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"; |
278 "ntrunc (Suc (Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"; |
281 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
279 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
282 qed "ntrunc_In0"; |
280 qed "ntrunc_In0"; |
283 |
281 |
284 goalw Univ.thy [In1_def] "ntrunc (Suc 0) (In1 M) = {}"; |
282 goalw Univ.thy [In1_def] "ntrunc (Suc 0) (In1 M) = {}"; |
285 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
283 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_0]) 1); |
286 by (rewtac Scons_def); |
284 by (rewtac Scons_def); |
287 by (Fast_tac 1); |
285 by (Blast_tac 1); |
288 qed "ntrunc_one_In1"; |
286 qed "ntrunc_one_In1"; |
289 |
287 |
290 goalw Univ.thy [In1_def] |
288 goalw Univ.thy [In1_def] |
291 "ntrunc (Suc (Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"; |
289 "ntrunc (Suc (Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"; |
292 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
290 by (simp_tac (!simpset addsimps [ntrunc_Scons,ntrunc_Numb]) 1); |
361 AddSDs [In0_inject, In1_inject]; |
359 AddSDs [In0_inject, In1_inject]; |
362 |
360 |
363 (*** proving equality of sets and functions using ntrunc ***) |
361 (*** proving equality of sets and functions using ntrunc ***) |
364 |
362 |
365 goalw Univ.thy [ntrunc_def] "ntrunc k M <= M"; |
363 goalw Univ.thy [ntrunc_def] "ntrunc k M <= M"; |
366 by (Fast_tac 1); |
364 by (Blast_tac 1); |
367 qed "ntrunc_subsetI"; |
365 qed "ntrunc_subsetI"; |
368 |
366 |
369 val [major] = goalw Univ.thy [ntrunc_def] |
367 val [major] = goalw Univ.thy [ntrunc_def] |
370 "(!!k. ntrunc k M <= N) ==> M<=N"; |
368 "(!!k. ntrunc k M <= N) ==> M<=N"; |
371 by (fast_tac (!claset addIs [less_add_Suc1, less_add_Suc2, |
369 by (blast_tac (!claset addIs [less_add_Suc1, less_add_Suc2, |
372 major RS subsetD]) 1); |
370 major RS subsetD]) 1); |
373 qed "ntrunc_subsetD"; |
371 qed "ntrunc_subsetD"; |
374 |
372 |
375 (*A generalized form of the take-lemma*) |
373 (*A generalized form of the take-lemma*) |
376 val [major] = goal Univ.thy "(!!k. ntrunc k M = ntrunc k N) ==> M=N"; |
374 val [major] = goal Univ.thy "(!!k. ntrunc k M = ntrunc k N) ==> M=N"; |
388 qed "ntrunc_o_equality"; |
386 qed "ntrunc_o_equality"; |
389 |
387 |
390 (*** Monotonicity ***) |
388 (*** Monotonicity ***) |
391 |
389 |
392 goalw Univ.thy [uprod_def] "!!A B. [| A<=A'; B<=B' |] ==> A<*>B <= A'<*>B'"; |
390 goalw Univ.thy [uprod_def] "!!A B. [| A<=A'; B<=B' |] ==> A<*>B <= A'<*>B'"; |
393 by (Fast_tac 1); |
391 by (Blast_tac 1); |
394 qed "uprod_mono"; |
392 qed "uprod_mono"; |
395 |
393 |
396 goalw Univ.thy [usum_def] "!!A B. [| A<=A'; B<=B' |] ==> A<+>B <= A'<+>B'"; |
394 goalw Univ.thy [usum_def] "!!A B. [| A<=A'; B<=B' |] ==> A<+>B <= A'<+>B'"; |
397 by (Fast_tac 1); |
395 by (Blast_tac 1); |
398 qed "usum_mono"; |
396 qed "usum_mono"; |
399 |
397 |
400 goalw Univ.thy [Scons_def] "!!M N. [| M<=M'; N<=N' |] ==> M$N <= M'$N'"; |
398 goalw Univ.thy [Scons_def] "!!M N. [| M<=M'; N<=N' |] ==> M$N <= M'$N'"; |
401 by (Fast_tac 1); |
399 by (Blast_tac 1); |
402 qed "Scons_mono"; |
400 qed "Scons_mono"; |
403 |
401 |
404 goalw Univ.thy [In0_def] "!!M N. M<=N ==> In0(M) <= In0(N)"; |
402 goalw Univ.thy [In0_def] "!!M N. M<=N ==> In0(M) <= In0(N)"; |
405 by (REPEAT (ares_tac [subset_refl,Scons_mono] 1)); |
403 by (REPEAT (ares_tac [subset_refl,Scons_mono] 1)); |
406 qed "In0_mono"; |
404 qed "In0_mono"; |
411 |
409 |
412 |
410 |
413 (*** Split and Case ***) |
411 (*** Split and Case ***) |
414 |
412 |
415 goalw Univ.thy [Split_def] "Split c (M$N) = c M N"; |
413 goalw Univ.thy [Split_def] "Split c (M$N) = c M N"; |
416 by (fast_tac (!claset addIs [select_equality]) 1); |
414 by (blast_tac (!claset addIs [select_equality]) 1); |
417 qed "Split"; |
415 qed "Split"; |
418 |
416 |
419 goalw Univ.thy [Case_def] "Case c d (In0 M) = c(M)"; |
417 goalw Univ.thy [Case_def] "Case c d (In0 M) = c(M)"; |
420 by (fast_tac (!claset addIs [select_equality]) 1); |
418 by (blast_tac (!claset addIs [select_equality]) 1); |
421 qed "Case_In0"; |
419 qed "Case_In0"; |
422 |
420 |
423 goalw Univ.thy [Case_def] "Case c d (In1 N) = d(N)"; |
421 goalw Univ.thy [Case_def] "Case c d (In1 N) = d(N)"; |
424 by (fast_tac (!claset addIs [select_equality]) 1); |
422 by (blast_tac (!claset addIs [select_equality]) 1); |
425 qed "Case_In1"; |
423 qed "Case_In1"; |
426 |
424 |
427 (**** UN x. B(x) rules ****) |
425 (**** UN x. B(x) rules ****) |
428 |
426 |
429 goalw Univ.thy [ntrunc_def] "ntrunc k (UN x.f(x)) = (UN x. ntrunc k (f x))"; |
427 goalw Univ.thy [ntrunc_def] "ntrunc k (UN x.f(x)) = (UN x. ntrunc k (f x))"; |
430 by (Fast_tac 1); |
428 by (Blast_tac 1); |
431 qed "ntrunc_UN1"; |
429 qed "ntrunc_UN1"; |
432 |
430 |
433 goalw Univ.thy [Scons_def] "(UN x.f(x)) $ M = (UN x. f(x) $ M)"; |
431 goalw Univ.thy [Scons_def] "(UN x.f(x)) $ M = (UN x. f(x) $ M)"; |
434 by (Fast_tac 1); |
432 by (Blast_tac 1); |
435 qed "Scons_UN1_x"; |
433 qed "Scons_UN1_x"; |
436 |
434 |
437 goalw Univ.thy [Scons_def] "M $ (UN x.f(x)) = (UN x. M $ f(x))"; |
435 goalw Univ.thy [Scons_def] "M $ (UN x.f(x)) = (UN x. M $ f(x))"; |
438 by (Fast_tac 1); |
436 by (Blast_tac 1); |
439 qed "Scons_UN1_y"; |
437 qed "Scons_UN1_y"; |
440 |
438 |
441 goalw Univ.thy [In0_def] "In0(UN x.f(x)) = (UN x. In0(f(x)))"; |
439 goalw Univ.thy [In0_def] "In0(UN x.f(x)) = (UN x. In0(f(x)))"; |
442 by (rtac Scons_UN1_y 1); |
440 by (rtac Scons_UN1_y 1); |
443 qed "In0_UN1"; |
441 qed "In0_UN1"; |
466 |
464 |
467 (*** Equality for Cartesian Product ***) |
465 (*** Equality for Cartesian Product ***) |
468 |
466 |
469 goalw Univ.thy [dprod_def] |
467 goalw Univ.thy [dprod_def] |
470 "!!r s. [| (M,M'):r; (N,N'):s |] ==> (M$N, M'$N') : r<**>s"; |
468 "!!r s. [| (M,M'):r; (N,N'):s |] ==> (M$N, M'$N') : r<**>s"; |
471 by (Fast_tac 1); |
469 by (Blast_tac 1); |
472 qed "dprodI"; |
470 qed "dprodI"; |
473 |
471 |
474 (*The general elimination rule*) |
472 (*The general elimination rule*) |
475 val major::prems = goalw Univ.thy [dprod_def] |
473 val major::prems = goalw Univ.thy [dprod_def] |
476 "[| c : r<**>s; \ |
474 "[| c : r<**>s; \ |
483 |
481 |
484 |
482 |
485 (*** Equality for Disjoint Sum ***) |
483 (*** Equality for Disjoint Sum ***) |
486 |
484 |
487 goalw Univ.thy [dsum_def] "!!r. (M,M'):r ==> (In0(M), In0(M')) : r<++>s"; |
485 goalw Univ.thy [dsum_def] "!!r. (M,M'):r ==> (In0(M), In0(M')) : r<++>s"; |
488 by (Fast_tac 1); |
486 by (Blast_tac 1); |
489 qed "dsum_In0I"; |
487 qed "dsum_In0I"; |
490 |
488 |
491 goalw Univ.thy [dsum_def] "!!r. (N,N'):s ==> (In1(N), In1(N')) : r<++>s"; |
489 goalw Univ.thy [dsum_def] "!!r. (N,N'):s ==> (In1(N), In1(N')) : r<++>s"; |
492 by (Fast_tac 1); |
490 by (Blast_tac 1); |
493 qed "dsum_In1I"; |
491 qed "dsum_In1I"; |
494 |
492 |
495 val major::prems = goalw Univ.thy [dsum_def] |
493 val major::prems = goalw Univ.thy [dsum_def] |
496 "[| w : r<++>s; \ |
494 "[| w : r<++>s; \ |
497 \ !!x x'. [| (x,x') : r; w = (In0(x), In0(x')) |] ==> P; \ |
495 \ !!x x'. [| (x,x') : r; w = (In0(x), In0(x')) |] ==> P; \ |
508 AddSEs [diagE, uprodE, dprodE, usumE, dsumE]; |
506 AddSEs [diagE, uprodE, dprodE, usumE, dsumE]; |
509 |
507 |
510 (*** Monotonicity ***) |
508 (*** Monotonicity ***) |
511 |
509 |
512 goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<**>s <= r'<**>s'"; |
510 goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<**>s <= r'<**>s'"; |
513 by (Fast_tac 1); |
511 by (Blast_tac 1); |
514 qed "dprod_mono"; |
512 qed "dprod_mono"; |
515 |
513 |
516 goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<++>s <= r'<++>s'"; |
514 goal Univ.thy "!!r s. [| r<=r'; s<=s' |] ==> r<++>s <= r'<++>s'"; |
517 by (Fast_tac 1); |
515 by (Blast_tac 1); |
518 qed "dsum_mono"; |
516 qed "dsum_mono"; |
519 |
517 |
520 |
518 |
521 (*** Bounding theorems ***) |
519 (*** Bounding theorems ***) |
522 |
520 |
523 goal Univ.thy "diag(A) <= A Times A"; |
521 goal Univ.thy "diag(A) <= A Times A"; |
524 by (Fast_tac 1); |
522 by (Blast_tac 1); |
525 qed "diag_subset_Sigma"; |
523 qed "diag_subset_Sigma"; |
526 |
524 |
527 goal Univ.thy "((A Times B) <**> (C Times D)) <= (A<*>C) Times (B<*>D)"; |
525 goal Univ.thy "((A Times B) <**> (C Times D)) <= (A<*>C) Times (B<*>D)"; |
528 by (Fast_tac 1); |
526 by (Blast_tac 1); |
529 qed "dprod_Sigma"; |
527 qed "dprod_Sigma"; |
530 |
528 |
531 val dprod_subset_Sigma = [dprod_mono, dprod_Sigma] MRS subset_trans |>standard; |
529 val dprod_subset_Sigma = [dprod_mono, dprod_Sigma] MRS subset_trans |>standard; |
532 |
530 |
533 (*Dependent version*) |
531 (*Dependent version*) |
534 goal Univ.thy |
532 goal Univ.thy |
535 "(Sigma A B <**> Sigma C D) <= Sigma (A<*>C) (Split(%x y. B(x)<*>D(y)))"; |
533 "(Sigma A B <**> Sigma C D) <= Sigma (A<*>C) (Split(%x y. B(x)<*>D(y)))"; |
536 by (safe_tac (!claset)); |
534 by (safe_tac (!claset)); |
537 by (stac Split 1); |
535 by (stac Split 1); |
538 by (Fast_tac 1); |
536 by (Blast_tac 1); |
539 qed "dprod_subset_Sigma2"; |
537 qed "dprod_subset_Sigma2"; |
540 |
538 |
541 goal Univ.thy "(A Times B <++> C Times D) <= (A<+>C) Times (B<+>D)"; |
539 goal Univ.thy "(A Times B <++> C Times D) <= (A<+>C) Times (B<+>D)"; |
542 by (Fast_tac 1); |
540 by (Blast_tac 1); |
543 qed "dsum_Sigma"; |
541 qed "dsum_Sigma"; |
544 |
542 |
545 val dsum_subset_Sigma = [dsum_mono, dsum_Sigma] MRS subset_trans |> standard; |
543 val dsum_subset_Sigma = [dsum_mono, dsum_Sigma] MRS subset_trans |> standard; |
546 |
544 |
547 |
545 |
548 (*** Domain ***) |
546 (*** Domain ***) |
549 |
547 |
550 goal Univ.thy "fst `` diag(A) = A"; |
548 goal Univ.thy "fst `` diag(A) = A"; |
551 by (Fast_tac 1); |
549 by (Blast_tac 1); |
552 qed "fst_image_diag"; |
550 qed "fst_image_diag"; |
553 |
551 |
554 goal Univ.thy "fst `` (r<**>s) = (fst``r) <*> (fst``s)"; |
552 goal Univ.thy "fst `` (r<**>s) = (fst``r) <*> (fst``s)"; |
555 by (Fast_tac 1); |
553 by (Blast_tac 1); |
556 qed "fst_image_dprod"; |
554 qed "fst_image_dprod"; |
557 |
555 |
558 goal Univ.thy "fst `` (r<++>s) = (fst``r) <+> (fst``s)"; |
556 goal Univ.thy "fst `` (r<++>s) = (fst``r) <+> (fst``s)"; |
559 by (Fast_tac 1); |
557 by (Blast_tac 1); |
560 qed "fst_image_dsum"; |
558 qed "fst_image_dsum"; |
561 |
559 |
562 Addsimps [fst_image_diag, fst_image_dprod, fst_image_dsum]; |
560 Addsimps [fst_image_diag, fst_image_dprod, fst_image_dsum]; |