author  lcp 
Fri, 24 Sep 1993 10:52:55 +0200  
changeset 11  d0e17c42dbb4 
parent 0  a5a9c433f639 
child 67  8380bc0adde7 
permissions  rwrr 
0  1 
(* Title: drule 
2 
ID: $Id$ 

3 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory 

4 
Copyright 1993 University of Cambridge 

5 

6 
Derived rules and other operations on theorems and theories 

7 
*) 

8 

11
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

9 
infix 0 RS RSN RL RLN MRS MRL COMP; 
0  10 

11 
signature DRULE = 

12 
sig 

13 
structure Thm : THM 

14 
local open Thm in 

15 
val asm_rl: thm 

16 
val assume_ax: theory > string > thm 

17 
val COMP: thm * thm > thm 

18 
val compose: thm * int * thm > thm list 

19 
val cterm_instantiate: (Sign.cterm*Sign.cterm)list > thm > thm 

20 
val cut_rl: thm 

21 
val equal_abs_elim: Sign.cterm > thm > thm 

22 
val equal_abs_elim_list: Sign.cterm list > thm > thm 

23 
val eq_sg: Sign.sg * Sign.sg > bool 

24 
val eq_thm: thm * thm > bool 

25 
val eq_thm_sg: thm * thm > bool 

26 
val flexpair_abs_elim_list: Sign.cterm list > thm > thm 

27 
val forall_intr_list: Sign.cterm list > thm > thm 

28 
val forall_intr_frees: thm > thm 

29 
val forall_elim_list: Sign.cterm list > thm > thm 

30 
val forall_elim_var: int > thm > thm 

31 
val forall_elim_vars: int > thm > thm 

32 
val implies_elim_list: thm > thm list > thm 

33 
val implies_intr_list: Sign.cterm list > thm > thm 

11
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

34 
val MRL: thm list list * thm list > thm list 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

35 
val MRS: thm list * thm > thm 
0  36 
val print_cterm: Sign.cterm > unit 
37 
val print_ctyp: Sign.ctyp > unit 

38 
val print_goals: int > thm > unit 

39 
val print_sg: Sign.sg > unit 

40 
val print_theory: theory > unit 

41 
val pprint_sg: Sign.sg > pprint_args > unit 

42 
val pprint_theory: theory > pprint_args > unit 

43 
val print_thm: thm > unit 

44 
val prth: thm > thm 

45 
val prthq: thm Sequence.seq > thm Sequence.seq 

46 
val prths: thm list > thm list 

47 
val read_instantiate: (string*string)list > thm > thm 

48 
val read_instantiate_sg: Sign.sg > (string*string)list > thm > thm 

49 
val reflexive_thm: thm 

50 
val revcut_rl: thm 

51 
val rewrite_goal_rule: (meta_simpset > thm > thm option) > meta_simpset > 

52 
int > thm > thm 

53 
val rewrite_goals_rule: thm list > thm > thm 

54 
val rewrite_rule: thm list > thm > thm 

55 
val RS: thm * thm > thm 

56 
val RSN: thm * (int * thm) > thm 

57 
val RL: thm list * thm list > thm list 

58 
val RLN: thm list * (int * thm list) > thm list 

59 
val show_hyps: bool ref 

60 
val size_of_thm: thm > int 

61 
val standard: thm > thm 

62 
val string_of_thm: thm > string 

63 
val symmetric_thm: thm 

64 
val pprint_thm: thm > pprint_args > unit 

65 
val transitive_thm: thm 

66 
val triv_forall_equality: thm 

67 
val types_sorts: thm > (indexname> typ option) * (indexname> sort option) 

68 
val zero_var_indexes: thm > thm 

69 
end 

70 
end; 

71 

72 
functor DruleFun (structure Logic: LOGIC and Thm: THM) : DRULE = 

73 
struct 

74 
structure Thm = Thm; 

75 
structure Sign = Thm.Sign; 

76 
structure Type = Sign.Type; 

77 
structure Pretty = Sign.Syntax.Pretty 

78 
local open Thm 

79 
in 

80 

81 
(**** More derived rules and operations on theorems ****) 

82 

83 
(*** Find the type (sort) associated with a (T)Var or (T)Free in a term 

84 
Used for establishing default types (of variables) and sorts (of 

85 
type variables) when reading another term. 

86 
Index 1 indicates that a (T)Free rather than a (T)Var is wanted. 

87 
***) 

88 

89 
fun types_sorts thm = 

90 
let val {prop,hyps,...} = rep_thm thm; 

91 
val big = list_comb(prop,hyps); (* bogus term! *) 

92 
val vars = map dest_Var (term_vars big); 

93 
val frees = map dest_Free (term_frees big); 

94 
val tvars = term_tvars big; 

95 
val tfrees = term_tfrees big; 

96 
fun typ(a,i) = if i<0 then assoc(frees,a) else assoc(vars,(a,i)); 

97 
fun sort(a,i) = if i<0 then assoc(tfrees,a) else assoc(tvars,(a,i)); 

98 
in (typ,sort) end; 

99 

100 
(** Standardization of rules **) 

101 

102 
(*Generalization over a list of variables, IGNORING bad ones*) 

103 
fun forall_intr_list [] th = th 

104 
 forall_intr_list (y::ys) th = 

105 
let val gth = forall_intr_list ys th 

106 
in forall_intr y gth handle THM _ => gth end; 

107 

108 
(*Generalization over all suitable Free variables*) 

109 
fun forall_intr_frees th = 

110 
let val {prop,sign,...} = rep_thm th 

111 
in forall_intr_list 

112 
(map (Sign.cterm_of sign) (sort atless (term_frees prop))) 

113 
th 

114 
end; 

115 

116 
(*Replace outermost quantified variable by Var of given index. 

117 
Could clash with Vars already present.*) 

118 
fun forall_elim_var i th = 

119 
let val {prop,sign,...} = rep_thm th 

120 
in case prop of 

121 
Const("all",_) $ Abs(a,T,_) => 

122 
forall_elim (Sign.cterm_of sign (Var((a,i), T))) th 

123 
 _ => raise THM("forall_elim_var", i, [th]) 

124 
end; 

125 

126 
(*Repeat forall_elim_var until all outer quantifiers are removed*) 

127 
fun forall_elim_vars i th = 

128 
forall_elim_vars i (forall_elim_var i th) 

129 
handle THM _ => th; 

130 

131 
(*Specialization over a list of cterms*) 

132 
fun forall_elim_list cts th = foldr (uncurry forall_elim) (rev cts, th); 

133 

134 
(* maps [A1,...,An], B to [ A1;...;An ] ==> B *) 

135 
fun implies_intr_list cAs th = foldr (uncurry implies_intr) (cAs,th); 

136 

137 
(* maps [ A1;...;An ] ==> B and [A1,...,An] to B *) 

138 
fun implies_elim_list impth ths = foldl (uncurry implies_elim) (impth,ths); 

139 

140 
(*Reset Var indexes to zero, renaming to preserve distinctness*) 

141 
fun zero_var_indexes th = 

142 
let val {prop,sign,...} = rep_thm th; 

143 
val vars = term_vars prop 

144 
val bs = foldl add_new_id ([], map (fn Var((a,_),_)=>a) vars) 

145 
val inrs = add_term_tvars(prop,[]); 

146 
val nms' = rev(foldl add_new_id ([], map (#1 o #1) inrs)); 

147 
val tye = map (fn ((v,rs),a) => (v, TVar((a,0),rs))) (inrs ~~ nms') 

148 
val ctye = map (fn (v,T) => (v,Sign.ctyp_of sign T)) tye; 

149 
fun varpairs([],[]) = [] 

150 
 varpairs((var as Var(v,T)) :: vars, b::bs) = 

151 
let val T' = typ_subst_TVars tye T 

152 
in (Sign.cterm_of sign (Var(v,T')), 

153 
Sign.cterm_of sign (Var((b,0),T'))) :: varpairs(vars,bs) 

154 
end 

155 
 varpairs _ = raise TERM("varpairs", []); 

156 
in instantiate (ctye, varpairs(vars,rev bs)) th end; 

157 

158 

159 
(*Standard form of objectrule: no hypotheses, Frees, or outer quantifiers; 

160 
all generality expressed by Vars having index 0.*) 

161 
fun standard th = 

162 
let val {maxidx,...} = rep_thm th 

163 
in varifyT (zero_var_indexes (forall_elim_vars(maxidx+1) 

164 
(forall_intr_frees(implies_intr_hyps th)))) 

165 
end; 

166 

167 
(*Assume a new formula, read following the same conventions as axioms. 

168 
Generalizes over Free variables, 

169 
creates the assumption, and then strips quantifiers. 

170 
Example is [ ALL x:?A. ?P(x) ] ==> [ ?P(?a) ] 

171 
[ !(A,P,a)[ ALL x:A. P(x) ] ==> [ P(a) ] ] *) 

172 
fun assume_ax thy sP = 

173 
let val sign = sign_of thy 

174 
val prop = Logic.close_form (Sign.term_of (Sign.read_cterm sign 

175 
(sP, propT))) 

176 
in forall_elim_vars 0 (assume (Sign.cterm_of sign prop)) end; 

177 

178 
(*Resolution: exactly one resolvent must be produced.*) 

179 
fun tha RSN (i,thb) = 

180 
case Sequence.chop (2, biresolution false [(false,tha)] i thb) of 

181 
([th],_) => th 

182 
 ([],_) => raise THM("RSN: no unifiers", i, [tha,thb]) 

183 
 _ => raise THM("RSN: multiple unifiers", i, [tha,thb]); 

184 

185 
(*resolution: P==>Q, Q==>R gives P==>R. *) 

186 
fun tha RS thb = tha RSN (1,thb); 

187 

188 
(*For joining lists of rules*) 

189 
fun thas RLN (i,thbs) = 

190 
let val resolve = biresolution false (map (pair false) thas) i 

191 
fun resb thb = Sequence.list_of_s (resolve thb) handle THM _ => [] 

192 
in flat (map resb thbs) end; 

193 

194 
fun thas RL thbs = thas RLN (1,thbs); 

195 

11
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

196 
(*Resolve a list of rules against bottom_rl from right to left; 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

197 
makes proof trees*) 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

198 
fun rls MRS bottom_rl = 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

199 
let fun rs_aux i [] = bottom_rl 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

200 
 rs_aux i (rl::rls) = rl RSN (i, rs_aux (i+1) rls) 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

201 
in rs_aux 1 rls end; 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

202 

d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

203 
(*As above, but for rule lists*) 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

204 
fun rlss MRL bottom_rls = 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

205 
let fun rs_aux i [] = bottom_rls 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

206 
 rs_aux i (rls::rlss) = rls RLN (i, rs_aux (i+1) rlss) 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

207 
in rs_aux 1 rlss end; 
d0e17c42dbb4
Added MRS, MRL from ZF/ROOT.ML. These support forward proof, resolving a
lcp
parents:
0
diff
changeset

208 

0  209 
(*compose Q and [...,Qi,Q(i+1),...]==>R to [...,Q(i+1),...]==>R 
210 
with no lifting or renaming! Q may contain ==> or metaquants 

211 
ALWAYS deletes premise i *) 

212 
fun compose(tha,i,thb) = 

213 
Sequence.list_of_s (bicompose false (false,tha,0) i thb); 

214 

215 
(*compose Q and [Q1,Q2,...,Qk]==>R to [Q2,...,Qk]==>R getting unique result*) 

216 
fun tha COMP thb = 

217 
case compose(tha,1,thb) of 

218 
[th] => th 

219 
 _ => raise THM("COMP", 1, [tha,thb]); 

220 

221 
(*Instantiate theorem th, reading instantiations under signature sg*) 

222 
fun read_instantiate_sg sg sinsts th = 

223 
let val ts = types_sorts th; 

224 
val instpair = Sign.read_insts sg ts ts sinsts 

225 
in instantiate instpair th end; 

226 

227 
(*Instantiate theorem th, reading instantiations under theory of th*) 

228 
fun read_instantiate sinsts th = 

229 
read_instantiate_sg (#sign (rep_thm th)) sinsts th; 

230 

231 

232 
(*Lefttoright replacements: tpairs = [...,(vi,ti),...]. 

233 
Instantiates distinct Vars by terms, inferring type instantiations. *) 

234 
local 

235 
fun add_types ((ct,cu), (sign,tye)) = 

236 
let val {sign=signt, t=t, T= T, ...} = Sign.rep_cterm ct 

237 
and {sign=signu, t=u, T= U, ...} = Sign.rep_cterm cu 

238 
val sign' = Sign.merge(sign, Sign.merge(signt, signu)) 

239 
val tye' = Type.unify (#tsig(Sign.rep_sg sign')) ((T,U), tye) 

240 
handle Type.TUNIFY => raise TYPE("add_types", [T,U], [t,u]) 

241 
in (sign', tye') end; 

242 
in 

243 
fun cterm_instantiate ctpairs0 th = 

244 
let val (sign,tye) = foldr add_types (ctpairs0, (#sign(rep_thm th),[])) 

245 
val tsig = #tsig(Sign.rep_sg sign); 

246 
fun instT(ct,cu) = let val inst = subst_TVars tye 

247 
in (Sign.cfun inst ct, Sign.cfun inst cu) end 

248 
fun ctyp2 (ix,T) = (ix, Sign.ctyp_of sign T) 

249 
in instantiate (map ctyp2 tye, map instT ctpairs0) th end 

250 
handle TERM _ => 

251 
raise THM("cterm_instantiate: incompatible signatures",0,[th]) 

252 
 TYPE _ => raise THM("cterm_instantiate: types", 0, [th]) 

253 
end; 

254 

255 

256 
(*** Printing of theorems ***) 

257 

258 
(*If false, hypotheses are printed as dots*) 

259 
val show_hyps = ref true; 

260 

261 
fun pretty_thm th = 

262 
let val {sign, hyps, prop,...} = rep_thm th 

263 
val hsymbs = if null hyps then [] 

264 
else if !show_hyps then 

265 
[Pretty.brk 2, 

266 
Pretty.lst("[","]") (map (Sign.pretty_term sign) hyps)] 

267 
else Pretty.str" [" :: map (fn _ => Pretty.str".") hyps @ 

268 
[Pretty.str"]"]; 

269 
in Pretty.blk(0, Sign.pretty_term sign prop :: hsymbs) end; 

270 

271 
val string_of_thm = Pretty.string_of o pretty_thm; 

272 

273 
val pprint_thm = Pretty.pprint o Pretty.quote o pretty_thm; 

274 

275 

276 
(** Toplevel commands for printing theorems **) 

277 
val print_thm = writeln o string_of_thm; 

278 

279 
fun prth th = (print_thm th; th); 

280 

281 
(*Print and return a sequence of theorems, separated by blank lines. *) 

282 
fun prthq thseq = 

283 
(Sequence.prints (fn _ => print_thm) 100000 thseq; 

284 
thseq); 

285 

286 
(*Print and return a list of theorems, separated by blank lines. *) 

287 
fun prths ths = (print_list_ln print_thm ths; ths); 

288 

289 
(*Other printing commands*) 

290 
val print_cterm = writeln o Sign.string_of_cterm; 

291 
val print_ctyp = writeln o Sign.string_of_ctyp; 

292 
fun pretty_sg sg = 

293 
Pretty.lst ("{", "}") (map (Pretty.str o !) (#stamps (Sign.rep_sg sg))); 

294 

295 
val pprint_sg = Pretty.pprint o pretty_sg; 

296 

297 
val pprint_theory = pprint_sg o sign_of; 

298 

299 
val print_sg = writeln o Pretty.string_of o pretty_sg; 

300 
val print_theory = print_sg o sign_of; 

301 

302 

303 
(** Print thm A1,...,An/B in "goal style"  premises as numbered subgoals **) 

304 

305 
fun prettyprints es = writeln(Pretty.string_of(Pretty.blk(0,es))); 

306 

307 
fun print_goals maxgoals th : unit = 

308 
let val {sign, hyps, prop,...} = rep_thm th; 

309 
fun printgoals (_, []) = () 

310 
 printgoals (n, A::As) = 

311 
let val prettyn = Pretty.str(" " ^ string_of_int n ^ ". "); 

312 
val prettyA = Sign.pretty_term sign A 

313 
in prettyprints[prettyn,prettyA]; 

314 
printgoals (n+1,As) 

315 
end; 

316 
fun prettypair(t,u) = 

317 
Pretty.blk(0, [Sign.pretty_term sign t, Pretty.str" =?=", Pretty.brk 1, 

318 
Sign.pretty_term sign u]); 

319 
fun printff [] = () 

320 
 printff tpairs = 

321 
writeln("\nFlexflex pairs:\n" ^ 

322 
Pretty.string_of(Pretty.lst("","") (map prettypair tpairs))) 

323 
val (tpairs,As,B) = Logic.strip_horn(prop); 

324 
val ngoals = length As 

325 
in 

326 
writeln (Sign.string_of_term sign B); 

327 
if ngoals=0 then writeln"No subgoals!" 

328 
else if ngoals>maxgoals 

329 
then (printgoals (1, take(maxgoals,As)); 

330 
writeln("A total of " ^ string_of_int ngoals ^ " subgoals...")) 

331 
else printgoals (1, As); 

332 
printff tpairs 

333 
end; 

334 

335 

336 
(** theorem equality test is exported and used by BEST_FIRST **) 

337 

338 
(*equality of signatures means exact identity  by ref equality*) 

339 
fun eq_sg (sg1,sg2) = (#stamps(Sign.rep_sg sg1) = #stamps(Sign.rep_sg sg2)); 

340 

341 
(*equality of theorems uses equality of signatures and 

342 
the aconvertible test for terms*) 

343 
fun eq_thm (th1,th2) = 

344 
let val {sign=sg1, hyps=hyps1, prop=prop1, ...} = rep_thm th1 

345 
and {sign=sg2, hyps=hyps2, prop=prop2, ...} = rep_thm th2 

346 
in eq_sg (sg1,sg2) andalso 

347 
aconvs(hyps1,hyps2) andalso 

348 
prop1 aconv prop2 

349 
end; 

350 

351 
(*Do the two theorems have the same signature?*) 

352 
fun eq_thm_sg (th1,th2) = eq_sg(#sign(rep_thm th1), #sign(rep_thm th2)); 

353 

354 
(*Useful "distance" function for BEST_FIRST*) 

355 
val size_of_thm = size_of_term o #prop o rep_thm; 

356 

357 

358 
(*** MetaRewriting Rules ***) 

359 

360 

361 
val reflexive_thm = 

362 
let val cx = Sign.cterm_of Sign.pure (Var(("x",0),TVar(("'a",0),["logic"]))) 

363 
in Thm.reflexive cx end; 

364 

365 
val symmetric_thm = 

366 
let val xy = Sign.read_cterm Sign.pure ("x::'a::logic == y",propT) 

367 
in standard(Thm.implies_intr_hyps(Thm.symmetric(Thm.assume xy))) end; 

368 

369 
val transitive_thm = 

370 
let val xy = Sign.read_cterm Sign.pure ("x::'a::logic == y",propT) 

371 
val yz = Sign.read_cterm Sign.pure ("y::'a::logic == z",propT) 

372 
val xythm = Thm.assume xy and yzthm = Thm.assume yz 

373 
in standard(Thm.implies_intr yz (Thm.transitive xythm yzthm)) end; 

374 

375 

376 
(** Below, a "conversion" has type sign>term>thm **) 

377 

378 
(*In [A1,...,An]==>B, rewrite the selected A's only  for rewrite_goals_tac*) 

379 
fun goals_conv pred cv sign = 

380 
let val triv = reflexive o Sign.cterm_of sign 

381 
fun gconv i t = 

382 
let val (A,B) = Logic.dest_implies t 

383 
val thA = if (pred i) then (cv sign A) else (triv A) 

384 
in combination (combination (triv implies) thA) 

385 
(gconv (i+1) B) 

386 
end 

387 
handle TERM _ => triv t 

388 
in gconv 1 end; 

389 

390 
(*Use a conversion to transform a theorem*) 

391 
fun fconv_rule cv th = 

392 
let val {sign,prop,...} = rep_thm th 

393 
in equal_elim (cv sign prop) th end; 

394 

395 
(*rewriting conversion*) 

396 
fun rew_conv prover mss sign t = 

397 
rewrite_cterm mss prover (Sign.cterm_of sign t); 

398 

399 
(*Rewrite a theorem*) 

400 
fun rewrite_rule thms = fconv_rule (rew_conv (K(K None)) (Thm.mss_of thms)); 

401 

402 
(*Rewrite the subgoals of a proof state (represented by a theorem) *) 

403 
fun rewrite_goals_rule thms = 

404 
fconv_rule (goals_conv (K true) (rew_conv (K(K None)) (Thm.mss_of thms))); 

405 

406 
(*Rewrite the subgoal of a proof state (represented by a theorem) *) 

407 
fun rewrite_goal_rule prover mss i = 

408 
fconv_rule (goals_conv (fn j => j=i) (rew_conv prover mss)); 

409 

410 

411 
(** Derived rules mainly for METAHYPS **) 

412 

413 
(*Given the term "a", takes (%x.t)==(%x.u) to t[a/x]==u[a/x]*) 

414 
fun equal_abs_elim ca eqth = 

415 
let val {sign=signa, t=a, ...} = Sign.rep_cterm ca 

416 
and combth = combination eqth (reflexive ca) 

417 
val {sign,prop,...} = rep_thm eqth 

418 
val (abst,absu) = Logic.dest_equals prop 

419 
val cterm = Sign.cterm_of (Sign.merge (sign,signa)) 

420 
in transitive (symmetric (beta_conversion (cterm (abst$a)))) 

421 
(transitive combth (beta_conversion (cterm (absu$a)))) 

422 
end 

423 
handle THM _ => raise THM("equal_abs_elim", 0, [eqth]); 

424 

425 
(*Calling equal_abs_elim with multiple terms*) 

426 
fun equal_abs_elim_list cts th = foldr (uncurry equal_abs_elim) (rev cts, th); 

427 

428 
local 

429 
open Logic 

430 
val alpha = TVar(("'a",0), []) (* type ?'a::{} *) 

431 
fun err th = raise THM("flexpair_inst: ", 0, [th]) 

432 
fun flexpair_inst def th = 

433 
let val {prop = Const _ $ t $ u, sign,...} = rep_thm th 

434 
val cterm = Sign.cterm_of sign 

435 
fun cvar a = cterm(Var((a,0),alpha)) 

436 
val def' = cterm_instantiate [(cvar"t", cterm t), (cvar"u", cterm u)] 

437 
def 

438 
in equal_elim def' th 

439 
end 

440 
handle THM _ => err th  bind => err th 

441 
in 

442 
val flexpair_intr = flexpair_inst (symmetric flexpair_def) 

443 
and flexpair_elim = flexpair_inst flexpair_def 

444 
end; 

445 

446 
(*Version for flexflex pairs  this supports lifting.*) 

447 
fun flexpair_abs_elim_list cts = 

448 
flexpair_intr o equal_abs_elim_list cts o flexpair_elim; 

449 

450 

451 
(*** Some useful metatheorems ***) 

452 

453 
(*The rule V/V, obtains assumption solving for eresolve_tac*) 

454 
val asm_rl = trivial(Sign.read_cterm Sign.pure ("PROP ?psi",propT)); 

455 

456 
(*Metalevel cut rule: [ V==>W; V ] ==> W *) 

457 
val cut_rl = trivial(Sign.read_cterm Sign.pure 

458 
("PROP ?psi ==> PROP ?theta", propT)); 

459 

460 
(*Generalized elim rule for one conclusion; cut_rl with reversed premises: 

461 
[ PROP V; PROP V ==> PROP W ] ==> PROP W *) 

462 
val revcut_rl = 

463 
let val V = Sign.read_cterm Sign.pure ("PROP V", propT) 

464 
and VW = Sign.read_cterm Sign.pure ("PROP V ==> PROP W", propT); 

465 
in standard (implies_intr V 

466 
(implies_intr VW 

467 
(implies_elim (assume VW) (assume V)))) 

468 
end; 

469 

470 
(* (!!x. PROP ?V) == PROP ?V Allows removal of redundant parameters*) 

471 
val triv_forall_equality = 

472 
let val V = Sign.read_cterm Sign.pure ("PROP V", propT) 

473 
and QV = Sign.read_cterm Sign.pure ("!!x::'a. PROP V", propT) 

474 
and x = Sign.read_cterm Sign.pure ("x", TFree("'a",["logic"])); 

475 
in standard (equal_intr (implies_intr QV (forall_elim x (assume QV))) 

476 
(implies_intr V (forall_intr x (assume V)))) 

477 
end; 

478 

479 
end 

480 
end; 