src/Tools/isac/Interpret/rewtools.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38015 67ba02dffacc
child 38050 4c52ad406c20
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
   107     let datatype switch = Appl | Noap
   107     let datatype switch = Appl | Noap
   108 	fun rew_once lim rts t Noap [] = 
   108 	fun rew_once lim rts t Noap [] = 
   109 	    (case goal of 
   109 	    (case goal of 
   110 		 NONE => rts
   110 		 NONE => rts
   111 	       | SOME g => 
   111 	       | SOME g => 
   112 		 raise error ("make_deriv: no derivation for "^(term2str t)))
   112 		 error ("make_deriv: no derivation for "^(term2str t)))
   113 	  | rew_once lim rts t Appl [] = 
   113 	  | rew_once lim rts t Appl [] = 
   114 	    (*(case rs of Rls _ =>*) rew_once lim rts t Noap rs
   114 	    (*(case rs of Rls _ =>*) rew_once lim rts t Noap rs
   115 	  (*| Seq _ => rts) FIXXXXXME 14.3.03*)
   115 	  (*| Seq _ => rts) FIXXXXXME 14.3.03*)
   116 	  | rew_once lim rts t apno rs' =
   116 	  | rew_once lim rts t apno rs' =
   117 	    (case goal of 
   117 	    (case goal of 
   145 			    val _ = if not (!trace_rewrite) then () else
   145 			    val _ = if not (!trace_rewrite) then () else
   146 				    tracing("### calc. to: " ^ (term2str t'))
   146 				    tracing("### calc. to: " ^ (term2str t'))
   147 			    val r' = Thm (thmid, tm)
   147 			    val r' = Thm (thmid, tm)
   148 			in rew_once (lim-1) (rts@[(t,r',(t',a'))]) t' Appl rrs'
   148 			in rew_once (lim-1) (rts@[(t,r',(t',a'))]) t' Appl rrs'
   149 			end) 
   149 			end) 
   150 		       handle _ => raise error "derive_norm, Calc: no rewrite"
   150 		       handle _ => error "derive_norm, Calc: no rewrite"
   151 		end
   151 		end
   152 (* TODO.WN080222: see rewrite__set_
   152 (* TODO.WN080222: see rewrite__set_
   153    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   153    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   154       | Cal1 (cc as (op_,_)) => 
   154       | Cal1 (cc as (op_,_)) => 
   155 	  (let val _= if !trace_rewrite andalso i < ! depth then
   155 	  (let val _= if !trace_rewrite andalso i < ! depth then
   161 	       let 
   161 	       let 
   162 		 val pairopt = 
   162 		 val pairopt = 
   163 		   rewrite__ thy (i+1) bdv ((snd o #rew_ord o rep_rls) rls)
   163 		   rewrite__ thy (i+1) bdv ((snd o #rew_ord o rep_rls) rls)
   164 		   ((#erls o rep_rls) rls) put_asm thm' ct;
   164 		   ((#erls o rep_rls) rls) put_asm thm' ct;
   165 		 val _ = if pairopt <> NONE then () 
   165 		 val _ = if pairopt <> NONE then () 
   166 			 else raise error("rewrite_set_, rewrite_ \""^
   166 			 else error("rewrite_set_, rewrite_ \""^
   167 			 (string_of_thmI thm')^"\" "^(term2str ct)^" = NONE")
   167 			 (string_of_thmI thm')^"\" "^(term2str ct)^" = NONE")
   168 		 val _ = if ! trace_rewrite andalso i < ! depth 
   168 		 val _ = if ! trace_rewrite andalso i < ! depth 
   169 			   then tracing((idt"="(i+1))^" cal1. to: "^
   169 			   then tracing((idt"="(i+1))^" cal1. to: "^
   170 					(term2str ((fst o the) pairopt)))
   170 					(term2str ((fst o the) pairopt)))
   171 			 else()
   171 			 else()
   227     Rrls {id="sym_"^id, scr=scr, calc=calc, erls=erls, prepat=prepat, 
   227     Rrls {id="sym_"^id, scr=scr, calc=calc, erls=erls, prepat=prepat, 
   228 	  rew_ord=rew_ord};
   228 	  rew_ord=rew_ord};
   229 
   229 
   230 fun sym_Thm (Thm (thmID, thm)) = Thm (sym_thmID thmID, sym_thm thm)
   230 fun sym_Thm (Thm (thmID, thm)) = Thm (sym_thmID thmID, sym_thm thm)
   231   | sym_Thm (Rls_ rls) = Rls_ (*WN060825?!?*) (sym_rls rls)
   231   | sym_Thm (Rls_ rls) = Rls_ (*WN060825?!?*) (sym_rls rls)
   232   | sym_Thm r = raise error ("sym_Thm: not for "^(rule2str r));
   232   | sym_Thm r = error ("sym_Thm: not for "^(rule2str r));
   233 (*
   233 (*
   234   val th =  Thm ("real_one_collect",num_str @{thm real_one_collect});
   234   val th =  Thm ("real_one_collect",num_str @{thm real_one_collect});
   235   sym_Thm th;
   235   sym_Thm th;
   236 val th =
   236 val th =
   237   Thm ("real_one_collect","?m is_const ==> ?n + ?m * ?n = (1 + ?m) * ?n")
   237   Thm ("real_one_collect","?m is_const ==> ?n + ?m * ?n = (1 + ?m) * ?n")
   253 
   253 
   254 fun eq_Thm (Thm (id1,_), Thm (id2,_)) = id1 = id2
   254 fun eq_Thm (Thm (id1,_), Thm (id2,_)) = id1 = id2
   255   | eq_Thm (Thm (id1,_), _) = false
   255   | eq_Thm (Thm (id1,_), _) = false
   256   | eq_Thm (Rls_ r1, Rls_ r2) = id_rls r1 = id_rls r2
   256   | eq_Thm (Rls_ r1, Rls_ r2) = id_rls r1 = id_rls r2
   257   | eq_Thm (Rls_ r1, _) = false
   257   | eq_Thm (Rls_ r1, _) = false
   258   | eq_Thm (r1, r2) = raise error ("eq_Thm: called with '"^
   258   | eq_Thm (r1, r2) = error ("eq_Thm: called with '"^
   259 				(rule2str r1)^"' '"^(rule2str r2)^"'");
   259 				(rule2str r1)^"' '"^(rule2str r2)^"'");
   260 fun distinct_Thm r = gen_distinct eq_Thm r;
   260 fun distinct_Thm r = gen_distinct eq_Thm r;
   261 
   261 
   262 fun eq_Thms thmIDs thm = (member op = thmIDs (id_of_thm thm))
   262 fun eq_Thms thmIDs thm = (member op = thmIDs (id_of_thm thm))
   263     handle _ => false;
   263     handle _ => false;
   269 fun part2guh ([str]:theID) =
   269 fun part2guh ([str]:theID) =
   270     (case str of
   270     (case str of
   271 	"Isabelle" => "thy_isab_" ^ str ^ "-part" : guh
   271 	"Isabelle" => "thy_isab_" ^ str ^ "-part" : guh
   272       | "IsacScripts" => "thy_scri_" ^ str ^ "-part"
   272       | "IsacScripts" => "thy_scri_" ^ str ^ "-part"
   273       | "IsacKnowledge" => "thy_isac_" ^ str ^ "-part"
   273       | "IsacKnowledge" => "thy_isac_" ^ str ^ "-part"
   274       | str => raise error ("thy2guh: called with '"^str^"'"))
   274       | str => error ("thy2guh: called with '"^str^"'"))
   275   | part2guh theID = raise error ("part2guh called with theID = "
   275   | part2guh theID = error ("part2guh called with theID = "
   276 				  ^ theID2str theID);
   276 				  ^ theID2str theID);
   277 fun part2filename str = part2guh str ^ ".xml" : filename;
   277 fun part2filename str = part2guh str ^ ".xml" : filename;
   278 
   278 
   279 
   279 
   280 fun thy2guh ([part, thyID]:theID) =
   280 fun thy2guh ([part, thyID]:theID) =
   281     (case part of
   281     (case part of
   282 	"Isabelle" => "thy_isab_" ^ thyID : guh
   282 	"Isabelle" => "thy_isab_" ^ thyID : guh
   283       | "IsacScripts" => "thy_scri_" ^ thyID
   283       | "IsacScripts" => "thy_scri_" ^ thyID
   284       | "IsacKnowledge" => "thy_isac_" ^ thyID
   284       | "IsacKnowledge" => "thy_isac_" ^ thyID
   285       | str => raise error ("thy2guh: called with '"^str^"'"))
   285       | str => error ("thy2guh: called with '"^str^"'"))
   286   | thy2guh theID = raise error ("thy2guh called with '"^strs2str' theID^"'");
   286   | thy2guh theID = error ("thy2guh called with '"^strs2str' theID^"'");
   287 fun thy2filename thy' = thy2guh thy' ^ ".xml" : filename;
   287 fun thy2filename thy' = thy2guh thy' ^ ".xml" : filename;
   288 fun thypart2guh ([part, thyID, thypart]:theID) = 
   288 fun thypart2guh ([part, thyID, thypart]:theID) = 
   289     case part of
   289     case part of
   290 	"Isabelle" => "thy_isab_" ^ thyID ^ "-" ^ thypart : guh
   290 	"Isabelle" => "thy_isab_" ^ thyID ^ "-" ^ thypart : guh
   291       | "IsacScripts" => "thy_scri_" ^ thyID ^ "-" ^ thypart
   291       | "IsacScripts" => "thy_scri_" ^ thyID ^ "-" ^ thypart
   292       | "IsacKnowledge" => "thy_isac_" ^ thyID ^ "-" ^ thypart
   292       | "IsacKnowledge" => "thy_isac_" ^ thyID ^ "-" ^ thypart
   293       | str => raise error ("thypart2guh: called with '"^str^"'");
   293       | str => error ("thypart2guh: called with '"^str^"'");
   294 fun thypart2filename thy' = thypart2guh thy' ^ ".xml" : filename;
   294 fun thypart2filename thy' = thypart2guh thy' ^ ".xml" : filename;
   295 
   295 
   296 (*.convert the data got via contextToThy to a globally unique handle
   296 (*.convert the data got via contextToThy to a globally unique handle
   297    there is another way to get the guh out of the 'theID' in the hierarchy.*)
   297    there is another way to get the guh out of the 'theID' in the hierarchy.*)
   298 fun thm2guh (isa, thyID:thyID) (thmID:thmID) =
   298 fun thm2guh (isa, thyID:thyID) (thmID:thmID) =
   301 	"thy_isab_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID : guh
   301 	"thy_isab_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID : guh
   302     | "IsacKnowledge" =>
   302     | "IsacKnowledge" =>
   303 	"thy_isac_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
   303 	"thy_isac_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
   304     | "IsacScripts" =>
   304     | "IsacScripts" =>
   305 	"thy_scri_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
   305 	"thy_scri_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
   306     | str => raise error ("thm2guh called with isa = '"^isa^
   306     | str => error ("thm2guh called with isa = '"^isa^
   307 			  "' for thm = "^thmID^"'");
   307 			  "' for thm = "^thmID^"'");
   308 fun thm2filename (isa_thyID: string * thyID) thmID =
   308 fun thm2filename (isa_thyID: string * thyID) thmID =
   309     (thm2guh isa_thyID thmID) ^ ".xml" : filename;
   309     (thm2guh isa_thyID thmID) ^ ".xml" : filename;
   310 
   310 
   311 fun rls2guh (isa, thyID:thyID) (rls':rls') =
   311 fun rls2guh (isa, thyID:thyID) (rls':rls') =
   314 	    "thy_isab_" ^ theory'2thyID thyID ^ "-rls-" ^ rls' : guh
   314 	    "thy_isab_" ^ theory'2thyID thyID ^ "-rls-" ^ rls' : guh
   315     | "IsacKnowledge" =>
   315     | "IsacKnowledge" =>
   316 	    "thy_isac_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
   316 	    "thy_isac_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
   317     | "IsacScripts" =>
   317     | "IsacScripts" =>
   318 	    "thy_scri_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
   318 	    "thy_scri_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
   319     | str => raise error ("rls2guh called with isa = '"^isa^
   319     | str => error ("rls2guh called with isa = '"^isa^
   320 			  "' for rls = '"^rls'^"'");
   320 			  "' for rls = '"^rls'^"'");
   321 	fun rls2filename (isa, thyID) rls' =
   321 	fun rls2filename (isa, thyID) rls' =
   322     rls2guh (isa, thyID) rls' ^ ".xml" : filename;
   322     rls2guh (isa, thyID) rls' ^ ".xml" : filename;
   323 
   323 
   324 fun cal2guh (isa, thyID:thyID) calID =
   324 fun cal2guh (isa, thyID:thyID) calID =
   327 	"thy_isab_" ^ theory'2thyID thyID ^ "-cal-" ^ calID : guh
   327 	"thy_isab_" ^ theory'2thyID thyID ^ "-cal-" ^ calID : guh
   328       | "IsacKnowledge" =>
   328       | "IsacKnowledge" =>
   329 	"thy_isac_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
   329 	"thy_isac_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
   330       | "IsacScripts" =>
   330       | "IsacScripts" =>
   331 	"thy_scri_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
   331 	"thy_scri_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
   332       | str => raise error ("cal2guh called with isa = '"^isa^
   332       | str => error ("cal2guh called with isa = '"^isa^
   333 			  "' for cal = '"^calID^"'");
   333 			  "' for cal = '"^calID^"'");
   334 fun cal2filename (isa, thyID:thyID) calID = 
   334 fun cal2filename (isa, thyID:thyID) calID = 
   335     cal2guh (isa, thyID:thyID) calID ^ ".xml" : filename;
   335     cal2guh (isa, thyID:thyID) calID ^ ".xml" : filename;
   336 
   336 
   337 fun ord2guh (isa, thyID:thyID) (rew_ord':rew_ord') =
   337 fun ord2guh (isa, thyID:thyID) (rew_ord':rew_ord') =
   340 	"thy_isab_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord' : guh
   340 	"thy_isab_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord' : guh
   341       | "IsacKnowledge" =>
   341       | "IsacKnowledge" =>
   342 	"thy_isac_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
   342 	"thy_isac_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
   343       | "IsacScripts" =>
   343       | "IsacScripts" =>
   344 	"thy_scri_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
   344 	"thy_scri_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
   345       | str => raise error ("ord2guh called with isa = '"^isa^
   345       | str => error ("ord2guh called with isa = '"^isa^
   346 			  "' for ord = '"^rew_ord'^"'");
   346 			  "' for ord = '"^rew_ord'^"'");
   347 fun ord2filename (isa, thyID:thyID) (rew_ord':rew_ord') =
   347 fun ord2filename (isa, thyID:thyID) (rew_ord':rew_ord') =
   348     ord2guh (isa, thyID:thyID) (rew_ord':rew_ord') ^ ".xml" : filename;
   348     ord2guh (isa, thyID:thyID) (rew_ord':rew_ord') ^ ".xml" : filename;
   349 
   349 
   350 
   350 
   419     in case find_first (thy_contains_thm str) startsearch of
   419     in case find_first (thy_contains_thm str) startsearch of
   420 	   SOME (thy',_) => ("IsacKnowledge", thy')
   420 	   SOME (thy',_) => ("IsacKnowledge", thy')
   421 	 | NONE => (case assoc (!isab_thm_thy (*see Isac.ML*), str) of
   421 	 | NONE => (case assoc (!isab_thm_thy (*see Isac.ML*), str) of
   422 		     SOME (thyID,_) => ("Isabelle", thyID)
   422 		     SOME (thyID,_) => ("Isabelle", thyID)
   423 		   | NONE => 
   423 		   | NONE => 
   424 		     raise error ("thy_containing_thm: theorem '"^str^
   424 		     error ("thy_containing_thm: theorem '"^str^
   425 				  "' not in !theory' above thy '"^thy'^"'"))
   425 				  "' not in !theory' above thy '"^thy'^"'"))
   426     end;
   426     end;
   427 
   427 
   428 
   428 
   429 (*.which theory below thy' contains a ruleset;
   429 (*.which theory below thy' contains a ruleset;
   448 				      ((#1 o #2) : rls' * (theory' * rls) 
   448 				      ((#1 o #2) : rls' * (theory' * rls) 
   449 						   -> theory'))
   449 						   -> theory'))
   450 				     (rev (!ruleset'))
   450 				     (rev (!ruleset'))
   451     in case assoc (startsearch, rls') of
   451     in case assoc (startsearch, rls') of
   452 	   SOME (thy', _) => ("IsacKnowledge", thyID2theory' thy')
   452 	   SOME (thy', _) => ("IsacKnowledge", thyID2theory' thy')
   453 	 | _ => raise error ("thy_containing_rls : rls '"^rls'^
   453 	 | _ => error ("thy_containing_rls : rls '"^rls'^
   454 			     "' not in !rulset' above thy '"^thy'^"'")
   454 			     "' not in !rulset' above thy '"^thy'^"'")
   455     end;
   455     end;
   456 (* val (thy', termop) = (thyID, termop);
   456 (* val (thy', termop) = (thyID, termop);
   457    *)
   457    *)
   458 fun thy_containing_cal (thy':theory') termop =
   458 fun thy_containing_cal (thy':theory') termop =
   464 			    dropthys
   464 			    dropthys
   465 	val startsearch = filter_out ((curry ((op mem) o swap) dropthy's) o
   465 	val startsearch = filter_out ((curry ((op mem) o swap) dropthy's) o
   466 				      (#1 : calc -> string)) (rev (!calclist'))
   466 				      (#1 : calc -> string)) (rev (!calclist'))
   467     in case assoc (startsearch, strip_thy termop) of
   467     in case assoc (startsearch, strip_thy termop) of
   468 	   SOME (th_termop, _) => ("IsacKnowledge", strip_thy th_termop)
   468 	   SOME (th_termop, _) => ("IsacKnowledge", strip_thy th_termop)
   469 	 | _ => raise error ("thy_containing_rls : rls '"^termop^
   469 	 | _ => error ("thy_containing_rls : rls '"^termop^
   470 			     "' not in !calclist' above thy '"^thy'^"'")
   470 			     "' not in !calclist' above thy '"^thy'^"'")
   471     end
   471     end
   472 end;
   472 end;
   473 	
   473 	
   474 (* print_depth 99; map #1 startsearch; print_depth 3;
   474 (* print_depth 99; map #1 startsearch; print_depth 3;
   739 
   739 
   740 
   740 
   741 (*.not only for thydata, but also for thy's etc.*)
   741 (*.not only for thydata, but also for thy's etc.*)
   742 fun theID2guh (theID:theID) =
   742 fun theID2guh (theID:theID) =
   743     case length theID of
   743     case length theID of
   744 	0 => raise error ("theID2guh: called with theID = "^strs2str' theID)
   744 	0 => error ("theID2guh: called with theID = "^strs2str' theID)
   745       | 1 => part2guh theID
   745       | 1 => part2guh theID
   746       | 2 => thy2guh theID
   746       | 2 => thy2guh theID
   747       | 3 => thypart2guh theID
   747       | 3 => thypart2guh theID
   748       | 4 => let val [isa, thyID, typ, elemID] = theID
   748       | 4 => let val [isa, thyID, typ, elemID] = theID
   749 	     in case typ of
   749 	     in case typ of
   750 		    "Theorems" => thm2guh (isa, thyID) elemID
   750 		    "Theorems" => thm2guh (isa, thyID) elemID
   751 		  | "Rulesets" => rls2guh (isa, thyID) elemID
   751 		  | "Rulesets" => rls2guh (isa, thyID) elemID
   752 		  | "Calculations" => cal2guh (isa, thyID) elemID
   752 		  | "Calculations" => cal2guh (isa, thyID) elemID
   753 		  | "Orders" => ord2guh (isa, thyID) elemID
   753 		  | "Orders" => ord2guh (isa, thyID) elemID
   754 		  | "Theorems" => thy2guh [isa, thyID]
   754 		  | "Theorems" => thy2guh [isa, thyID]
   755 		  | str => raise error ("theID2guh: called with theID = "^
   755 		  | str => error ("theID2guh: called with theID = "^
   756 					strs2str' theID)
   756 					strs2str' theID)
   757 	     end
   757 	     end
   758       | n => raise error ("theID2guh called with theID = "^strs2str' theID);
   758       | n => error ("theID2guh called with theID = "^strs2str' theID);
   759 (*.filenames not only for thydata, but also for thy's etc.*)
   759 (*.filenames not only for thydata, but also for thy's etc.*)
   760 fun theID2filename (theID:theID) = theID2guh theID ^ ".xml" : filename;
   760 fun theID2filename (theID:theID) = theID2guh theID ^ ".xml" : filename;
   761 
   761 
   762 fun guh2theID (guh:guh) =
   762 fun guh2theID (guh:guh) =
   763     let val guh' = explode guh
   763     let val guh' = explode guh
   764 	val part = implode (take_fromto 1 4 guh')
   764 	val part = implode (take_fromto 1 4 guh')
   765 	val isa = implode (take_fromto 5 9 guh')
   765 	val isa = implode (take_fromto 5 9 guh')
   766     in if not (member op = ["exp_", "thy_", "pbl_", "met_"] part)
   766     in if not (member op = ["exp_", "thy_", "pbl_", "met_"] part)
   767        then raise error ("guh '"^guh^"' does not begin with \
   767        then error ("guh '"^guh^"' does not begin with \
   768 				     \exp_ | thy_ | pbl_ | met_")
   768 				     \exp_ | thy_ | pbl_ | met_")
   769        else let val chap = case isa of
   769        else let val chap = case isa of
   770 				"isab_" => "Isabelle"
   770 				"isab_" => "Isabelle"
   771 			      | "scri_" => "IsacScripts"
   771 			      | "scri_" => "IsacScripts"
   772 			      | "isac_" => "IsacKnowledge"
   772 			      | "isac_" => "IsacKnowledge"
   773 			      | _ => 
   773 			      | _ => 
   774 				raise error ("guh2theID: '"^guh^
   774 				error ("guh2theID: '"^guh^
   775 					     "' does not have isab_ | scri_ | \
   775 					     "' does not have isab_ | scri_ | \
   776 					     \isac_ at position 5..9")
   776 					     \isac_ at position 5..9")
   777 		val rest = takerest (9, guh') 
   777 		val rest = takerest (9, guh') 
   778 		val thyID = takewhile [] (not o (curry op= "-")) rest
   778 		val thyID = takewhile [] (not o (curry op= "-")) rest
   779 		val rest' = dropuntil (curry op= "-") rest
   779 		val rest' = dropuntil (curry op= "-") rest
   791 			       "-thm-" => "Theorems"
   791 			       "-thm-" => "Theorems"
   792 			     | "-rls-" => "Rulesets"
   792 			     | "-rls-" => "Rulesets"
   793 			     | "-cal-" => "Operations"
   793 			     | "-cal-" => "Operations"
   794 			     | "-ord-" => "Orders"
   794 			     | "-ord-" => "Orders"
   795 			     | str => 
   795 			     | str => 
   796 			       raise error ("guh2theID: '"^guh^"' has '"^sect^
   796 			       error ("guh2theID: '"^guh^"' has '"^sect^
   797 					    "' instead -thm- | -rls- | \
   797 					    "' instead -thm- | -rls- | \
   798 					    \-cal- | -ord-")
   798 					    \-cal- | -ord-")
   799 		   in [chap, implode thyID, sect', implode 
   799 		   in [chap, implode thyID, sect', implode 
   800 						       (takerest (5, rest'))]
   800 						       (takerest (5, rest'))]
   801 		   end
   801 		   end
   813 fun guh2rewtac (guh:guh) ([] : subs) =
   813 fun guh2rewtac (guh:guh) ([] : subs) =
   814     let val [isa, thy, sect, xstr] = guh2theID guh
   814     let val [isa, thy, sect, xstr] = guh2theID guh
   815     in case sect of
   815     in case sect of
   816 	   "Theorems" => Rewrite (xstr, "")
   816 	   "Theorems" => Rewrite (xstr, "")
   817 	 | "Rulesets" => Rewrite_Set xstr
   817 	 | "Rulesets" => Rewrite_Set xstr
   818 	 | str => raise error ("guh2rewtac: not impl. for '"^xstr^"'") 
   818 	 | str => error ("guh2rewtac: not impl. for '"^xstr^"'") 
   819     end
   819     end
   820   | guh2rewtac (guh:guh) subs =
   820   | guh2rewtac (guh:guh) subs =
   821     let val [isa, thy, sect, xstr] = guh2theID guh
   821     let val [isa, thy, sect, xstr] = guh2theID guh
   822     in case sect of
   822     in case sect of
   823 	   "Theorems" => Rewrite_Inst (subs, (xstr, ""))
   823 	   "Theorems" => Rewrite_Inst (subs, (xstr, ""))
   824 	 | "Rulesets" => Rewrite_Set_Inst (subs,  xstr)
   824 	 | "Rulesets" => Rewrite_Set_Inst (subs,  xstr)
   825 	 | str => raise error ("guh2rewtac: not impl. for '"^xstr^"'") 
   825 	 | str => error ("guh2rewtac: not impl. for '"^xstr^"'") 
   826     end;
   826     end;
   827 (*> guh2rewtac "thy_isac_Test-thm-constant_mult_square" [];
   827 (*> guh2rewtac "thy_isac_Test-thm-constant_mult_square" [];
   828 val it = Rewrite ("constant_mult_square", "") : tac
   828 val it = Rewrite ("constant_mult_square", "") : tac
   829 > guh2rewtac "thy_isac_Test-thm-risolate_bdv_add" ["(bdv, x)"];
   829 > guh2rewtac "thy_isac_Test-thm-risolate_bdv_add" ["(bdv, x)"];
   830 val it = Rewrite_Inst (["(bdv, x)"], ("risolate_bdv_add", "")) : tac
   830 val it = Rewrite_Inst (["(bdv, x)"], ("risolate_bdv_add", "")) : tac