author  paulson 
Wed, 09 Oct 1996 13:36:17 +0200  
changeset 2074  30a65172e003 
parent 2065  b696f087f052 
child 2469  b50b8c0eec01 
permissions  rwrr 
1459  1 
(* Title: FOL/simpdata 
0  2 
ID: $Id$ 
1459  3 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory 
282  4 
Copyright 1994 University of Cambridge 
0  5 

6 
Simplification data for FOL 

7 
*) 

8 

9 
(*** Rewrite rules ***) 

10 

11 
fun int_prove_fun s = 

282  12 
(writeln s; 
13 
prove_goal IFOL.thy s 

14 
(fn prems => [ (cut_facts_tac prems 1), 

1459  15 
(Int.fast_tac 1) ])); 
0  16 

1953  17 
val conj_simps = map int_prove_fun 
1459  18 
["P & True <> P", "True & P <> P", 
0  19 
"P & False <> False", "False & P <> False", 
20 
"P & P <> P", 

1459  21 
"P & ~P <> False", "~P & P <> False", 
0  22 
"(P & Q) & R <> P & (Q & R)"]; 
23 

1953  24 
val disj_simps = map int_prove_fun 
1459  25 
["P  True <> True", "True  P <> True", 
26 
"P  False <> P", "False  P <> P", 

0  27 
"P  P <> P", 
28 
"(P  Q)  R <> P  (Q  R)"]; 

29 

1953  30 
val not_simps = map int_prove_fun 
282  31 
["~(PQ) <> ~P & ~Q", 
1459  32 
"~ False <> True", "~ True <> False"]; 
0  33 

1953  34 
val imp_simps = map int_prove_fun 
1459  35 
["(P > False) <> ~P", "(P > True) <> True", 
36 
"(False > P) <> True", "(True > P) <> P", 

37 
"(P > P) <> True", "(P > ~P) <> ~P"]; 

0  38 

1953  39 
val iff_simps = map int_prove_fun 
1459  40 
["(True <> P) <> P", "(P <> True) <> P", 
0  41 
"(P <> P) <> True", 
1459  42 
"(False <> P) <> ~P", "(P <> False) <> ~P"]; 
0  43 

1953  44 
val quant_simps = map int_prove_fun 
1459  45 
["(ALL x.P) <> P", "(EX x.P) <> P"]; 
0  46 

47 
(*These are NOT supplied by default!*) 

1953  48 
val distrib_simps = map int_prove_fun 
282  49 
["P & (Q  R) <> P&Q  P&R", 
50 
"(Q  R) & P <> Q&P  R&P", 

0  51 
"(P  Q > R) <> (P > R) & (Q > R)"]; 
52 

282  53 
(** Conversion into rewrite rules **) 
0  54 

53  55 
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; 
56 

282  57 
(*Make atomic rewrite rules*) 
429
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

58 
fun atomize r = 
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

59 
case concl_of r of 
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

60 
Const("Trueprop",_) $ p => 
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

61 
(case p of 
1459  62 
Const("op >",_)$_$_ => atomize(r RS mp) 
429
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

63 
 Const("op &",_)$_$_ => atomize(r RS conjunct1) @ 
1459  64 
atomize(r RS conjunct2) 
429
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

65 
 Const("All",_)$_ => atomize(r RS spec) 
1459  66 
 Const("True",_) => [] (*True is DELETED*) 
67 
 Const("False",_) => [] (*should False do something?*) 

429
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

68 
 _ => [r]) 
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

69 
 _ => [r]; 
888bbb4119f8
atomize: borrowed HOL version, which checks for both Trueprop
lcp
parents:
394
diff
changeset

70 

282  71 

72 
val P_iff_F = int_prove_fun "~P ==> (P <> False)"; 

73 
val iff_reflection_F = P_iff_F RS iff_reflection; 

74 

75 
val P_iff_T = int_prove_fun "P ==> (P <> True)"; 

76 
val iff_reflection_T = P_iff_T RS iff_reflection; 

77 

78 
(*Make metaequalities. The operator below is Trueprop*) 

79 
fun mk_meta_eq th = case concl_of th of 

394
432bb9995893
Modified mk_meta_eq to leave metaequlities on unchanged.
nipkow
parents:
371
diff
changeset

80 
Const("==",_)$_$_ => th 
432bb9995893
Modified mk_meta_eq to leave metaequlities on unchanged.
nipkow
parents:
371
diff
changeset

81 
 _ $ (Const("op =",_)$_$_) => th RS eq_reflection 
282  82 
 _ $ (Const("op <>",_)$_$_) => th RS iff_reflection 
83 
 _ $ (Const("Not",_)$_) => th RS iff_reflection_F 

84 
 _ => th RS iff_reflection_T; 

0  85 

981  86 

2074
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

87 
(*** Classical laws ***) 
282  88 

0  89 
fun prove_fun s = 
282  90 
(writeln s; 
91 
prove_goal FOL.thy s 

92 
(fn prems => [ (cut_facts_tac prems 1), 

1459  93 
(Cla.fast_tac FOL_cs 1) ])); 
745  94 

1953  95 
(*Avoids duplication of subgoals after expand_if, when the true and false 
96 
cases boil down to the same thing.*) 

97 
val cases_simp = prove_fun "(P > Q) & (~P > Q) <> Q"; 

98 

99 
(*At present, miniscoping is for classical logic only. We do NOT include 

100 
distribution of ALL over &, or dually that of EX over .*) 

0  101 

1953  102 
(*Miniscoping: pushing in existential quantifiers*) 
103 
val ex_simps = map prove_fun 

2065  104 
["(EX x. x=t & P(x)) <> P(t)", 
105 
"(EX x. t=x & P(x)) <> P(t)", 

106 
"(EX x. P(x) & Q) <> (EX x.P(x)) & Q", 

1953  107 
"(EX x. P & Q(x)) <> P & (EX x.Q(x))", 
108 
"(EX x. P(x)  Q) <> (EX x.P(x))  Q", 

109 
"(EX x. P  Q(x)) <> P  (EX x.Q(x))", 

110 
"(EX x. P(x) > Q) <> (ALL x.P(x)) > Q", 

111 
"(EX x. P > Q(x)) <> P > (EX x.Q(x))"]; 

112 

113 
(*Miniscoping: pushing in universal quantifiers*) 

114 
val all_simps = map prove_fun 

2065  115 
["(ALL x. x=t > P(x)) <> P(t)", 
116 
"(ALL x. t=x > P(x)) <> P(t)", 

117 
"(ALL x. P(x) & Q) <> (ALL x.P(x)) & Q", 

1953  118 
"(ALL x. P & Q(x)) <> P & (ALL x.Q(x))", 
119 
"(ALL x. P(x)  Q) <> (ALL x.P(x))  Q", 

120 
"(ALL x. P  Q(x)) <> P  (ALL x.Q(x))", 

121 
"(ALL x. P(x) > Q) <> (EX x.P(x)) > Q", 

122 
"(ALL x. P > Q(x)) <> P > (ALL x.Q(x))"]; 

123 

1914  124 
fun int_prove nm thm = qed_goal nm IFOL.thy thm 
125 
(fn prems => [ (cut_facts_tac prems 1), 

126 
(Int.fast_tac 1) ]); 

127 

128 
fun prove nm thm = qed_goal nm FOL.thy thm (fn _ => [fast_tac FOL_cs 1]); 

129 

130 
int_prove "conj_commute" "P&Q <> Q&P"; 

131 
int_prove "conj_left_commute" "P&(Q&R) <> Q&(P&R)"; 

132 
val conj_comms = [conj_commute, conj_left_commute]; 

133 

134 
int_prove "disj_commute" "PQ <> QP"; 

135 
int_prove "disj_left_commute" "P(QR) <> Q(PR)"; 

136 
val disj_comms = [disj_commute, disj_left_commute]; 

137 

138 
int_prove "conj_disj_distribL" "P&(QR) <> (P&Q  P&R)"; 

139 
int_prove "conj_disj_distribR" "(PQ)&R <> (P&R  Q&R)"; 

140 

141 
int_prove "disj_conj_distribL" "P(Q&R) <> (PQ) & (PR)"; 

142 
int_prove "disj_conj_distribR" "(P&Q)R <> (PR) & (QR)"; 

143 

144 
int_prove "imp_conj_distrib" "(P > (Q&R)) <> (P>Q) & (P>R)"; 

145 
int_prove "imp_conj" "((P&Q)>R) <> (P > (Q > R))"; 

146 
int_prove "imp_disj" "(PQ > R) <> (P>R) & (Q>R)"; 

147 

148 
int_prove "de_Morgan_disj" "(~(P  Q)) <> (~P & ~Q)"; 

149 
prove "de_Morgan_conj" "(~(P & Q)) <> (~P  ~Q)"; 

150 

151 
prove "not_iff" "~(P <> Q) <> (P <> ~Q)"; 

152 

153 
prove "not_all" "(~ (ALL x.P(x))) <> (EX x.~P(x))"; 

154 
prove "imp_all" "((ALL x.P(x)) > Q) <> (EX x.P(x) > Q)"; 

155 
int_prove "not_ex" "(~ (EX x.P(x))) <> (ALL x.~P(x))"; 

156 
int_prove "imp_ex" "((EX x. P(x)) > Q) <> (ALL x. P(x) > Q)"; 

157 

158 
int_prove "ex_disj_distrib" 

159 
"(EX x. P(x)  Q(x)) <> ((EX x. P(x))  (EX x. Q(x)))"; 

160 
int_prove "all_conj_distrib" 

161 
"(ALL x. P(x) & Q(x)) <> ((ALL x. P(x)) & (ALL x. Q(x)))"; 

162 

163 

1088
fc4fb6e8a636
Imported meta_eq_to_obj_eq from HOL for use with 'split'.
lcp
parents:
981
diff
changeset

164 
(*Used in ZF, perhaps elsewhere?*) 
fc4fb6e8a636
Imported meta_eq_to_obj_eq from HOL for use with 'split'.
lcp
parents:
981
diff
changeset

165 
val meta_eq_to_obj_eq = prove_goal IFOL.thy "x==y ==> x=y" 
fc4fb6e8a636
Imported meta_eq_to_obj_eq from HOL for use with 'split'.
lcp
parents:
981
diff
changeset

166 
(fn [prem] => [rewtac prem, rtac refl 1]); 
fc4fb6e8a636
Imported meta_eq_to_obj_eq from HOL for use with 'split'.
lcp
parents:
981
diff
changeset

167 

0  168 
(*** case splitting ***) 
169 

1088
fc4fb6e8a636
Imported meta_eq_to_obj_eq from HOL for use with 'split'.
lcp
parents:
981
diff
changeset

170 
qed_goal "meta_iffD" IFOL.thy "[ P==Q; Q ] ==> P" 
756  171 
(fn [prem1,prem2] => [rewtac prem1, rtac prem2 1]); 
282  172 

942  173 
local val mktac = mk_case_split_tac meta_iffD 
174 
in 

175 
fun split_tac splits = mktac (map mk_meta_eq splits) 

176 
end; 

1722  177 

178 
local val mktac = mk_case_split_inside_tac meta_iffD 

179 
in 

180 
fun split_inside_tac splits = mktac (map mk_meta_eq splits) 

181 
end; 

182 

183 

2074
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

184 
(*** Standard simpsets ***) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

185 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

186 
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

187 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

188 
open Simplifier Induction; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

189 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

190 
(*Add congruence rules for = or <> (instead of ==) *) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

191 
infix 4 addcongs; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

192 
fun ss addcongs congs = 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

193 
ss addeqcongs (congs RL [eq_reflection,iff_reflection]); 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

194 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

195 
(*Add a simpset to a classical set!*) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

196 
infix 4 addss; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

197 
fun cs addss ss = cs addbefore asm_full_simp_tac ss 1; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

198 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

199 
val IFOL_simps = 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

200 
[refl RS P_iff_T] @ conj_simps @ disj_simps @ not_simps @ 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

201 
imp_simps @ iff_simps @ quant_simps; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

202 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

203 
val notFalseI = int_prove_fun "~False"; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

204 
val triv_rls = [TrueI,refl,iff_refl,notFalseI]; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

205 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

206 
val IFOL_ss = 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

207 
empty_ss 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

208 
setmksimps (map mk_meta_eq o atomize o gen_all) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

209 
setsolver (fn prems => resolve_tac (triv_rls@prems) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

210 
ORELSE' assume_tac 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

211 
ORELSE' etac FalseE) 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

212 
setsubgoaler asm_simp_tac 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

213 
addsimps IFOL_simps 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

214 
addcongs [imp_cong]; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

215 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

216 
val cla_simps = 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

217 
[de_Morgan_conj, de_Morgan_disj, not_all, not_ex, cases_simp] @ 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

218 
map prove_fun 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

219 
["~(P&Q) <> ~P  ~Q", 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

220 
"P  ~P", "~P  P", 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

221 
"~ ~ P <> P", "(~P > P) <> P", 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

222 
"(~P <> ~Q) <> (P<>Q)"]; 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

223 

30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

224 
val FOL_ss = IFOL_ss addsimps (cla_simps @ ex_simps @ all_simps); 
30a65172e003
Added the de Morgan laws (incl quantifier versions) to basic simpset
paulson
parents:
2065
diff
changeset

225 