9 |
9 |
10 signature METIS_RECONSTRUCT = |
10 signature METIS_RECONSTRUCT = |
11 sig |
11 sig |
12 type mode = Metis_Translate.mode |
12 type mode = Metis_Translate.mode |
13 |
13 |
14 val trace : bool Unsynchronized.ref |
14 val trace : bool Config.T |
|
15 val trace_msg : Proof.context -> (unit -> string) -> unit |
15 val lookth : (Metis_Thm.thm * 'a) list -> Metis_Thm.thm -> 'a |
16 val lookth : (Metis_Thm.thm * 'a) list -> Metis_Thm.thm -> 'a |
16 val untyped_aconv : term -> term -> bool |
17 val untyped_aconv : term -> term -> bool |
17 val replay_one_inference : |
18 val replay_one_inference : |
18 Proof.context -> mode -> (string * term) list |
19 Proof.context -> mode -> (string * term) list |
19 -> Metis_Thm.thm * Metis_Proof.inference -> (Metis_Thm.thm * thm) list |
20 -> Metis_Thm.thm * Metis_Proof.inference -> (Metis_Thm.thm * thm) list |
20 -> (Metis_Thm.thm * thm) list |
21 -> (Metis_Thm.thm * thm) list |
21 val discharge_skolem_premises : |
22 val discharge_skolem_premises : |
22 Proof.context -> (thm * term) option list -> thm -> thm |
23 Proof.context -> (thm * term) option list -> thm -> thm |
|
24 val setup : theory -> theory |
23 end; |
25 end; |
24 |
26 |
25 structure Metis_Reconstruct : METIS_RECONSTRUCT = |
27 structure Metis_Reconstruct : METIS_RECONSTRUCT = |
26 struct |
28 struct |
27 |
29 |
28 open Metis_Translate |
30 open Metis_Translate |
29 |
31 |
30 val trace = Unsynchronized.ref false |
32 val (trace, trace_setup) = Attrib.config_bool "trace_metis" (K false) |
31 fun trace_msg msg = if !trace then tracing (msg ()) else () |
33 |
|
34 fun trace_msg ctxt msg = if Config.get ctxt trace then tracing (msg ()) else () |
32 |
35 |
33 datatype term_or_type = SomeTerm of term | SomeType of typ |
36 datatype term_or_type = SomeTerm of term | SomeType of typ |
34 |
37 |
35 fun terms_of [] = [] |
38 fun terms_of [] = [] |
36 | terms_of (SomeTerm t :: tts) = t :: terms_of tts |
39 | terms_of (SomeTerm t :: tts) = t :: terms_of tts |
90 | NONE => raise Fail ("hol_type_from_metis_term: " ^ x)); |
93 | NONE => raise Fail ("hol_type_from_metis_term: " ^ x)); |
91 |
94 |
92 (*Maps metis terms to isabelle terms*) |
95 (*Maps metis terms to isabelle terms*) |
93 fun hol_term_from_metis_PT ctxt fol_tm = |
96 fun hol_term_from_metis_PT ctxt fol_tm = |
94 let val thy = ProofContext.theory_of ctxt |
97 let val thy = ProofContext.theory_of ctxt |
95 val _ = trace_msg (fn () => "hol_term_from_metis_PT: " ^ |
98 val _ = trace_msg ctxt (fn () => "hol_term_from_metis_PT: " ^ |
96 Metis_Term.toString fol_tm) |
99 Metis_Term.toString fol_tm) |
97 fun tm_to_tt (Metis_Term.Var v) = |
100 fun tm_to_tt (Metis_Term.Var v) = |
98 (case strip_prefix_and_unascii tvar_prefix v of |
101 (case strip_prefix_and_unascii tvar_prefix v of |
99 SOME w => SomeType (make_tvar w) |
102 SOME w => SomeType (make_tvar w) |
100 | NONE => |
103 | NONE => |
101 case strip_prefix_and_unascii schematic_var_prefix v of |
104 case strip_prefix_and_unascii schematic_var_prefix v of |
158 | SomeType T => raise TYPE ("fol_tm_to_tt: Term expected", [T], []) |
161 | SomeType T => raise TYPE ("fol_tm_to_tt: Term expected", [T], []) |
159 end |
162 end |
160 |
163 |
161 (*Maps fully-typed metis terms to isabelle terms*) |
164 (*Maps fully-typed metis terms to isabelle terms*) |
162 fun hol_term_from_metis_FT ctxt fol_tm = |
165 fun hol_term_from_metis_FT ctxt fol_tm = |
163 let val _ = trace_msg (fn () => "hol_term_from_metis_FT: " ^ |
166 let val _ = trace_msg ctxt (fn () => "hol_term_from_metis_FT: " ^ |
164 Metis_Term.toString fol_tm) |
167 Metis_Term.toString fol_tm) |
165 fun cvt (Metis_Term.Fn ("ti", [Metis_Term.Var v, _])) = |
168 fun cvt (Metis_Term.Fn ("ti", [Metis_Term.Var v, _])) = |
166 (case strip_prefix_and_unascii schematic_var_prefix v of |
169 (case strip_prefix_and_unascii schematic_var_prefix v of |
167 SOME w => mk_var(w, dummyT) |
170 SOME w => mk_var(w, dummyT) |
168 | NONE => mk_var(v, dummyT)) |
171 | NONE => mk_var(v, dummyT)) |
169 | cvt (Metis_Term.Fn ("ti", [Metis_Term.Fn ("=",[]), _])) = |
172 | cvt (Metis_Term.Fn ("ti", [Metis_Term.Fn ("=",[]), _])) = |
186 (case strip_prefix_and_unascii const_prefix x of |
189 (case strip_prefix_and_unascii const_prefix x of |
187 SOME c => Const (smart_invert_const c, dummyT) |
190 SOME c => Const (smart_invert_const c, dummyT) |
188 | NONE => (*Not a constant. Is it a fixed variable??*) |
191 | NONE => (*Not a constant. Is it a fixed variable??*) |
189 case strip_prefix_and_unascii fixed_var_prefix x of |
192 case strip_prefix_and_unascii fixed_var_prefix x of |
190 SOME v => Free (v, dummyT) |
193 SOME v => Free (v, dummyT) |
191 | NONE => (trace_msg (fn () => "hol_term_from_metis_FT bad const: " ^ x); |
194 | NONE => (trace_msg ctxt (fn () => |
192 hol_term_from_metis_PT ctxt t)) |
195 "hol_term_from_metis_FT bad const: " ^ x); |
193 | cvt t = (trace_msg (fn () => "hol_term_from_metis_FT bad term: " ^ Metis_Term.toString t); |
196 hol_term_from_metis_PT ctxt t)) |
194 hol_term_from_metis_PT ctxt t) |
197 | cvt t = (trace_msg ctxt (fn () => |
|
198 "hol_term_from_metis_FT bad term: " ^ Metis_Term.toString t); |
|
199 hol_term_from_metis_PT ctxt t) |
195 in fol_tm |> cvt end |
200 in fol_tm |> cvt end |
196 |
201 |
197 fun hol_term_from_metis FT = hol_term_from_metis_FT |
202 fun hol_term_from_metis FT = hol_term_from_metis_FT |
198 | hol_term_from_metis _ = hol_term_from_metis_PT |
203 | hol_term_from_metis _ = hol_term_from_metis_PT |
199 |
204 |
200 fun hol_terms_from_fol ctxt mode old_skolems fol_tms = |
205 fun hol_terms_from_fol ctxt mode old_skolems fol_tms = |
201 let val ts = map (hol_term_from_metis mode ctxt) fol_tms |
206 let val ts = map (hol_term_from_metis mode ctxt) fol_tms |
202 val _ = trace_msg (fn () => " calling type inference:") |
207 val _ = trace_msg ctxt (fn () => " calling type inference:") |
203 val _ = app (fn t => trace_msg (fn () => Syntax.string_of_term ctxt t)) ts |
208 val _ = app (fn t => trace_msg ctxt |
|
209 (fn () => Syntax.string_of_term ctxt t)) ts |
204 val ts' = ts |> map (reveal_old_skolem_terms old_skolems) |
210 val ts' = ts |> map (reveal_old_skolem_terms old_skolems) |
205 |> infer_types ctxt |
211 |> infer_types ctxt |
206 val _ = app (fn t => trace_msg |
212 val _ = app (fn t => trace_msg ctxt |
207 (fn () => " final term: " ^ Syntax.string_of_term ctxt t ^ |
213 (fn () => " final term: " ^ Syntax.string_of_term ctxt t ^ |
208 " of type " ^ Syntax.string_of_typ ctxt (type_of t))) |
214 " of type " ^ Syntax.string_of_typ ctxt (type_of t))) |
209 ts' |
215 ts' |
210 in ts' end; |
216 in ts' end; |
211 |
217 |
213 (* FOL step Inference Rules *) |
219 (* FOL step Inference Rules *) |
214 (* ------------------------------------------------------------------------- *) |
220 (* ------------------------------------------------------------------------- *) |
215 |
221 |
216 (*for debugging only*) |
222 (*for debugging only*) |
217 (* |
223 (* |
218 fun print_thpair (fth,th) = |
224 fun print_thpair ctxt (fth,th) = |
219 (trace_msg (fn () => "============================================="); |
225 (trace_msg ctxt (fn () => "============================================="); |
220 trace_msg (fn () => "Metis: " ^ Metis_Thm.toString fth); |
226 trace_msg ctxt (fn () => "Metis: " ^ Metis_Thm.toString fth); |
221 trace_msg (fn () => "Isabelle: " ^ Display.string_of_thm_without_context th)); |
227 trace_msg ctxt (fn () => "Isabelle: " ^ Display.string_of_thm_without_context th)); |
222 *) |
228 *) |
223 |
229 |
224 fun lookth thpairs (fth : Metis_Thm.thm) = |
230 fun lookth thpairs (fth : Metis_Thm.thm) = |
225 the (AList.lookup (uncurry Metis_Thm.equal) thpairs fth) |
231 the (AList.lookup (uncurry Metis_Thm.equal) thpairs fth) |
226 handle Option.Option => |
232 handle Option.Option => |
262 let val v = find_var x |
268 let val v = find_var x |
263 (* We call "reveal_old_skolem_terms" and "infer_types" below. *) |
269 (* We call "reveal_old_skolem_terms" and "infer_types" below. *) |
264 val t = hol_term_from_metis mode ctxt y |
270 val t = hol_term_from_metis mode ctxt y |
265 in SOME (cterm_of thy (Var v), t) end |
271 in SOME (cterm_of thy (Var v), t) end |
266 handle Option.Option => |
272 handle Option.Option => |
267 (trace_msg (fn () => "\"find_var\" failed for " ^ x ^ |
273 (trace_msg ctxt (fn () => "\"find_var\" failed for " ^ x ^ |
268 " in " ^ Display.string_of_thm ctxt i_th); |
274 " in " ^ Display.string_of_thm ctxt i_th); |
269 NONE) |
275 NONE) |
270 | TYPE _ => |
276 | TYPE _ => |
271 (trace_msg (fn () => "\"hol_term_from_metis\" failed for " ^ x ^ |
277 (trace_msg ctxt (fn () => "\"hol_term_from_metis\" failed for " ^ x ^ |
272 " in " ^ Display.string_of_thm ctxt i_th); |
278 " in " ^ Display.string_of_thm ctxt i_th); |
273 NONE) |
279 NONE) |
274 fun remove_typeinst (a, t) = |
280 fun remove_typeinst (a, t) = |
275 case strip_prefix_and_unascii schematic_var_prefix a of |
281 case strip_prefix_and_unascii schematic_var_prefix a of |
276 SOME b => SOME (b, t) |
282 SOME b => SOME (b, t) |
277 | NONE => case strip_prefix_and_unascii tvar_prefix a of |
283 | NONE => case strip_prefix_and_unascii tvar_prefix a of |
278 SOME _ => NONE (*type instantiations are forbidden!*) |
284 SOME _ => NONE (*type instantiations are forbidden!*) |
279 | NONE => SOME (a,t) (*internal Metis var?*) |
285 | NONE => SOME (a,t) (*internal Metis var?*) |
280 val _ = trace_msg (fn () => " isa th: " ^ Display.string_of_thm ctxt i_th) |
286 val _ = trace_msg ctxt (fn () => " isa th: " ^ Display.string_of_thm ctxt i_th) |
281 val substs = map_filter remove_typeinst (Metis_Subst.toList fsubst) |
287 val substs = map_filter remove_typeinst (Metis_Subst.toList fsubst) |
282 val (vars,rawtms) = ListPair.unzip (map_filter subst_translation substs) |
288 val (vars,rawtms) = ListPair.unzip (map_filter subst_translation substs) |
283 val tms = rawtms |> map (reveal_old_skolem_terms old_skolems) |
289 val tms = rawtms |> map (reveal_old_skolem_terms old_skolems) |
284 |> infer_types ctxt |
290 |> infer_types ctxt |
285 val ctm_of = cterm_incr_types thy (1 + Thm.maxidx_of i_th) |
291 val ctm_of = cterm_incr_types thy (1 + Thm.maxidx_of i_th) |
286 val substs' = ListPair.zip (vars, map ctm_of tms) |
292 val substs' = ListPair.zip (vars, map ctm_of tms) |
287 val _ = trace_msg (fn () => |
293 val _ = trace_msg ctxt (fn () => |
288 cat_lines ("subst_translations:" :: |
294 cat_lines ("subst_translations:" :: |
289 (substs' |> map (fn (x, y) => |
295 (substs' |> map (fn (x, y) => |
290 Syntax.string_of_term ctxt (term_of x) ^ " |-> " ^ |
296 Syntax.string_of_term ctxt (term_of x) ^ " |-> " ^ |
291 Syntax.string_of_term ctxt (term_of y))))); |
297 Syntax.string_of_term ctxt (term_of y))))); |
292 in cterm_instantiate substs' i_th end |
298 in cterm_instantiate substs' i_th end |
373 |
379 |
374 fun resolve_inf ctxt mode old_skolems thpairs atm th1 th2 = |
380 fun resolve_inf ctxt mode old_skolems thpairs atm th1 th2 = |
375 let |
381 let |
376 val thy = ProofContext.theory_of ctxt |
382 val thy = ProofContext.theory_of ctxt |
377 val i_th1 = lookth thpairs th1 and i_th2 = lookth thpairs th2 |
383 val i_th1 = lookth thpairs th1 and i_th2 = lookth thpairs th2 |
378 val _ = trace_msg (fn () => " isa th1 (pos): " ^ Display.string_of_thm ctxt i_th1) |
384 val _ = trace_msg ctxt (fn () => " isa th1 (pos): " ^ Display.string_of_thm ctxt i_th1) |
379 val _ = trace_msg (fn () => " isa th2 (neg): " ^ Display.string_of_thm ctxt i_th2) |
385 val _ = trace_msg ctxt (fn () => " isa th2 (neg): " ^ Display.string_of_thm ctxt i_th2) |
380 in |
386 in |
381 (* Trivial cases where one operand is type info *) |
387 (* Trivial cases where one operand is type info *) |
382 if Thm.eq_thm (TrueI, i_th1) then |
388 if Thm.eq_thm (TrueI, i_th1) then |
383 i_th2 |
389 i_th2 |
384 else if Thm.eq_thm (TrueI, i_th2) then |
390 else if Thm.eq_thm (TrueI, i_th2) then |
385 i_th1 |
391 i_th1 |
386 else |
392 else |
387 let |
393 let |
388 val i_atm = singleton (hol_terms_from_fol ctxt mode old_skolems) |
394 val i_atm = singleton (hol_terms_from_fol ctxt mode old_skolems) |
389 (Metis_Term.Fn atm) |
395 (Metis_Term.Fn atm) |
390 val _ = trace_msg (fn () => " atom: " ^ Syntax.string_of_term ctxt i_atm) |
396 val _ = trace_msg ctxt (fn () => " atom: " ^ Syntax.string_of_term ctxt i_atm) |
391 val prems_th1 = prems_of i_th1 |
397 val prems_th1 = prems_of i_th1 |
392 val prems_th2 = prems_of i_th2 |
398 val prems_th2 = prems_of i_th2 |
393 val index_th1 = literal_index (mk_not i_atm) prems_th1 |
399 val index_th1 = literal_index (mk_not i_atm) prems_th1 |
394 handle Empty => raise Fail "Failed to find literal in th1" |
400 handle Empty => raise Fail "Failed to find literal in th1" |
395 val _ = trace_msg (fn () => " index_th1: " ^ Int.toString index_th1) |
401 val _ = trace_msg ctxt (fn () => " index_th1: " ^ Int.toString index_th1) |
396 val index_th2 = literal_index i_atm prems_th2 |
402 val index_th2 = literal_index i_atm prems_th2 |
397 handle Empty => raise Fail "Failed to find literal in th2" |
403 handle Empty => raise Fail "Failed to find literal in th2" |
398 val _ = trace_msg (fn () => " index_th2: " ^ Int.toString index_th2) |
404 val _ = trace_msg ctxt (fn () => " index_th2: " ^ Int.toString index_th2) |
399 in |
405 in |
400 resolve_inc_tyvars thy (select_literal index_th1 i_th1) index_th2 i_th2 |
406 resolve_inc_tyvars thy (select_literal index_th1 i_th1) index_th2 i_th2 |
401 end |
407 end |
402 end; |
408 end; |
403 |
409 |
409 val refl_idx = 1 + Thm.maxidx_of REFL_THM; |
415 val refl_idx = 1 + Thm.maxidx_of REFL_THM; |
410 |
416 |
411 fun refl_inf ctxt mode old_skolems t = |
417 fun refl_inf ctxt mode old_skolems t = |
412 let val thy = ProofContext.theory_of ctxt |
418 let val thy = ProofContext.theory_of ctxt |
413 val i_t = singleton (hol_terms_from_fol ctxt mode old_skolems) t |
419 val i_t = singleton (hol_terms_from_fol ctxt mode old_skolems) t |
414 val _ = trace_msg (fn () => " term: " ^ Syntax.string_of_term ctxt i_t) |
420 val _ = trace_msg ctxt (fn () => " term: " ^ Syntax.string_of_term ctxt i_t) |
415 val c_t = cterm_incr_types thy refl_idx i_t |
421 val c_t = cterm_incr_types thy refl_idx i_t |
416 in cterm_instantiate [(refl_x, c_t)] REFL_THM end; |
422 in cterm_instantiate [(refl_x, c_t)] REFL_THM end; |
417 |
423 |
418 (* INFERENCE RULE: EQUALITY *) |
424 (* INFERENCE RULE: EQUALITY *) |
419 |
425 |
428 |
434 |
429 fun equality_inf ctxt mode old_skolems (pos, atm) fp fr = |
435 fun equality_inf ctxt mode old_skolems (pos, atm) fp fr = |
430 let val thy = ProofContext.theory_of ctxt |
436 let val thy = ProofContext.theory_of ctxt |
431 val m_tm = Metis_Term.Fn atm |
437 val m_tm = Metis_Term.Fn atm |
432 val [i_atm,i_tm] = hol_terms_from_fol ctxt mode old_skolems [m_tm, fr] |
438 val [i_atm,i_tm] = hol_terms_from_fol ctxt mode old_skolems [m_tm, fr] |
433 val _ = trace_msg (fn () => "sign of the literal: " ^ Bool.toString pos) |
439 val _ = trace_msg ctxt (fn () => "sign of the literal: " ^ Bool.toString pos) |
434 fun replace_item_list lx 0 (_::ls) = lx::ls |
440 fun replace_item_list lx 0 (_::ls) = lx::ls |
435 | replace_item_list lx i (l::ls) = l :: replace_item_list lx (i-1) ls |
441 | replace_item_list lx i (l::ls) = l :: replace_item_list lx (i-1) ls |
436 fun path_finder_FO tm [] = (tm, Bound 0) |
442 fun path_finder_FO tm [] = (tm, Bound 0) |
437 | path_finder_FO tm (p::ps) = |
443 | path_finder_FO tm (p::ps) = |
438 let val (tm1,args) = strip_comb tm |
444 let val (tm1,args) = strip_comb tm |
442 handle Subscript => |
448 handle Subscript => |
443 error ("Cannot replay Metis proof in Isabelle:\n" ^ |
449 error ("Cannot replay Metis proof in Isabelle:\n" ^ |
444 "equality_inf: " ^ Int.toString p ^ " adj " ^ |
450 "equality_inf: " ^ Int.toString p ^ " adj " ^ |
445 Int.toString adjustment ^ " term " ^ |
451 Int.toString adjustment ^ " term " ^ |
446 Syntax.string_of_term ctxt tm) |
452 Syntax.string_of_term ctxt tm) |
447 val _ = trace_msg (fn () => "path_finder: " ^ Int.toString p ^ |
453 val _ = trace_msg ctxt (fn () => "path_finder: " ^ Int.toString p ^ |
448 " " ^ Syntax.string_of_term ctxt tm_p) |
454 " " ^ Syntax.string_of_term ctxt tm_p) |
449 val (r,t) = path_finder_FO tm_p ps |
455 val (r,t) = path_finder_FO tm_p ps |
450 in |
456 in |
451 (r, list_comb (tm1, replace_item_list t p' args)) |
457 (r, list_comb (tm1, replace_item_list t p' args)) |
452 end |
458 end |
494 let val (tm, tm_rslt) = path_finder mode tm_a idx m_tm |
500 let val (tm, tm_rslt) = path_finder mode tm_a idx m_tm |
495 in (tm, nt $ tm_rslt) end |
501 in (tm, nt $ tm_rslt) end |
496 | path_finder_lit tm_a idx = path_finder mode tm_a idx m_tm |
502 | path_finder_lit tm_a idx = path_finder mode tm_a idx m_tm |
497 val (tm_subst, body) = path_finder_lit i_atm fp |
503 val (tm_subst, body) = path_finder_lit i_atm fp |
498 val tm_abs = Abs ("x", type_of tm_subst, body) |
504 val tm_abs = Abs ("x", type_of tm_subst, body) |
499 val _ = trace_msg (fn () => "abstraction: " ^ Syntax.string_of_term ctxt tm_abs) |
505 val _ = trace_msg ctxt (fn () => "abstraction: " ^ Syntax.string_of_term ctxt tm_abs) |
500 val _ = trace_msg (fn () => "i_tm: " ^ Syntax.string_of_term ctxt i_tm) |
506 val _ = trace_msg ctxt (fn () => "i_tm: " ^ Syntax.string_of_term ctxt i_tm) |
501 val _ = trace_msg (fn () => "located term: " ^ Syntax.string_of_term ctxt tm_subst) |
507 val _ = trace_msg ctxt (fn () => "located term: " ^ Syntax.string_of_term ctxt tm_subst) |
502 val imax = maxidx_of_term (i_tm $ tm_abs $ tm_subst) (*ill typed but gives right max*) |
508 val imax = maxidx_of_term (i_tm $ tm_abs $ tm_subst) (*ill typed but gives right max*) |
503 val subst' = Thm.incr_indexes (imax+1) (if pos then subst_em else ssubst_em) |
509 val subst' = Thm.incr_indexes (imax+1) (if pos then subst_em else ssubst_em) |
504 val _ = trace_msg (fn () => "subst' " ^ Display.string_of_thm ctxt subst') |
510 val _ = trace_msg ctxt (fn () => "subst' " ^ Display.string_of_thm ctxt subst') |
505 val eq_terms = map (pairself (cterm_of thy)) |
511 val eq_terms = map (pairself (cterm_of thy)) |
506 (ListPair.zip (OldTerm.term_vars (prop_of subst'), [tm_abs, tm_subst, i_tm])) |
512 (ListPair.zip (OldTerm.term_vars (prop_of subst'), [tm_abs, tm_subst, i_tm])) |
507 in cterm_instantiate eq_terms subst' end; |
513 in cterm_instantiate eq_terms subst' end; |
508 |
514 |
509 val factor = Seq.hd o distinct_subgoals_tac; |
515 val factor = Seq.hd o distinct_subgoals_tac; |
538 |
544 |
539 fun count p xs = fold (fn x => if p x then Integer.add 1 else I) xs 0 |
545 fun count p xs = fold (fn x => if p x then Integer.add 1 else I) xs 0 |
540 |
546 |
541 fun replay_one_inference ctxt mode old_skolems (fol_th, inf) thpairs = |
547 fun replay_one_inference ctxt mode old_skolems (fol_th, inf) thpairs = |
542 let |
548 let |
543 val _ = trace_msg (fn () => "=============================================") |
549 val _ = trace_msg ctxt (fn () => "=============================================") |
544 val _ = trace_msg (fn () => "METIS THM: " ^ Metis_Thm.toString fol_th) |
550 val _ = trace_msg ctxt (fn () => "METIS THM: " ^ Metis_Thm.toString fol_th) |
545 val _ = trace_msg (fn () => "INFERENCE: " ^ Metis_Proof.inferenceToString inf) |
551 val _ = trace_msg ctxt (fn () => "INFERENCE: " ^ Metis_Proof.inferenceToString inf) |
546 val th = step ctxt mode old_skolems thpairs (fol_th, inf) |
552 val th = step ctxt mode old_skolems thpairs (fol_th, inf) |
547 |> flexflex_first_order |
553 |> flexflex_first_order |
548 val _ = trace_msg (fn () => "ISABELLE THM: " ^ Display.string_of_thm ctxt th) |
554 val _ = trace_msg ctxt (fn () => "ISABELLE THM: " ^ Display.string_of_thm ctxt th) |
549 val _ = trace_msg (fn () => "=============================================") |
555 val _ = trace_msg ctxt (fn () => "=============================================") |
550 val num_metis_lits = |
556 val num_metis_lits = |
551 fol_th |> Metis_Thm.clause |> Metis_LiteralSet.toList |
557 fol_th |> Metis_Thm.clause |> Metis_LiteralSet.toList |
552 |> count is_metis_literal_genuine |
558 |> count is_metis_literal_genuine |
553 val num_isabelle_lits = |
559 val num_isabelle_lits = |
554 th |> prems_of |> count is_isabelle_literal_genuine |
560 th |> prems_of |> count is_isabelle_literal_genuine |
555 val _ = if num_metis_lits = num_isabelle_lits then () |
561 val _ = if num_metis_lits = num_isabelle_lits then () |
556 else error "Cannot replay Metis proof in Isabelle: Out of sync." |
562 else error "Cannot replay Metis proof in Isabelle: Out of sync." |
557 in (fol_th, th) :: thpairs end |
563 in (fol_th, th) :: thpairs end |
558 |
|
559 (* FIXME ### GET RID OF skolem WRAPPER by looking at substitution *) |
|
560 |
564 |
561 fun term_instantiate thy = cterm_instantiate o map (pairself (cterm_of thy)) |
565 fun term_instantiate thy = cterm_instantiate o map (pairself (cterm_of thy)) |
562 |
566 |
563 (* In principle, it should be sufficient to apply "assume_tac" to unify the |
567 (* In principle, it should be sufficient to apply "assume_tac" to unify the |
564 conclusion with one of the premises. However, in practice, this is unreliable |
568 conclusion with one of the premises. However, in practice, this is unreliable |