| author | wenzelm | 
| Mon, 13 Nov 2006 12:10:49 +0100 | |
| changeset 21318 | edb595802d22 | 
| parent 20223 | 89d2758ecddf | 
| child 21539 | c5cf9243ad62 | 
| permissions | -rw-r--r-- | 
| 9889 | 1  | 
(* Title: FOL/simpdata.ML  | 
| 0 | 2  | 
ID: $Id$  | 
| 1459 | 3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 282 | 4  | 
Copyright 1994 University of Cambridge  | 
| 0 | 5  | 
|
| 9889 | 6  | 
Simplification data for FOL.  | 
| 0 | 7  | 
*)  | 
8  | 
||
| 20223 | 9  | 
val ex1_functional = thm "ex1_functional";  | 
10  | 
val True_implies_equals = thm "True_implies_equals";  | 
|
| 5496 | 11  | 
|
12  | 
||
13  | 
||
| 0 | 14  | 
(*** Rewrite rules ***)  | 
15  | 
||
| 10431 | 16  | 
fun int_prove_fun s =  | 
17  | 
(writeln s;  | 
|
| 282 | 18  | 
prove_goal IFOL.thy s  | 
| 10431 | 19  | 
(fn prems => [ (cut_facts_tac prems 1),  | 
| 
2601
 
b301958c465d
Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
 
paulson 
parents: 
2469 
diff
changeset
 | 
20  | 
(IntPr.fast_tac 1) ]));  | 
| 0 | 21  | 
|
| 12038 | 22  | 
bind_thms ("conj_simps", map int_prove_fun
 | 
| 1459 | 23  | 
["P & True <-> P", "True & P <-> P",  | 
| 0 | 24  | 
"P & False <-> False", "False & P <-> False",  | 
| 2801 | 25  | 
"P & P <-> P", "P & P & Q <-> P & Q",  | 
| 1459 | 26  | 
"P & ~P <-> False", "~P & P <-> False",  | 
| 12038 | 27  | 
"(P & Q) & R <-> P & (Q & R)"]);  | 
| 0 | 28  | 
|
| 12038 | 29  | 
bind_thms ("disj_simps", map int_prove_fun
 | 
| 1459 | 30  | 
["P | True <-> True", "True | P <-> True",  | 
31  | 
"P | False <-> P", "False | P <-> P",  | 
|
| 2801 | 32  | 
"P | P <-> P", "P | P | Q <-> P | Q",  | 
| 12038 | 33  | 
"(P | Q) | R <-> P | (Q | R)"]);  | 
| 0 | 34  | 
|
| 12038 | 35  | 
bind_thms ("not_simps", map int_prove_fun
 | 
| 282 | 36  | 
["~(P|Q) <-> ~P & ~Q",  | 
| 12038 | 37  | 
"~ False <-> True", "~ True <-> False"]);  | 
| 0 | 38  | 
|
| 12038 | 39  | 
bind_thms ("imp_simps", map int_prove_fun
 | 
| 1459 | 40  | 
["(P --> False) <-> ~P", "(P --> True) <-> True",  | 
| 10431 | 41  | 
"(False --> P) <-> True", "(True --> P) <-> P",  | 
| 12038 | 42  | 
"(P --> P) <-> True", "(P --> ~P) <-> ~P"]);  | 
| 0 | 43  | 
|
| 12038 | 44  | 
bind_thms ("iff_simps", map int_prove_fun
 | 
| 1459 | 45  | 
["(True <-> P) <-> P", "(P <-> True) <-> P",  | 
| 0 | 46  | 
"(P <-> P) <-> True",  | 
| 12038 | 47  | 
"(False <-> P) <-> ~P", "(P <-> False) <-> ~P"]);  | 
| 0 | 48  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
49  | 
(*The x=t versions are needed for the simplification procedures*)  | 
| 12038 | 50  | 
bind_thms ("quant_simps", map int_prove_fun
 | 
| 10431 | 51  | 
["(ALL x. P) <-> P",  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
52  | 
"(ALL x. x=t --> P(x)) <-> P(t)",  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
53  | 
"(ALL x. t=x --> P(x)) <-> P(t)",  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
54  | 
"(EX x. P) <-> P",  | 
| 
13149
 
773657d466cb
better simplification of trivial existential equalities
 
paulson 
parents: 
12825 
diff
changeset
 | 
55  | 
"EX x. x=t", "EX x. t=x",  | 
| 10431 | 56  | 
"(EX x. x=t & P(x)) <-> P(t)",  | 
| 12038 | 57  | 
"(EX x. t=x & P(x)) <-> P(t)"]);  | 
| 0 | 58  | 
|
59  | 
(*These are NOT supplied by default!*)  | 
|
| 12038 | 60  | 
bind_thms ("distrib_simps", map int_prove_fun
 | 
| 10431 | 61  | 
["P & (Q | R) <-> P&Q | P&R",  | 
| 282 | 62  | 
"(Q | R) & P <-> Q&P | R&P",  | 
| 12038 | 63  | 
"(P | Q --> R) <-> (P --> R) & (Q --> R)"]);  | 
| 0 | 64  | 
|
| 282 | 65  | 
(** Conversion into rewrite rules **)  | 
| 0 | 66  | 
|
| 12038 | 67  | 
bind_thm ("P_iff_F", int_prove_fun "~P ==> (P <-> False)");
 | 
68  | 
bind_thm ("iff_reflection_F", P_iff_F RS iff_reflection);
 | 
|
| 282 | 69  | 
|
| 12038 | 70  | 
bind_thm ("P_iff_T", int_prove_fun "P ==> (P <-> True)");
 | 
71  | 
bind_thm ("iff_reflection_T", P_iff_T RS iff_reflection);
 | 
|
| 282 | 72  | 
|
73  | 
(*Make meta-equalities. The operator below is Trueprop*)  | 
|
| 5555 | 74  | 
|
| 282 | 75  | 
fun mk_meta_eq th = case concl_of th of  | 
| 5555 | 76  | 
    _ $ (Const("op =",_)$_$_)   => th RS eq_reflection
 | 
77  | 
  | _ $ (Const("op <->",_)$_$_) => th RS iff_reflection
 | 
|
| 10431 | 78  | 
| _ =>  | 
| 5555 | 79  | 
  error("conclusion must be a =-equality or <->");;
 | 
80  | 
||
81  | 
fun mk_eq th = case concl_of th of  | 
|
| 
394
 
432bb9995893
Modified mk_meta_eq to leave meta-equlities on unchanged.
 
nipkow 
parents: 
371 
diff
changeset
 | 
82  | 
    Const("==",_)$_$_           => th
 | 
| 5555 | 83  | 
  | _ $ (Const("op =",_)$_$_)   => mk_meta_eq th
 | 
84  | 
  | _ $ (Const("op <->",_)$_$_) => mk_meta_eq th
 | 
|
| 282 | 85  | 
  | _ $ (Const("Not",_)$_)      => th RS iff_reflection_F
 | 
86  | 
| _ => th RS iff_reflection_T;  | 
|
| 0 | 87  | 
|
| 
6114
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
88  | 
(*Replace premises x=y, X<->Y by X==Y*)  | 
| 10431 | 89  | 
val mk_meta_prems =  | 
90  | 
rule_by_tactic  | 
|
| 
6114
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
91  | 
(REPEAT_FIRST (resolve_tac [meta_eq_to_obj_eq, def_imp_iff]));  | 
| 
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
92  | 
|
| 9713 | 93  | 
(*Congruence rules for = or <-> (instead of ==)*)  | 
| 
6114
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
94  | 
fun mk_meta_cong rl =  | 
| 
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
95  | 
standard(mk_meta_eq (mk_meta_prems rl))  | 
| 
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
96  | 
handle THM _ =>  | 
| 
 
45958e54d72e
congruence rules finally use == instead of = and <->
 
paulson 
parents: 
5555 
diff
changeset
 | 
97  | 
  error("Premises and conclusion of congruence rules must use =-equality or <->");
 | 
| 5555 | 98  | 
|
| 5304 | 99  | 
val mksimps_pairs =  | 
100  | 
  [("op -->", [mp]), ("op &", [conjunct1,conjunct2]),
 | 
|
101  | 
   ("All", [spec]), ("True", []), ("False", [])];
 | 
|
102  | 
||
| 16019 | 103  | 
(* ###FIXME: move to simplifier.ML  | 
| 5304 | 104  | 
val mk_atomize: (string * thm list) list -> thm -> thm list  | 
105  | 
*)  | 
|
| 16019 | 106  | 
(* ###FIXME: move to simplifier.ML *)  | 
| 5304 | 107  | 
fun mk_atomize pairs =  | 
108  | 
let fun atoms th =  | 
|
109  | 
(case concl_of th of  | 
|
110  | 
           Const("Trueprop",_) $ p =>
 | 
|
111  | 
(case head_of p of  | 
|
112  | 
Const(a,_) =>  | 
|
| 17325 | 113  | 
(case AList.lookup (op =) pairs a of  | 
| 15570 | 114  | 
SOME(rls) => List.concat (map atoms ([th] RL rls))  | 
| 15531 | 115  | 
| NONE => [th])  | 
| 5304 | 116  | 
| _ => [th])  | 
117  | 
| _ => [th])  | 
|
118  | 
in atoms end;  | 
|
119  | 
||
| 12725 | 120  | 
fun mksimps pairs = (map mk_eq o mk_atomize pairs o gen_all);  | 
| 981 | 121  | 
|
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
122  | 
(*** Classical laws ***)  | 
| 282 | 123  | 
|
| 10431 | 124  | 
fun prove_fun s =  | 
125  | 
(writeln s;  | 
|
| 
7355
 
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
 
wenzelm 
parents: 
6391 
diff
changeset
 | 
126  | 
prove_goal (the_context ()) s  | 
| 10431 | 127  | 
(fn prems => [ (cut_facts_tac prems 1),  | 
| 1459 | 128  | 
(Cla.fast_tac FOL_cs 1) ]));  | 
| 745 | 129  | 
|
| 10431 | 130  | 
(*Avoids duplication of subgoals after expand_if, when the true and false  | 
131  | 
cases boil down to the same thing.*)  | 
|
| 12038 | 132  | 
bind_thm ("cases_simp", prove_fun "(P --> Q) & (~P --> Q) <-> Q");
 | 
| 1953 | 133  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
134  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
135  | 
(*** Miniscoping: pushing quantifiers in  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
136  | 
We do NOT distribute of ALL over &, or dually that of EX over |  | 
| 10431 | 137  | 
Baaz and Leitsch, On Skolemization and Proof Complexity (1994)  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
138  | 
show that this step can increase proof length!  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
139  | 
***)  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
140  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
141  | 
(*existential miniscoping*)  | 
| 12038 | 142  | 
bind_thms ("int_ex_simps", map int_prove_fun
 | 
143  | 
["(EX x. P(x) & Q) <-> (EX x. P(x)) & Q",  | 
|
144  | 
"(EX x. P & Q(x)) <-> P & (EX x. Q(x))",  | 
|
145  | 
"(EX x. P(x) | Q) <-> (EX x. P(x)) | Q",  | 
|
146  | 
"(EX x. P | Q(x)) <-> P | (EX x. Q(x))"]);  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
147  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
148  | 
(*classical rules*)  | 
| 12038 | 149  | 
bind_thms ("cla_ex_simps", map prove_fun
 | 
150  | 
["(EX x. P(x) --> Q) <-> (ALL x. P(x)) --> Q",  | 
|
151  | 
"(EX x. P --> Q(x)) <-> P --> (EX x. Q(x))"]);  | 
|
| 0 | 152  | 
|
| 12038 | 153  | 
bind_thms ("ex_simps", int_ex_simps @ cla_ex_simps);
 | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
154  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
155  | 
(*universal miniscoping*)  | 
| 12038 | 156  | 
bind_thms ("int_all_simps", map int_prove_fun
 | 
157  | 
["(ALL x. P(x) & Q) <-> (ALL x. P(x)) & Q",  | 
|
158  | 
"(ALL x. P & Q(x)) <-> P & (ALL x. Q(x))",  | 
|
159  | 
"(ALL x. P(x) --> Q) <-> (EX x. P(x)) --> Q",  | 
|
160  | 
"(ALL x. P --> Q(x)) <-> P --> (ALL x. Q(x))"]);  | 
|
| 1953 | 161  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
162  | 
(*classical rules*)  | 
| 12038 | 163  | 
bind_thms ("cla_all_simps", map prove_fun
 | 
164  | 
["(ALL x. P(x) | Q) <-> (ALL x. P(x)) | Q",  | 
|
165  | 
"(ALL x. P | Q(x)) <-> P | (ALL x. Q(x))"]);  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
166  | 
|
| 12038 | 167  | 
bind_thms ("all_simps", int_all_simps @ cla_all_simps);
 | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
168  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
169  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
170  | 
(*** Named rewrite rules proved for IFOL ***)  | 
| 1953 | 171  | 
|
| 1914 | 172  | 
fun int_prove nm thm = qed_goal nm IFOL.thy thm  | 
| 10431 | 173  | 
(fn prems => [ (cut_facts_tac prems 1),  | 
| 
2601
 
b301958c465d
Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
 
paulson 
parents: 
2469 
diff
changeset
 | 
174  | 
(IntPr.fast_tac 1) ]);  | 
| 1914 | 175  | 
|
| 
7355
 
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
 
wenzelm 
parents: 
6391 
diff
changeset
 | 
176  | 
fun prove nm thm = qed_goal nm (the_context ()) thm (fn _ => [Blast_tac 1]);  | 
| 1914 | 177  | 
|
178  | 
int_prove "conj_commute" "P&Q <-> Q&P";  | 
|
179  | 
int_prove "conj_left_commute" "P&(Q&R) <-> Q&(P&R)";  | 
|
| 12038 | 180  | 
bind_thms ("conj_comms", [conj_commute, conj_left_commute]);
 | 
| 1914 | 181  | 
|
182  | 
int_prove "disj_commute" "P|Q <-> Q|P";  | 
|
183  | 
int_prove "disj_left_commute" "P|(Q|R) <-> Q|(P|R)";  | 
|
| 12038 | 184  | 
bind_thms ("disj_comms", [disj_commute, disj_left_commute]);
 | 
| 1914 | 185  | 
|
186  | 
int_prove "conj_disj_distribL" "P&(Q|R) <-> (P&Q | P&R)";  | 
|
187  | 
int_prove "conj_disj_distribR" "(P|Q)&R <-> (P&R | Q&R)";  | 
|
188  | 
||
189  | 
int_prove "disj_conj_distribL" "P|(Q&R) <-> (P|Q) & (P|R)";  | 
|
190  | 
int_prove "disj_conj_distribR" "(P&Q)|R <-> (P|R) & (Q|R)";  | 
|
191  | 
||
192  | 
int_prove "imp_conj_distrib" "(P --> (Q&R)) <-> (P-->Q) & (P-->R)";  | 
|
193  | 
int_prove "imp_conj" "((P&Q)-->R) <-> (P --> (Q --> R))";  | 
|
194  | 
int_prove "imp_disj" "(P|Q --> R) <-> (P-->R) & (Q-->R)";  | 
|
195  | 
||
| 3910 | 196  | 
prove "imp_disj1" "(P-->Q) | R <-> (P-->Q | R)";  | 
197  | 
prove "imp_disj2" "Q | (P-->R) <-> (P-->Q | R)";  | 
|
198  | 
||
| 1914 | 199  | 
int_prove "de_Morgan_disj" "(~(P | Q)) <-> (~P & ~Q)";  | 
200  | 
prove "de_Morgan_conj" "(~(P & Q)) <-> (~P | ~Q)";  | 
|
201  | 
||
| 12765 | 202  | 
prove "not_imp" "~(P --> Q) <-> (P & ~Q)";  | 
| 1914 | 203  | 
prove "not_iff" "~(P <-> Q) <-> (P <-> ~Q)";  | 
204  | 
||
| 3835 | 205  | 
prove "not_all" "(~ (ALL x. P(x))) <-> (EX x.~P(x))";  | 
206  | 
prove "imp_all" "((ALL x. P(x)) --> Q) <-> (EX x. P(x) --> Q)";  | 
|
207  | 
int_prove "not_ex" "(~ (EX x. P(x))) <-> (ALL x.~P(x))";  | 
|
| 1914 | 208  | 
int_prove "imp_ex" "((EX x. P(x)) --> Q) <-> (ALL x. P(x) --> Q)";  | 
209  | 
||
210  | 
int_prove "ex_disj_distrib"  | 
|
211  | 
"(EX x. P(x) | Q(x)) <-> ((EX x. P(x)) | (EX x. Q(x)))";  | 
|
212  | 
int_prove "all_conj_distrib"  | 
|
213  | 
"(ALL x. P(x) & Q(x)) <-> ((ALL x. P(x)) & (ALL x. Q(x)))";  | 
|
214  | 
||
215  | 
||
| 11232 | 216  | 
local  | 
217  | 
val uncurry = prove_goal (the_context()) "P --> Q --> R ==> P & Q --> R"  | 
|
218  | 
(fn prems => [cut_facts_tac prems 1, Blast_tac 1]);  | 
|
219  | 
||
220  | 
val iff_allI = allI RS  | 
|
221  | 
prove_goal (the_context()) "ALL x. P(x) <-> Q(x) ==> (ALL x. P(x)) <-> (ALL x. Q(x))"  | 
|
222  | 
(fn prems => [cut_facts_tac prems 1, Blast_tac 1])  | 
|
| 
12526
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
223  | 
val iff_exI = allI RS  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
224  | 
prove_goal (the_context()) "ALL x. P(x) <-> Q(x) ==> (EX x. P(x)) <-> (EX x. Q(x))"  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
225  | 
(fn prems => [cut_facts_tac prems 1, Blast_tac 1])  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
226  | 
|
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
227  | 
val all_comm = prove_goal (the_context()) "(ALL x y. P(x,y)) <-> (ALL y x. P(x,y))"  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
228  | 
(fn _ => [Blast_tac 1])  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
229  | 
val ex_comm = prove_goal (the_context()) "(EX x y. P(x,y)) <-> (EX y x. P(x,y))"  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
230  | 
(fn _ => [Blast_tac 1])  | 
| 11232 | 231  | 
in  | 
232  | 
||
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
233  | 
(** make simplification procedures for quantifier elimination **)  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
234  | 
structure Quantifier1 = Quantifier1Fun(  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
235  | 
struct  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
236  | 
(*abstract syntax*)  | 
| 15531 | 237  | 
  fun dest_eq((c as Const("op =",_)) $ s $ t) = SOME(c,s,t)
 | 
238  | 
| dest_eq _ = NONE;  | 
|
239  | 
  fun dest_conj((c as Const("op &",_)) $ s $ t) = SOME(c,s,t)
 | 
|
240  | 
| dest_conj _ = NONE;  | 
|
241  | 
  fun dest_imp((c as Const("op -->",_)) $ s $ t) = SOME(c,s,t)
 | 
|
242  | 
| dest_imp _ = NONE;  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
243  | 
val conj = FOLogic.conj  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
244  | 
val imp = FOLogic.imp  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
245  | 
(*rules*)  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
246  | 
val iff_reflection = iff_reflection  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
247  | 
val iffI = iffI  | 
| 
12526
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
248  | 
val iff_trans = iff_trans  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
249  | 
val conjI= conjI  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
250  | 
val conjE= conjE  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
251  | 
val impI = impI  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
252  | 
val mp = mp  | 
| 11232 | 253  | 
val uncurry = uncurry  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
254  | 
val exI = exI  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
255  | 
val exE = exE  | 
| 11232 | 256  | 
val iff_allI = iff_allI  | 
| 
12526
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
257  | 
val iff_exI = iff_exI  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
258  | 
val all_comm = all_comm  | 
| 
 
1b9db2581fe2
mods due to changed 1-point simprocs (quantifier1).
 
nipkow 
parents: 
12038 
diff
changeset
 | 
259  | 
val ex_comm = ex_comm  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
260  | 
end);  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
261  | 
|
| 11232 | 262  | 
end;  | 
263  | 
||
| 13462 | 264  | 
val defEX_regroup =  | 
| 17002 | 265  | 
Simplifier.simproc (the_context ())  | 
| 13462 | 266  | 
"defined EX" ["EX x. P(x)"] Quantifier1.rearrange_ex;  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
267  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
268  | 
val defALL_regroup =  | 
| 17002 | 269  | 
Simplifier.simproc (the_context ())  | 
| 13462 | 270  | 
"defined ALL" ["ALL x. P(x)"] Quantifier1.rearrange_all;  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
271  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
272  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
273  | 
(*** Case splitting ***)  | 
| 0 | 274  | 
|
| 12038 | 275  | 
bind_thm ("meta_eq_to_iff", prove_goal IFOL.thy "x==y ==> x<->y"
 | 
276  | 
(fn [prem] => [rewtac prem, rtac iffI 1, atac 1, atac 1]));  | 
|
| 1722 | 277  | 
|
| 5304 | 278  | 
structure SplitterData =  | 
279  | 
struct  | 
|
280  | 
structure Simplifier = Simplifier  | 
|
| 5555 | 281  | 
val mk_eq = mk_eq  | 
| 5304 | 282  | 
val meta_eq_to_iff = meta_eq_to_iff  | 
283  | 
val iffD = iffD2  | 
|
284  | 
val disjE = disjE  | 
|
285  | 
val conjE = conjE  | 
|
286  | 
val exE = exE  | 
|
287  | 
val contrapos = contrapos  | 
|
288  | 
val contrapos2 = contrapos2  | 
|
289  | 
val notnotD = notnotD  | 
|
290  | 
end;  | 
|
| 1722 | 291  | 
|
| 5304 | 292  | 
structure Splitter = SplitterFun(SplitterData);  | 
| 1722 | 293  | 
|
| 5304 | 294  | 
val split_tac = Splitter.split_tac;  | 
295  | 
val split_inside_tac = Splitter.split_inside_tac;  | 
|
296  | 
val split_asm_tac = Splitter.split_asm_tac;  | 
|
| 5307 | 297  | 
val op addsplits = Splitter.addsplits;  | 
298  | 
val op delsplits = Splitter.delsplits;  | 
|
| 5304 | 299  | 
val Addsplits = Splitter.Addsplits;  | 
300  | 
val Delsplits = Splitter.Delsplits;  | 
|
| 4325 | 301  | 
|
302  | 
||
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
303  | 
(*** Standard simpsets ***)  | 
| 
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
304  | 
|
| 
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
305  | 
structure Induction = InductionFun(struct val spec=IFOL.spec end);  | 
| 
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
306  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
307  | 
open Induction;  | 
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
308  | 
|
| 5555 | 309  | 
|
| 12038 | 310  | 
bind_thms ("meta_simps",
 | 
311  | 
[triv_forall_equality, (* prunes params *)  | 
|
312  | 
True_implies_equals]); (* prune asms `True' *)  | 
|
| 5496 | 313  | 
|
| 12038 | 314  | 
bind_thms ("IFOL_simps",
 | 
315  | 
[refl RS P_iff_T] @ conj_simps @ disj_simps @ not_simps @  | 
|
316  | 
imp_simps @ iff_simps @ quant_simps);  | 
|
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
317  | 
|
| 12038 | 318  | 
bind_thm ("notFalseI", int_prove_fun "~False");
 | 
319  | 
bind_thms ("triv_rls", [TrueI,refl,reflexive_thm,iff_refl,notFalseI]);
 | 
|
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
320  | 
|
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
321  | 
fun unsafe_solver prems = FIRST'[resolve_tac (triv_rls@prems),  | 
| 9713 | 322  | 
atac, etac FalseE];  | 
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
323  | 
(*No premature instantiation of variables during simplification*)  | 
| 
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
324  | 
fun safe_solver prems = FIRST'[match_tac (triv_rls@prems),  | 
| 9713 | 325  | 
eq_assume_tac, ematch_tac [FalseE]];  | 
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
326  | 
|
| 3910 | 327  | 
(*No simprules, but basic infastructure for simplification*)  | 
| 17892 | 328  | 
val FOL_basic_ss =  | 
329  | 
Simplifier.theory_context (the_context ()) empty_ss  | 
|
| 10431 | 330  | 
setsubgoaler asm_simp_tac  | 
331  | 
setSSolver (mk_solver "FOL safe" safe_solver)  | 
|
332  | 
setSolver (mk_solver "FOL unsafe" unsafe_solver)  | 
|
333  | 
setmksimps (mksimps mksimps_pairs)  | 
|
334  | 
setmkcong mk_meta_cong;  | 
|
| 5304 | 335  | 
|
| 18324 | 336  | 
fun unfold_tac ths =  | 
337  | 
let val ss0 = Simplifier.clear_ss FOL_basic_ss addsimps ths  | 
|
338  | 
in fn ss => ALLGOALS (full_simp_tac (Simplifier.inherit_context ss ss0)) end;  | 
|
| 17002 | 339  | 
|
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
340  | 
|
| 3910 | 341  | 
(*intuitionistic simprules only*)  | 
| 10431 | 342  | 
val IFOL_ss = FOL_basic_ss  | 
343  | 
addsimps (meta_simps @ IFOL_simps @ int_ex_simps @ int_all_simps)  | 
|
344  | 
addsimprocs [defALL_regroup, defEX_regroup]  | 
|
345  | 
addcongs [imp_cong];  | 
|
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
346  | 
|
| 12038 | 347  | 
bind_thms ("cla_simps",
 | 
348  | 
[de_Morgan_conj, de_Morgan_disj, imp_disj1, imp_disj2,  | 
|
| 12825 | 349  | 
not_imp, not_all, not_ex, cases_simp] @  | 
| 12038 | 350  | 
map prove_fun  | 
351  | 
["~(P&Q) <-> ~P | ~Q",  | 
|
352  | 
"P | ~P", "~P | P",  | 
|
353  | 
"~ ~ P <-> P", "(~P --> P) <-> P",  | 
|
354  | 
"(~P <-> ~Q) <-> (P<->Q)"]);  | 
|
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
355  | 
|
| 3910 | 356  | 
(*classical simprules too*)  | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents: 
4325 
diff
changeset
 | 
357  | 
val FOL_ss = IFOL_ss addsimps (cla_simps @ cla_ex_simps @ cla_all_simps);  | 
| 
2074
 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
 
paulson 
parents: 
2065 
diff
changeset
 | 
358  | 
|
| 18708 | 359  | 
val simpsetup = (fn thy => (change_simpset_of thy (fn _ => FOL_ss); thy));  | 
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
360  | 
|
| 
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
361  | 
|
| 5219 | 362  | 
(*** integration of simplifier with classical reasoner ***)  | 
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
363  | 
|
| 5219 | 364  | 
structure Clasimp = ClasimpFun  | 
| 8472 | 365  | 
(structure Simplifier = Simplifier and Splitter = Splitter  | 
| 9851 | 366  | 
and Classical = Cla and Blast = Blast  | 
| 18529 | 367  | 
val iffD1 = iffD1 val iffD2 = iffD2 val notE = notE);  | 
| 
4652
 
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
 
oheimb 
parents: 
4649 
diff
changeset
 | 
368  | 
open Clasimp;  | 
| 
2633
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
369  | 
|
| 
 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
 
oheimb 
parents: 
2601 
diff
changeset
 | 
370  | 
val FOL_css = (FOL_cs, FOL_ss);  |