author  oheimb 
Thu, 24 Sep 1998 17:18:33 +0200  
changeset 5555  4b9386224084 
parent 5496  42d13691be86 
child 6114  45958e54d72e 
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 

5496  9 
(* Elimination of True from asumptions: *) 
10 

11 
val True_implies_equals = prove_goal IFOL.thy 

12 
"(True ==> PROP P) == PROP P" 

13 
(K [rtac equal_intr_rule 1, atac 2, 

14 
METAHYPS (fn prems => resolve_tac prems 1) 1, 

15 
rtac TrueI 1]); 

16 

17 

0  18 
(*** Rewrite rules ***) 
19 

20 
fun int_prove_fun s = 

282  21 
(writeln s; 
22 
prove_goal IFOL.thy s 

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

2601
b301958c465d
Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents:
2469
diff
changeset

24 
(IntPr.fast_tac 1) ])); 
0  25 

1953  26 
val conj_simps = map int_prove_fun 
1459  27 
["P & True <> P", "True & P <> P", 
0  28 
"P & False <> False", "False & P <> False", 
2801  29 
"P & P <> P", "P & P & Q <> P & Q", 
1459  30 
"P & ~P <> False", "~P & P <> False", 
0  31 
"(P & Q) & R <> P & (Q & R)"]; 
32 

1953  33 
val disj_simps = map int_prove_fun 
1459  34 
["P  True <> True", "True  P <> True", 
35 
"P  False <> P", "False  P <> P", 

2801  36 
"P  P <> P", "P  P  Q <> P  Q", 
0  37 
"(P  Q)  R <> P  (Q  R)"]; 
38 

1953  39 
val not_simps = map int_prove_fun 
282  40 
["~(PQ) <> ~P & ~Q", 
1459  41 
"~ False <> True", "~ True <> False"]; 
0  42 

1953  43 
val imp_simps = map int_prove_fun 
1459  44 
["(P > False) <> ~P", "(P > True) <> True", 
45 
"(False > P) <> True", "(True > P) <> P", 

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

0  47 

1953  48 
val iff_simps = map int_prove_fun 
1459  49 
["(True <> P) <> P", "(P <> True) <> P", 
0  50 
"(P <> P) <> True", 
1459  51 
"(False <> P) <> ~P", "(P <> False) <> ~P"]; 
0  52 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

53 
(*The x=t versions are needed for the simplification procedures*) 
1953  54 
val quant_simps = map int_prove_fun 
4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

55 
["(ALL x. P) <> P", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

56 
"(ALL x. x=t > P(x)) <> P(t)", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

57 
"(ALL x. t=x > P(x)) <> P(t)", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

58 
"(EX x. P) <> P", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

59 
"(EX x. x=t & P(x)) <> P(t)", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

60 
"(EX x. t=x & P(x)) <> P(t)"]; 
0  61 

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

1953  63 
val distrib_simps = map int_prove_fun 
282  64 
["P & (Q  R) <> P&Q  P&R", 
65 
"(Q  R) & P <> Q&P  R&P", 

0  66 
"(P  Q > R) <> (P > R) & (Q > R)"]; 
67 

282  68 
(** Conversion into rewrite rules **) 
0  69 

53  70 
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; 
71 

282  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*) 

5555  79 

282  80 
fun mk_meta_eq th = case concl_of th of 
5555  81 
_ $ (Const("op =",_)$_$_) => th RS eq_reflection 
82 
 _ $ (Const("op <>",_)$_$_) => th RS iff_reflection 

83 
 _ => 

84 
error("conclusion must be a =equality or <>");; 

85 

86 
fun mk_eq th = case concl_of th of 

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

87 
Const("==",_)$_$_ => th 
5555  88 
 _ $ (Const("op =",_)$_$_) => mk_meta_eq th 
89 
 _ $ (Const("op <>",_)$_$_) => mk_meta_eq th 

282  90 
 _ $ (Const("Not",_)$_) => th RS iff_reflection_F 
91 
 _ => th RS iff_reflection_T; 

0  92 

5555  93 
fun mk_meta_cong rl = standard (mk_meta_eq rl); 
94 
(*FIXME: how about the premises?*) 

95 

5304  96 
val mksimps_pairs = 
97 
[("op >", [mp]), ("op &", [conjunct1,conjunct2]), 

98 
("All", [spec]), ("True", []), ("False", [])]; 

99 

5555  100 
(* ###FIXME: move to Provers/simplifier.ML 
5304  101 
val mk_atomize: (string * thm list) list > thm > thm list 
102 
*) 

5555  103 
(* ###FIXME: move to Provers/simplifier.ML *) 
5304  104 
fun mk_atomize pairs = 
105 
let fun atoms th = 

106 
(case concl_of th of 

107 
Const("Trueprop",_) $ p => 

108 
(case head_of p of 

109 
Const(a,_) => 

110 
(case assoc(pairs,a) of 

111 
Some(rls) => flat (map atoms ([th] RL rls)) 

112 
 None => [th]) 

113 
 _ => [th]) 

114 
 _ => [th]) 

115 
in atoms end; 

116 

5555  117 
fun mksimps pairs = (map mk_eq o mk_atomize pairs o gen_all); 
981  118 

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

119 
(*** Classical laws ***) 
282  120 

0  121 
fun prove_fun s = 
282  122 
(writeln s; 
123 
prove_goal FOL.thy s 

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

1459  125 
(Cla.fast_tac FOL_cs 1) ])); 
745  126 

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

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

130 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

131 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

132 
(*** Miniscoping: pushing quantifiers in 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

133 
We do NOT distribute of ALL over &, or dually that of EX over  
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

134 
Baaz and Leitsch, On Skolemization and Proof Complexity (1994) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

135 
show that this step can increase proof length! 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

136 
***) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

137 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

138 
(*existential miniscoping*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

139 
val int_ex_simps = map int_prove_fun 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

140 
["(EX x. P(x) & Q) <> (EX x. P(x)) & Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

141 
"(EX x. P & Q(x)) <> P & (EX x. Q(x))", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

142 
"(EX x. P(x)  Q) <> (EX x. P(x))  Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

143 
"(EX x. P  Q(x)) <> P  (EX x. Q(x))"]; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

144 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

145 
(*classical rules*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

146 
val cla_ex_simps = map prove_fun 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

147 
["(EX x. P(x) > Q) <> (ALL x. P(x)) > Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

148 
"(EX x. P > Q(x)) <> P > (EX x. Q(x))"]; 
0  149 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

150 
val ex_simps = int_ex_simps @ cla_ex_simps; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

151 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

152 
(*universal miniscoping*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

153 
val int_all_simps = map int_prove_fun 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

154 
["(ALL x. P(x) & Q) <> (ALL x. P(x)) & Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

155 
"(ALL x. P & Q(x)) <> P & (ALL x. Q(x))", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

156 
"(ALL x. P(x) > Q) <> (EX x. P(x)) > Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

157 
"(ALL x. P > Q(x)) <> P > (ALL x. Q(x))"]; 
1953  158 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

159 
(*classical rules*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

160 
val cla_all_simps = map prove_fun 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

161 
["(ALL x. P(x)  Q) <> (ALL x. P(x))  Q", 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

162 
"(ALL x. P  Q(x)) <> P  (ALL x. Q(x))"]; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

163 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

164 
val all_simps = int_all_simps @ cla_all_simps; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

165 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

166 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

167 
(*** Named rewrite rules proved for IFOL ***) 
1953  168 

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

2601
b301958c465d
Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents:
2469
diff
changeset

171 
(IntPr.fast_tac 1) ]); 
1914  172 

3910  173 
fun prove nm thm = qed_goal nm FOL.thy thm (fn _ => [Blast_tac 1]); 
1914  174 

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

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

177 
val conj_comms = [conj_commute, conj_left_commute]; 

178 

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

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

181 
val disj_comms = [disj_commute, disj_left_commute]; 

182 

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

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

185 

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

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

188 

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

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

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

192 

3910  193 
prove "imp_disj1" "(P>Q)  R <> (P>Q  R)"; 
194 
prove "imp_disj2" "Q  (P>R) <> (P>Q  R)"; 

195 

1914  196 
int_prove "de_Morgan_disj" "(~(P  Q)) <> (~P & ~Q)"; 
197 
prove "de_Morgan_conj" "(~(P & Q)) <> (~P  ~Q)"; 

198 

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

200 

3835  201 
prove "not_all" "(~ (ALL x. P(x))) <> (EX x.~P(x))"; 
202 
prove "imp_all" "((ALL x. P(x)) > Q) <> (EX x. P(x) > Q)"; 

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

1914  204 
int_prove "imp_ex" "((EX x. P(x)) > Q) <> (ALL x. P(x) > Q)"; 
205 

206 
int_prove "ex_disj_distrib" 

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

208 
int_prove "all_conj_distrib" 

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

210 

211 

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

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

213 
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

214 
(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

215 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

216 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

217 
(** make simplification procedures for quantifier elimination **) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

218 
structure Quantifier1 = Quantifier1Fun( 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

219 
struct 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

220 
(*abstract syntax*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

221 
fun dest_eq((c as Const("op =",_)) $ s $ t) = Some(c,s,t) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

222 
 dest_eq _ = None; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

223 
fun dest_conj((c as Const("op &",_)) $ s $ t) = Some(c,s,t) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

224 
 dest_conj _ = None; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

225 
val conj = FOLogic.conj 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

226 
val imp = FOLogic.imp 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

227 
(*rules*) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

228 
val iff_reflection = iff_reflection 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

229 
val iffI = iffI 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

230 
val sym = sym 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

231 
val conjI= conjI 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

232 
val conjE= conjE 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

233 
val impI = impI 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

234 
val impE = impE 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

235 
val mp = mp 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

236 
val exI = exI 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

237 
val exE = exE 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

238 
val allI = allI 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

239 
val allE = allE 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

240 
end); 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

241 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

242 
local 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

243 
val ex_pattern = 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

244 
read_cterm (sign_of FOL.thy) ("EX x. P(x) & Q(x)", FOLogic.oT) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

245 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

246 
val all_pattern = 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

247 
read_cterm (sign_of FOL.thy) ("ALL x. P(x) & P'(x) > Q(x)", FOLogic.oT) 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

248 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

249 
in 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

250 
val defEX_regroup = 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

251 
mk_simproc "defined EX" [ex_pattern] Quantifier1.rearrange_ex; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

252 
val defALL_regroup = 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

253 
mk_simproc "defined ALL" [all_pattern] Quantifier1.rearrange_all; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

254 
end; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

255 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

256 

50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

257 
(*** Case splitting ***) 
0  258 

5304  259 
val meta_eq_to_iff = prove_goal IFOL.thy "x==y ==> x<>y" 
260 
(fn [prem] => [rewtac prem, rtac iffI 1, atac 1, atac 1]); 

1722  261 

5304  262 
structure SplitterData = 
263 
struct 

264 
structure Simplifier = Simplifier 

5555  265 
val mk_eq = mk_eq 
5304  266 
val meta_eq_to_iff = meta_eq_to_iff 
267 
val iffD = iffD2 

268 
val disjE = disjE 

269 
val conjE = conjE 

270 
val exE = exE 

271 
val contrapos = contrapos 

272 
val contrapos2 = contrapos2 

273 
val notnotD = notnotD 

274 
end; 

1722  275 

5304  276 
structure Splitter = SplitterFun(SplitterData); 
1722  277 

5304  278 
val split_tac = Splitter.split_tac; 
279 
val split_inside_tac = Splitter.split_inside_tac; 

280 
val split_asm_tac = Splitter.split_asm_tac; 

5307  281 
val op addsplits = Splitter.addsplits; 
282 
val op delsplits = Splitter.delsplits; 

5304  283 
val Addsplits = Splitter.Addsplits; 
284 
val Delsplits = Splitter.Delsplits; 

4325  285 

286 

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

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

288 

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

289 
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

290 

4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

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

292 

5555  293 

294 
(* Add congruence rules for = or <> (instead of ==) *) 

295 

296 
(* ###FIXME: Move to simplifier, 

297 
taking mk_meta_cong as input, eliminating addeqcongs and deleqcongs *) 

2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

298 
infix 4 addcongs delcongs; 
5555  299 
fun ss addcongs congs = ss addeqcongs (map mk_meta_cong congs); 
300 
fun ss delcongs congs = ss deleqcongs (map mk_meta_cong congs); 

4094  301 
fun Addcongs congs = (simpset_ref() := simpset() addcongs congs); 
302 
fun Delcongs congs = (simpset_ref() := simpset() delcongs congs); 

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

303 

5115  304 

5496  305 
val meta_simps = 
306 
[triv_forall_equality, (* prunes params *) 

307 
True_implies_equals]; (* prune asms `True' *) 

308 

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

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

310 
[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

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

312 

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

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

314 
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

315 

2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

316 
fun unsafe_solver prems = FIRST'[resolve_tac (triv_rls@prems), 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

317 
atac, etac FalseE]; 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

318 
(*No premature instantiation of variables during simplification*) 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

319 
fun safe_solver prems = FIRST'[match_tac (triv_rls@prems), 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

320 
eq_assume_tac, ematch_tac [FalseE]]; 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

321 

3910  322 
(*No simprules, but basic infastructure for simplification*) 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

323 
val FOL_basic_ss = empty_ss setsubgoaler asm_simp_tac 
4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

324 
addsimprocs [defALL_regroup,defEX_regroup] 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

325 
setSSolver safe_solver 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

326 
setSolver unsafe_solver 
5304  327 
setmksimps (mksimps mksimps_pairs); 
328 

329 

2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

330 

3910  331 
(*intuitionistic simprules only*) 
5496  332 
val IFOL_ss = 
333 
FOL_basic_ss addsimps (meta_simps @ IFOL_simps @ 

334 
int_ex_simps @ int_all_simps) 

335 
addcongs [imp_cong]; 

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

336 

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

337 
val cla_simps = 
3910  338 
[de_Morgan_conj, de_Morgan_disj, imp_disj1, imp_disj2, 
339 
not_all, not_ex, cases_simp] @ 

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

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

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

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

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

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

345 

3910  346 
(*classical simprules too*) 
4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

347 
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

348 

4094  349 
simpset_ref() := FOL_ss; 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

350 

37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

351 

37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

352 

5219  353 
(*** integration of simplifier with classical reasoner ***) 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

354 

5219  355 
structure Clasimp = ClasimpFun 
5555  356 
(structure Simplifier = Simplifier 
357 
and Classical = Cla 

358 
and Blast = Blast); 

4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
4649
diff
changeset

359 
open Clasimp; 
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 
val FOL_css = (FOL_cs, FOL_ss); 