src/Tools/isac/Interpret/inform.sml
changeset 59276 56dc790071cb
parent 59273 2ba35efb07b7
child 59279 255c853ea2f0
equal deleted inserted replaced
59275:2423f0fbdd08 59276:56dc790071cb
     6 
     6 
     7 signature INPUT_FORMULAS =
     7 signature INPUT_FORMULAS =
     8 sig
     8 sig
     9   datatype iitem = Find of cterm' list | Given of cterm' list | Relate of cterm' list
     9   datatype iitem = Find of cterm' list | Given of cterm' list | Relate of cterm' list
    10   type imodel = iitem list
    10   type imodel = iitem list
    11   type icalhd = pos' * cterm' * imodel * pos_ * spec
    11   type icalhd = Ctree.pos' * cterm' * imodel * Ctree.pos_ * spec
    12   val fetchErrorpatterns : tac -> errpatID list
    12   val fetchErrorpatterns : Ctree.tac -> errpatID list
    13   val input_icalhd : ptree -> icalhd -> ptree * ocalhd
    13   val input_icalhd : Ctree.ptree -> icalhd -> Ctree.ptree * Ctree.ocalhd
    14   val inform : Chead.calcstate' -> string -> string * Chead.calcstate'
    14   val inform : Chead.calcstate' -> string -> string * Chead.calcstate'
    15   val find_fillpatterns : ptree * pos' -> errpatID -> (fillpatID * term * thm * subs option) list
    15   val find_fillpatterns : Ctree.ptree * Ctree.pos' -> errpatID -> (fillpatID * term * thm * Ctree.subs option) list
    16   val is_exactly_equal : ptree * (pos * pos_) -> string -> string * tac
    16   val is_exactly_equal : Ctree.ptree * Ctree.pos' -> string -> string * Ctree.tac
    17 
    17 
    18 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    18 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    19   val dropwhile' : ('a -> 'b -> bool) -> 'a list -> 'b list -> 'a list * 'b list
    19   val dropwhile' : ('a -> 'b -> bool) -> 'a list -> 'b list -> 'a list * 'b list
    20   val cas_input : term -> (ptree * ocalhd) option
    20   val cas_input : term -> (Ctree.ptree * Ctree.ocalhd) option
    21   val rev_deriv' : 'a * rule * ('b * 'c) -> 'b * rule * ('a * 'c)
    21   val rev_deriv' : 'a * rule * ('b * 'c) -> 'b * rule * ('a * 'c)
    22   val compare_step : Generate.taci list * pos' list * (ptree * pos') -> term -> string * Chead.calcstate'
    22   val compare_step : Generate.taci list * Ctree.pos' list * (Ctree.ptree * Ctree.pos') -> term -> string * Chead.calcstate'
    23   val check_err_patt : term * term -> subst -> errpatID * term -> rls -> errpatID option
    23   val check_err_patt : term * term -> subst -> errpatID * term -> rls -> errpatID option
    24   val concat_deriv : 'a * ((term * term) list -> term * term -> bool) ->
    24   val concat_deriv : 'a * ((term * term) list -> term * term -> bool) ->
    25     rls -> rule list -> term -> term -> bool * (term * rule * (term * term list)) list
    25     rls -> rule list -> term -> term -> bool * (term * rule * (term * term list)) list
    26   val check_error_patterns :
    26   val check_error_patterns :
    27     term * term ->
    27     term * term ->
    48 
    48 
    49 type imodel = iitem list
    49 type imodel = iitem list
    50 
    50 
    51 (*calc-head as input*)
    51 (*calc-head as input*)
    52 type icalhd =
    52 type icalhd =
    53   pos' *     (*the position of the calc-head in the calc-tree*) 
    53   Ctree.pos' *     (*the position of the calc-head in the calc-tree*) 
    54   cterm' *   (*the headline*)
    54   cterm' *   (*the headline*)
    55   imodel *   (*the model (without Find) of the calc-head*)
    55   imodel *   (*the model (without Find) of the calc-head*)
    56   pos_ *     (*model belongs to Pbl or Met*)
    56   Ctree.pos_ *     (*model belongs to Pbl or Met*)
    57   spec;      (*specification: domID, pblID, metID*)
    57   spec;      (*specification: domID, pblID, metID*)
    58 val e_icalhd = (e_pos', "", [Given [""]], Pbl, e_spec) : icalhd
    58 val e_icalhd = (Ctree.e_pos', "", [Given [""]], Ctree.Pbl, e_spec) : icalhd
    59 
    59 
    60 fun is_casinput (hdf : cterm') ((fmz_, spec) : fmz) =
    60 fun is_casinput (hdf : cterm') ((fmz_, spec) : Ctree.fmz) =
    61   hdf <> "" andalso fmz_ = [] andalso spec = e_spec
    61   hdf <> "" andalso fmz_ = [] andalso spec = e_spec
    62 
    62 
    63 (*.handle an input as into an algebra system.*)
    63 (*.handle an input as into an algebra system.*)
    64 fun dtss2itm_ ppc (d, ts) =
    64 fun dtss2itm_ ppc (d, ts) =
    65   let
    65   let
    89 	  val {ppc, pre, prls, ...} = Specify.get_met mI
    89 	  val {ppc, pre, prls, ...} = Specify.get_met mI
    90 	  val its_ = map (dtss2itm_ ppc) dtss (*([1],true,"#Given",Cor (...))*)
    90 	  val its_ = map (dtss2itm_ ppc) dtss (*([1],true,"#Given",Cor (...))*)
    91 	  val its = Specify.add_id its_
    91 	  val its = Specify.add_id its_
    92 	  val mits = map flattup2 its
    92 	  val mits = map flattup2 its
    93 	  val pre = check_preconds thy prls pre mits
    93 	  val pre = check_preconds thy prls pre mits
    94     val ctxt = e_ctxt (*WN110515 cas_input_ DOESNT WORK*)
    94     val ctxt = Ctree.e_ctxt (*WN110515 cas_input_ DOESNT WORK*)
    95   in (pI, pits: itm list, mI, mits: itm list, pre, ctxt) end;
    95   in (pI, pits: itm list, mI, mits: itm list, pre, ctxt) end;
    96 
    96 
    97 
    97 
    98 (* check if the input term is a CAScmd and return a ptree with a _complete_ calchead *)
    98 (* check if the input term is a CAScmd and return a ptree with a _complete_ calchead *)
    99 fun cas_input hdt =
    99 fun cas_input hdt =
   106 	      let
   106 	      let
   107           val dtss = argl2dtss argl
   107           val dtss = argl2dtss argl
   108 	        val (pI, pits, mI, mits, pre, ctxt) = cas_input_ spec dtss
   108 	        val (pI, pits, mI, mits, pre, ctxt) = cas_input_ spec dtss
   109 	        val spec = (dI, pI, mI)
   109 	        val spec = (dI, pI, mI)
   110 	        val (pt,_) = 
   110 	        val (pt,_) = 
   111 		        cappend_problem e_ptree [] (e_istate, e_ctxt) ([], e_spec) ([], e_spec, hdt)
   111 		        Ctree.cappend_problem Ctree.e_ptree [] (Ctree.e_istate, Ctree.e_ctxt) ([], e_spec) ([], e_spec, hdt)
   112 	        val pt = update_spec pt [] spec
   112 	        val pt = Ctree.update_spec pt [] spec
   113 	        val pt = update_pbl pt [] pits
   113 	        val pt = Ctree.update_pbl pt [] pits
   114 	        val pt = update_met pt [] mits
   114 	        val pt = Ctree.update_met pt [] mits
   115 	        val pt = update_ctxt pt [] ctxt
   115 	        val pt = Ctree.update_ctxt pt [] ctxt
   116 	      in
   116 	      in
   117 	        SOME (pt, (true, Met, hdt, mits, pre, spec) : ocalhd)
   117 	        SOME (pt, (true, Ctree.Met, hdt, mits, pre, spec) : Ctree.ocalhd)
   118 	      end
   118 	      end
   119   end
   119   end
   120 
   120 
   121 (*lazy evaluation for (Thy_Info.get_theory "Isac")*)
   121 (*lazy evaluation for (Thy_Info.get_theory "Isac")*)
   122 fun Isac _  = assoc_thy "Isac";
   122 fun Isac _  = assoc_thy "Isac";
   260   in xxx [] iitems end;
   260   in xxx [] iitems end;
   261 
   261 
   262 (* input a calchead, WN110505 "prep_oris -> (_, ctxt)" not handled properly *)
   262 (* input a calchead, WN110505 "prep_oris -> (_, ctxt)" not handled properly *)
   263 fun input_icalhd pt (((p, _), hdf, imodel, Pbl, spec as (dI, pI, mI)) : icalhd) =
   263 fun input_icalhd pt (((p, _), hdf, imodel, Pbl, spec as (dI, pI, mI)) : icalhd) =
   264     let
   264     let
   265 		  val (fmz, fmz_, oris, ospec, hdf', sspec, sdI, spI, smI, probl, meth) = case get_obj I pt p of
   265 		  val (fmz, fmz_, oris, ospec, hdf', sspec, sdI, spI, smI, probl, meth) = case Ctree.get_obj I pt p of
   266 		    PblObj {fmz = fmz as (fmz_,_), origin = (oris, ospec, hdf'), 
   266 		    Ctree.PblObj {fmz = fmz as (fmz_,_), origin = (oris, ospec, hdf'), 
   267 		      spec = sspec as (sdI, spI, smI), probl, meth, ...}
   267 		      spec = sspec as (sdI, spI, smI), probl, meth, ...}
   268         => (fmz, fmz_, oris, ospec, hdf', sspec, sdI, spI, smI, probl, meth)
   268         => (fmz, fmz_, oris, ospec, hdf', sspec, sdI, spI, smI, probl, meth)
   269       | _ => error "input_icalhd: uncovered case of get_obj I pt p"
   269       | _ => error "input_icalhd: uncovered case of get_obj I pt p"
   270     in if is_casinput hdf fmz then the (cas_input (str2term hdf)) 
   270     in if is_casinput hdf fmz then the (cas_input (str2term hdf)) 
   271        else        (*hacked WN0602 ~~~            ~~~~~~~~~,   ..dropped !*)
   271        else        (*hacked WN0602 ~~~            ~~~~~~~~~,   ..dropped !*)
   287 				              (map itms2fstr probl), meth) end 
   287 				              (map itms2fstr probl), meth) end 
   288              else if mI <> smI (*FIXME.WN0311: what if probl is incomplete?!*)
   288              else if mI <> smI (*FIXME.WN0311: what if probl is incomplete?!*)
   289 	                then let val met = (#ppc o Specify.get_met) mI
   289 	                then let val met = (#ppc o Specify.get_met) mI
   290 		                     val mits = Chead.complete_metitms oris probl meth met
   290 		                     val mits = Chead.complete_metitms oris probl meth met
   291 		                   in if foldl and_ (true, map #3 mits)
   291 		                   in if foldl and_ (true, map #3 mits)
   292 		                      then (Pbl, probl, mits) else (Met, probl, mits) 
   292 		                      then (Pbl, probl, mits) else (Ctree.Met, probl, mits) 
   293 		                   end 
   293 		                   end 
   294                   else (Pbl, appl_adds (#1 (Chead.some_spec ospec spec)) oris [(*!!!*)]
   294                   else (Pbl, appl_adds (#1 (Chead.some_spec ospec spec)) oris [(*!!!*)]
   295 			                  ((#ppc o Specify.get_pbt) (#2 (Chead.some_spec ospec spec)))
   295 			                  ((#ppc o Specify.get_pbt) (#2 (Chead.some_spec ospec spec)))
   296 			                  (imodel2fstr imodel), meth)
   296 			                  (imodel2fstr imodel), meth)
   297 	         val pt = update_spec pt p spec;
   297 	         val pt = Ctree.update_spec pt p spec;
   298          in if pos_ = Pbl
   298          in if pos_ = Pbl
   299 	          then let val {prls,where_,...} = Specify.get_pbt (#2 (Chead.some_spec ospec spec))
   299 	          then let val {prls,where_,...} = Specify.get_pbt (#2 (Chead.some_spec ospec spec))
   300 		               val pre =check_preconds(assoc_thy"Isac")prls where_ pits
   300 		               val pre =check_preconds(assoc_thy"Isac")prls where_ pits
   301 	               in (update_pbl pt p pits,
   301 	               in (Ctree.update_pbl pt p pits,
   302 		                 (Chead.ocalhd_complete pits pre spec, Pbl, hdf', pits, pre, spec):ocalhd) 
   302 		                 (Chead.ocalhd_complete pits pre spec, Pbl, hdf', pits, pre, spec): Ctree.ocalhd) 
   303                  end
   303                  end
   304 	           else let val {prls,pre,...} = Specify.get_met (#3 (Chead.some_spec ospec spec))
   304 	           else let val {prls,pre,...} = Specify.get_met (#3 (Chead.some_spec ospec spec))
   305 		                val pre = check_preconds (assoc_thy"Isac") prls pre mits
   305 		                val pre = check_preconds (assoc_thy"Isac") prls pre mits
   306 	                in (update_met pt p mits,
   306 	                in (Ctree.update_met pt p mits,
   307 		                  (Chead.ocalhd_complete mits pre spec, Met, hdf', mits, pre, spec) : ocalhd)
   307 		                  (Chead.ocalhd_complete mits pre spec, Ctree.Met, hdf', mits, pre, spec) : Ctree.ocalhd)
   308                   end
   308                   end
   309          end 
   309          end 
   310     end
   310     end
   311   | input_icalhd _ (_, _, _, _(*Met*), _) = error "input_icalhd Met not impl."
   311   | input_icalhd _ (_, _, _, _(*Met*), _) = error "input_icalhd Met not impl."
   312 
   312 
   335 
   335 
   336 (* 040214: version for concat_deriv *)
   336 (* 040214: version for concat_deriv *)
   337 fun rev_deriv' (t, r, (t', a)) = (t', Rtools.sym_rule r, (t, a));
   337 fun rev_deriv' (t, r, (t', a)) = (t', Rtools.sym_rule r, (t, a));
   338 
   338 
   339 fun mk_tacis ro erls (t, r as Thm (id, thm), (t', a)) = 
   339 fun mk_tacis ro erls (t, r as Thm (id, thm), (t', a)) = 
   340       (Rewrite (id, thm), 
   340       (Ctree.Rewrite (id, thm), 
   341          Rewrite' ("Isac", fst ro, erls, false, Lucin.rule2thm'' r, t, (t', a)),
   341          Ctree.Rewrite' ("Isac", fst ro, erls, false, Lucin.rule2thm'' r, t, (t', a)),
   342        (e_pos'(*to be updated before generate tacis!!!*), (Uistate, e_ctxt)))
   342        (Ctree.e_pos'(*to be updated before generate tacis!!!*), (Ctree.Uistate, Ctree.e_ctxt)))
   343   | mk_tacis _ _ (t, r as Rls_ rls, (t', a)) = 
   343   | mk_tacis _ _ (t, r as Rls_ rls, (t', a)) = 
   344       (Rewrite_Set (Lucin.rule2rls' r), 
   344       (Ctree.Rewrite_Set (Lucin.rule2rls' r), 
   345          Rewrite_Set' ("Isac", false, rls, t, (t', a)),
   345          Ctree.Rewrite_Set' ("Isac", false, rls, t, (t', a)),
   346        (e_pos'(*to be updated before generate tacis!!!*), (Uistate, e_ctxt)))
   346        (Ctree.e_pos'(*to be updated before generate tacis!!!*), (Ctree.Uistate, Ctree.e_ctxt)))
   347   | mk_tacis _ _ (t, r, _) = error ("mk_tacis: not impl. for " ^ rule2str r ^ " at " ^ term2str t)
   347   | mk_tacis _ _ (t, r, _) = error ("mk_tacis: not impl. for " ^ rule2str r ^ " at " ^ term2str t)
   348 
   348 
   349 (* fo = ifo excluded already in inform *)
   349 (* fo = ifo excluded already in inform *)
   350 fun concat_deriv rew_ord erls rules fo ifo =
   350 fun concat_deriv rew_ord erls rules fo ifo =
   351   let 
   351   let 
   376             all_modspec etc. has to be inserted at Subproblem'*)
   376             all_modspec etc. has to be inserted at Subproblem'*)
   377 fun compare_step ((tacis, c, ptp as (pt, pos as (p,p_))): Chead.calcstate') ifo =
   377 fun compare_step ((tacis, c, ptp as (pt, pos as (p,p_))): Chead.calcstate') ifo =
   378   let
   378   let
   379     val fo =
   379     val fo =
   380       case p_ of
   380       case p_ of
   381         Frm => get_obj g_form pt p
   381         Frm => Ctree.get_obj Ctree.g_form pt p
   382 			| Res => (fst o (get_obj g_result pt)) p
   382 			| Res => (fst o (Ctree.get_obj Ctree.g_result pt)) p
   383 			| _ => e_term (*on PblObj is fo <> ifo*);
   383 			| _ => e_term (*on PblObj is fo <> ifo*);
   384 	  val {nrls, ...} = Specify.get_met (get_obj g_metID pt (par_pblobj pt p))
   384 	  val {nrls, ...} = Specify.get_met (Ctree.get_obj Ctree.g_metID pt (Ctree.par_pblobj pt p))
   385 	  val {rew_ord, erls, rules, ...} = rep_rls nrls
   385 	  val {rew_ord, erls, rules, ...} = rep_rls nrls
   386 	  val (found, der) = concat_deriv rew_ord erls rules fo ifo; (*<---------------*)
   386 	  val (found, der) = concat_deriv rew_ord erls rules fo ifo; (*<---------------*)
   387   in
   387   in
   388     if found
   388     if found
   389     then
   389     then
   390        let
   390        let
   391          val tacis' = map (mk_tacis rew_ord erls) der;
   391          val tacis' = map (mk_tacis rew_ord erls) der;
   392 		     val (c', ptp) = Generate.embed_deriv tacis' ptp;
   392 		     val (c', ptp) = Generate.embed_deriv tacis' ptp;
   393 	     in ("ok", (tacis (*@ tacis'?WN050408*), c @ c', ptp)) end
   393 	     in ("ok", (tacis (*@ tacis'?WN050408*), c @ c', ptp)) end
   394      else 
   394      else 
   395 	     if pos = ([], Res) (*TODO: we should stop earlier with trying subproblems *)
   395 	     if pos = ([], Ctree.Res) (*TODO: we should stop earlier with trying subproblems *)
   396 	     then ("no derivation found", (tacis, c, ptp): Chead.calcstate') 
   396 	     then ("no derivation found", (tacis, c, ptp): Chead.calcstate') 
   397 	     else
   397 	     else
   398          let
   398          let
   399            val cs' as (tacis, c', ptp) = Solve.nxt_solve_ ptp; (*<---------------------*)
   399            val cs' as (tacis, c', ptp) = Solve.nxt_solve_ ptp; (*<---------------------*)
   400 		       val (tacis, c'', ptp) = case tacis of
   400 		       val (tacis, c'', ptp) = case tacis of
   401 			       ((Subproblem _, _, _)::_) => 
   401 			       ((Ctree.Subproblem _, _, _)::_) => 
   402 			         let
   402 			         let
   403                  val ptp as (pt, (p,_)) = Chead.all_modspec ptp (*<--------------------*)
   403                  val ptp as (pt, (p,_)) = Chead.all_modspec ptp (*<--------------------*)
   404 				         val mI = get_obj g_metID pt p
   404 				         val mI = Ctree.get_obj Ctree.g_metID pt p
   405 			         in
   405 			         in
   406 			           Solve.nxt_solv (Apply_Method' (mI, NONE, e_istate, e_ctxt)) (e_istate, e_ctxt) ptp
   406 			           Solve.nxt_solv (Ctree.Apply_Method' (mI, NONE, Ctree.e_istate, Ctree.e_ctxt)) (Ctree.e_istate, Ctree.e_ctxt) ptp
   407                end
   407                end
   408 			     | _ => cs';
   408 			     | _ => cs';
   409 		     in compare_step (tacis, c @ c' @ c'', ptp) ifo end
   409 		     in compare_step (tacis, c @ c' @ c'', ptp) ifo end
   410   end
   410   end
   411 
   411 
   458 fun inform (cs as (_, _, (pt, pos as (p, _))): Chead.calcstate') istr =
   458 fun inform (cs as (_, _, (pt, pos as (p, _))): Chead.calcstate') istr =
   459   case parse (assoc_thy "Isac") istr of
   459   case parse (assoc_thy "Isac") istr of
   460 	  SOME f_in =>
   460 	  SOME f_in =>
   461 	    let
   461 	    let
   462 	      val f_in = Thm.term_of f_in
   462 	      val f_in = Thm.term_of f_in
   463 	      val f_succ = get_curr_formula (pt, pos);
   463 	      val f_succ = Ctree.get_curr_formula (pt, pos);
   464 			in
   464 			in
   465 			  if f_succ = f_in
   465 			  if f_succ = f_in
   466 			  then ("same-formula", cs) (* ctree not cut with replaceFormula *)
   466 			  then ("same-formula", cs) (* ctree not cut with replaceFormula *)
   467 			  else
   467 			  else
   468 			    case cas_input f_in of
   468 			    case cas_input f_in of
   469 			      SOME (pt, _) => ("ok",([], [], (pt, (p, Met))))
   469 			      SOME (pt, _) => ("ok",([], [], (pt, (p, Ctree.Met))))
   470 			    | NONE =>
   470 			    | NONE =>
   471 			        let
   471 			        let
   472 			          val pos_pred = lev_back' pos (*f_pred ---"step pos cs"---> f_succ in appendFormula*)
   472 			          val pos_pred = Ctree.lev_back' pos (*f_pred ---"step pos cs"---> f_succ in appendFormula*)
   473 			          val f_pred = get_curr_formula (pt, pos_pred)
   473 			          val f_pred = Ctree.get_curr_formula (pt, pos_pred)
   474 			          val msg_calcstate' = compare_step ([], [], (pt, pos_pred)) f_in (*<<=====*)
   474 			          val msg_calcstate' = compare_step ([], [], (pt, pos_pred)) f_in (*<<=====*)
   475 			          (*last step re-calc in compare_step TODO before WN09*)
   475 			          (*last step re-calc in compare_step TODO before WN09*)
   476 			        in
   476 			        in
   477 			          case msg_calcstate' of
   477 			          case msg_calcstate' of
   478 			            ("no derivation found", calcstate') => 
   478 			            ("no derivation found", calcstate') => 
   479 			               let
   479 			               let
   480 			                 val pp = par_pblobj pt p
   480 			                 val pp = Ctree.par_pblobj pt p
   481 			                 val (errpats, nrls, prog) = case Specify.get_met (get_obj g_metID pt pp) of
   481 			                 val (errpats, nrls, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
   482 			                   {errpats, nrls, scr = Prog prog, ...} => (errpats, nrls, prog)
   482 			                   {errpats, nrls, scr = Prog prog, ...} => (errpats, nrls, prog)
   483 			                 | _ => error "inform: uncovered case of get_met"
   483 			                 | _ => error "inform: uncovered case of get_met"
   484 			                 val env = case get_istate pt pos of
   484 			                 val env = case Ctree.get_istate pt pos of
   485 			                   ScrState (env, _, _, _, _, _) => env
   485 			                   Ctree.ScrState (env, _, _, _, _, _) => env
   486 			                 | _ => error "inform: uncovered case of get_istate"
   486 			                 | _ => error "inform: uncovered case of get_istate"
   487 			               in
   487 			               in
   488 			                 case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
   488 			                 case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
   489 			                   SOME errpatID => ("error pattern #" ^ errpatID ^ "#", calcstate')
   489 			                   SOME errpatID => ("error pattern #" ^ errpatID ^ "#", calcstate')
   490 			                 | NONE => msg_calcstate'
   490 			                 | NONE => msg_calcstate'
   515       Hthm {fillpats, ...} => fillpats
   515       Hthm {fillpats, ...} => fillpats
   516     | _ => error "get_fillpats: uncovered case of get_the"
   516     | _ => error "get_fillpats: uncovered case of get_the"
   517     val some = map (get_fillform subst (thm, form) errpatID) fillpats
   517     val some = map (get_fillform subst (thm, form) errpatID) fillpats
   518   in some |> filter is_some |> map the end
   518   in some |> filter is_some |> map the end
   519 
   519 
   520 fun find_fillpatterns (pt, pos as (p, _): pos') errpatID =
   520 fun find_fillpatterns (pt, pos as (p, _): Ctree.pos') errpatID =
   521   let 
   521   let 
   522     val f_curr = get_curr_formula (pt, pos);
   522     val f_curr = Ctree.get_curr_formula (pt, pos);
   523     val pp = par_pblobj pt p
   523     val pp = Ctree.par_pblobj pt p
   524     val (errpats, prog) = case Specify.get_met (get_obj g_metID pt pp) of
   524     val (errpats, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
   525       {errpats, scr = Prog prog, ...} => (errpats, prog)
   525       {errpats, scr = Prog prog, ...} => (errpats, prog)
   526     | _ => error "find_fillpatterns: uncovered case of get_met"
   526     | _ => error "find_fillpatterns: uncovered case of get_met"
   527     val env = case get_istate pt pos of
   527     val env = case Ctree.get_istate pt pos of
   528 		  ScrState (env, _, _, _, _, _) => env
   528 		  Ctree.ScrState (env, _, _, _, _, _) => env
   529 		| _ => error "inform: uncovered case of get_istate"
   529 		| _ => error "inform: uncovered case of get_istate"
   530     val subst = Rtools.get_bdv_subst prog env
   530     val subst = Rtools.get_bdv_subst prog env
   531     val errpatthms = errpats
   531     val errpatthms = errpats
   532       |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
   532       |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
   533       |> map (#3: errpat -> thm list)
   533       |> map (#3: errpat -> thm list)
   536 
   536 
   537 (* check if an input formula is exactly equal the rewrite from a rule
   537 (* check if an input formula is exactly equal the rewrite from a rule
   538    which is stored at the pos where the input is stored of "ok". *)
   538    which is stored at the pos where the input is stored of "ok". *)
   539 fun is_exactly_equal (pt, pos as (p, _)) istr =
   539 fun is_exactly_equal (pt, pos as (p, _)) istr =
   540   case parseNEW (assoc_thy "Isac" |> thy2ctxt) istr of
   540   case parseNEW (assoc_thy "Isac" |> thy2ctxt) istr of
   541     NONE => ("syntax error in '" ^ istr ^ "'", Tac "")
   541     NONE => ("syntax error in '" ^ istr ^ "'", Ctree.Tac "")
   542   | SOME ifo => 
   542   | SOME ifo => 
   543       let
   543       let
   544         val p' = lev_on p;
   544         val p' = Ctree.lev_on p;
   545         val tac = get_obj g_tac pt p';
   545         val tac = Ctree.get_obj Ctree.g_tac pt p';
   546       in 
   546       in 
   547         case Applicable.applicable_in pos pt tac of
   547         case Applicable.applicable_in pos pt tac of
   548           Chead.Notappl msg => (msg, Tac "")
   548           Chead.Notappl msg => (msg, Ctree.Tac "")
   549         | Chead.Appl rew =>
   549         | Chead.Appl rew =>
   550             let
   550             let
   551               val res = case rew of
   551               val res = case rew of
   552                 Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) => res
   552                 Ctree.Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) => res
   553               | Rewrite' (_, _, _, _, _, _, (res, _)) => res
   553               | Ctree.Rewrite' (_, _, _, _, _, _, (res, _)) => res
   554               | t => error ("is_exactly_equal: uncovered case for " ^ tac_2str t)
   554               | t => error ("is_exactly_equal: uncovered case for " ^ Ctree.tac_2str t)
   555             in 
   555             in 
   556               if not (ifo = res)
   556               if not (ifo = res)
   557               then ("input does not exactly fill the gaps", Tac "")
   557               then ("input does not exactly fill the gaps", Ctree.Tac "")
   558               else ("ok", tac)
   558               else ("ok", tac)
   559             end
   559             end
   560       end
   560       end
   561 
   561 
   562 (* fetch errpatIDs from an arbitrary tactic *)
   562 (* fetch errpatIDs from an arbitrary tactic *)
   563 fun fetchErrorpatterns tac =
   563 fun fetchErrorpatterns tac =
   564   let
   564   let
   565     val rlsID =
   565     val rlsID =
   566       case tac of
   566       case tac of
   567         Rewrite_Set rlsID => rlsID
   567         Ctree.Rewrite_Set rlsID => rlsID
   568       | Rewrite_Set_Inst (_, rlsID) => rlsID
   568       | Ctree.Rewrite_Set_Inst (_, rlsID) => rlsID
   569       | _ => "e_rls"
   569       | _ => "e_rls"
   570     val (part, thyID) = Rtools.thy_containing_rls "Isac" rlsID;
   570     val (part, thyID) = Rtools.thy_containing_rls "Isac" rlsID;
   571     val rls = case Specify.get_the [part, thyID, "Rulesets", rlsID] of
   571     val rls = case Specify.get_the [part, thyID, "Rulesets", rlsID] of
   572       Hrls {thy_rls = (_, rls), ...} => rls
   572       Hrls {thy_rls = (_, rls), ...} => rls
   573     | _ => error "fetchErrorpatterns: uncovered case of get_the"
   573     | _ => error "fetchErrorpatterns: uncovered case of get_the"