intermed: make autocalc..CompleteCalc run with x+1=2 decompose-isar
authorWalther Neuper <neuper@ist.tugraz.at>
Mon, 18 Jul 2011 09:29:17 +0200
branchdecompose-isar
changeset 420921a6d6089e594
parent 42090 908dfde7cf75
child 42093 3b25d093e0b0
intermed: make autocalc..CompleteCalc run with x+1=2

runs, although correction not perfect
error WAS in fun all_modspec: ctxt from fmz and not pors
TODO: check all other "prep_ori fmz thy ppc |> #1"
src/Tools/isac/Interpret/calchead.sml
src/Tools/isac/Interpret/script.sml
src/Tools/isac/Interpret/solve.sml
test/Tools/isac/ADDTESTS/All_Ctxt.thy
test/Tools/isac/Minisubpbl/300-init-subpbl.sml
test/Tools/isac/Test_Isac.thy
     1.1 --- a/src/Tools/isac/Interpret/calchead.sml	Fri Jul 15 13:51:50 2011 +0200
     1.2 +++ b/src/Tools/isac/Interpret/calchead.sml	Mon Jul 18 09:29:17 2011 +0200
     1.3 @@ -111,6 +111,7 @@
     1.4         (int list * string * Term.term * Term.term list) list
     1.5      val match_ags :
     1.6         theory -> pat list -> Term.term list -> SpecifyTools.ori list
     1.7 +    val oris2fmz_vals : ori list -> string list * term list
     1.8      val maxl : int list -> int
     1.9      val match_ags_msg : string list -> Term.term -> Term.term list -> unit
    1.10      val memI : ''a list -> ''a -> bool
    1.11 @@ -252,6 +253,13 @@
    1.12      foldl and_ (true, map #1 pre) andalso 
    1.13      dI<>e_domID andalso pI<>e_pblID andalso mI<>e_metID;
    1.14  
    1.15 +(*["BOOL (1+x=2)","REAL x"] --match_ags--> oris 
    1.16 +  --oris2fmz_vals--> ["equality (1+x=2)","boundVariable x","solutions L"]*)
    1.17 +fun oris2fmz_vals oris =
    1.18 +    let fun ori2fmz_vals ((_,_,_,dsc,ts):ori) = 
    1.19 +	    ((term2str o comp_dts') (dsc, ts), last_elem ts) 
    1.20 +	    handle _ => error ("ori2fmz_env called with "^terms2str ts)
    1.21 +    in (split_list o (map ori2fmz_vals)) oris end;
    1.22  
    1.23  (* make a term 'typeless' for comparing with another 'typeless' term;
    1.24     'type-less' usually is illtyped                                  *)
    1.25 @@ -1082,7 +1090,7 @@
    1.26          then ([], e_ctxt)
    1.27    	    else pI' |> #ppc o get_pbt |> prep_ori fmz thy
    1.28        val (pt,c) = cappend_problem e_ptree [] (e_istate, ctxt) (fmz,(dI',pI',mI'))
    1.29 -  			(oris, (dI',pI',mI'),e_term)
    1.30 +  			(oris, (dI',pI',mI'), e_term)
    1.31        val pt = update_ctxt pt [] ctxt
    1.32        val {ppc, prls, where_, ...} = get_pbt pI'
    1.33        val (pbl, pre, pb) = ([], [], false)
    1.34 @@ -1727,10 +1735,20 @@
    1.35      val (PblObj {fmz = (fmz_, _), origin = (pors, spec as (dI,pI,mI), hdl), ...}) = get_obj I pt p;
    1.36      val thy = assoc_thy dI;
    1.37  	  val {ppc, ...} = get_met mI;
    1.38 +    val (fmz_, vals) = oris2fmz_vals pors;
    1.39 +	  val ctxt = dI |> Thy_Info.get_theory |> ProofContext.init_global 
    1.40 +      |> declare_constraints' vals
    1.41 +    val pt = update_pblppc pt p (map (ori2Coritm ppc) pors);
    1.42 +	  val pt = update_metppc pt p (map (ori2Coritm ppc) pors); (*WN110716 = _pblppc ?!?*)
    1.43 +	  val pt = update_spec pt p (dI,pI,mI);
    1.44 +    val pt = update_ctxt pt p ctxt
    1.45 +(*
    1.46  	  val mors = prep_ori fmz_ thy ppc |> #1;
    1.47      val pt = update_pblppc pt p (map (ori2Coritm ppc) pors);
    1.48  	  val pt = update_metppc pt p (map (ori2Coritm ppc) mors);
    1.49 +    (*WN110715: why pors, mors handled so differently?*)
    1.50  	  val pt = update_spec pt p (dI,pI,mI);
    1.51 +*)
    1.52    in (pt, (p,Met): pos') end;
    1.53  
    1.54  (*WN0312: use in nxt_spec, too ? what about variants ???*)
     2.1 --- a/src/Tools/isac/Interpret/script.sml	Fri Jul 15 13:51:50 2011 +0200
     2.2 +++ b/src/Tools/isac/Interpret/script.sml	Mon Jul 18 09:29:17 2011 +0200
     2.3 @@ -348,14 +348,6 @@
     2.4  *)
     2.5  
     2.6  
     2.7 -(*["BOOL (1+x=2)","REAL x"] --match_ags--> oris 
     2.8 -  --oris2fmz_vals--> ["equality (1+x=2)","boundVariable x","solutions L"]*)
     2.9 -fun oris2fmz_vals oris =
    2.10 -    let fun ori2fmz_vals ((_,_,_,dsc,ts):ori) = 
    2.11 -	    ((term2str o comp_dts') (dsc, ts), last_elem ts) 
    2.12 -	    handle _ => error ("ori2fmz_env called with "^terms2str ts)
    2.13 -    in (split_list o (map ori2fmz_vals)) oris end;
    2.14 -
    2.15  (*detour necessary, because generate1 delivers a string-result*)
    2.16  fun mout2term thy (Form' (FormKF (_,_,_,_,res))) = 
    2.17    (term_of o the o (parse (assoc_thy thy))) res
    2.18 @@ -908,7 +900,7 @@
    2.19  (*this constructions doesnt allow arbitrary nesting of Or !!!*)
    2.20  
    2.21  
    2.22 -(*assy, ass_up, astep_up scanning for locate_gen at stactic in a script.
    2.23 +(*assy, ass_up, astep_up scan for locate_gen in a script.
    2.24    search is clearly separated into (1)-(2):
    2.25    (1) assy is recursive descent;
    2.26    (2) ass_up resumes interpretation at a location somewhere in the script;
     3.1 --- a/src/Tools/isac/Interpret/solve.sml	Fri Jul 15 13:51:50 2011 +0200
     3.2 +++ b/src/Tools/isac/Interpret/solve.sml	Mon Jul 18 09:29:17 2011 +0200
     3.3 @@ -366,18 +366,19 @@
     3.4  				       (pos, is))], [], (pt, pos))
     3.5  	         | _ => nxt_solv tac_ is ptp end;
     3.6  
     3.7 -(*.says how may steps of a calculation should be done by "fun autocalc".*)
     3.8 +(* says how may steps of a calculation should be done by "fun autocalc" *)
     3.9  (*TODO.WN0512 redesign togehter with autocalc ?*)
    3.10  datatype auto = 
    3.11    Step of int      (*1 do #int steps; may stop in model/specify:
    3.12  		     IS VERY INEFFICIENT IN MODEL/SPECIY*)
    3.13  | CompleteModel    (*2 complete modeling
    3.14 -                     if model complete, finish specifying + start solving*)
    3.15 +                       if model complete, finish specifying + start solving*)
    3.16  | CompleteCalcHead (*3 complete model/specify in one go + start solving*)
    3.17  | CompleteToSubpbl (*4 stop at the next begin of a subproblem,
    3.18 -                     if none, complete the actual (sub)problem*)
    3.19 +                       if none, complete the actual (sub)problem*)
    3.20  | CompleteSubpbl   (*5 complete the actual (sub)problem (incl.ev.subproblems)*)
    3.21  | CompleteCalc;    (*6 complete the calculation as a whole*)	
    3.22 +
    3.23  fun autoord (Step _ ) = 1
    3.24    | autoord CompleteModel = 2
    3.25    | autoord CompleteCalcHead = 3
    3.26 @@ -385,38 +386,6 @@
    3.27    | autoord CompleteSubpbl = 5
    3.28    | autoord CompleteCalc = 6;
    3.29  
    3.30 -(* val (auto, c, (ptp as (_, p))) = (auto, (c@c'), ptp);
    3.31 -   *)
    3.32 -fun complete_solve auto c (ptp as (_, p): ptree * pos') =
    3.33 -  if p = ([], Res)
    3.34 -  then ("end-of-calculation", [], ptp)
    3.35 -  else
    3.36 -    case nxt_solve_ ptp of
    3.37 -	    ((Subproblem _, tac_, (_, is))::_, c', ptp') =>
    3.38 -	      if autoord auto < 5
    3.39 -        then ("ok", c@c', ptp)
    3.40 -	      else
    3.41 -          let
    3.42 -            val ptp = all_modspec ptp';
    3.43 -	          val (_, c'', ptp) = all_solve auto (c@c') ptp;
    3.44 -	        in complete_solve auto (c@c'@c'') ptp end
    3.45 -    | ((Check_Postcond _, tac_, (_, is))::_, c', ptp' as (_, p')) =>
    3.46 -	      if autoord auto < 6 orelse p' = ([],Res)
    3.47 -        then ("ok", c @ c', ptp')
    3.48 -	      else complete_solve auto (c @ c') ptp'
    3.49 -    | ((End_Detail, _, _)::_, c', ptp') => 
    3.50 -	      if autoord auto < 6
    3.51 -        then ("ok", c @ c', ptp')
    3.52 -	      else complete_solve auto (c @ c') ptp'
    3.53 -    | (_, c', ptp') => complete_solve auto (c @ c') ptp'
    3.54 -
    3.55 -and all_solve auto c (ptp as (pt, pos as (p,_)): ptree * pos') = 
    3.56 -  let
    3.57 -    val (_,_,mI) = get_obj g_spec pt p;
    3.58 -    val ctxt = get_ctxt pt pos
    3.59 -    val (_, c', ptp) = nxt_solv (Apply_Method' (mI, NONE, e_istate, ctxt)) (e_istate, ctxt) ptp;
    3.60 -  in complete_solve auto (c @ c') ptp end;
    3.61 -
    3.62  fun complete_solve auto c (ptp as (_, p as (_,p_)): ptree * pos') =
    3.63    if p = ([], Res)
    3.64    then ("end-of-calculation", [], ptp)
     4.1 --- a/test/Tools/isac/ADDTESTS/All_Ctxt.thy	Fri Jul 15 13:51:50 2011 +0200
     4.2 +++ b/test/Tools/isac/ADDTESTS/All_Ctxt.thy	Mon Jul 18 09:29:17 2011 +0200
     4.3 @@ -15,7 +15,6 @@
     4.4  *}
     4.5  
     4.6  section {* start of specify phase *}
     4.7 -
     4.8  text {* variables known from formalisation provide type-inference 
     4.9    for further input *}
    4.10  
    4.11 @@ -37,7 +36,6 @@
    4.12  *}
    4.13  
    4.14  section {* start interpretation of method *}
    4.15 -
    4.16  text {* preconditions are known at start of interpretation of (root-)method *}
    4.17  
    4.18  ML {*
    4.19 @@ -45,16 +43,17 @@
    4.20  *}
    4.21  
    4.22  ML {*
    4.23 -val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.24 -val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.25 -val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.26 +  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.27 +  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.28 +  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
    4.29  *}
    4.30  
    4.31  section {* start a subproblem: specification *}
    4.32 +text {* 
    4.33 +  ctxt is initialised from the thy in "SubProblem (thy, pbl, met) args"
    4.34 +  and extended with the types of the variables in args. *}
    4.35  
    4.36 -text {* variables known from arguments of (sub-)method provide type-inference for further input *}
    4.37 -
    4.38 -ML {*
    4.39 +ML {* (*not significant in this example*)
    4.40    val ctxt = get_ctxt pt p;
    4.41    val SOME known_x = parseNEW ctxt "x+y+z";
    4.42    val SOME unknown = parseNEW ctxt "a+b+c";
     5.1 --- a/test/Tools/isac/Minisubpbl/300-init-subpbl.sml	Fri Jul 15 13:51:50 2011 +0200
     5.2 +++ b/test/Tools/isac/Minisubpbl/300-init-subpbl.sml	Mon Jul 18 09:29:17 2011 +0200
     5.3 @@ -25,6 +25,41 @@
     5.4  "~~~~~ fun locatetac, args:"; val (tac, ptp as (pt, p)) = (tac, (pt,p));
     5.5  val (mI,m) = mk_tac'_ tac;
     5.6  val Appl m = applicable_in p pt m;
     5.7 +member op = specsteps mI; (*false*)
     5.8 +(*val Updated (cs' as (_,_,(_,p'))) =  loc_solve_ (mI,m) ptp;*)
     5.9 +"~~~~~ fun loc_solve_, args:"; val (m, (pt,pos)) = ((mI,m), ptp);
    5.10 +(*val (msg, cs') = solve m (pt, pos);*)
    5.11 +"~~~~~ fun solve, args:"; val ((mI,m), (pt, po as (p,p_))) = (m, (pt, pos));
    5.12 +e_metID = get_obj g_metID pt (par_pblobj pt p) (*false*);
    5.13 +	      val thy' = get_obj g_domID pt (par_pblobj pt p);
    5.14 +	      val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
    5.15 +		      val d = e_rls; (*FIXME.WN0108: canon.simplifier for domain is missing: generate from domID?*)
    5.16 +(*val Steps (is', ss as (m',f',pt',p',c')::_) = locate_gen (thy',srls) m  (pt,(p,p_)) (sc,d) is;*)
    5.17 +"~~~~~ fun locate_gen, args:"; val ((ts as (thy',srls)), (m:tac_), ((pt,p):ptree * pos'), 
    5.18 +	                   (scr as Script (h $ body),d), (ScrState (E,l,a,v,S,b), ctxt)) =
    5.19 +                   ((thy',srls), m,  (pt,(p,p_)), (sc,d), is);
    5.20 +val thy = assoc_thy thy';
    5.21 +l = [] orelse ((*init.in solve..Apply_Method...*)
    5.22 +			         (last_elem o fst) p = 0 andalso snd p = Res) (*false*);
    5.23 +(*val Assoc (iss as (is as (_,_,_,_,_,bb), ss as ((m',f',pt',p',c')::_))) =
    5.24 +    (astep_up (thy',srls,scr,d) ((E,l,a,v,S,b), [(m,EmptyMout,pt,p,[])]) );*)
    5.25 +"~~~~~ fun astep_up, args:"; val ((ys as (_,_,Script sc,_)), ((E,l,a,v,S,b),ss)) =
    5.26 +                     ((thy',srls,scr,d), ((E,l,a,v,S,b), [(m,EmptyMout,pt,p,[])]) );
    5.27 +1 < length l (*true*);
    5.28 +val up = drop_last l;
    5.29 +(*ass_up ys ((E,up,a,v,S,b),ss) (go up sc);*)
    5.30 +"~~~~~ fun ass_up, args:"; val (ysa, iss, (Const ("Script.Try",_) $ e)) =
    5.31 +                                             (ys, ((E,up,a,v,S,b),ss), (go up sc));
    5.32 +(* STOPPED stepping into HERE due to type problem:  Can't unify _a to pos * pos_
    5.33 +astep_up ysa iss;
    5.34 +
    5.35 +at bottom of | assy we see:
    5.36 +                 :
    5.37 +                 case assod pt d m stac of
    5.38 +"~~~~~ fun assod, args:"; val (...Subproblem'...) = ();
    5.39 +	      val ctxt = dI |> Thy_Info.get_theory |> ProofContext.init_global 
    5.40 +          |> declare_constraints' vals
    5.41 +*)
    5.42  
    5.43  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    5.44  case nxt of ("Model_Problem", _) => ()
     6.1 --- a/test/Tools/isac/Test_Isac.thy	Fri Jul 15 13:51:50 2011 +0200
     6.2 +++ b/test/Tools/isac/Test_Isac.thy	Mon Jul 18 09:29:17 2011 +0200
     6.3 @@ -14,9 +14,9 @@
     6.4    "ADDTESTS/Ctxt"
     6.5    "ADDTESTS/test-depend/Build_Test"
     6.6    "ADDTESTS/All_Ctxt"
     6.7 -(*"ADDTESTS/course/T2_Rewriting" theory has not been declared*)
     6.8 -(*"ADDTESTS/course/T1_Basics.thy" could not find ^^^*)
     6.9 -(*"ADDTESTS/course/T3_MathEngine" could not find ^^^*)
    6.10 +  "ADDTESTS/course/phst11/T1_Basics" (*could not find ^^^*)
    6.11 +  "ADDTESTS/course/phst11/T2_Rewriting"
    6.12 +  "ADDTESTS/course/phst11/T3_MathEngine" (*could not find ^^^*)
    6.13    "ADDTESTS/file-depend/Build_Test"
    6.14    "../../Pure/Isar/Test_Parsers"
    6.15  (*"../../Pure/Isar/Pure/Isar/Struct_Deriv" update 2009-2-->2011*)
    6.16 @@ -150,113 +150,56 @@
    6.17  autoord auto > 3 andalso just_created (pt, pos); (*true*)
    6.18  val ptp = all_modspec (pt, pos);
    6.19  (*all_solve auto c ptp; (*WAS Type unification failed...*)*)
    6.20 -"~~~~~ and all_solve, args:"; val (auto, c, (ptp as (pt, pos as (p,_)))) = (auto, c, ptp);
    6.21 +"~~~~~ and all_solve, args:"; val (auto, c, (ptp as (pt, pos as (p,_)))) =
    6.22 +                                                                  (auto, c, ptp);
    6.23      val (_,_,mI) = get_obj g_spec pt p
    6.24      val ctxt = get_ctxt pt pos
    6.25 -    val (_, c', ptp) = nxt_solv (Apply_Method' (mI, NONE, e_istate, ctxt))
    6.26 -			      (e_istate, ctxt) ptp;
    6.27 +    val (ttt, c', ptp) = nxt_solv (Apply_Method' (mI, NONE, e_istate, ctxt)) (e_istate, ctxt) ptp;
    6.28  (* complete_solve auto (c @ c') ptp; (*WAS Type unification failed...*) pos = ([], Met)*)
    6.29 -"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p))) = (auto, (c @ c'), ptp);
    6.30 +"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p as (_,p_)))) =
    6.31 +                                                           (auto, (c @ c'), ptp);
    6.32  p = ([], Res) (*false p = ([1], Frm)*);
    6.33 -val (_, c', ptp') = nxt_solve_ ptp;
    6.34 -(* complete_solve auto (c @ c') ptp; (*WAS Type unification failed...*)*)
    6.35 -"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p))) = (auto, (c @ c'), ptp');
    6.36 +member op = [Pbl,Met] p_ (*false*);
    6.37 +val (ttt, c', ptp') = nxt_solve_ ptp; (*ttt = Rewrite_Set "norm_equation"*)
    6.38 +(* complete_solve auto (c @ c') ptp'; (*WAS Type unification failed...*) pos = ([], Met)*)
    6.39 +"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p as (_,p_)))) =
    6.40 +                                                           (auto, (c @ c'), ptp');
    6.41  p = ([], Res) (*false p = ([1], Res)*);
    6.42 -val (_, c', ptp') = nxt_solve_ ptp;
    6.43 -(* complete_solve auto (c @ c') ptp; (*WAS Type unification failed...*)*)
    6.44 -"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p))) = (auto, (c @ c'), ptp');
    6.45 +member op = [Pbl,Met] p_ (*false*);
    6.46 +val (ttt, c', ptp') = nxt_solve_ ptp; (*ttt = Rewrite_Set "Test_simplify"*)
    6.47 +(* complete_solve auto (c @ c') ptp'; (*WAS Type unification failed...*) pos = ([], Met)*)
    6.48 +"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p as (_,p_)))) =
    6.49 +                                                           (auto, (c @ c'), ptp');
    6.50  p = ([], Res) (*false p = ([2], Res)*);
    6.51  member op = [Pbl,Met] p_ (*false*);
    6.52 -val (_, c', ptp') = nxt_solve_ ptp;
    6.53 -(* complete_solve auto (c @ c') ptp; (*WAS Type unification failed...*)*)
    6.54 -"~~~~~ fun complete_solve, args:"; val (auto, c, (ptp as (_, p))) = (auto, (c @ c'), ptp');
    6.55 -p = ([], Res) (*false p = ([3], Pbl)*);
    6.56 -member op = [Pbl,Met] p_ (*true*);
    6.57 -(*val ptp = all_modspec ptp; (*WAS Type unification failed...*)*)
    6.58 -"~~~~~ fun all_modspec, args:"; val (pt, (p,_):pos') = (ptp);
    6.59 -*}
    6.60 -ML {*
    6.61 +val ((Subproblem _, tac_, (_, is))::_, c', ptp') = nxt_solve_ ptp;
    6.62 +autoord auto < 5 (*false*);
    6.63 +(* val ptp = all_modspec ptp' (*WAS Type unification failed...*)*)
    6.64 +"~~~~~ fun all_modspec, args:"; val (pt, (p,_)) = (ptp');
    6.65      val (PblObj {fmz = (fmz_, _), origin = (pors, spec as (dI,pI,mI), hdl), ...}) = get_obj I pt p;
    6.66      val thy = assoc_thy dI;
    6.67 -	  val {ppc, ...} = get_met mI;
    6.68 -	*}
    6.69 -ML {*
    6.70 -fmz_; ppc;
    6.71 -*}
    6.72 -ML {*
    6.73 -*}
    6.74 -ML {*
    6.75 -(*  val (mors, ctxt) = prep_ori fmz_ thy ppc; *)
    6.76 -*}
    6.77 -ML {*
    6.78 -*}
    6.79 -ML {*
    6.80 -*}
    6.81 -ML {*
    6.82 -*}
    6.83 -ML {*
    6.84 -*}
    6.85 -ML {*
    6.86 -*}
    6.87 -ML {*
    6.88 -*}
    6.89 -ML {*
    6.90 -
    6.91 -
    6.92 -*}
    6.93 -ML {*
    6.94 -*}
    6.95 -ML {*
    6.96 -"~~~~~ fun nxt_solve_, args:"; val (ptp as (pt, pos as (p,p_))) = (ptp);
    6.97 -e_metID = get_obj g_metID pt (par_pblobj pt p) (*false*);
    6.98 -        val thy' = get_obj g_domID pt (par_pblobj pt p);
    6.99 -*}
   6.100 -ML {*
   6.101 -"~~~~~ fun from_pblobj_or_detail', args:"; val (thy', (p,p_), pt) = (thy', (p,p_), pt);
   6.102 -val ctxt = get_ctxt pt (p,p_);
   6.103 -member op = [Pbl,Met] p_ (*true*);
   6.104 -get_obj g_env pt p
   6.105 -*}
   6.106 -ML {*
   6.107 -(p,p_)
   6.108 -*}
   6.109 -ML {*
   6.110 -*}
   6.111 -ML {*
   6.112 -*}
   6.113 -ML {*
   6.114 -*}
   6.115 -ML {*
   6.116 -*}
   6.117 -ML {*
   6.118 -*}
   6.119 -ML {*
   6.120 -*}
   6.121 -ML {* 
   6.122 -print_depth 999;
   6.123 -(*
   6.124 -val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt; (*from_pblobj_or_detail': no istate*)
   6.125 -
   6.126 -val (_, c', ptp') = nxt_solve_ ptp; (*from_pblobj_or_detail': no istate*)
   6.127 -...
   6.128 -complete_solve auto (c @ c') ptp
   6.129 -  -"-                                                    
   6.130 -all_solve auto c ptp;
   6.131 -  -"-                                                    
   6.132 -autocalc [] pold (get_calc cI) auto;  (*Type unification failed
   6.133 -  Type error in application: incompatible operand type
   6.134 -  Operator:  solveFor :: real \<Rightarrow> una
   6.135 -  Operand:   x :: 'a *)
   6.136 -autoCalculate 1 CompleteCalc; (*WAS <SYSERROR>..<ERROR> error in kernel </ERROR>*)
   6.137 -*)
   6.138 -*}
   6.139 -ML {*
   6.140 -print_depth 5;
   6.141 -*}
   6.142 -ML {*
   6.143 -(*
   6.144 -
   6.145 -*)
   6.146 +	    val {ppc, ...} = get_met mI;
   6.147 +(*  val (mors, ctxt) = prep_ori fmz_ thy ppc; WAS Type unification failed because
   6.148 +val ctxt' = dI |> Thy_Info.get_theory |> ProofContext.init_global;
   6.149 +(parseNEW ctxt' "x" |> the |> type_of) = TFree ("'a",[]); *)
   6.150 +(*vvv from:  | assod pt _ (Subproblem'...*)
   6.151 +    val (fmz_, vals) = oris2fmz_vals pors;
   6.152 +	    val ctxt = dI |> Thy_Info.get_theory |> ProofContext.init_global 
   6.153 +      |> declare_constraints' vals
   6.154 +(*^^^ from:  | assod pt _ (Subproblem'...*)
   6.155 +val [(1, [1], "#Given", dsc_eq, [equality]),
   6.156 +     (2, [1], "#Given", dsc_solvefor, [xxx]),
   6.157 +     (3, [1], "#Find", dsc_solutions, [x_i])] = pors;
   6.158 +if term2str xxx = "x" andalso type_of xxx = HOLogic.realT then () 
   6.159 +else error "autoCalculate..CompleteCalc: SubProblem broken 1";
   6.160 +    val pt = update_pblppc pt p (map (ori2Coritm ppc) pors);
   6.161 +	    val pt = update_metppc pt p (map (ori2Coritm ppc) pors);
   6.162 +	    val pt = update_spec pt p (dI,pI,mI);
   6.163 +    val pt = update_ctxt pt p ctxt;
   6.164 +"~~~~~ return to complete_solve, args:"; val (ptp) = (pt, (p,Met));
   6.165 +case complete_solve auto (c @ c') ptp of
   6.166 +  ("end-of-calculation",[],(_,([], Res))) => ()
   6.167 +| _ => error "autoCalculate..CompleteCalc: SubProblem broken 2";
   6.168  *}
   6.169  
   6.170