src/FOL/IFOL_lemmas.ML
changeset 9887 318051e88faa
parent 9527 de95b5125580
child 14085 8dc3e532959a
equal deleted inserted replaced
9886:897d6602cbfb 9887:318051e88faa
   422 
   422 
   423 val major::prems = Goal "[| P|Q;  P==>R;  Q==>S |] ==> R|S";
   423 val major::prems = Goal "[| P|Q;  P==>R;  Q==>S |] ==> R|S";
   424 by (rtac (major RS disjE) 1);
   424 by (rtac (major RS disjE) 1);
   425 by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1));
   425 by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1));
   426 qed "disj_imp_disj";
   426 qed "disj_imp_disj";
   427 
       
   428 
       
   429 (** strip ALL and --> from proved goal while preserving ALL-bound var names **)
       
   430 
       
   431 fun make_new_spec rl =
       
   432   (* Use a crazy name to avoid forall_intr failing because of
       
   433      duplicate variable name *)
       
   434   let val myspec = read_instantiate [("P","?wlzickd")] rl
       
   435       val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec;
       
   436       val cvx = cterm_of (#sign(rep_thm myspec)) vx
       
   437   in (vxT, forall_intr cvx myspec) end;
       
   438 
       
   439 local
       
   440 
       
   441 val (specT,  spec')  = make_new_spec spec
       
   442 
       
   443 in
       
   444 
       
   445 fun RSspec th =
       
   446   (case concl_of th of
       
   447      _ $ (Const("All",_) $ Abs(a,_,_)) =>
       
   448          let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),specT))
       
   449          in th RS forall_elim ca spec' end
       
   450   | _ => raise THM("RSspec",0,[th]));
       
   451 
       
   452 fun RSmp th =
       
   453   (case concl_of th of
       
   454      _ $ (Const("op -->",_)$_$_) => th RS mp
       
   455   | _ => raise THM("RSmp",0,[th]));
       
   456 
       
   457 fun normalize_thm funs =
       
   458   let fun trans [] th = th
       
   459 	| trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th
       
   460   in trans funs end;
       
   461 
       
   462 fun qed_spec_mp name =
       
   463   let val thm = normalize_thm [RSspec,RSmp] (result())
       
   464   in bind_thm(name, thm) end;
       
   465 
       
   466 fun qed_goal_spec_mp name thy s p = 
       
   467       bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goal thy s p));
       
   468 
       
   469 fun qed_goalw_spec_mp name thy defs s p = 
       
   470       bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goalw thy defs s p));
       
   471 
       
   472 end;
       
   473 
       
   474 
       
   475 (* attributes *)
       
   476 
       
   477 local
       
   478 
       
   479 fun gen_rulify x = Attrib.no_args (Drule.rule_attribute (K (normalize_thm [RSspec, RSmp]))) x;
       
   480 
       
   481 in
       
   482 
       
   483 val attrib_setup =
       
   484  [Attrib.add_attributes
       
   485   [("rulify", (gen_rulify, gen_rulify), "put theorem into standard rule form")]];
       
   486 
       
   487 end;