255 in (map (skolem_of_def o #2) (axioms_of thy'), thy') end; |
255 in (map (skolem_of_def o #2) (axioms_of thy'), thy') end; |
256 |
256 |
257 (*Populate the clause cache using the supplied theorems*) |
257 (*Populate the clause cache using the supplied theorems*) |
258 fun skolemlist [] thy = thy |
258 fun skolemlist [] thy = thy |
259 | skolemlist ((name,th)::nths) thy = |
259 | skolemlist ((name,th)::nths) thy = |
260 (case Symtab.lookup (!clause_cache,name) of |
260 (case Symtab.curried_lookup (!clause_cache) name of |
261 NONE => |
261 NONE => |
262 let val (nnfth,ok) = (to_nnf thy th, true) |
262 let val (nnfth,ok) = (to_nnf thy th, true) |
263 handle THM _ => (asm_rl, false) |
263 handle THM _ => (asm_rl, false) |
264 in |
264 in |
265 if ok then |
265 if ok then |
266 let val (skoths,thy') = skolem thy (name, nnfth) |
266 let val (skoths,thy') = skolem thy (name, nnfth) |
267 val cls = Meson.make_cnf skoths nnfth |
267 val cls = Meson.make_cnf skoths nnfth |
268 in clause_cache := |
268 in change clause_cache (Symtab.curried_update (name, (th, cls))); |
269 Symtab.update ((name, (th,cls)), !clause_cache); |
|
270 skolemlist nths thy' |
269 skolemlist nths thy' |
271 end |
270 end |
272 else skolemlist nths thy |
271 else skolemlist nths thy |
273 end |
272 end |
274 | SOME _ => skolemlist nths thy) (*FIXME: check for duplicate names?*) |
273 | SOME _ => skolemlist nths thy) (*FIXME: check for duplicate names?*) |
275 |
274 |
276 (*Exported function to convert Isabelle theorems into axiom clauses*) |
275 (*Exported function to convert Isabelle theorems into axiom clauses*) |
277 fun cnf_axiom (name,th) = |
276 fun cnf_axiom (name,th) = |
278 case name of |
277 case name of |
279 "" => cnf_axiom_aux th (*no name, so can't cache*) |
278 "" => cnf_axiom_aux th (*no name, so can't cache*) |
280 | s => case Symtab.lookup (!clause_cache,s) of |
279 | s => case Symtab.curried_lookup (!clause_cache) s of |
281 NONE => |
280 NONE => |
282 let val cls = cnf_axiom_aux th |
281 let val cls = cnf_axiom_aux th |
283 in clause_cache := Symtab.update ((s, (th,cls)), !clause_cache); cls |
282 in change clause_cache (Symtab.curried_update (s, (th, cls))); cls end |
284 end |
|
285 | SOME(th',cls) => |
283 | SOME(th',cls) => |
286 if eq_thm(th,th') then cls |
284 if eq_thm(th,th') then cls |
287 else (*New theorem stored under the same name? Possible??*) |
285 else (*New theorem stored under the same name? Possible??*) |
288 let val cls = cnf_axiom_aux th |
286 let val cls = cnf_axiom_aux th |
289 in clause_cache := Symtab.update ((s, (th,cls)), !clause_cache); cls |
287 in change clause_cache (Symtab.curried_update (s, (th, cls))); cls end; |
290 end; |
|
291 |
288 |
292 fun pairname th = (Thm.name_of_thm th, th); |
289 fun pairname th = (Thm.name_of_thm th, th); |
293 |
290 |
294 fun meta_cnf_axiom th = |
291 fun meta_cnf_axiom th = |
295 map Meson.make_meta_clause (cnf_axiom (pairname th)); |
292 map Meson.make_meta_clause (cnf_axiom (pairname th)); |