244 |
244 |
245 fun computer_of (PComputer (_,computer,_,_)) = computer |
245 fun computer_of (PComputer (_,computer,_,_)) = computer |
246 |
246 |
247 fun collect_consts_of_thm th = |
247 fun collect_consts_of_thm th = |
248 let |
248 let |
249 val th = prop_of th |
249 val th = Thm.prop_of th |
250 val (prems, th) = (Logic.strip_imp_prems th, Logic.strip_imp_concl th) |
250 val (prems, th) = (Logic.strip_imp_prems th, Logic.strip_imp_concl th) |
251 val (left, right) = Logic.dest_equals th |
251 val (left, right) = Logic.dest_equals th |
252 in |
252 in |
253 (Linker.collect_consts [left], Linker.collect_consts (right::prems)) |
253 (Linker.collect_consts [left], Linker.collect_consts (right::prems)) |
254 end |
254 end |
313 in |
313 in |
314 Compute.update_with_cache computer pats ths |
314 Compute.update_with_cache computer pats ths |
315 end |
315 end |
316 |
316 |
317 fun conv_subst thy (subst : Type.tyenv) = |
317 fun conv_subst thy (subst : Type.tyenv) = |
318 map (fn (iname, (sort, ty)) => (ctyp_of thy (TVar (iname, sort)), ctyp_of thy ty)) (Vartab.dest subst) |
318 map (fn (iname, (sort, ty)) => (Thm.ctyp_of thy (TVar (iname, sort)), Thm.ctyp_of thy ty)) |
|
319 (Vartab.dest subst) |
319 |
320 |
320 fun add_monos thy monocs pats ths = |
321 fun add_monos thy monocs pats ths = |
321 let |
322 let |
322 val changed = Unsynchronized.ref false |
323 val changed = Unsynchronized.ref false |
323 fun add monocs (th as (MonoThm _)) = ([], th) |
324 fun add monocs (th as (MonoThm _)) = ([], th) |
431 |
432 |
432 fun add_instances' pc ts = add_instances pc (Linker.collect_consts ts) |
433 fun add_instances' pc ts = add_instances pc (Linker.collect_consts ts) |
433 |
434 |
434 fun rewrite pc cts = |
435 fun rewrite pc cts = |
435 let |
436 let |
436 val _ = add_instances' pc (map term_of cts) |
437 val _ = add_instances' pc (map Thm.term_of cts) |
437 val computer = (computer_of pc) |
438 val computer = (computer_of pc) |
438 in |
439 in |
439 map (fn ct => Compute.rewrite computer ct) cts |
440 map (fn ct => Compute.rewrite computer ct) cts |
440 end |
441 end |
441 |
442 |
442 fun simplify pc th = Compute.simplify (computer_of pc) th |
443 fun simplify pc th = Compute.simplify (computer_of pc) th |
443 |
444 |
444 fun make_theorem pc th vars = |
445 fun make_theorem pc th vars = |
445 let |
446 let |
446 val _ = add_instances' pc [prop_of th] |
447 val _ = add_instances' pc [Thm.prop_of th] |
447 |
448 |
448 in |
449 in |
449 Compute.make_theorem (computer_of pc) th vars |
450 Compute.make_theorem (computer_of pc) th vars |
450 end |
451 end |
451 |
452 |
452 fun instantiate pc insts th = |
453 fun instantiate pc insts th = |
453 let |
454 let |
454 val _ = add_instances' pc (map (term_of o snd) insts) |
455 val _ = add_instances' pc (map (Thm.term_of o snd) insts) |
455 in |
456 in |
456 Compute.instantiate (computer_of pc) insts th |
457 Compute.instantiate (computer_of pc) insts th |
457 end |
458 end |
458 |
459 |
459 fun evaluate_prem pc prem_no th = Compute.evaluate_prem (computer_of pc) prem_no th |
460 fun evaluate_prem pc prem_no th = Compute.evaluate_prem (computer_of pc) prem_no th |
460 |
461 |
461 fun modus_ponens pc prem_no th' th = |
462 fun modus_ponens pc prem_no th' th = |
462 let |
463 let |
463 val _ = add_instances' pc [prop_of th'] |
464 val _ = add_instances' pc [Thm.prop_of th'] |
464 in |
465 in |
465 Compute.modus_ponens (computer_of pc) prem_no th' th |
466 Compute.modus_ponens (computer_of pc) prem_no th' th |
466 end |
467 end |
467 |
468 |
468 |
469 |