src/sml/ME/solve.sml
author wneuper
Thu, 28 Aug 2003 15:41:50 +0200
changeset 825 74a959d79726
parent 819 738140f79c40
child 839 7c694e61470d
permissions -rw-r--r--
*** empty log message ***
agriesma@328
     1
(* use"../ME/solve.sml";
agriesma@328
     2
   use"ME/solve.sml";
agriesma@328
     3
   use"solve.sml";
agriesma@328
     4
   W.N.10.12.99
agriesma@328
     5
agriesma@328
     6
   cd ~/Isabelle/Zerlege-Isa98-1/src/HOL/
agriesma@328
     7
   /src/HOL> sml @SMLload=HOL-plus
agriesma@328
     8
   cd"~/MathEngine99/src/";
agriesma@328
     9
   use"ROOT.sml";
agriesma@328
    10
*)
agriesma@328
    11
agriesma@328
    12
fun safe (ScrState (_,_,_,_,s,_)) = s
agriesma@328
    13
  | safe (RrlsState _) = Safe;
agriesma@328
    14
agriesma@328
    15
type mstID = string;
wneuper@807
    16
type tac'_ = mstID * tac; (*DG <-> ME*)
wneuper@807
    17
val e_tac'_ = ("Empty_Tac", Empty_Tac):tac'_;
agriesma@328
    18
wneuper@807
    19
fun mk_tac'_   m = case m of
agriesma@328
    20
  Init_Proof (ppc, spec)    => ("Init_Proof", Init_Proof (ppc, spec )) 
agriesma@328
    21
| Model_Problem pblID       => ("Model_Problem", Model_Problem pblID)
agriesma@328
    22
| Refine_Tacitly pblID      => ("Refine_Tacitly", Refine_Tacitly pblID)
agriesma@328
    23
| Refine_Problem pblID      => ("Refine_Problem", Refine_Problem pblID)
agriesma@328
    24
| Add_Given cterm'          => ("Add_Given", Add_Given cterm') 
agriesma@328
    25
| Del_Given cterm'          => ("Del_Given", Del_Given cterm') 
agriesma@328
    26
| Add_Find cterm'           => ("Add_Find", Add_Find cterm') 
agriesma@328
    27
| Del_Find cterm'           => ("Del_Find", Del_Find cterm') 
agriesma@328
    28
| Add_Relation cterm'       => ("Add_Relation", Add_Relation cterm') 
agriesma@328
    29
| Del_Relation cterm'       => ("Del_Relation", Del_Relation cterm') 
agriesma@328
    30
agriesma@328
    31
| Specify_Domain domID	    => ("Specify_Domain", Specify_Domain domID) 
agriesma@328
    32
| Specify_Problem pblID     => ("Specify_Problem", Specify_Problem pblID)
agriesma@328
    33
| Specify_Method metID	    => ("Specify_Method", Specify_Method metID) 
agriesma@328
    34
| Apply_Method metID	    => ("Apply_Method", Apply_Method metID) 
agriesma@328
    35
| Check_Postcond pblID	    => ("Check_Postcond", Check_Postcond pblID)
agriesma@328
    36
| Free_Solve                => ("Free_Solve",Free_Solve)
agriesma@328
    37
		    
agriesma@328
    38
| Rewrite_Inst (subs, thm') => ("Rewrite_Inst", Rewrite_Inst (subs, thm')) 
agriesma@328
    39
| Rewrite thm'		    => ("Rewrite", Rewrite thm') 
agriesma@328
    40
| Rewrite_Asm thm'	    => ("Rewrite_Asm", Rewrite_Asm thm') 
agriesma@328
    41
| Rewrite_Set_Inst (subs, rls')
agriesma@328
    42
               => ("Rewrite_Set_Inst", Rewrite_Set_Inst (subs, rls')) 
agriesma@328
    43
| Rewrite_Set rls'          => ("Rewrite_Set", Rewrite_Set rls') 
agriesma@328
    44
| End_Ruleset		    => ("End_Ruleset", End_Ruleset)
agriesma@328
    45
agriesma@328
    46
| End_Detail                => ("End_Detail", End_Detail)
agriesma@328
    47
| Detail_Set rls'           => ("Detail_Set", Detail_Set rls')
agriesma@328
    48
| Detail_Set_Inst (s, rls') => ("Detail_Set_Inst", Detail_Set_Inst (s, rls'))
agriesma@328
    49
agriesma@328
    50
| Calculate op_             => ("Calculate", Calculate op_)
agriesma@328
    51
| Substitute subs           => ("Substitute", Substitute subs) 
agriesma@328
    52
| Apply_Assumption cts'	    => ("Apply_Assumption", Apply_Assumption cts')
agriesma@328
    53
agriesma@328
    54
| Take cterm'               => ("Take", Take cterm') 
agriesma@328
    55
| Take_Inst cterm'          => ("Take_Inst", Take_Inst cterm') 
agriesma@328
    56
| Group (con, ints) 	    => ("Group", Group (con, ints)) 
agriesma@328
    57
| Subproblem (domID, pblID) => ("Subproblem", Subproblem (domID, pblID)) 
agriesma@328
    58
(*
agriesma@328
    59
| Subproblem_Full(spec,cts')=> ("Subproblem_Full", Subproblem_Full(spec,cts')) 
agriesma@328
    60
*)
agriesma@328
    61
| End_Subproblem            => ("End_Subproblem",End_Subproblem)
agriesma@328
    62
| CAScmd cterm'		    => ("CAScmd", CAScmd cterm')
agriesma@328
    63
			    
agriesma@328
    64
| Split_And                 => ("Split_And", Split_And) 
agriesma@328
    65
| Conclude_And		    => ("Conclude_And", Conclude_And) 
agriesma@328
    66
| Split_Or                  => ("Split_Or", Split_Or) 
agriesma@328
    67
| Conclude_Or		    => ("Conclude_Or", Conclude_Or) 
agriesma@328
    68
| Begin_Trans               => ("Begin_Trans", Begin_Trans) 
agriesma@328
    69
| End_Trans		    => ("End_Trans", End_Trans) 
agriesma@328
    70
| Begin_Sequ                => ("Begin_Sequ", Begin_Sequ) 
agriesma@328
    71
| End_Sequ                  => ("End_Sequ", Begin_Sequ) 
agriesma@328
    72
| Split_Intersect           => ("Split_Intersect", Split_Intersect) 
agriesma@328
    73
| End_Intersect		    => ("End_Intersect", End_Intersect) 
agriesma@328
    74
| Check_elementwise cterm'  => ("Check_elementwise", Check_elementwise cterm')
agriesma@328
    75
| Or_to_List                => ("Or_to_List", Or_to_List) 
agriesma@328
    76
| Collect_Trues	            => ("Collect_Results", Collect_Trues) 
agriesma@328
    77
			    
wneuper@807
    78
| Empty_Tac               => ("Empty_Tac",Empty_Tac)
wneuper@807
    79
| Tac string              => ("Tac",Tac string)
agriesma@328
    80
| User                      => ("User",User)
agriesma@328
    81
| End_Proof'                => ("End_Proof'",End_Proof'); 
agriesma@328
    82
agriesma@328
    83
(*Detail*)
wneuper@807
    84
val empty_tac'_ = (mk_tac'_ Empty_Tac):tac'_;
agriesma@328
    85
wneuper@807
    86
fun mk_tac ((_,m):tac'_) = m; 
wneuper@807
    87
fun mk_mstID ((mI,_):tac'_) = mI;
agriesma@328
    88
wneuper@807
    89
fun tac'_2str ((ID,ms):tac'_) = ID ^ (tac2str ms);
wneuper@807
    90
(* TODO: tac2str, tac'_2str NOT tested *)
agriesma@328
    91
agriesma@328
    92
agriesma@328
    93
agriesma@328
    94
type squ = ptree; (* TODO: safe etc. *)
agriesma@328
    95
agriesma@328
    96
(*13.9.02--------------
agriesma@328
    97
type ctr = (loc * pos) list;
agriesma@328
    98
val ops = [("plus","op +"),("minus","op -"),("times","op *"),
agriesma@328
    99
	   ("cancel","cancel"),("pow","pow"),("sqrt","sqrt")];
agriesma@328
   100
fun op_intern op_ =
agriesma@328
   101
  case assoc (ops,op_) of
agriesma@328
   102
    Some op' => op' | None => raise error ("op_intern: no op= "^op_);
agriesma@328
   103
-----------------------*)
agriesma@328
   104
agriesma@328
   105
agriesma@328
   106
agriesma@328
   107
(* use"ME/solve.sml";
agriesma@328
   108
   use"solve.sml";
agriesma@328
   109
agriesma@328
   110
val ttt = (term_of o the o (parse thy))"Substitute [(bdv,x)] g";
agriesma@328
   111
val ttt = (term_of o the o (parse thy))"Rewrite thmid True g";
agriesma@328
   112
agriesma@328
   113
  Const ("Script.Rewrite'_Inst",_) $ sub $ Free (thm',_) $ Const (pa,_) $ f'
agriesma@328
   114
   *)
agriesma@328
   115
agriesma@328
   116
agriesma@328
   117
agriesma@328
   118
val specsteps = ["Init_Proof","Refine_Tacitly","Refine_Problem",
agriesma@328
   119
		 "Model_Problem",(*"Match_Problem",*)
agriesma@328
   120
		 "Add_Given","Del_Given","Add_Find","Del_Find",
agriesma@328
   121
		 "Add_Relation","Del_Relation",
agriesma@328
   122
		 "Specify_Domain","Specify_Problem","Specify_Method"];
agriesma@328
   123
wneuper@825
   124
"-----------------------------------------------------------------------";
agriesma@328
   125
wneuper@816
   126
(* val ("Apply_Method",Apply_Method' (mI,_))=(mI,m);
agriesma@328
   127
   *)
wneuper@816
   128
fun solve ("Apply_Method",Apply_Method' (mI,_)) (pos as (p,_)) (pt:ptree) =
agriesma@328
   129
  let val {srls,...} = get_met mI;
agriesma@328
   130
    val PblObj{meth=itms,...} = get_obj I pt p;
agriesma@328
   131
    val thy' = get_obj g_domID pt p;
agriesma@328
   132
    val thy = assoc_thy thy';
agriesma@328
   133
    val (is as ScrState (env,_,_,_,_,_), scr) = init_scrstate thy itms mI;
agriesma@328
   134
    val ini = init_form thy scr env;
agriesma@328
   135
    val (p,p_) = (lev_dn p,Res);
agriesma@328
   136
  in 
agriesma@328
   137
    case ini of
agriesma@328
   138
    Some t => (* val Some t = ini; 
agriesma@328
   139
	         *)
wneuper@816
   140
    let (*val (p,p_) = (lev_on p,Frm); implicit Take -> generate1*)
agriesma@328
   141
	val f = Sign.string_of_term (sign_of (assoc_thy thy')) t;
wneuper@816
   142
	(*val (pt,ps) = cappend_form pt p is t*)
wneuper@816
   143
	(*writes to pt without asking user !!!?*)
wneuper@816
   144
	val ((p,p_),_,_,pt) = (*implicit Take*)
wneuper@816
   145
	    generate1 thy (Apply_Method' (mI,Some (t, is)))
wneuper@825
   146
		      is(*Uistate.19.8.03*) (lev_on p,Frm) pt
wneuper@825
   147
	val {srls,...} = get_met mI
wneuper@825
   148
	val (nx,is,_) = next_tac (thy',srls) (pt,(p,p_)) scr is
wneuper@825
   149
    in ((p,p_), ((lev_onFrm o lev_dnRes) pos, is, nx), 
wneuper@825
   150
	Form' (FormKF (~1,EdUndef,(length p), Nundef, f)), 
wneuper@825
   151
	tac_2tac nx, Safe, pt) end
agriesma@328
   152
  | None =>
wneuper@825
   153
    let val m = fst3 (next_tac (thy',srls) (pt,(lev_on p,Frm)) scr is);
agriesma@328
   154
	val f = case m of 
wneuper@807
   155
		    Subproblem' ((domID, pblID,_),_,_) => 
agriesma@328
   156
		    Form' (FormKF (~1,EdUndef,(length p), Nundef, 
agriesma@328
   157
			   (Sign.string_of_term (sign_of (assoc_thy thy')) 
agriesma@328
   158
						(subpbl domID pblID))))
neuper@711
   159
		  | _ => EmptyMout;
agriesma@328
   160
    (*nothing written to pt !!!*)
wneuper@825
   161
    in ((p,p_), (lev_dnRes pos, is, m), f, tac_2tac m, Safe, pt) end
agriesma@328
   162
  end
agriesma@328
   163
agriesma@328
   164
  | solve ("Free_Solve", Free_Solve') (p,_) pt =
agriesma@328
   165
  let val _=writeln"###solve Free_Solve";
agriesma@328
   166
    val p' = lev_dn_ (p,Res);
agriesma@328
   167
    val pt = update_metID pt (par_pblobj pt p) e_metID;
wneuper@825
   168
  in (p', (p',Uistate,Empty_Tac_), EmptyMout, Empty_Tac, Unsafe, pt) end
agriesma@328
   169
agriesma@328
   170
(* val ("Check_Postcond",Check_Postcond' (pI,_)) = (mI,m);
agriesma@328
   171
   *)
wneuper@825
   172
  | solve ("Check_Postcond",Check_Postcond' (pI,_)) (pos as (p,p_)) pt =
agriesma@328
   173
    let (*val _=writeln"###solve Check_Postcond";*)
neuper@732
   174
      val pp = par_pblobj pt p
wneuper@807
   175
      val asm = (case get_obj g_tac pt p of
neuper@732
   176
		    Check_elementwise _ => (*collects and instantiates asms*)
neuper@732
   177
		    (snd o (get_obj g_result pt)) p
neuper@732
   178
		  | _ => ((map fst) o (get_assumptions_ pt)) (p,p_))
neuper@732
   179
	  handle _ => [] (*WN.27.5.03 asms in subpbls not completely clear*)
agriesma@328
   180
      val metID = get_obj g_metID pt pp;
agriesma@328
   181
      val {srls=srls,scr=sc,...} = get_met metID;
agriesma@328
   182
      val is as ScrState (E,l,a,_,_,b) = get_istate pt (p,p_); 
agriesma@328
   183
     (*val _= writeln("### solve Check_postc, subpbl pos= "^(pos'2str (p,p_)));
agriesma@328
   184
      val _= writeln("### solve Check_postc, is= "^(istate2str is));*)
agriesma@328
   185
      val thy' = get_obj g_domID pt pp;
agriesma@328
   186
      val thy = assoc_thy thy';
wneuper@825
   187
      val (_,_,(scval,scsaf)) = next_tac (thy',srls) (pt,(p,p_)) sc is;
agriesma@328
   188
      (*val _= writeln("### solve Check_postc, scval= "^(term2str scval));*)
agriesma@328
   189
    in if pp = [] then 
wneuper@825
   190
	   let val is = ScrState (E,l,a,scval,scsaf,b)
wneuper@825
   191
	       val ((p,p_),ps,f,pt) = 
neuper@750
   192
		   generate1 thy (Check_Postcond'(pI,(scval,
neuper@750
   193
						      map term2str asm)))
wneuper@825
   194
			     is (pp,Res) pt;
wneuper@825
   195
	   in ((p,p_), (([],Res),is,End_Proof''), f, End_Proof', scsaf, pt) end
agriesma@328
   196
       else
agriesma@328
   197
        let
agriesma@328
   198
	  (*resume script of parpbl, transfer value of subpbl-script*)
wneuper@819
   199
        val ppp = par_pblobj pt (lev_up p);
agriesma@328
   200
	val thy' = get_obj g_domID pt ppp;
agriesma@328
   201
        val thy = assoc_thy thy';
agriesma@328
   202
	val metID = get_obj g_metID pt ppp;
agriesma@328
   203
        val sc = (#scr o get_met) metID;
agriesma@328
   204
        val is as ScrState (E,l,a,_,_,b) = get_istate pt (pp(*!/p/*),Frm); 
agriesma@328
   205
     (*val _=writeln("### solve Check_postc, parpbl pos= "^(pos'2str(pp,Frm)));
agriesma@328
   206
  	val _=writeln("### solve Check_postc, is(pt)= "^(istate2str is));
agriesma@328
   207
  	val _=writeln("### solve Check_postc, is'= "^
agriesma@328
   208
		      (istate2str (E,l,a,scval,scsaf,b)));*)
neuper@750
   209
        val ((p,p_),ps,f,pt) = 
neuper@750
   210
	    generate1 thy (Check_Postcond' (pI, (scval, map term2str asm)))
agriesma@328
   211
		(ScrState (E,l,a,scval,scsaf,b)) (pp,Res) pt;
agriesma@328
   212
	(*val _=writeln("### solve Check_postc, is(pt')= "^
agriesma@328
   213
		      (istate2str (get_istate pt ([3],Res))));*)
wneuper@825
   214
	val (nx,is',_) = next_tac (thy',srls) (pt,(p,p_)) sc 
wneuper@825
   215
				(ScrState (E,l,a,scval,scsaf,b));
wneuper@825
   216
       in ((p,p_), ((pp,Res),is',nx), f, tac_2tac nx, scsaf, pt) end
agriesma@328
   217
    end
agriesma@328
   218
(* writeln(istate2str(get_istate pt (p,p_)));
agriesma@328
   219
   *)
agriesma@328
   220
agriesma@328
   221
  | solve (_,End_Proof'') (p,p_) pt =
wneuper@825
   222
      ((p,p_), (([],Res),Uistate,Empty_Tac_), EmptyMout, Empty_Tac, Safe, pt)
agriesma@328
   223
agriesma@328
   224
(*.start interpreter and do one rewrite.*)
neuper@750
   225
(* val (_,Detail_Set'(thy',rls,t)) = (mI,m); val p = (p,p_);
neuper@750
   226
   solve ("",Detail_Set'(thy', rls, t)) p pt;
agriesma@328
   227
   *)
neuper@750
   228
  | solve (_,Detail_Set'(thy', rls, t)) p pt =
agriesma@328
   229
    let (*val rls = the (assoc(!ruleset',rls'))
agriesma@328
   230
	    handle _ => raise error ("solve: '"^rls'^"' not known");*)
agriesma@328
   231
	val thy = assoc_thy thy';
agriesma@328
   232
        val (srls, sc, is) = 
agriesma@328
   233
	    case rls of
agriesma@328
   234
		Rrls {scr=sc as Rfuns {init_state=ii,...},...} => 
agriesma@328
   235
		(e_rls, sc, RrlsState (ii t))
agriesma@328
   236
	      | Rls {srls=srls,scr=sc as Script s,...} => 
agriesma@328
   237
		(srls, sc, ScrState ([(one_scr_arg s,t)], [], 
agriesma@328
   238
			       None, e_term, Sundef, true));
wneuper@807
   239
	val pt = update_tac pt (fst p) (Detail_Set (id_rls rls));
agriesma@328
   240
	val (p,cid,_,pt) = generate1 thy (Begin_Trans' t) is p pt;
wneuper@825
   241
	val nx = (tac_2tac o fst3) (next_tac (thy',srls) (pt,p) sc is);
agriesma@328
   242
	val aopt = applicable_in p pt nx;
agriesma@328
   243
    in case aopt of
agriesma@328
   244
	   Notappl s => raise error ("solve Detail_Set: "^s)
agriesma@328
   245
	 (* val Appl m = aopt;
agriesma@328
   246
	    *)
agriesma@328
   247
	 | Appl m => solve ("discardFIXME",m) p pt end
agriesma@328
   248
agriesma@328
   249
  | solve (_,End_Detail' t) (p,p_) pt =
agriesma@328
   250
    let val pr as (p',_) = (lev_up p, Res)
agriesma@328
   251
	val pp = par_pblobj pt p
neuper@703
   252
	val r = (fst o (get_obj g_result pt)) p' 
wneuper@825
   253
	(*Rewrite_Set* done at Detail_Set*: this result is already in ptree*)
agriesma@328
   254
	val thy' = get_obj g_domID pt pp
agriesma@328
   255
	val (srls, is, sc) = from_pblobj' thy' pr pt
wneuper@825
   256
	val (tac_,is',_) = next_tac (thy',srls)  (pt,pr) sc is
wneuper@825
   257
    in (pr, ((pp,Frm(*???*)),is,tac_), 
wneuper@825
   258
	Form' (FormKF (~1, EdUndef, length p', Nundef, term2str r)),
wneuper@825
   259
	tac_2tac tac_, Sundef, pt)end
agriesma@328
   260
(* val (mI,(p,p_)) = ("xxx",p);
agriesma@328
   261
   *)
agriesma@328
   262
  | solve (mI,m) (p,p_) pt =
agriesma@328
   263
    if e_metID = get_obj g_metID pt (par_pblobj pt p)(*29.8.02:
agriesma@328
   264
						      could be detail, too !!*)
agriesma@328
   265
    then let val ((p,p_),ps,f,pt) = 
agriesma@328
   266
		 generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p))) 
agriesma@328
   267
			   m e_istate (p,p_) pt;
wneuper@825
   268
	 in ((p,p_),((p,p_),Uistate,Empty_Tac_),f, Empty_Tac, Unsafe, pt) end
agriesma@328
   269
    else
neuper@711
   270
	let 
neuper@711
   271
	    val thy' = get_obj g_domID pt (par_pblobj pt p);
agriesma@328
   272
	    val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
agriesma@328
   273
(*val _= writeln("### solve, before locate_gen p="^(pos'2str(p,p_)));*)
agriesma@328
   274
		val d = e_rls; (*FIXME: canon.simplifier for domain is missing
agriesma@328
   275
				8.01: generate from domID?*)
agriesma@328
   276
	in case locate_gen (thy',srls) m  (pt,(p,p_)) (sc,d) is of 
agriesma@328
   277
	       Steps (is', (m',f',pt',p',c')::ss) =>
agriesma@328
   278
	       (* val Steps (is', (m',f',pt',p',c')::ss) =
agriesma@328
   279
		      locate_gen (thy',srls) m  (pt,(p,p_)) (sc,d) is;
agriesma@328
   280
		*)
wneuper@825
   281
	       let val nxt_ = 
wneuper@807
   282
		       case p' of (*change from solve to model subprobl#####*)
wneuper@825
   283
			   (_,Pbl) => nxt_model_pbl m' (pt',p')
wneuper@825
   284
			 | _ => fst3 (next_tac (thy',srls) (pt',p') sc is'); 
wneuper@825
   285
	       (*27.8.02:next_tac may change to other branches in pt FIXXXXME*)
wneuper@825
   286
	       in (p',(p',is',nxt_), f', tac_2tac nxt_, safe is', pt'(*'*)) end
agriesma@328
   287
	     | NotLocatable =>  
agriesma@328
   288
	       let val (p,ps,f,pt) = 
agriesma@328
   289
		       generate_hard (assoc_thy "Isac.thy") m (p,p_) pt;
wneuper@825
   290
	       in (p,(p,Uistate,Empty_Tac_),f, Empty_Tac, Unsafe, pt) end
agriesma@328
   291
	end;
agriesma@328
   292
agriesma@328
   293
agriesma@328
   294
(* val (pos' as (p,p_),pt) = (p,EmptyPtree);
agriesma@328
   295
   
agriesma@328
   296
   val (mI,m) = nxt; val pos' as (p,p_) = p;
agriesma@328
   297
   *)
wneuper@825
   298
fun meOLD ((mI,m):tac'_) (pos' as (p,p_):pos') (c:cid) (pt:ptree) =
agriesma@328
   299
  case applicable_in (p,p_) pt m of
neuper@718
   300
    Appl m => (* val Appl m''' = applicable_in (p,p_) pt m;
neuper@718
   301
                 val Appl m = applicable_in (p,p_) pt m;
neuper@750
   302
	       *)
agriesma@328
   303
    (case m of
agriesma@328
   304
	( Refine_Problem' ms) => 
wneuper@825
   305
	 (pos',[], Problems (RefinedKF ms), 
agriesma@328
   306
	  ("Specify_Problem", Specify_Problem (refined ms)), Safe, pt)
agriesma@328
   307
agriesma@328
   308
       | _ => (if mI mem specsteps
wneuper@825
   309
	       then let val (p',c,f,m,s,pt) = specify m (p,p_) [] pt;
wneuper@825
   310
		   in (p',[],f,mk_tac'_ m,s,pt)
agriesma@328
   311
		    end
agriesma@328
   312
	       else let val ((p,p_),c,f,m,s,pt) = solve (mI,m) (p,p_) pt;
wneuper@825
   313
		   in ((p,p_),[],f,mk_tac'_ m,s,pt) end))
wneuper@825
   314
  | Notappl e => ((p,p_),[], Error' (Error_ e),
wneuper@807
   315
		  mk_tac'_ Empty_Tac (*nxtstep ??*), Unsafe,pt);
agriesma@328
   316
wneuper@825
   317
val me = meOLD;
wneuper@825
   318
agriesma@328
   319
(* val(mI,m)=m;val ppp=p;(*!!!*)val(p,p_)=pos;val(_,pt,_)=ppp(*!!!*);
wneuper@807
   320
   get_form ((mI,m):tac'_) ((p,p_):pos') ppp;
agriesma@328
   321
   *)
wneuper@807
   322
fun get_form ((mI,m):tac'_) ((p,p_):pos') pt = 
agriesma@328
   323
  case applicable_in (p,p_) pt m of
agriesma@328
   324
    Notappl e => Error' (Error_ e)
agriesma@328
   325
  | Appl m => 
agriesma@328
   326
      (* val Appl m=applicable_in (p,p_) pt m;
agriesma@328
   327
         *)
agriesma@328
   328
      if mI mem specsteps
agriesma@328
   329
	then let val (_,_,f,_,_,_) = specify m (p,p_) [] pt
agriesma@328
   330
	     in f end
agriesma@328
   331
      else let val (_,_,f,_,_,_) = solve (mI,m) (p,p_) pt
agriesma@328
   332
	   in f end;
wneuper@825
   333