src/Tools/isac/Interpret/script.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38029 bd062a85ec67
child 38050 4c52ad406c20
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
    56     * pos'       (*position in ptree; ptree * pos' is the proofstate*)
    56     * pos'       (*position in ptree; ptree * pos' is the proofstate*)
    57     * pos' list; (*of ptree-nodes probably cut (by fst tac_)*)
    57     * pos' list; (*of ptree-nodes probably cut (by fst tac_)*)
    58 val e_step = (Empty_Tac_, EmptyMout, EmptyPtree, e_pos',[]:pos' list):step;
    58 val e_step = (Empty_Tac_, EmptyMout, EmptyPtree, e_pos',[]:pos' list):step;
    59 
    59 
    60 fun rule2thm' (Thm (id, thm)) = (id, string_of_thmI thm):thm'
    60 fun rule2thm' (Thm (id, thm)) = (id, string_of_thmI thm):thm'
    61   | rule2thm' r = raise error ("rule2thm': not defined for "^(rule2str r));
    61   | rule2thm' r = error ("rule2thm': not defined for "^(rule2str r));
    62 fun rule2rls' (Rls_ rls) = id_rls rls
    62 fun rule2rls' (Rls_ rls) = id_rls rls
    63   | rule2rls' r = raise error ("rule2rls': not defined for "^(rule2str r));
    63   | rule2rls' r = error ("rule2rls': not defined for "^(rule2str r));
    64 
    64 
    65 (*.makes a (rule,term) list to a Step (m, mout, pt', p', cid) for solve;
    65 (*.makes a (rule,term) list to a Step (m, mout, pt', p', cid) for solve;
    66    complicated with current t in rrlsstate.*)
    66    complicated with current t in rrlsstate.*)
    67 fun rts2steps steps ((pt,p),(f,f'',rss,rts),(thy',ro,er,pa)) [(r, (f', am))] =
    67 fun rts2steps steps ((pt,p),(f,f'',rss,rts),(thy',ro,er,pa)) [(r, (f', am))] =
    68     let val thy = assoc_thy thy'
    68     let val thy = assoc_thy thy'
   108 (*go at a location in a script and fetch the contents*)
   108 (*go at a location in a script and fetch the contents*)
   109 fun go [] t = t
   109 fun go [] t = t
   110   | go (D::p) (Abs(s,ty,t0)) = go (p:loc_) t0
   110   | go (D::p) (Abs(s,ty,t0)) = go (p:loc_) t0
   111   | go (L::p) (t1 $ t2) = go p t1
   111   | go (L::p) (t1 $ t2) = go p t1
   112   | go (R::p) (t1 $ t2) = go p t2
   112   | go (R::p) (t1 $ t2) = go p t2
   113   | go l _ = raise error ("go: no "^(loc_2str l));
   113   | go l _ = error ("go: no "^(loc_2str l));
   114 (*
   114 (*
   115 > val t = (term_of o the o (parse thy)) "a+b";
   115 > val t = (term_of o the o (parse thy)) "a+b";
   116 val it = Const (#,#) $ Free (#,#) $ Free ("b","RealDef.real") : term
   116 val it = Const (#,#) $ Free (#,#) $ Free ("b","RealDef.real") : term
   117 > val plus_a = go [L] t; 
   117 > val plus_a = go [L] t; 
   118 > val b = go [R] t; 
   118 > val b = go [R] t; 
   215 (*FIXME: get 1st stac by next_stac [] instead of ... ?? 29.7.02*)
   215 (*FIXME: get 1st stac by next_stac [] instead of ... ?? 29.7.02*)
   216 (* val Script sc = scr;
   216 (* val Script sc = scr;
   217    *)
   217    *)
   218 fun init_form thy (Script sc) env =
   218 fun init_form thy (Script sc) env =
   219   (case get_stac thy sc of
   219   (case get_stac thy sc of
   220      NONE => NONE (*raise error ("init_form: no 1st stac in "^
   220      NONE => NONE (*error ("init_form: no 1st stac in "^
   221 			  (Syntax.string_of_term (thy2ctxt thy) sc))*)
   221 			  (Syntax.string_of_term (thy2ctxt thy) sc))*)
   222    | SOME stac => SOME (subst_atomic env stac))
   222    | SOME stac => SOME (subst_atomic env stac))
   223   | init_form _ _ _ = raise error "init_form: no match";
   223   | init_form _ _ _ = error "init_form: no match";
   224 
   224 
   225 (* use"ME/script.sml";
   225 (* use"ME/script.sml";
   226    use"script.sml";
   226    use"script.sml";
   227    *)
   227    *)
   228 
   228 
   236   | itr_arg _ (Const ("Script.Calculate",_) $ _ $ v) = v
   236   | itr_arg _ (Const ("Script.Calculate",_) $ _ $ v) = v
   237   | itr_arg _ (Const ("Script.Check'_elementwise",_) $ consts $ _) = consts
   237   | itr_arg _ (Const ("Script.Check'_elementwise",_) $ consts $ _) = consts
   238   | itr_arg _ (Const ("Script.Or'_to'_List",_) $ _) = e_term
   238   | itr_arg _ (Const ("Script.Or'_to'_List",_) $ _) = e_term
   239   | itr_arg _ (Const ("Script.Tac",_) $ _) = e_term
   239   | itr_arg _ (Const ("Script.Tac",_) $ _) = e_term
   240   | itr_arg _ (Const ("Script.SubProblem",_) $ _ $ _) = e_term
   240   | itr_arg _ (Const ("Script.SubProblem",_) $ _ $ _) = e_term
   241   | itr_arg thy t = raise error 
   241   | itr_arg thy t = error 
   242     ("itr_arg not impl. for "^
   242     ("itr_arg not impl. for "^
   243      (Syntax.string_of_term (thy2ctxt (assoc_thy thy)) t));
   243      (Syntax.string_of_term (thy2ctxt (assoc_thy thy)) t));
   244 (* val t = (term_of o the o (parse thy))"Rewrite rroot_square_inv False e_";
   244 (* val t = (term_of o the o (parse thy))"Rewrite rroot_square_inv False e_";
   245 > itr_arg "Script.thy" t;
   245 > itr_arg "Script.thy" t;
   246 val it = Free ("e_","RealDef.real") : term 
   246 val it = Free ("e_","RealDef.real") : term 
   292 val dsc = "nam" : string*)
   292 val dsc = "nam" : string*)
   293 
   293 
   294 (*.from penv in itm_ make args for script depending on type of description.*)
   294 (*.from penv in itm_ make args for script depending on type of description.*)
   295 (*6.5.03 TODO: push penv into script -- and drop mk_arg here || drop penv
   295 (*6.5.03 TODO: push penv into script -- and drop mk_arg here || drop penv
   296   9.5.03 penv postponed: penv = env for script at the moment, (*mk_arg*)*)
   296   9.5.03 penv postponed: penv = env for script at the moment, (*mk_arg*)*)
   297 fun mk_arg thy d [] = raise error ("mk_arg: no data for "^
   297 fun mk_arg thy d [] = error ("mk_arg: no data for "^
   298 			       (Syntax.string_of_term (thy2ctxt thy) d))
   298 			       (Syntax.string_of_term (thy2ctxt thy) d))
   299   | mk_arg thy d [t] = 
   299   | mk_arg thy d [t] = 
   300     (case dsc_valT d of
   300     (case dsc_valT d of
   301 	 "una" => [t]
   301 	 "una" => [t]
   302        | "nam" => 
   302        | "nam" => 
   303 	 [case t of
   303 	 [case t of
   304 	      r as (Const ("op =",_) $ _ $ _) => r
   304 	      r as (Const ("op =",_) $ _ $ _) => r
   305 	    | _ => raise error 
   305 	    | _ => error 
   306 			     ("mk_arg: dsc-typ 'nam' applied to non-equality "^
   306 			     ("mk_arg: dsc-typ 'nam' applied to non-equality "^
   307 			      (Syntax.string_of_term (thy2ctxt thy) t))]
   307 			      (Syntax.string_of_term (thy2ctxt thy) t))]
   308        | s => raise error ("mk_arg: not impl. for "^s))
   308        | s => error ("mk_arg: not impl. for "^s))
   309     
   309     
   310   | mk_arg thy d (t::ts) = (mk_arg thy d [t]) @ (mk_arg thy d ts);
   310   | mk_arg thy d (t::ts) = (mk_arg thy d [t]) @ (mk_arg thy d ts);
   311 (* 
   311 (* 
   312  val d = d_in itm_;
   312  val d = d_in itm_;
   313  val [t] = ts_in itm_;
   313  val [t] = ts_in itm_;
   330 	val itms = filter (okv mvat) itms
   330 	val itms = filter (okv mvat) itms
   331 	fun test_dsc d (_,_,_,_,itm_) = (d = d_in itm_)
   331 	fun test_dsc d (_,_,_,_,itm_) = (d = d_in itm_)
   332 	fun itm2arg itms (_,(d,_)) =
   332 	fun itm2arg itms (_,(d,_)) =
   333 	    case find_first (test_dsc d) itms of
   333 	    case find_first (test_dsc d) itms of
   334 		NONE => 
   334 		NONE => 
   335 		raise error ("itms2args: '"^term2str d^"' not in itms")
   335 		error ("itms2args: '"^term2str d^"' not in itms")
   336 	      (*| SOME (_,_,_,_,itm_) => mk_arg thy (d_in itm_) (ts_in itm_);
   336 	      (*| SOME (_,_,_,_,itm_) => mk_arg thy (d_in itm_) (ts_in itm_);
   337                penv postponed; presently penv holds already env for script*)
   337                penv postponed; presently penv holds already env for script*)
   338 	      | SOME (_,_,_,_,itm_) => penvval_in itm_
   338 	      | SOME (_,_,_,_,itm_) => penvval_in itm_
   339 	fun sel_given_find (s,_) = (s = "#Given") orelse (s = "#Find")
   339 	fun sel_given_find (s,_) = (s = "#Given") orelse (s = "#Find")
   340 	val pats = (#ppc o get_met) mI
   340 	val pats = (#ppc o get_met) mI
   352 (*["BOOL (1+x=2)","REAL x"] --match_ags--> oris 
   352 (*["BOOL (1+x=2)","REAL x"] --match_ags--> oris 
   353   --oris2fmz_vals--> ["equality (1+x=2)","boundVariable x","solutions L"]*)
   353   --oris2fmz_vals--> ["equality (1+x=2)","boundVariable x","solutions L"]*)
   354 fun oris2fmz_vals oris =
   354 fun oris2fmz_vals oris =
   355     let fun ori2fmz_vals ((_,_,_,dsc,ts):ori) = 
   355     let fun ori2fmz_vals ((_,_,_,dsc,ts):ori) = 
   356 	    ((term2str o comp_dts') (dsc, ts), last_elem ts) 
   356 	    ((term2str o comp_dts') (dsc, ts), last_elem ts) 
   357 	    handle _ => raise error ("ori2fmz_env called with "^terms2str ts)
   357 	    handle _ => error ("ori2fmz_env called with "^terms2str ts)
   358     in (split_list o (map ori2fmz_vals)) oris end;
   358     in (split_list o (map ori2fmz_vals)) oris end;
   359 
   359 
   360 (*detour necessary, because generate1 delivers a string-result*)
   360 (*detour necessary, because generate1 delivers a string-result*)
   361 fun mout2term thy (Form' (FormKF (_,_,_,_,res))) = 
   361 fun mout2term thy (Form' (FormKF (_,_,_,_,res))) = 
   362   (term_of o the o (parse (assoc_thy thy))) res
   362   (term_of o the o (parse (assoc_thy thy))) res
   467         val f = subpbl (strip_thy dI) pI
   467         val f = subpbl (strip_thy dI) pI
   468     in (Subproblem (dI, pI),
   468     in (Subproblem (dI, pI),
   469 	Subproblem' ((dI, pI, mI), pors, hdl, fmz_, f))
   469 	Subproblem' ((dI, pI, mI), pors, hdl, fmz_, f))
   470     end
   470     end
   471 
   471 
   472   | stac2tac_ pt thy t = raise error 
   472   | stac2tac_ pt thy t = error 
   473   ("stac2tac_ TODO: no match for "^
   473   ("stac2tac_ TODO: no match for "^
   474    (Syntax.string_of_term (thy2ctxt thy) t));
   474    (Syntax.string_of_term (thy2ctxt thy) t));
   475 (*
   475 (*
   476 > val t = (term_of o the o (parse thy)) 
   476 > val t = (term_of o the o (parse thy)) 
   477  "Rewrite_Set_Inst [(bdv,v_::real)] isolate_bdv False (x=a+#1)";
   477  "Rewrite_Set_Inst [(bdv,v_::real)] isolate_bdv False (x=a+#1)";
   534     val pred = if pred <> Const ("Script.Assumptions",bool)
   534     val pred = if pred <> Const ("Script.Assumptions",bool)
   535 		 then pred 
   535 		 then pred 
   536 	       else (mk_and o (map fst)) (get_assumptions_ pt (p,Res))
   536 	       else (mk_and o (map fst)) (get_assumptions_ pt (p,Res))
   537   in (bdv, pred) end
   537   in (bdv, pred) end
   538   | rep_set thy _ _ set = 
   538   | rep_set thy _ _ set = 
   539     raise error ("check_elementwise: no set "^ (*from script*)
   539     error ("check_elementwise: no set "^ (*from script*)
   540 		 (Syntax.string_of_term (thy2ctxt thy) set));
   540 		 (Syntax.string_of_term (thy2ctxt thy) set));
   541 (*> val set = (term_of o the o (parse thy)) "{(x::real). Assumptions}";
   541 (*> val set = (term_of o the o (parse thy)) "{(x::real). Assumptions}";
   542 > val p = [];
   542 > val p = [];
   543 > val pt = union_asm pt p [("#0 <= sqrt x + sqrt (#5 + x)",[11]),
   543 > val pt = union_asm pt p [("#0 <= sqrt x + sqrt (#5 + x)",[11]),
   544                            ("#0 <= #9 + #4 * x",[22]),
   544                            ("#0 <= #9 + #4 * x",[22]),
   792   | tac_2tac (Check_Postcond' (pblID, _)) = 
   792   | tac_2tac (Check_Postcond' (pblID, _)) = 
   793 		  Check_Postcond pblID
   793 		  Check_Postcond pblID
   794   | tac_2tac Empty_Tac_ = Empty_Tac
   794   | tac_2tac Empty_Tac_ = Empty_Tac
   795 
   795 
   796   | tac_2tac m = 
   796   | tac_2tac m = 
   797   raise error ("tac_2tac: not impl. for "^(tac_2str m));
   797   error ("tac_2tac: not impl. for "^(tac_2str m));
   798 
   798 
   799 
   799 
   800 
   800 
   801 
   801 
   802 (** decompose tac_ to a rule and to (lhs,rhs)
   802 (** decompose tac_ to a rule and to (lhs,rhs)
   950   | rep_tac_ (Check_elementwise' (t,str,(t',asm)))  = (Erule, (e_term, t'))
   950   | rep_tac_ (Check_elementwise' (t,str,(t',asm)))  = (Erule, (e_term, t'))
   951   | rep_tac_ (Subproblem' (_,_,_,_,t'))  = (Erule, (e_term, t'))
   951   | rep_tac_ (Subproblem' (_,_,_,_,t'))  = (Erule, (e_term, t'))
   952   | rep_tac_ (Take' (t'))  = (Erule, (e_term, t'))
   952   | rep_tac_ (Take' (t'))  = (Erule, (e_term, t'))
   953   | rep_tac_ (Substitute' (subst,t,t'))  = (Erule, (t, t'))
   953   | rep_tac_ (Substitute' (subst,t,t'))  = (Erule, (t, t'))
   954   | rep_tac_ (Or_to_List' (t, t'))  = (Erule, (t, t'))
   954   | rep_tac_ (Or_to_List' (t, t'))  = (Erule, (t, t'))
   955   | rep_tac_ m = raise error ("rep_tac_: not impl.for "^
   955   | rep_tac_ m = error ("rep_tac_: not impl.for "^
   956 				 (tac_2str m));
   956 				 (tac_2str m));
   957 
   957 
   958 (*"N.3.6.03------
   958 (*"N.3.6.03------
   959 fun tac_2rule m = (fst o rep_tac_) m;
   959 fun tac_2rule m = (fst o rep_tac_) m;
   960 fun tac_2etac m = (snd o rep_tac_) m;
   960 fun tac_2etac m = (snd o rep_tac_) m;
  1116 	      (case assy (y, AssGen) ((E,(l@[L,L,R]),SOME a,v,S,b),ss) e1 of
  1116 	      (case assy (y, AssGen) ((E,(l@[L,L,R]),SOME a,v,S,b),ss) e1 of
  1117 	       NasNap (v, E) => 
  1117 	       NasNap (v, E) => 
  1118 	       assy (y, AssGen) ((E, (l@[L,R]), SOME a,v,S,b),ss) e2
  1118 	       assy (y, AssGen) ((E, (l@[L,R]), SOME a,v,S,b),ss) e2
  1119 	     | ay => ay)
  1119 	     | ay => ay)
  1120 	    | ay =>(ay))
  1120 	    | ay =>(ay))
  1121        | NasApp _ => raise error ("assy: FIXXXME ///must not return NasApp///")
  1121        | NasApp _ => error ("assy: FIXXXME ///must not return NasApp///")
  1122        | ay => (ay))
  1122        | ay => (ay))
  1123 
  1123 
  1124   | assy ya ((E,l,a,v,S,b),ss) (Const ("Script.Or",_) $e1 $ e2) =
  1124   | assy ya ((E,l,a,v,S,b),ss) (Const ("Script.Or",_) $e1 $ e2) =
  1125     (case assy ya ((E,(l@[L,R]),a,v,S,b),ss) e1 of
  1125     (case assy ya ((E,(l@[L,R]),a,v,S,b),ss) e1 of
  1126 	 NasNap (v, E) => 
  1126 	 NasNap (v, E) => 
  1152       (* val (_,STac stac) = subst_stacexpr E a v t;
  1152       (* val (_,STac stac) = subst_stacexpr E a v t;
  1153          *)
  1153          *)
  1154       | (a', STac stac) =>
  1154       | (a', STac stac) =>
  1155 	let (*val _=tracing("### assy, stac = "^term2str stac);*)
  1155 	let (*val _=tracing("### assy, stac = "^term2str stac);*)
  1156 	    val p' = case p_ of Frm => p | Res => lev_on p
  1156 	    val p' = case p_ of Frm => p | Res => lev_on p
  1157 			      | _ => raise error ("assy: call by "^
  1157 			      | _ => error ("assy: call by "^
  1158 						  (pos'2str (p,p_)));
  1158 						  (pos'2str (p,p_)));
  1159 	in case assod pt d m stac of
  1159 	in case assod pt d m stac of
  1160 	 Ass (m,v') =>
  1160 	 Ass (m,v') =>
  1161 	 let (*val _=tracing("### assy: Ass ("^tac_2str m^", "^
  1161 	 let (*val _=tracing("### assy: Ass ("^tac_2str m^", "^
  1162 			       term2str v'^")");*)
  1162 			       term2str v'^")");*)
  1305 
  1305 
  1306   | ass_up y ((E,l,a,v,S,b),ss) (Const ("Script.Or",_) $ _ ) = 
  1306   | ass_up y ((E,l,a,v,S,b),ss) (Const ("Script.Or",_) $ _ ) = 
  1307     astep_up y ((E, (drop_last l), a,v,S,b),ss)
  1307     astep_up y ((E, (drop_last l), a,v,S,b),ss)
  1308 
  1308 
  1309   | ass_up y iss t =
  1309   | ass_up y iss t =
  1310     raise error ("ass_up not impl for t= "^(term2str t))
  1310     error ("ass_up not impl for t= "^(term2str t))
  1311 (* 9.6.03
  1311 (* 9.6.03
  1312    val (ys as (_,_,Script sc,_), ss) = 
  1312    val (ys as (_,_,Script sc,_), ss) = 
  1313        ((thy',srls,scr,d), [(m,EmptyMout,pt,p,[])]:step list);
  1313        ((thy',srls,scr,d), [(m,EmptyMout,pt,p,[])]:step list);
  1314    astep_up ys ((E,l,a,v,S,b),ss);
  1314    astep_up ys ((E,l,a,v,S,b),ss);
  1315    val ((ys as (_,_,Script sc,_)), ((E,l,a,v,S,b),ss)) = 
  1315    val ((ys as (_,_,Script sc,_)), ((E,l,a,v,S,b),ss)) = 
  1446 	      (*drop the intermediate steps !*)
  1446 	      (*drop the intermediate steps !*)
  1447 	      in Steps (ScrState is, [(m, f'',pt'',p'',c'')]) end
  1447 	      in Steps (ScrState is, [(m, f'',pt'',p'',c'')]) end
  1448 	 else Steps (ScrState is, ss))
  1448 	 else Steps (ScrState is, ss))
  1449 	
  1449 	
  1450      | NasApp _ (*[((E,l,a,v,S,bb),(m',f',pt',p',c'))] => 
  1450      | NasApp _ (*[((E,l,a,v,S,bb),(m',f',pt',p',c'))] => 
  1451 	   raise error ("locate_gen: should not have got NasApp, ets =")*)
  1451 	   error ("locate_gen: should not have got NasApp, ets =")*)
  1452        => NotLocatable
  1452        => NotLocatable
  1453      | NasNap (_,_) =>
  1453      | NasNap (_,_) =>
  1454        if l=[] then NotLocatable
  1454        if l=[] then NotLocatable
  1455        else (*scan from begin of script for rew_only*)
  1455        else (*scan from begin of script for rew_only*)
  1456 	   (case assy ((ts,d),Aundef) ((E,[R],a,v,Unsafe,b),
  1456 	   (case assy ((ts,d),Aundef) ((E,[R],a,v,Unsafe,b),
  1466 		     else NotLocatable)
  1466 		     else NotLocatable)
  1467 	      | _ => ((*tracing ("#### locate_gen: after Fini");*)
  1467 	      | _ => ((*tracing ("#### locate_gen: after Fini");*)
  1468 		      NotLocatable))
  1468 		      NotLocatable))
  1469   end
  1469   end
  1470   | locate_gen _ m _ (sc,_) is = 
  1470   | locate_gen _ m _ (sc,_) is = 
  1471     raise error ("locate_gen: wrong arguments,\n tac= "^(tac_2str m)^
  1471     error ("locate_gen: wrong arguments,\n tac= "^(tac_2str m)^
  1472 		 ",\n scr= "^(scr2str sc)^",\n istate= "^(istate2str is));
  1472 		 ",\n scr= "^(scr2str sc)^",\n istate= "^(istate2str is));
  1473 
  1473 
  1474 
  1474 
  1475 
  1475 
  1476 (** find the next stactic in a script **)
  1476 (** find the next stactic in a script **)
  1798 	    Appy lr => Appy lr
  1798 	    Appy lr => Appy lr
  1799 	  | Napp E => nstep_up thy ptp scr E up Napp_ a v
  1799 	  | Napp E => nstep_up thy ptp scr E up Napp_ a v
  1800 	  | Skip (v,E) => nstep_up thy ptp scr E up Skip_ a v end
  1800 	  | Skip (v,E) => nstep_up thy ptp scr E up Skip_ a v end
  1801 
  1801 
  1802   | nxt_up (thy,_) ptp scr E l ay t a v =
  1802   | nxt_up (thy,_) ptp scr E l ay t a v =
  1803   raise error ("nxt_up not impl for "^
  1803   error ("nxt_up not impl for "^
  1804 	       (Syntax.string_of_term (thy2ctxt (assoc_thy thy)) t))
  1804 	       (Syntax.string_of_term (thy2ctxt (assoc_thy thy)) t))
  1805 
  1805 
  1806 (* val (thy, ptp, (Script sc), E, l, ay,    a, v)=
  1806 (* val (thy, ptp, (Script sc), E, l, ay,    a, v)=
  1807        (thy, ptp, scr,         E, l, Skip_, a, v);
  1807        (thy, ptp, scr,         E, l, Skip_, a, v);
  1808    val (thy, ptp, (Script sc), E, l, ay,    a, v)=
  1808    val (thy, ptp, (Script sc), E, l, ay,    a, v)=
  1869 	 | (_,p',rls') => (End_Detail' (e_term,[])(*8.6.03*), e_istate, (v,s)))
  1869 	 | (_,p',rls') => (End_Detail' (e_term,[])(*8.6.03*), e_istate, (v,s)))
  1870     | Napp _ => (Empty_Tac_, e_istate, (e_term, Sundef))         (*helpless*)
  1870     | Napp _ => (Empty_Tac_, e_istate, (e_term, Sundef))         (*helpless*)
  1871     | Appy (m', scrst as (_,_,_,v,_,_)) => (m', ScrState scrst,
  1871     | Appy (m', scrst as (_,_,_,v,_,_)) => (m', ScrState scrst,
  1872 			   (v, Sundef)))                         (*next stac*)
  1872 			   (v, Sundef)))                         (*next stac*)
  1873 
  1873 
  1874   | next_tac _ _ _ is = raise error ("next_tac: not impl for "^
  1874   | next_tac _ _ _ is = error ("next_tac: not impl for "^
  1875 				     (istate2str is));
  1875 				     (istate2str is));
  1876 
  1876 
  1877 
  1877 
  1878 
  1878 
  1879 
  1879 
  1886         val formals = formal_args sc
  1886         val formals = formal_args sc
  1887 	(*expects same sequence of (actual) args in itms 
  1887 	(*expects same sequence of (actual) args in itms 
  1888           and (formal) args in met*)
  1888           and (formal) args in met*)
  1889 	fun relate_args env [] [] = env
  1889 	fun relate_args env [] [] = env
  1890 	  | relate_args env _ [] = 
  1890 	  | relate_args env _ [] = 
  1891 	    raise error ("ERROR in creating the environment for '"
  1891 	    error ("ERROR in creating the environment for '"
  1892 			 ^id_of_scr sc^"' from \nthe items of the guard of "
  1892 			 ^id_of_scr sc^"' from \nthe items of the guard of "
  1893 			 ^metID2str metID^",\n\
  1893 			 ^metID2str metID^",\n\
  1894 			 \formal arg(s), from the script,\
  1894 			 \formal arg(s), from the script,\
  1895 			 \ miss actual arg(s), from the guards env:\n"
  1895 			 \ miss actual arg(s), from the guards env:\n"
  1896 			 ^(string_of_int o length) formals
  1896 			 ^(string_of_int o length) formals
  1899 			 ^" actuals: "^terms2str actuals)
  1899 			 ^" actuals: "^terms2str actuals)
  1900 	  | relate_args env [] actual_finds = env (*may drop Find!*)
  1900 	  | relate_args env [] actual_finds = env (*may drop Find!*)
  1901 	  | relate_args env (a::aa) (f::ff) = 
  1901 	  | relate_args env (a::aa) (f::ff) = 
  1902 	    if type_of a = type_of f 
  1902 	    if type_of a = type_of f 
  1903 	    then relate_args (env @ [(a, f)]) aa ff else 
  1903 	    then relate_args (env @ [(a, f)]) aa ff else 
  1904 	    raise error ("ERROR in creating the environment for '"
  1904 	    error ("ERROR in creating the environment for '"
  1905 			 ^id_of_scr sc^"' from \nthe items of the guard of "
  1905 			 ^id_of_scr sc^"' from \nthe items of the guard of "
  1906 			 ^metID2str metID^",\n\			 
  1906 			 ^metID2str metID^",\n\			 
  1907 			 \different types of formal arg, from the script,\
  1907 			 \different types of formal arg, from the script,\
  1908 			 \ and actual arg, from the guards env:'\n\
  1908 			 \ and actual arg, from the guards env:'\n\
  1909 			 \formal: '"^term2str a^"::"^(type2str o type_of) a^"'\n\
  1909 			 \formal: '"^term2str a^"::"^(type2str o type_of) a^"'\n\
  1921 (* val (thy', (p,p_), pt) = (thy', (p,p_), pt);
  1921 (* val (thy', (p,p_), pt) = (thy', (p,p_), pt);
  1922    *)
  1922    *)
  1923 fun from_pblobj_or_detail' thy' (p,p_) pt =
  1923 fun from_pblobj_or_detail' thy' (p,p_) pt =
  1924     if member op = [Pbl,Met] p_
  1924     if member op = [Pbl,Met] p_
  1925     then case get_obj g_env pt p of
  1925     then case get_obj g_env pt p of
  1926 	     NONE => raise error "from_pblobj_or_detail': no istate"
  1926 	     NONE => error "from_pblobj_or_detail': no istate"
  1927 	   | SOME is =>
  1927 	   | SOME is =>
  1928 	     let val metID = get_obj g_metID pt p
  1928 	     let val metID = get_obj g_metID pt p
  1929 		 val {srls,...} = get_met metID
  1929 		 val {srls,...} = get_met metID
  1930 	     in (srls, is, (#scr o get_met) metID) end
  1930 	     in (srls, is, (#scr o get_met) metID) end
  1931     else
  1931     else