author  paulson 
Wed, 03 Dec 1997 10:48:16 +0100  
changeset 4349  50403e5a44c0 
parent 4325  e72cba5af6c5 
child 4477  b3e5857d8d99 
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), 

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

15 
(IntPr.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", 
2801  20 
"P & P <> P", "P & P & Q <> P & Q", 
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", 

2801  27 
"P  P <> P", "P  P  Q <> P  Q", 
0  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 

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

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

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

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

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

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

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

51 
"(EX x. t=x & P(x)) <> P(t)"]; 
0  52 

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

1953  54 
val distrib_simps = map int_prove_fun 
282  55 
["P & (Q  R) <> P&Q  P&R", 
56 
"(Q  R) & P <> Q&P  R&P", 

0  57 
"(P  Q > R) <> (P > R) & (Q > R)"]; 
58 

282  59 
(** Conversion into rewrite rules **) 
0  60 

53  61 
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; 
62 

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

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

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

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

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

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

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

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

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

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

76 

282  77 

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

79 
val iff_reflection_F = P_iff_F RS iff_reflection; 

80 

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

82 
val iff_reflection_T = P_iff_T RS iff_reflection; 

83 

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

85 
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

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

87 
 _ $ (Const("op =",_)$_$_) => th RS eq_reflection 
282  88 
 _ $ (Const("op <>",_)$_$_) => th RS iff_reflection 
89 
 _ $ (Const("Not",_)$_) => th RS iff_reflection_F 

90 
 _ => th RS iff_reflection_T; 

0  91 

981  92 

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

93 
(*** Classical laws ***) 
282  94 

0  95 
fun prove_fun s = 
282  96 
(writeln s; 
97 
prove_goal FOL.thy s 

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

1459  99 
(Cla.fast_tac FOL_cs 1) ])); 
745  100 

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

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

104 

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

105 

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

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

107 
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

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

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

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

111 

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

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

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

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

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

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

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

118 

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

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

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

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

122 
"(EX x. P > Q(x)) <> P > (EX x. Q(x))"]; 
0  123 

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

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

125 

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

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

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

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

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

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

131 
"(ALL x. P > Q(x)) <> P > (ALL x. Q(x))"]; 
1953  132 

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

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

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

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

136 
"(ALL x. P  Q(x)) <> P  (ALL x. Q(x))"]; 
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 
val all_simps = int_all_simps @ cla_all_simps; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

139 

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

140 

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

141 
(*** Named rewrite rules proved for IFOL ***) 
1953  142 

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

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

145 
(IntPr.fast_tac 1) ]); 
1914  146 

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

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

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

151 
val conj_comms = [conj_commute, conj_left_commute]; 

152 

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

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

155 
val disj_comms = [disj_commute, disj_left_commute]; 

156 

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

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

159 

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

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

162 

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

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

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

166 

3910  167 
prove "imp_disj1" "(P>Q)  R <> (P>Q  R)"; 
168 
prove "imp_disj2" "Q  (P>R) <> (P>Q  R)"; 

169 

1914  170 
int_prove "de_Morgan_disj" "(~(P  Q)) <> (~P & ~Q)"; 
171 
prove "de_Morgan_conj" "(~(P & Q)) <> (~P  ~Q)"; 

172 

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

174 

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

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

1914  178 
int_prove "imp_ex" "((EX x. P(x)) > Q) <> (ALL x. P(x) > Q)"; 
179 

180 
int_prove "ex_disj_distrib" 

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

182 
int_prove "all_conj_distrib" 

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

184 

185 

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

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

187 
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

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

189 

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

190 

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

191 
open Simplifier; 
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

192 

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

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

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

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

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

197 
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

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

199 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

217 

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

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

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

220 
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

221 

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

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

223 
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

224 

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

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

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

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

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

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

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

231 

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

232 

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

233 
(*** Case splitting ***) 
0  234 

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

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

942  238 
local val mktac = mk_case_split_tac meta_iffD 
239 
in 

240 
fun split_tac splits = mktac (map mk_meta_eq splits) 

241 
end; 

1722  242 

243 
local val mktac = mk_case_split_inside_tac meta_iffD 

244 
in 

245 
fun split_inside_tac splits = mktac (map mk_meta_eq splits) 

246 
end; 

247 

4203  248 
val split_asm_tac = mk_case_split_asm_tac split_tac 
249 
(disjE,conjE,exE,contrapos,contrapos2,notnotD); 

1722  250 

4325  251 

252 

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

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

254 

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

255 
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

256 

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

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

258 

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

259 
(*Add congruence rules for = or <> (instead of ==) *) 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

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

261 
fun ss addcongs congs = 
3566  262 
ss addeqcongs (map standard (congs RL [eq_reflection,iff_reflection])); 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

263 
fun ss delcongs congs = 
3566  264 
ss deleqcongs (map standard (congs RL [eq_reflection,iff_reflection])); 
2469  265 

4094  266 
fun Addcongs congs = (simpset_ref() := simpset() addcongs congs); 
267 
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

268 

4325  269 
infix 4 addsplits; 
270 
fun ss addsplits splits = ss addloop (split_tac splits); 

271 

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

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

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

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

275 

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

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

277 
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

278 

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

279 
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

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

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

282 
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

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

284 

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

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

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

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

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

290 
setmksimps (map mk_meta_eq o atomize o gen_all); 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

291 

3910  292 
(*intuitionistic simprules only*) 
4349
50403e5a44c0
Instantiated the onepointrule quantifier simpprocs for FOL
paulson
parents:
4325
diff
changeset

293 
val IFOL_ss = FOL_basic_ss addsimps (IFOL_simps @ int_ex_simps @ int_all_simps) 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

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

295 

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

296 
val cla_simps = 
3910  297 
[de_Morgan_conj, de_Morgan_disj, imp_disj1, imp_disj2, 
298 
not_all, not_ex, cases_simp] @ 

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

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

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

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

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

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

304 

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

306 
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

307 

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

309 

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

310 

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

311 

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

312 
(*** Integration of simplifier with classical reasoner ***) 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

313 

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

314 
(* rot_eq_tac rotates the first equality premise of subgoal i to the front, 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

315 
fails if there is no equaliy or if an equality is already at the front *) 
3537  316 
local 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

317 
fun is_eq (Const ("Trueprop", _) $ (Const("op =" ,_) $ _ $ _)) = true 
3537  318 
 is_eq (Const ("Trueprop", _) $ (Const("op <>",_) $ _ $ _)) = true 
319 
 is_eq _ = false; 

4188
1025a27b08f9
changed libraray function find to find_index_eq, currying it
oheimb
parents:
4094
diff
changeset

320 
val find_eq = find_index is_eq; 
3537  321 
in 
322 
val rot_eq_tac = 

4188
1025a27b08f9
changed libraray function find to find_index_eq, currying it
oheimb
parents:
4094
diff
changeset

323 
SUBGOAL (fn (Bi,i) => let val n = find_eq (Logic.strip_assums_hyp Bi) in 
1025a27b08f9
changed libraray function find to find_index_eq, currying it
oheimb
parents:
4094
diff
changeset

324 
if n>0 then rotate_tac n i else no_tac end) 
3537  325 
end; 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

326 

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

327 

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

328 
fun safe_asm_more_full_simp_tac ss = TRY o rot_eq_tac THEN' 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

329 
safe_asm_full_simp_tac ss; 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

330 
(*an unsatisfactory fix for the incomplete asm_full_simp_tac! 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

331 
better: asm_really_full_simp_tac, a yet to be implemented version of 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

332 
asm_full_simp_tac that applies all equalities in the 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

333 
premises to all the premises *) 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

334 

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

335 
(*Add a simpset to a classical set!*) 
3206
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

336 
infix 4 addSss addss; 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

337 
fun cs addSss ss = cs addSaltern (CHANGED o (safe_asm_more_full_simp_tac ss)); 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

338 
fun cs addss ss = cs addbefore asm_full_simp_tac ss; 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

339 

4094  340 
fun Addss ss = (claset_ref() := claset() addss ss); 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

341 

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

342 
(*Designed to be idempotent, except if best_tac instantiates variables 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

343 
in some of the subgoals*) 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

344 

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

345 
type clasimpset = (claset * simpset); 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

346 

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

347 
val FOL_css = (FOL_cs, FOL_ss); 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

348 

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

349 
fun pair_upd1 f ((a,b),x) = (f(a,x), b); 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

350 
fun pair_upd2 f ((a,b),x) = (a, f(b,x)); 
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 
infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2 
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

353 
addsimps2 delsimps2 addcongs2 delcongs2; 
2727
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

354 
fun op addSIs2 arg = pair_upd1 (op addSIs) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

355 
fun op addSEs2 arg = pair_upd1 (op addSEs) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

356 
fun op addSDs2 arg = pair_upd1 (op addSDs) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

357 
fun op addIs2 arg = pair_upd1 (op addIs ) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

358 
fun op addEs2 arg = pair_upd1 (op addEs ) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

359 
fun op addDs2 arg = pair_upd1 (op addDs ) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

360 
fun op addsimps2 arg = pair_upd2 (op addsimps) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

361 
fun op delsimps2 arg = pair_upd2 (op delsimps) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

362 
fun op addcongs2 arg = pair_upd2 (op addcongs) arg; 
230f2643107e
Etaexpanded declarations of addSIs2, etc., to avoid polymorphism errors
paulson
parents:
2633
diff
changeset

363 
fun op delcongs2 arg = pair_upd2 (op delcongs) arg; 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

364 

3206
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

365 
fun auto_tac (cs,ss) = 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

366 
let val cs' = cs addss ss 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

367 
in EVERY [TRY (safe_tac cs'), 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

368 
REPEAT (FIRSTGOAL (fast_tac cs')), 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

369 
TRY (safe_tac (cs addSss ss)), 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

370 
prune_params_tac] 
a3de7f32728c
renamed addss to addSss, unsafe_addss to addss, extended auto_tac
oheimb
parents:
2801
diff
changeset

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

372 

4094  373 
fun Auto_tac () = auto_tac (claset(), simpset()); 
2633
37c0b5a7ee5d
added delcongs, Delcongs, unsafe_solver, safe_solver, FOL_basic_ss,
oheimb
parents:
2601
diff
changeset

374 

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

375 
fun auto () = by (Auto_tac ()); 