499 fun smp_tac j = EVERY'[dresolve_tac (smp j), atac] |
499 fun smp_tac j = EVERY'[dresolve_tac (smp j), atac] |
500 end; |
500 end; |
501 |
501 |
502 |
502 |
503 fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); |
503 fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); |
504 |
|
505 (** strip ALL and --> from proved goal while preserving ALL-bound var names **) |
|
506 |
|
507 (** THIS CODE IS A MESS!!! **) |
|
508 |
|
509 local |
|
510 |
|
511 (* Use XXX to avoid forall_intr failing because of duplicate variable name *) |
|
512 val myspec = read_instantiate [("P","?XXX")] spec; |
|
513 val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec; |
|
514 val cvx = cterm_of (#sign(rep_thm myspec)) vx; |
|
515 val aspec = forall_intr cvx myspec; |
|
516 |
|
517 in |
|
518 |
|
519 fun RSspec th = |
|
520 (case concl_of th of |
|
521 _ $ (Const("All",_) $ Abs(a,_,_)) => |
|
522 let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),vxT)) |
|
523 in th RS forall_elim ca aspec end |
|
524 | _ => raise THM("RSspec",0,[th])); |
|
525 |
|
526 fun RSmp th = |
|
527 (case concl_of th of |
|
528 _ $ (Const("op -->",_)$_$_) => th RS mp |
|
529 | _ => raise THM("RSmp",0,[th])); |
|
530 |
|
531 fun normalize_thm funs = |
|
532 let fun trans [] th = th |
|
533 | trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th |
|
534 in zero_var_indexes o strip_shyps_warning o trans funs end; |
|
535 |
|
536 fun qed_spec_mp name = |
|
537 let val thm = normalize_thm [RSspec,RSmp] (result()) |
|
538 in ThmDatabase.ml_store_thm(name, thm) end; |
|
539 |
|
540 fun qed_goal_spec_mp name thy s p = |
|
541 bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goal thy s p)); |
|
542 |
|
543 fun qed_goalw_spec_mp name thy defs s p = |
|
544 bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goalw thy defs s p)); |
|
545 |
|
546 end; |
|
547 |
|
548 |
|
549 (* attributes *) |
|
550 |
|
551 local |
|
552 |
|
553 fun gen_rulify x = |
|
554 Attrib.no_args (Drule.rule_attribute (fn _ => (normalize_thm [RSspec, RSmp]))) x; |
|
555 |
|
556 in |
|
557 |
|
558 val attrib_setup = |
|
559 [Attrib.add_attributes |
|
560 [("rulify", (gen_rulify, gen_rulify), "put theorem into standard rule form")]]; |
|
561 |
|
562 end; |
|