author | paulson |
Fri, 17 Jul 1998 11:23:17 +0200 | |
changeset 5158 | 48ca9ef35fb0 |
parent 5137 | 60205b0de9b9 |
child 5202 | 084ceb3844f5 |
permissions | -rw-r--r-- |
0 | 1 |
(* Title: ZF/simpdata |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1991 University of Cambridge |
|
5 |
||
2469 | 6 |
Rewriting for ZF set theory: specialized extraction of rewrites from theorems |
0 | 7 |
*) |
8 |
||
2469 | 9 |
(** Rewriting **) |
0 | 10 |
|
3425 | 11 |
local |
12 |
(*For proving rewrite rules*) |
|
13 |
fun prover s = (prove_goal ZF.thy s (fn _ => [Blast_tac 1])); |
|
14 |
||
15 |
in |
|
0 | 16 |
|
3425 | 17 |
val ball_simps = map prover |
18 |
["(ALL x:A. P(x) | Q) <-> ((ALL x:A. P(x)) | Q)", |
|
19 |
"(ALL x:A. P | Q(x)) <-> (P | (ALL x:A. Q(x)))", |
|
20 |
"(ALL x:A. P --> Q(x)) <-> (P --> (ALL x:A. Q(x)))", |
|
21 |
"(ALL x:A. P(x) --> Q) <-> ((EX x:A. P(x)) --> Q)", |
|
22 |
"(ALL x:0.P(x)) <-> True", |
|
3840 | 23 |
"(ALL x:succ(i).P(x)) <-> P(i) & (ALL x:i. P(x))", |
24 |
"(ALL x:cons(a,B).P(x)) <-> P(a) & (ALL x:B. P(x))", |
|
2482
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
25 |
"(ALL x:RepFun(A,f). P(x)) <-> (ALL y:A. P(f(y)))", |
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
26 |
"(ALL x:Union(A).P(x)) <-> (ALL y:A. ALL x:y. P(x))", |
3859 | 27 |
"(ALL x:Collect(A,Q).P(x)) <-> (ALL x:A. Q(x) --> P(x))", |
28 |
"(~(ALL x:A. P(x))) <-> (EX x:A. ~P(x))"]; |
|
2482
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
29 |
|
3425 | 30 |
val ball_conj_distrib = |
31 |
prover "(ALL x:A. P(x) & Q(x)) <-> ((ALL x:A. P(x)) & (ALL x:A. Q(x)))"; |
|
32 |
||
33 |
val bex_simps = map prover |
|
34 |
["(EX x:A. P(x) & Q) <-> ((EX x:A. P(x)) & Q)", |
|
35 |
"(EX x:A. P & Q(x)) <-> (P & (EX x:A. Q(x)))", |
|
36 |
"(EX x:0.P(x)) <-> False", |
|
3840 | 37 |
"(EX x:succ(i).P(x)) <-> P(i) | (EX x:i. P(x))", |
38 |
"(EX x:cons(a,B).P(x)) <-> P(a) | (EX x:B. P(x))", |
|
2482
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
39 |
"(EX x:RepFun(A,f). P(x)) <-> (EX y:A. P(f(y)))", |
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
40 |
"(EX x:Union(A).P(x)) <-> (EX y:A. EX x:y. P(x))", |
3859 | 41 |
"(EX x:Collect(A,Q).P(x)) <-> (EX x:A. Q(x) & P(x))", |
42 |
"(~(EX x:A. P(x))) <-> (ALL x:A. ~P(x))"]; |
|
2482
87383dd9f4b5
Default rewrite rules for quantification over Collect(A,P)
paulson
parents:
2469
diff
changeset
|
43 |
|
3425 | 44 |
val bex_disj_distrib = |
45 |
prover "(EX x:A. P(x) | Q(x)) <-> ((EX x:A. P(x)) | (EX x:A. Q(x)))"; |
|
46 |
||
47 |
val Rep_simps = map prover |
|
48 |
["{x:0. P(x)} = 0", |
|
49 |
"{x:A. False} = 0", |
|
50 |
"{x:A. True} = A", |
|
51 |
"RepFun(0,f) = 0", |
|
52 |
"RepFun(succ(i),f) = cons(f(i), RepFun(i,f))", |
|
53 |
"RepFun(cons(a,B),f) = cons(f(a), RepFun(B,f))"] |
|
0 | 54 |
|
3425 | 55 |
val misc_simps = map prover |
56 |
["0 Un A = A", "A Un 0 = A", |
|
57 |
"0 Int A = 0", "A Int 0 = 0", |
|
58 |
"0-A = 0", "A-0 = A", |
|
59 |
"Union(0) = 0", |
|
60 |
"Union(cons(b,A)) = b Un Union(A)", |
|
61 |
"Inter({b}) = b"] |
|
0 | 62 |
|
3425 | 63 |
end; |
64 |
||
65 |
Addsimps (ball_simps @ bex_simps @ Rep_simps @ misc_simps); |
|
66 |
||
0 | 67 |
|
68 |
(** New version of mk_rew_rules **) |
|
69 |
||
70 |
(*Should False yield False<->True, or should it solve goals some other way?*) |
|
71 |
||
1036 | 72 |
(*Analyse a theorem to atomic rewrite rules*) |
73 |
fun atomize (conn_pairs, mem_pairs) th = |
|
74 |
let fun tryrules pairs t = |
|
1461 | 75 |
case head_of t of |
76 |
Const(a,_) => |
|
77 |
(case assoc(pairs,a) of |
|
78 |
Some rls => flat (map (atomize (conn_pairs, mem_pairs)) |
|
79 |
([th] RL rls)) |
|
80 |
| None => [th]) |
|
81 |
| _ => [th] |
|
1036 | 82 |
in case concl_of th of |
1461 | 83 |
Const("Trueprop",_) $ P => |
84 |
(case P of |
|
85 |
Const("op :",_) $ a $ b => tryrules mem_pairs b |
|
86 |
| Const("True",_) => [] |
|
87 |
| Const("False",_) => [] |
|
88 |
| A => tryrules conn_pairs A) |
|
1036 | 89 |
| _ => [th] |
90 |
end; |
|
91 |
||
0 | 92 |
(*Analyse a rigid formula*) |
1036 | 93 |
val ZF_conn_pairs = |
1461 | 94 |
[("Ball", [bspec]), |
95 |
("All", [spec]), |
|
96 |
("op -->", [mp]), |
|
97 |
("op &", [conjunct1,conjunct2])]; |
|
0 | 98 |
|
99 |
(*Analyse a:b, where b is rigid*) |
|
1036 | 100 |
val ZF_mem_pairs = |
1461 | 101 |
[("Collect", [CollectD1,CollectD2]), |
102 |
("op -", [DiffD1,DiffD2]), |
|
103 |
("op Int", [IntD1,IntD2])]; |
|
0 | 104 |
|
1036 | 105 |
val ZF_atomize = atomize (ZF_conn_pairs, ZF_mem_pairs); |
106 |
||
5137 | 107 |
simpset_ref() := simpset() setmksimps (map mk_meta_eq o ZF_atomize o gen_all) |
108 |
addsplits [split_if]; |
|
2469 | 109 |
|
4091 | 110 |
val ZF_ss = simpset(); |