author  paulson 
Mon, 19 Aug 1996 11:20:37 +0200  
changeset 1914  86b095835de9 
parent 1722  bb326972ede6 
child 1953  832ccc1dba95 
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 

17 
val conj_rews = 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 

24 
val disj_rews = 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 

30 
val not_rews = map int_prove_fun 

282  31 
["~(PQ) <> ~P & ~Q", 
1459  32 
"~ False <> True", "~ True <> False"]; 
0  33 

34 
val imp_rews = 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 

39 
val iff_rews = 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 

44 
val quant_rews = map int_prove_fun 

1459  45 
["(ALL x.P) <> P", "(EX x.P) <> P"]; 
0  46 

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

48 
val distrib_rews = 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 

86 
structure Induction = InductionFun(struct val spec=IFOL.spec end); 

87 

88 
open Simplifier Induction; 

89 

981  90 
(*Add congruence rules for = or <> (instead of ==) *) 
91 
infix 4 addcongs; 

3  92 
fun ss addcongs congs = 
282  93 
ss addeqcongs (congs RL [eq_reflection,iff_reflection]); 
94 

981  95 
(*Add a simpset to a classical set!*) 
96 
infix 4 addss; 

97 
fun cs addss ss = cs addbefore asm_full_simp_tac ss 1; 

98 

99 

282  100 
val IFOL_rews = 
101 
[refl RS P_iff_T] @ conj_rews @ disj_rews @ not_rews @ 

102 
imp_rews @ iff_rews @ quant_rews; 

3  103 

282  104 
val notFalseI = int_prove_fun "~False"; 
105 
val triv_rls = [TrueI,refl,iff_refl,notFalseI]; 

106 

107 
val IFOL_ss = 

108 
empty_ss 

109 
setmksimps (map mk_meta_eq o atomize o gen_all) 

371
3a853818f1d2
FOL/simpdata: added etac FalseE in setsolver call. Toby: "now that the
lcp
parents:
282
diff
changeset

110 
setsolver (fn prems => resolve_tac (triv_rls@prems) 
1459  111 
ORELSE' assume_tac 
112 
ORELSE' etac FalseE) 

282  113 
setsubgoaler asm_simp_tac 
114 
addsimps IFOL_rews 

115 
addcongs [imp_cong]; 

0  116 

117 
(*Classical version...*) 

118 
fun prove_fun s = 

282  119 
(writeln s; 
120 
prove_goal FOL.thy s 

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

1459  122 
(Cla.fast_tac FOL_cs 1) ])); 
745  123 

0  124 
val cla_rews = map prove_fun 
282  125 
["~(P&Q) <> ~P  ~Q", 
1459  126 
"P  ~P", "~P  P", 
127 
"~ ~ P <> P", "(~P > P) <> P"]; 

0  128 

129 
val FOL_ss = IFOL_ss addsimps cla_rews; 

130 

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

133 
(Int.fast_tac 1) ]); 

134 

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

136 

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

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

139 
val conj_comms = [conj_commute, conj_left_commute]; 

140 

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

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

143 
val disj_comms = [disj_commute, disj_left_commute]; 

144 

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

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

147 

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

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

150 

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

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

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

154 

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

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

157 

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

159 

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

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

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

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

164 

165 
int_prove "ex_disj_distrib" 

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

167 
int_prove "all_conj_distrib" 

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

169 

170 

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

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

172 
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

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

174 

0  175 
(*** case splitting ***) 
176 

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

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

942  180 
local val mktac = mk_case_split_tac meta_iffD 
181 
in 

182 
fun split_tac splits = mktac (map mk_meta_eq splits) 

183 
end; 

1722  184 

185 
local val mktac = mk_case_split_inside_tac meta_iffD 

186 
in 

187 
fun split_inside_tac splits = mktac (map mk_meta_eq splits) 

188 
end; 

189 

190 