src/Tools/isac/Interpret/script.sml
changeset 59554 23bb6e7026c7
parent 59550 2e7631381921
child 59556 bbc27b8c8ee7
equal deleted inserted replaced
59553:c917b7d6e9e2 59554:23bb6e7026c7
     7 sig
     7 sig
     8 
     8 
     9   type step = Tac.tac_ * Generate.mout * Ctree.ctree * Ctree.pos' * Ctree.pos' list
     9   type step = Tac.tac_ * Generate.mout * Ctree.ctree * Ctree.pos' * Ctree.pos' list
    10   datatype locate = NotLocatable | Steps of Selem.istate * step list
    10   datatype locate = NotLocatable | Steps of Selem.istate * step list
    11   
    11   
    12   val next_tac : (*diss: next-tactic-function*)
       
    13     Rule.theory' * Rule.rls -> Ctree.state -> Rule.scr -> Selem.istate * 'a -> Tac.tac_ * (Selem.istate * 'a) * (term * Selem.safe)
       
    14   val locate_gen : (*diss: locate-function*)
    12   val locate_gen : (*diss: locate-function*)
    15     Rule.theory' * Rule.rls -> Tac.tac_ -> Ctree.state -> Rule.scr * 'a -> Selem.istate * Proof.context -> locate
    13     Rule.theory' * Rule.rls -> Tac.tac_ -> Ctree.state -> Rule.scr * 'a -> Selem.istate * Proof.context -> locate
    16                          
    14                          
    17 (* can these functions be local to Lucin or part of LItools ? *)
    15 (* can these functions be local to Lucin or part of LItools ? *)
    18   val sel_rules : Ctree.ctree -> Ctree.pos' -> Tac.tac list 
    16   val sel_rules : Ctree.ctree -> Ctree.pos' -> Tac.tac list 
    23   val from_pblobj_or_detail' : Rule.theory' -> Ctree.pos' -> Ctree.ctree -> 
    21   val from_pblobj_or_detail' : Rule.theory' -> Ctree.pos' -> Ctree.ctree -> 
    24     Rule.rls * (Selem.istate * Proof.context) * Rule.scr
    22     Rule.rls * (Selem.istate * Proof.context) * Rule.scr
    25   val rule2thm'' : Rule.rule -> Celem.thm''
    23   val rule2thm'' : Rule.rule -> Celem.thm''
    26   val rule2rls' : Rule.rule -> string
    24   val rule2rls' : Rule.rule -> string
    27   val sel_appl_atomic_tacs : Ctree.ctree -> Ctree.pos' -> Tac.tac list
    25   val sel_appl_atomic_tacs : Ctree.ctree -> Ctree.pos' -> Tac.tac list
       
    26 (*cp here from "! aktivate for Test_Isac" below due to LucinNEW*)
       
    27   val upd_env_opt : LTool.env -> term option * term -> LTool.env
       
    28   val stac2tac_ : Ctree.ctree -> theory -> term -> Tac.tac * Tac.tac_
       
    29   val tac_2res : Tac.tac_ -> term
       
    30 
       
    31 
       
    32 
    28 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
    33 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
    29   (* NONE *)
    34   (* NONE *)
    30 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    35 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    31   datatype asap = Aundef | AssOnly | AssGen
    36   datatype asap = Aundef | AssOnly | AssGen
    32   datatype appy = Appy of Tac.tac_ * Selem.scrstate | Napp of LTool.env | Skip of term * LTool.env
    37   datatype appy = Appy of Tac.tac_ * Selem.scrstate | Napp of LTool.env | Skip of term * LTool.env
    44   val assod: Ctree.ctree -> 'a -> Tac.tac_ -> term -> ass
    49   val assod: Ctree.ctree -> 'a -> Tac.tac_ -> term -> ass
    45   val get_stac : 'a -> term -> term option 
    50   val get_stac : 'a -> term -> term option 
    46   val go : Celem.loc_ -> term -> term
    51   val go : Celem.loc_ -> term -> term
    47   val handle_leaf : string -> Rule.theory' -> Rule.rls -> LTool.env -> term option -> term -> term -> 
    52   val handle_leaf : string -> Rule.theory' -> Rule.rls -> LTool.env -> term option -> term -> term -> 
    48     term option * LTool.stacexpr
    53     term option * LTool.stacexpr
    49    val is_spec_pos : Ctree.pos_ -> bool
    54   val is_spec_pos : Ctree.pos_ -> bool
    50   val itms2args : 'a -> Celem.metID -> Model.itm list -> term list
    55   val itms2args : 'a -> Celem.metID -> Model.itm list -> term list
    51   val nstep_up : Rule.theory' * Rule.rls -> Ctree.state -> Rule.scr -> LTool.env ->
    56   val nstep_up : Rule.theory' * Rule.rls -> Ctree.state -> Rule.scr -> LTool.env ->
    52     Celem.lrd list -> appy_ -> term option -> term -> appy
    57     Celem.lrd list -> appy_ -> term option -> term -> appy
    53   val nxt_up: Rule.theory' * Rule.rls -> Ctree.state -> Rule.scr -> LTool.env ->
    58   val nxt_up: Rule.theory' * Rule.rls -> Ctree.state -> Rule.scr -> LTool.env ->
    54     Celem.lrd list -> appy_ -> term -> term option -> term -> appy
    59     Celem.lrd list -> appy_ -> term -> term option -> term -> appy
    55   val stac2tac : Ctree.ctree -> theory -> term -> Tac.tac
    60   val stac2tac : Ctree.ctree -> theory -> term -> Tac.tac
    56   val stac2tac_ : Ctree.ctree -> theory -> term -> Tac.tac * Tac.tac_
       
    57   val tac_2res : Tac.tac_ -> term
       
    58   val upd_env_opt : LTool.env -> term option * term -> LTool.env
       
    59 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
    61 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
    60 
    62 
    61 end 
    63 end 
    62 
    64 
    63 (* traces the leaves (ie. non-tactical nodes) of Prog found by next_tac, see "and scr" *)   
    65 (* traces the leaves (ie. non-tactical nodes) of Prog found by next_tac, see "and scr" *)   
   123   let
   125   let
   124     fun scan [] = []
   126     fun scan [] = []
   125     | scan (s :: ss) = if s = "'" then (scan ss) else (s :: (scan ss))
   127     | scan (s :: ss) = if s = "'" then (scan ss) else (s :: (scan ss))
   126   in (implode o scan o Symbol.explode) str end;
   128   in (implode o scan o Symbol.explode) str end;
   127 
   129 
   128 (*go at a location in a script and fetch the contents*)
   130 (*go at a location in a script and fetch the contents*)        (*TODO-LucinNEW del in script.sml*)
   129 fun go [] t = t
   131 fun go [] t = t
   130   | go (Celem.D :: p) (Abs(_, _, t0)) = go (p : Celem.loc_) t0
   132   | go (Celem.D :: p) (Abs(_, _, t0)) = go (p : Celem.loc_) t0
   131   | go (Celem.L :: p) (t1 $ _) = go p t1
   133   | go (Celem.L :: p) (t1 $ _) = go p t1
   132   | go (Celem.R :: p) (_ $ t2) = go p t2
   134   | go (Celem.R :: p) (_ $ t2) = go p t2
   133   | go l _ = error ("go: no " ^ Celem.loc_2str l);
   135   | go l _ = error ("go: no " ^ Celem.loc_2str l);
   531   | rep_tac_ (Tac.Or_to_List' (t, t')) = (Rule.Erule, (t, t'))
   533   | rep_tac_ (Tac.Or_to_List' (t, t')) = (Rule.Erule, (t, t'))
   532   | rep_tac_ m = error ("rep_tac_: not impl.for " ^ Tac.tac_2str m)
   534   | rep_tac_ m = error ("rep_tac_: not impl.for " ^ Tac.tac_2str m)
   533 
   535 
   534 fun tac_2res m = (snd o snd o rep_tac_) m;
   536 fun tac_2res m = (snd o snd o rep_tac_) m;
   535 
   537 
   536 (* handle a leaf at the end of recursive descent:
   538 (* handle a leaf at the end of recursive descent:               (*TODO-LucinNEW del in script.sml*)
   537    a leaf is either a tactic or an 'expr' in "let v = expr"
   539    a leaf is either a tactic or an 'expr' in "let v = expr"
   538    where "expr" does not contain a tactic.
   540    where "expr" does not contain a tactic.
   539    Handling a leaf comprises
   541    Handling a leaf comprises
   540    (1) 'subst_stacexpr' substitute LTool.env and complete curried tactic
   542    (1) 'subst_stacexpr' substitute LTool.env and complete curried tactic
   541    (2) rewrite the leaf by 'srls'
   543    (2) rewrite the leaf by 'srls'
   542 *)
   544 *)
   543 fun handle_leaf call thy srls E a v t =
   545 fun handle_leaf call thy srls E a v t =                         (*TODO-LucinNEW del in script.sml*)
   544       (*WN050916 'upd_env_opt' is a blind copy from previous version*)
   546       (*WN050916 'upd_env_opt' is a blind copy from previous version*)
   545     case LTool.subst_stacexpr E a v t of
   547     case LTool.subst_stacexpr E a v t of
   546 	    (a', LTool.STac stac) => (*script-tactic*)
   548 	    (a', LTool.STac stac) => (*script-tactic*)
   547 	      let val stac' =
   549 	      let val stac' =
   548             Rewrite.eval_listexpr_ (Celem.assoc_thy thy) srls (subst_atomic (upd_env_opt E (a,v)) stac)
   550             Rewrite.eval_listexpr_ (Celem.assoc_thy thy) srls (subst_atomic (upd_env_opt E (a,v)) stac)
   852     error ("locate_gen: wrong arguments,\n tac= " ^ Tac.tac_2str m ^ ",\n " ^
   854     error ("locate_gen: wrong arguments,\n tac= " ^ Tac.tac_2str m ^ ",\n " ^
   853       "scr= " ^ Rule.scr2str sc ^ ",\n istate= " ^ Selem.istate2str is);
   855       "scr= " ^ Rule.scr2str sc ^ ",\n istate= " ^ Selem.istate2str is);
   854 
   856 
   855 (** find the next stactic in a script **)
   857 (** find the next stactic in a script **)
   856 
   858 
   857 (*appy, nxt_up, nstep_up scanning for next_tac.
   859 (*appy, nxt_up, nstep_up scanning for next_tac.                (*TODO-LucinNEW del in script.sml*)
   858   search is clearly separated into (1)-(2):
   860   search is clearly separated into (1)-(2):
   859   (1) appy is recursive descent;
   861   (1) appy is recursive descent;
   860   (2) nxt_up resumes interpretation at a location somewhere in the script;
   862   (2) nxt_up resumes interpretation at a location somewhere in the script;
   861       nstep_up does only get to the parentnode of the scriptexpr.
   863       nstep_up does only get to the parentnode of the scriptexpr.
   862   consequence:
   864   consequence:
   879 (*Appy              is only (final) returnvalue, not argument during search  *)
   881 (*Appy              is only (final) returnvalue, not argument during search  *)
   880   Napp_          (* ev. detects 'script is not appropriate for this example' *)
   882   Napp_          (* ev. detects 'script is not appropriate for this example' *)
   881 | Skip_;         (* detects 'script successfully finished'
   883 | Skip_;         (* detects 'script successfully finished'
   882 		                also used as init-value for resuming; this works,
   884 		                also used as init-value for resuming; this works,
   883 	                  because 'nxt_up Or e1' treats as Appy                    *)
   885 	                  because 'nxt_up Or e1' treats as Appy                    *)
   884 
       
   885 fun appy thy ptp E l (Const ("HOL.Let",_) $ e $ (Abs (i,T,b))) a v =
       
   886     (case appy thy ptp E (l @ [Celem.L, Celem.R]) e a v of
       
   887       Skip (res, E) => 
       
   888         let val E' = LTool.upd_env E (Free (i,T), res);
       
   889         in appy thy ptp E' (l @ [Celem.R, Celem.D]) b a v end
       
   890     | ay => ay)
       
   891   | appy (thy as (th,sr)) ptp E l (Const ("Script.While"(*1*),_) $ c $ e $ a) _ v =
       
   892     (if Rewrite.eval_true_ th sr (subst_atomic (LTool.upd_env E (a,v)) c)
       
   893      then appy thy ptp E (l @ [Celem.L, Celem.R]) e (SOME a) v
       
   894      else Skip (v, E))
       
   895   | appy (thy as (th,sr)) ptp E l (Const ("Script.While"(*2*),_) $ c $ e) a v =
       
   896     (if Rewrite.eval_true_ th sr (subst_atomic (upd_env_opt E (a,v)) c)
       
   897      then appy thy ptp E (l @ [Celem.R]) e a v
       
   898      else Skip (v, E))
       
   899   | appy (thy as (th,sr)) ptp E l (Const ("If",_) $ c $ e1 $ e2) a v =
       
   900     (if Rewrite.eval_true_ th sr (subst_atomic (upd_env_opt E (a,v)) c)
       
   901      then appy thy ptp E (l @ [Celem.L, Celem.R]) e1 a v
       
   902      else appy thy ptp E (l @ [Celem.R]) e2 a v)
       
   903   | appy thy ptp E l (Const ("Script.Repeat"(*1*),_) $ e $ a) _ v = 
       
   904     appy thy ptp E (l @ [Celem.L, Celem.R]) e (SOME a) v
       
   905   | appy thy ptp E l (Const ("Script.Repeat"(*2*),_) $ e) a v = appy thy ptp E (l @ [Celem.R]) e a v
       
   906   | appy thy ptp E l (Const ("Script.Try"(*2*),_) $ e $ a) _ v =
       
   907     (case appy thy ptp E (l @ [Celem.L, Celem.R]) e (SOME a) v of
       
   908       Napp E => (Skip (v, E))
       
   909     | ay => ay)
       
   910   | appy thy ptp E l(Const ("Script.Try"(*1*),_) $ e) a v =
       
   911     (case appy thy ptp E (l @ [Celem.R]) e a v of
       
   912       Napp E => (Skip (v, E))
       
   913     | ay => ay)
       
   914   | appy thy ptp E l (Const ("Script.Or"(*1*),_) $e1 $ e2 $ a) _ v =
       
   915     (case appy thy ptp E (l @ [Celem.L, Celem.L, Celem.R]) e1 (SOME a) v of
       
   916 	    Appy lme => Appy lme
       
   917     | _ => appy thy ptp E (*LTool.env*) (l @ [Celem.L, Celem.R]) e2 (SOME a) v)
       
   918   | appy thy ptp E l (Const ("Script.Or"(*2*),_) $e1 $ e2) a v =
       
   919     (case appy thy ptp E (l @ [Celem.L, Celem.R]) e1 a v of
       
   920 	    Appy lme => Appy lme
       
   921     | _ => appy thy ptp E (l @ [Celem.R]) e2 a v)
       
   922   | appy thy ptp E l (Const ("Script.Seq"(*2*),_) $ e1 $ e2 $ a) _ v =
       
   923     (case appy thy ptp E (l @ [Celem.L, Celem.L, Celem.R]) e1 (SOME a) v of
       
   924 	    Skip (v,E) => appy thy ptp E (l @ [Celem.L, Celem.R]) e2 (SOME a) v
       
   925     | ay => ay)
       
   926   | appy thy ptp E l (Const ("Script.Seq"(*1*),_) $ e1 $ e2) a v =
       
   927     (case appy thy ptp E (l @ [Celem.L, Celem.R]) e1 a v of
       
   928 	    Skip (v,E) => appy thy ptp E (l @ [Celem.R]) e2 a v
       
   929     | ay => ay)
       
   930   (* a leaf has been found *)   
       
   931   | appy ((th,sr)) (pt, p) E l t a v =
       
   932     case handle_leaf "next  " th sr E a v t of
       
   933 	    (_, LTool.Expr s) => Skip (s, E)
       
   934     | (a', LTool.STac stac) =>
       
   935 	    let val (m,m') = stac2tac_ pt (Celem.assoc_thy th) stac
       
   936       in case m of
       
   937 	      Tac.Subproblem _ => Appy (m', (E,l,a',tac_2res m',Selem.Sundef,false))
       
   938 	    | _ =>
       
   939         (case Applicable.applicable_in p pt m of
       
   940 		       Chead.Appl m' => (Appy (m', (E,l,a',tac_2res m',Selem.Sundef,false)))
       
   941 		     | _ => Napp E)
       
   942 	    end
       
   943 
       
   944 fun nxt_up thy ptp (scr as (Rule.Prog sc)) E l ay (Const ("HOL.Let", _) $ _) a v = (*comes from let=...*)
       
   945     if ay = Napp_
       
   946     then nstep_up thy ptp scr E (drop_last l) Napp_ a v
       
   947     else (*Skip_*)
       
   948 	    let
       
   949         val up = drop_last l
       
   950         val (i, T, body) =
       
   951           (case go up sc of
       
   952              Const ("HOL.Let",_) $ _ $ (Abs aa) => aa
       
   953            | t => error ("nxt_up..HOL.Let $ _ with " ^ Rule.term2str t))
       
   954         val i = TermC.mk_Free (i, T)
       
   955         val E = LTool.upd_env E (i, v)
       
   956       in
       
   957         case appy thy ptp E (up @ [Celem.R, Celem.D]) body a v  of
       
   958 	        Appy lre => Appy lre
       
   959 	      | Napp E => nstep_up thy ptp scr E up Napp_ a v
       
   960 	      | Skip (v,E) => nstep_up thy ptp scr E up Skip_ a v
       
   961 	    end
       
   962   | nxt_up thy ptp scr E l ay (Abs _) a v =  nstep_up thy ptp scr E l ay a v
       
   963   | nxt_up thy ptp scr E l ay (Const ("HOL.Let",_) $ _ $ (Abs _)) a v =
       
   964     nstep_up thy ptp scr E l ay a v
       
   965   (*no appy_: never causes Napp -> Helpless*)
       
   966   | nxt_up (thy as (th, sr)) ptp scr E l _ (Const ("Script.While"(*1*), _) $ c $ e $ _) a v = 
       
   967     if Rewrite.eval_true_ th sr (subst_atomic (upd_env_opt E (a, v)) c) 
       
   968     then case appy thy ptp E (l @ [Celem.L, Celem.R]) e a v of
       
   969 	     Appy lr => Appy lr
       
   970 	  | Napp E => nstep_up thy ptp scr E l Skip_ a v
       
   971 	  | Skip (v,E) => nstep_up thy ptp scr E l Skip_ a v
       
   972     else nstep_up thy ptp scr E l Skip_ a v
       
   973   (*no appy_: never causes Napp - Helpless*)
       
   974   | nxt_up (thy as (th, sr)) ptp scr E l _ (Const ("Script.While"(*2*), _) $ c $ e) a v = 
       
   975     if Rewrite.eval_true_ th sr (subst_atomic (upd_env_opt E (a, v)) c) 
       
   976     then case appy thy ptp E (l @ [Celem.R]) e a v of
       
   977 	    Appy lr => Appy lr
       
   978 	  | Napp E => nstep_up thy ptp scr E l Skip_ a v
       
   979 	  | Skip (v,E) => nstep_up thy ptp scr E l Skip_ a v
       
   980     else nstep_up thy ptp scr E l Skip_ a v
       
   981   | nxt_up thy ptp scr E l ay (Const ("If", _) $ _ $ _ $ _) a v = nstep_up thy ptp scr E l ay a v
       
   982   | nxt_up thy ptp scr E l _ (*no appy_: there was already a stac below*)
       
   983       (Const ("Script.Repeat"(*1*), _) $ e $ _) a v =
       
   984     (case appy thy ptp (*upd_env*) E (*a,v)*) (l @ [Celem.L, Celem.R]) e a v  of
       
   985       Appy lr => Appy lr
       
   986     | Napp E =>  nstep_up thy ptp scr E l Skip_ a v
       
   987     | Skip (v,E) =>  nstep_up thy ptp scr E l Skip_ a v)
       
   988   | nxt_up thy ptp scr E l _ (*no appy_: there was already a stac below*)
       
   989       (Const ("Script.Repeat"(*2*), _) $ e) a v =
       
   990     (case appy thy ptp (*upd_env*) E (*a,v)*) (l @ [Celem.R]) e a v  of
       
   991       Appy lr => Appy lr
       
   992     | Napp E => nstep_up thy ptp scr E l Skip_ a v
       
   993     | Skip (v,E) => nstep_up thy ptp scr E l Skip_ a v)
       
   994   | nxt_up thy ptp scr E l _ (Const ("Script.Try"(*2*),_) $ _ $ _) a v = (*makes Napp to Skip*)
       
   995     nstep_up thy ptp scr E l Skip_ a v
       
   996 
       
   997   | nxt_up thy ptp scr E l _ (Const ("Script.Try"(*1*), _) $ _) a v = (*makes Napp to Skip*)
       
   998     nstep_up thy ptp scr E l Skip_ a v
       
   999   | nxt_up thy ptp scr E l ay (Const ("Script.Or",_) $ _ $ _ $ _) a v =
       
  1000     nstep_up thy ptp scr E l ay a v
       
  1001   | nxt_up thy ptp scr E l ay (Const ("Script.Or",_) $ _ $ _) a v = nstep_up thy ptp scr E l ay a v
       
  1002   | nxt_up thy ptp scr E l ay (Const ("Script.Or",_) $ _ ) a v = 
       
  1003     nstep_up thy ptp scr E (drop_last l) ay a v
       
  1004   | nxt_up thy ptp scr E l ay (Const ("Script.Seq"(*1*),_) $ _ $ _ $ _) a v =
       
  1005     (*all has been done in (*2*) below*) nstep_up thy ptp scr E l ay a v
       
  1006   | nxt_up thy ptp scr E l ay (Const ("Script.Seq"(*2*),_) $ _ $ _) a v = (*comes from e2*)
       
  1007     nstep_up thy ptp scr E l ay a v
       
  1008   | nxt_up thy ptp (scr as Rule.Prog sc) E l ay (Const ("Script.Seq"(*3*),_) $ _) a v = (*comes from e1*)
       
  1009     if ay = Napp_
       
  1010     then nstep_up thy ptp scr E (drop_last l) Napp_ a v
       
  1011     else (*Skip_*)
       
  1012       let val up = drop_last l;
       
  1013           val e2 =
       
  1014             (case go up sc of
       
  1015                Const ("Script.Seq"(*2*), _) $ _ $ e2 => e2
       
  1016              | t => error ("nxt_up..Script.Seq $ _ with " ^ Rule.term2str t))
       
  1017       in case appy thy ptp E (up @ [Celem.R]) e2 a v  of
       
  1018         Appy lr => Appy lr
       
  1019       | Napp E => nstep_up thy ptp scr E up Napp_ a v
       
  1020       | Skip (v,E) => nstep_up thy ptp scr E up Skip_ a v end
       
  1021   | nxt_up _ _ _ _ _ _ t _ _ = error ("nxt_up not impl for " ^ Rule.term2str t)
       
  1022 and nstep_up thy ptp (Rule.Prog sc) E l ay a v = 
       
  1023     if 1 < length l
       
  1024     then 
       
  1025       let val up = drop_last l; 
       
  1026       in (nxt_up thy ptp (Rule.Prog sc) E up ay (go up sc) a v ) end
       
  1027     else (*interpreted to end*)
       
  1028       if ay = Skip_ then Skip (v, E) else Napp E 
       
  1029   | nstep_up _ _ _ _ l _ _ _ = error ("nstep_up: uncovered fun-def at " ^ Celem.loc_2str l)
       
  1030 
       
  1031 (* decide for the next applicable stac in the script;
       
  1032    returns (stactic, value) - the value in case the script is finished 
       
  1033    12.8.02:         ~~~~~ and no assumptions ??? FIXME ???
       
  1034    20.8.02: must return p in case of finished, because the next script
       
  1035             consulted need not be the calling script:
       
  1036             in case of detail ie. _inserted_ PrfObjs, the next stac
       
  1037             has to searched in a script with PblObj.status<>Complete !
       
  1038             (.. not true for other details ..PrfObj ??????????????????
       
  1039    20.8.02: do NOT return safe (is only changed in locate !!!)
       
  1040 *)
       
  1041 fun next_tac (thy,_) _ (Rule.Rfuns {next_rule, ...}) (Selem.RrlsState(f, f', rss, _), ctxt) =
       
  1042     if f = f'
       
  1043     then (Tac.End_Detail' (f',[])(*8.6.03*), (Selem.Uistate, ctxt), 
       
  1044     	(f', Selem.Sundef(*FIXME is no value of next_tac! vor 8.6.03*)))                (*finished*)
       
  1045     else
       
  1046       (case next_rule rss f of
       
  1047     	  NONE => (Tac.Empty_Tac_, (Selem.Uistate, ctxt), (Rule.e_term, Selem.Sundef))       (*helpless*)
       
  1048     	| SOME (Rule.Thm thm'')(*8.6.03: muss auch f' liefern ?!!*) => 
       
  1049     	    (Tac.Rewrite' (thy, "e_rew_ord", Rule.e_rls, false, thm'', f, (Rule.e_term, [(*!?!8.6.03*)])),
       
  1050   	         (Selem.Uistate, ctxt), (Rule.e_term, Selem.Sundef))                          (*next stac*)
       
  1051       | _ => error "next_tac: uncovered case next_rule")
       
  1052   | next_tac thy (ptp as (pt, (p, _))) (sc as Rule.Prog prog) 
       
  1053 	    (Selem.ScrState (E,l,a,v,s,_), ctxt) =
       
  1054     (case if l = [] then appy thy ptp E [Celem.R] (LTool.body_of prog) NONE v
       
  1055           else nstep_up thy ptp sc E l Skip_ a v of
       
  1056        Skip (v, _) =>                                                                 (*finished*)
       
  1057          (case par_pbl_det pt p of
       
  1058 	          (true, p', _) => 
       
  1059 	             let
       
  1060 	               val (_,pblID,_) = get_obj g_spec pt p';
       
  1061 	              in (Tac.Check_Postcond' (pblID, (v, [(*assigned in next step*)])), 
       
  1062 	                   (Selem.e_istate, ctxt), (v,s)) 
       
  1063                 end
       
  1064 	        | _ => (Tac.End_Detail' (Rule.e_term,[])(*8.6.03*), (Selem.e_istate, ctxt), (v,s)))
       
  1065      | Napp _ => (Tac.Empty_Tac_, (Selem.e_istate, ctxt), (Rule.e_term, Selem.Sundef))     (*helpless*)
       
  1066      | Appy (m', scrst as (_,_,_,v,_,_)) =>
       
  1067          (m', (Selem.ScrState scrst, ctxt), (v, Selem.Sundef)))                      (*next stac*)
       
  1068   | next_tac _ _ _ (is, _) = error ("next_tac: not impl for " ^ (Selem.istate2str is));
       
  1069 
   886 
  1070 (* create the initial interpreter state
   887 (* create the initial interpreter state
  1071   from the items of the guard and the formal arguments of the partial_function.
   888   from the items of the guard and the formal arguments of the partial_function.
  1072 Note on progression from (a) type fmz_ \<longrightarrow> (e) arguments of the partial_function:
   889 Note on progression from (a) type fmz_ \<longrightarrow> (e) arguments of the partial_function:
  1073   (a) fmz is given by a math author
   890   (a) fmz is given by a math author