src/Tools/isac/Interpret/mstools.sml
author Walther Neuper <neuper@ist.tugraz.at>
Tue, 28 Sep 2010 09:06:56 +0200
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38015 67ba02dffacc
child 38050 4c52ad406c20
permissions -rw-r--r--
tuned error and writeln

# raise error --> error
# writeln in atomtyp, atomty, atomt and xmlsrc
     1 (* Types and tools for 'modeling' und 'specifying' to be used in
     2    modspec.sml. The types are separated from calchead.sml into this file,
     3    because some of them are stored in the calc-tree, and thus are required
     4    _before_ ctree.sml. 
     5    author: Walther Neuper
     6    (c) due to copyright terms
     7 
     8 use"ME/mstools.sml" (*re-evaluate sml/ from scratch!*);
     9 use"mstools.sml";
    10 12345678901234567890123456789012345678901234567890123456789012345678901234567890
    11         10        20        30        40        50        60        70        80
    12 *)
    13 
    14 signature SPECIFY_TOOLS =
    15   sig
    16     type envv
    17     datatype
    18       item =
    19           Correct of cterm'
    20         | False of cterm'
    21         | Incompl of cterm'
    22         | Missing of cterm'
    23         | Superfl of string
    24         | SyntaxE of string
    25         | TypeE of string
    26     val item2str : item -> string
    27     type itm
    28     val itm2str_ : Proof.context -> itm -> string
    29     datatype
    30       itm_ =
    31           Cor of (term * term list) * (term * term list)
    32         | Inc of (term * term list) * (term * term list)
    33         | Mis of term * term
    34         | Par of cterm'
    35         | Sup of term * term list
    36         | Syn of cterm'
    37         | Typ of cterm'
    38     val itm_2str : itm_ -> string
    39     val itm_2str_ : Proof.context -> itm_ -> string
    40     val itms2str_ : Proof.context -> itm list -> string
    41     type 'a ppc
    42     val ppc2str :
    43        {Find: string list, With: string list, Given: string list,
    44          Where: string list, Relate: string list} -> string
    45     datatype
    46       match =
    47           Matches of pblID * item ppc
    48         | NoMatch of pblID * item ppc
    49     val match2str : match -> string
    50     datatype
    51       match_ =
    52           Match_ of pblID * (itm list * (bool * term) list)
    53         | NoMatch_
    54     val matchs2str : match list -> string
    55     type ori
    56     val ori2str : ori -> string
    57     val oris2str : ori list -> string
    58     type preori
    59     val preori2str : preori -> string
    60     val preoris2str : preori list -> string
    61     type penv
    62     (* val penv2str_ : Proof.context -> penv -> string *)
    63     type vats
    64     (*----------------------------------------------------------------------*)
    65     val all_ts_in : itm_ list -> term list
    66     val check_preconds :
    67        'a ->
    68        rls ->
    69        term list -> itm list -> (bool * term) list
    70     val check_preconds' :
    71        rls ->
    72        term list ->
    73        itm list -> 'a -> (bool * term) list
    74    (* val chkpre2item : rls -> term -> bool * item  *)
    75     val pres2str : (bool * term) list -> string
    76    (* val evalprecond : rls -> term -> bool * term  *)
    77    (* val cnt : itm list -> int -> int * int *)
    78     val comp_dts : theory -> term * term list -> term
    79     val comp_dts' : term * term list -> term
    80     val comp_dts'' : term * term list -> string
    81     val comp_ts : term * term list -> term
    82     val d_in : itm_ -> term
    83     val de_item : item -> cterm'
    84     val dest_list : term * term list -> term list (* for testing *)
    85     val dest_list' : term -> term list
    86     val dts2str : term * term list -> string
    87     val e_itm : itm
    88   (*  val e_listBool : term  *)
    89   (*  val e_listReal : term  *)
    90     val e_ori : ori
    91     val e_ori_ : ori
    92     val empty_ppc : item ppc
    93    (* val empty_ppc_ct' : cterm' ppc *)
    94    (* val getval : term * term list -> term * term *)
    95    (*val head_precond :
    96        domID * pblID * 'a ->
    97        term option ->
    98        rls ->
    99        term list ->
   100        itm list -> 'b -> term * (bool * term) list*)
   101    (* val init_item : string -> item *)
   102    (* val is_matches : match -> bool *)
   103    (* val is_matches_ : match_ -> bool *)
   104     val is_var : term -> bool
   105    (* val item_ppc :
   106        string ppc -> item ppc  *)
   107     val itemppc2str : item ppc -> string
   108    (* val matches_pblID : match -> pblID *)
   109     val max2 : ('a * int) list -> 'a * int
   110     val max_vt : itm list -> int
   111     val mk_e : itm_ -> (term * term) list
   112     val mk_en : int -> itm -> (term * term) list
   113     val mk_env : itm list -> (term * term) list
   114     val mkval : 'a -> term list -> term
   115     val mkval' : term list -> term
   116    (* val pblID_of_match : match -> pblID *)
   117     val pbl_ids : Proof.context -> term -> term -> term list
   118     val pbl_ids' : 'a -> term -> term list -> term list
   119    (* val pen2str : theory -> term * term list -> string *)
   120     val penvval_in : itm_ -> term list
   121     val refined : match list -> pblID
   122     val refined_ :
   123        match_ list -> match_ option
   124   (*  val refined_IDitms :
   125        match list -> match option  *)
   126     val split_dts : 'a -> term -> term * term list
   127     val split_dts' : term * term -> term list
   128   (*  val take_apart : term -> term list  *)
   129   (*  val take_apart_inv : term list -> term *)
   130     val ts_in : itm_ -> term list
   131    (* val unique : term  *)
   132     val untouched : itm list -> bool
   133     val upd :
   134        Proof.context ->
   135        (''a * (''b * term list) list) list ->
   136        term ->
   137        ''b * term -> ''a -> ''a * (''b * term list) list
   138     val upd_envv :
   139        Proof.context ->
   140        envv ->
   141        vats ->
   142        term -> term -> term -> envv
   143     val upd_penv :
   144        Proof.context ->
   145        (''a * term list) list ->
   146        term -> ''a * term -> (''a * term list) list
   147    (* val upds_envv :
   148        Proof.context ->
   149        envv ->
   150        (vats * term * term * term) list ->
   151        envv                         *)
   152     val vts_cnt : int list -> itm list -> (int * int) list
   153     val vts_in : itm list -> int list
   154    (* val w_itms2str_ : Proof.context -> itm list -> unit *)
   155   end
   156 
   157 (*----------------------------------------------------------*)
   158 structure SpecifyTools : SPECIFY_TOOLS =
   159 struct
   160 (*----------------------------------------------------------*)
   161 val e_listReal = (term_of o the o (parse (theory "Script"))) "[]::(real list)";
   162 val e_listBool = (term_of o the o (parse (theory "Script"))) "[]::(bool list)";
   163 
   164 (*.take list-term apart w.r.t. handling elementwise input.*)
   165 fun take_apart t =
   166     let val elems = isalist2list t
   167     in map ((list2isalist (type_of (hd elems))) o single) elems end;
   168 (*val t = str2term "[a, b]";
   169 > val ts = take_apart t; tracing (terms2str ts);
   170 ["[a]","[b]"] 
   171 
   172 > t = (take_apart_inv o take_apart) t;
   173 true*)
   174 fun take_apart_inv ts =
   175     let val elems = (flat o (map isalist2list)) ts;
   176     in list2isalist (type_of (hd elems)) elems end;
   177 (*val ts = [str2term "[a]", str2term "[b]"];
   178 > val t = take_apart_inv ts; term2str t;
   179 "[a, b]"
   180 
   181 ts = (take_apart o take_apart_inv) ts;
   182 true*)
   183 
   184 
   185 
   186 
   187 (*.revert split_dts only for ts; compare comp_dts.*)
   188 fun comp_ts (d, ts) = 
   189     if is_list_dsc d
   190     then if is_list (hd ts)
   191 	 then if is_unl d
   192 	      then (hd ts)            (*e.g. someList [1,3,2]*)
   193 	      else (take_apart_inv ts) 
   194 	 (*             SML[ [a], [b] ]SML --> [a,b]             *)
   195 	 else (hd ts) (*a variable or metavariable for a list*)
   196     else (hd ts);
   197 (*.revert split_.
   198  WN050903 we do NOT know which is from subtheory, description or term;
   199  typecheck thus may lead to TYPE-error 'unknown constant';
   200  solution: typecheck with Isac.thy; i.e. arg 'thy' superfluous*)
   201 (*fun comp_dts thy (d,[]) = 
   202     cterm_of (*(sign_of o assoc_thy) "Isac.thy"*)
   203 	     (theory "Isac")
   204 	     (*comp_dts:FIXXME stay with term for efficiency !!!*)
   205 	     (if is_reall_dsc d then (d $ e_listReal)
   206 	      else if is_booll_dsc d then (d $ e_listBool)
   207 	      else d)
   208   | comp_dts thy (d,ts) =
   209     (cterm_of (*(sign_of o assoc_thy) "Isac.thy"*)
   210 	      (theory "Isac")
   211 	      (*comp_dts:FIXXME stay with term for efficiency !!*)
   212 	      (d $ (comp_ts (d, ts)))
   213        handle _ => error ("comp_dts: "^(term2str d)^
   214 				" $ "^(term2str (hd ts))));*)
   215 fun comp_dts thy (d,[]) = 
   216 	     (if is_reall_dsc d then (d $ e_listReal)
   217 	      else if is_booll_dsc d then (d $ e_listBool)
   218 	      else d)
   219   | comp_dts thy (d,ts) =
   220 	      (d $ (comp_ts (d, ts)))
   221        handle _ => error ("comp_dts: "^(term2str d)^
   222 				" $ "^(term2str (hd ts))); 
   223 (*25.8.03*)
   224 fun comp_dts' (d,[]) = 
   225     if is_reall_dsc d then (d $ e_listReal)
   226     else if is_booll_dsc d then (d $ e_listBool)
   227     else d
   228   | comp_dts' (d,ts) = (d $ (comp_ts (d, ts)))
   229        handle _ => error ("comp_dts': "^(term2str d)^
   230 				" $ "^(term2str (hd ts))); 
   231 (*val t = str2term "maximum A"; 
   232 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   233 val it = "maximum A" : cterm
   234 > val t = str2term "fixedValues [r=Arbfix]"; 
   235 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   236 "fixedValues [r = Arbfix]"
   237 > val t = str2term "valuesFor [a]"; 
   238 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   239 "valuesFor [a]"
   240 > val t = str2term "valuesFor [a,b]"; 
   241 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   242 "valuesFor [a, b]"
   243 > val t = str2term "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]"; 
   244 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   245 relations [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]"
   246 > val t = str2term "boundVariable a";
   247 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   248 "boundVariable a"
   249 > val t = str2term "interval {x::real. 0 <= x & x <= 2*r}"; 
   250 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   251 "interval {x. 0 <= x & x <= 2 * r}"
   252 
   253 > val t = str2term "equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))"; 
   254 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   255 "equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))"
   256 > val t = str2term "solveFor x"; 
   257 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   258 "solveFor x"
   259 > val t = str2term "errorBound (eps=0)"; 
   260 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   261 "errorBound (eps = 0)"
   262 > val t = str2term "solutions L";
   263 > val (d,ts) = split_dts thy t; comp_dts thy (d,ts);
   264 "solutions L"
   265 
   266 before 6.5.03:
   267 > val t = (term_of o the o (parse thy)) "testdscforlist [#1]";
   268 > val (d,ts) = split_dts t;
   269 > comp_dts thy (d,ts);
   270 val it = "testdscforlist [#1]" : cterm
   271 
   272 > val t = (term_of o the o (parse thy)) "(A::real)";
   273 > val (d,ts) = split_dts t;
   274 val d = Const ("empty","empty") : term
   275 val ts = [Free ("A","RealDef.real")] : term list
   276 > val t = (term_of o the o (parse thy)) "[R=(R::real)]";
   277 > val (d,ts) = split_dts t;
   278 val d = Const ("empty","empty") : term
   279 val ts = [Const # $ Free # $ Free (#,#)] : term list
   280 > val t = (term_of o the o (parse thy)) "[#1,#2]";
   281 > val (d,ts) = split_dts t;
   282 val ts = [Free ("#1","'a"),Free ("#2","'a")] : NOT WANTED
   283 *)
   284 
   285 (*for input_icalhd 11.03*)
   286 fun comp_dts'' (d,[]) = 
   287     if is_reall_dsc d then term2str (d $ e_listReal)
   288     else if is_booll_dsc d then term2str (d $ e_listBool)
   289     else term2str d
   290   | comp_dts'' (d,ts) = term2str (d $ (comp_ts (d, ts)))
   291        handle _ => error ("comp_dts'': "^(term2str d)^
   292 				" $ "^(term2str (hd ts))); 
   293 
   294 
   295 
   296 
   297 
   298 
   299 (* this may decompose an object-language isa-list;
   300    use only, if description is not available, eg. not input ?WN:14.5.03 ??!?*)
   301 fun dest_list' t = if is_list t then isalist2list t  else [t];
   302 
   303 (*fun is_metavar (Free (str, _)) =
   304     if (last_elem o explode) str = "_" then true else false
   305   | is_metavar _ = false;*)
   306 fun is_var (Free _) = true
   307   | is_var _ = false;
   308 
   309 (*.special handling for lists. ?WN:14.5.03 ??!?*)
   310 fun dest_list (d,ts) = 
   311   let fun dest t = 
   312     if is_list_dsc d andalso not (is_unl d) 
   313       andalso not (is_var t) (*..for pbt*)
   314       then isalist2list t  else [t]
   315   in (flat o (map dest)) ts end;
   316 
   317 
   318 (*.decompose an input into description, terms (ev. elems of lists),
   319     and the value for the problem-environment; inv to comp_dts .*)
   320 (*WN.8.6.03: corrected with minimal effort,
   321 fn : theory -> term ->
   322      term *       description
   323      term list *  lists decomposed for elementwise input
   324      term list    pbl_ids not _HERE_: dont know which list-elems input*)
   325 fun split_dts thy (t as d $ arg) =
   326     if is_dsc d
   327     then if is_list_dsc d
   328 	 then if is_list arg
   329 	      then if is_unl d
   330 		   then (d, [arg])                 (*e.g. someList [1,3,2]*)
   331 		   else (d, take_apart arg)(*[a,b] --> SML[ [a], [b] ]SML*)
   332 	      else (d, [arg])      (*a variable or metavariable for a list*)
   333 	 else (d, [arg])
   334     else (e_term, dest_list' t(*9.01 ???*))
   335   | split_dts thy t = (*either dsc or term*)
   336   let val (h,argl) = strip_comb t
   337   in if (not o is_dsc) h then (e_term, dest_list' t)
   338      else (h, dest_list (h,argl))
   339   end;
   340 (* tests see fun comp_dts 
   341 
   342 > val t = str2term "someList []";
   343 > val (_,ts) = split_dts thy t; tracing (terms2str ts);
   344 ["[]"]
   345 > val t = str2term "valuesFor []";
   346 > val (_,ts) = split_dts thy t; tracing (terms2str ts);
   347 ["[]"]*)
   348 
   349 (*.version returning ts only.*)
   350 fun split_dts' (d, arg) = 
   351     if is_dsc d
   352     then if is_list_dsc d
   353 	 then if is_list arg
   354 	      then if is_unl d
   355 		   then ([arg])                 (*e.g. someList [1,3,2]*)
   356 		   else (take_apart arg)(*[a,b] --> SML[ [a], [b] ]SML*)
   357 	      else ([arg])      (*a variable or metavariable for a list*)
   358 	 else ([arg])
   359     else (dest_list' arg(*9.01 ???*))
   360   | split_dts' (d, t) = (*either dsc or term; 14.5.03 only copied*)
   361   let val (h,argl) = strip_comb t
   362   in if (not o is_dsc) h then (dest_list' t)
   363      else (dest_list (h,argl))
   364   end;
   365 
   366 
   367 
   368 
   369 
   370 (*27.8.01: problem-environment
   371 WN.6.5.03: FIXXME reconsider if penv is worth the effort --
   372            -- just rerun a whole expl with num/var may show the same ?!
   373 WN.9.5.03: penv-concept stalled, immediately generate script env !
   374            but [#0, epsilon] only outcommented for eventual reconsideration  
   375 *)
   376 type penv = (term          (*err_*)
   377 	     * (term list) (*[#0, epsilon] 9.5.03 outcommented*)
   378 	     ) list;
   379 fun pen2str ctxt (t, ts) =
   380     pair2str(Syntax.string_of_term ctxt t,
   381 	     (strs2str' o map (Syntax.string_of_term ctxt)) ts);
   382 fun penv2str_ thy (penv:penv) = (strs2str' o (map (pen2str thy))) penv;
   383 
   384 (*
   385   9.5.03: still unused, but left for eventual future development*)
   386 type envv = (int * penv) list; (*over variants*)
   387 
   388 (*. 14.9.01: not used after putting penv-values into itm_
   389       make the result of split_* a value of problem-environment .*)
   390 fun mkval dsc [] = error "mkval called with []"
   391   | mkval dsc [t] = t
   392   | mkval dsc ts = list2isalist ((type_of o hd) ts) ts;
   393 (*WN.12.12.03*)
   394 fun mkval' x = mkval e_term x;
   395 
   396 
   397 
   398 (*. get the constant value from a penv .*)
   399 fun getval (id, values) = 
   400     case values of
   401 	[] => error ("penv_value: no values in '"^
   402 			   (Syntax.string_of_term (thy2ctxt' "Tools") id))
   403       | [v] => (id, v)
   404       | (v1::v2::_) => (case v1 of 
   405 			     Const ("Script.Arbfix",_) => (id, v2)
   406 			   | _ => (id, v1));
   407 (*
   408   val e_ = (term_of o the o (parse thy)) "e_::bool";
   409   val ev = (term_of o the o (parse thy)) "#4 + #3 * x^^^#2 = #0";
   410   val v_ = (term_of o the o (parse thy)) "v_";
   411   val vv = (term_of o the o (parse thy)) "x";
   412   val r_ = (term_of o the o (parse thy)) "err_::bool";
   413   val rv1 = (term_of o the o (parse thy)) "#0";
   414   val rv2 = (term_of o the o (parse thy)) "eps";
   415 
   416   val penv = [(e_,[ev]),(v_,[vv]),(r_,[rv2,rv2])]:penv;
   417   map getval penv;
   418 [(Free ("e_","bool"),
   419   Const (#,#) $ (# $ # $ (# $ #)) $ Free ("#0","RealDef.real")),
   420  (Free ("v_","RealDef.real"),Free ("x","RealDef.real")),
   421  (Free ("err_","bool"),Free ("#0","RealDef.real"))] : (term * term) list      
   422 *)
   423 
   424 
   425 (*==========================================================================
   426 23.3.02 TODO: ideas on redesign of type itm_,type item,type ori,type item ppc
   427 (1) kinds of itms:
   428   (1.1) untouched: for modeling only dsc displayed(impossible after match_itms)
   429         =(presently) Mis (? should be Inc initially, and Mis after match_itms?)
   430   (1.2)  Syn,Typ,Sup: not related to oris
   431     Syn, Typ (presently) should be accepted in appl_add (instead Error')
   432     Sup      (presently) should be accepted in appl_add (instead Error')
   433          _could_ be w.r.t current vat (and then _is_ related to vat
   434     Mis should _not_ be  made Inc ((presently, by appl_add & match_itms)
   435 - dsc in itm_ is timeconsuming -- keep id for respective queries ?
   436 - order of items in ppc should be stable w.r.t order of itms
   437 
   438 - stepwise input of itms --- match_itms (in one go) ..not coordinated
   439   - unify code
   440   - match_itms / match_itms_oris ..2 versions ?!
   441     (fast, for refine / slow, for modeling)
   442 
   443 - clarify: efficiency <--> simplicity !!!
   444   ?: shift dsc itm_ -> itm | discard int in ori,itm | take int instead dsc 
   445     | take int for perserving order of item ppc in itms 
   446     | make all(!?) handling of itms stable against reordering(?)
   447     | field in ori ?? (not from fmz!) -- meant for efficiency (not doc!???)
   448       -"- "#undef" ?= not touched ?= (id,..)
   449 -----------------------------------------------------------------
   450 27.3.02:
   451 def: type pbt = (field, (dsc, pid)) *** design considerations ***
   452 
   453 (1) fmz + pbt -> oris
   454 (2) input + oris -> itm
   455 (3) match_itms      : schnell(?) f"ur refine
   456     match_itms_oris : r"uckmeldung f"ur item ppc
   457 
   458 (1.1) in oris fehlt daher pid: (i,v,f,d,ts,pid)
   459 ---------- ^^^^^ --- dh. pbt meist als argument zu viel !!!
   460 
   461 (3.1) abwarten, wie das matchen mehr unterschiedlicher pbt's sich macht;
   462       wenn Problem pbt v"ollig neue, dann w"are eigentlich n"otig ????:
   463       (a) (_,_,d1,ts,_):ori + pbt -> (i,vt,d2,ts,pid)  dh.vt neu  ????
   464       (b) 
   465 ==========================================================================*)
   466 
   467 (*the internal representation of a models' item
   468 
   469   4.9.01: not consistent:
   470   after Init_Proof 'Inc', but after copy_probl 'Mis' - for same situation
   471   (involves 'is_error');
   472   bool in itm really necessary ???*)
   473 datatype itm_ = 
   474     Cor of (term *              (* description *)
   475 	    (term list)) *      (* for list: elem-wise input *) 
   476 	   (*split_dts <-> comp_dts*)
   477 	   (term * (term list)) (* elem of penv *)
   478 	 (*9.5.03:  ---- is already for script -- penv delayed to future*)
   479   | Syn of cterm'
   480   | Typ of cterm'
   481   | Inc of (term * (term list))	* (term * (term list)) (*lists,
   482 				+ init_pbl WN.11.03 FIXXME: empty penv .. bad
   483                                 init_pbl should return Mis !!!*)
   484   | Sup of (term * (term list)) (* user-input not found in pbt(+?oris?11.03)*)
   485   | Mis of (term * term)        (* after re-specification pbt-item not found 
   486                                    in pbl: only dsc, pid_*)
   487   | Par of cterm';  (*internal state from fun parsitm*)
   488 
   489 type vats = int list;      (*variants in formalizations*)
   490 
   491 (*.data-type for working on pbl/met-ppc: 
   492    in pbl initially holds descriptions (only) for user guidance.*)
   493 type itm = 
   494   int *        (* id  =0 .. untouched - descript (only) from init 
   495 		  23.3.02: seems to correspond to ori (fun insert_ppc)
   496 		           <> maintain order in item ppc?*)
   497   vats *       (* variants - copy from ori *)
   498   bool *       (* input on this item is not/complete *)
   499   string *     (* #Given | #Find | #Relate *)
   500   itm_;        (*  *)
   501 (* use"ME/sequent.sml";
   502    *)
   503 val e_itm = (0,[],false,"e_itm",Syn"e_itm"):itm;
   504 (*in CalcTree/Subproblem an 'untouched' model is created
   505   FIXME.WN.9.03 model should be filled to 'untouched' by Model/Refine_Problem*)
   506 fun untouched (itms: itm list) = 
   507     foldl and_ (true ,map ((curry op= 0) o #1) itms);
   508 (*> untouched [];
   509 val it = true : bool
   510 > untouched [e_itm];
   511 val it = true : bool
   512 > untouched [e_itm, (1,[],false,"e_itm",Syn "e_itm")];
   513 val it = false : bool*)
   514 
   515 
   516 
   517 
   518 
   519 (* find most frequent variant v in itms *)
   520 
   521 fun vts_in itms = (distinct o flat o (map #2)) (itms:itm list);
   522 
   523 fun cnt itms v = (v,(length o (filter (curry op= v)) o 
   524 		     flat o (map #2)) (itms:itm list));
   525 fun vts_cnt vts itms = map (cnt itms) vts;
   526 fun max2 [] = error "max2 of []"
   527   | max2 (y::ys) =
   528   let fun mx (a,x) [] = (a,x)
   529 	| mx (a,x) ((b,y)::ys) = 
   530     if x < y then mx (b,y) ys else mx (a,x) ys;
   531 in mx y ys end;
   532 
   533 (*. find the variant with most items already input .*)
   534 fun max_vt itms = 
   535     let val vts = (vts_cnt (vts_in itms)) itms;
   536     in if vts = [] then 0 else (fst o max2) vts end;
   537 
   538 
   539 (* TODO ev. make more efficient by avoiding flat *)
   540 fun mk_e (Cor (_, iv)) = [getval iv]
   541   | mk_e (Syn _) = []
   542   | mk_e (Typ _) = [] 
   543   | mk_e (Inc (_, iv)) = [getval iv]
   544   | mk_e (Sup _) = []
   545   | mk_e (Mis _) = [];
   546 fun mk_en vt ((i,vts,b,f,itm_):itm) =
   547     if member op = vts vt then mk_e itm_ else [];
   548 (*. extract the environment from an item list; 
   549     takes the variant with most items .*)
   550 fun mk_env itms = 
   551     let val vt = max_vt itms
   552     in (flat o (map (mk_en vt))) itms end;
   553 
   554 
   555 
   556 (*. example as provided by an author, complete w.r.t. pbt specified 
   557     not touched by any user action                                 .*)
   558 type ori = (int *      (* id: 10.3.00ff impl. only <>0 .. touched 
   559 			  21.3.02: insert_ppc needs it ! ?:purpose maintain
   560 				   order in item ppc ???*)
   561 	    vats *     (* variants 21.3.02: related to pbt..discard ?*)
   562 	    string *   (* #Given | #Find | #Relate 21.3.02: discard ?*)
   563 	    term *     (* description *)
   564 	    term list  (* isalist2list t | [t] *)
   565 	    );
   566 val e_ori_ = (0,[],"",e_term,[e_term]):ori;
   567 val e_ori = (0,[],"",e_term,[e_term]):ori;
   568 
   569 fun ori2str ((i,vs,fi,t,ts):ori) = 
   570     "("^(string_of_int i)^", "^((strs2str o (map string_of_int)) vs)^", "^fi^","^
   571     (term2str t)^", "^((strs2str o (map term2str)) ts)^")";
   572 val oris2str = 
   573     let val s = !show_types
   574 	val _ = show_types:= true
   575 	val str = (strs2str' o (map (linefeed o ori2str)))
   576 	val _ = show_types:= s
   577     in str end;
   578 
   579 (*.an or without leading integer.*)
   580 type preori = (vats *  
   581 	       string *   
   582 	       term *     
   583 	       term list);
   584 fun preori2str ((vs,fi,t,ts):preori) = 
   585     "("^((strs2str o (map string_of_int)) vs)^", "^fi^", "^
   586     (term2str t)^", "^((strs2str o (map term2str)) ts)^")";
   587 val preoris2str = (strs2str' o (map (linefeed o preori2str)));
   588 
   589 (*. given the input value (from split_dts)
   590     make the value in a problem-env according to description-type .*)
   591 (*28.8.01: .nam and .una impl. properly, others copied .. TODO*)
   592 fun pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.nam",_)]))) v =
   593     if is_list v 
   594     then [v]         (*eg. [r=Arbfix]*)
   595     else (case v of  (*eg. eps=#0*)
   596 	      (Const ("op =",_) $ l $ r) => [r,l]
   597 	    | _ => error ("pbl_ids Tools.nam: no equality "
   598 				^(Syntax.string_of_term ctxt v)))
   599   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.una",_)]))) v = [v]
   600   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.unl",_)]))) v = [v]
   601   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.str",_)]))) v = [v]
   602   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.toreal",_)]))) v = [v] 
   603   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.toreall",_)])))v = [v] 
   604   | pbl_ids ctxt (Const(_,Type("fun",[_,Type("Tools.unknown",_)])))v = [v] 
   605   | pbl_ids ctxt _ v = error ("pbl_ids: not implemented for "
   606 				    ^(Syntax.string_of_term ctxt v));
   607 (*
   608 val t as t1 $ t2 = str2term "antiDerivativeName M_b";
   609 pbl_ids ctxt t1 t2;
   610 
   611   val t = (term_of o the o (parse thy)) "fixedValues [r=Arbfix]";
   612   val (d,argl) = strip_comb t;
   613   is_dsc d;                      (*see split_dts*)
   614   dest_list (d,argl);
   615   val (_ $ v) = t;
   616   is_list v;
   617   pbl_ids ctxt d v;
   618 [Const ("List.list.Cons","[bool, bool List.list] => bool List.list") $
   619        (Const # $ Free # $ Const (#,#)) $ Const ("List.list.Nil","bool List..
   620 
   621   val (dsc,vl) = (split_dts o term_of o the o (parse thy)) "solveFor x";
   622 val dsc = Const ("Descript.solveFor","RealDef.real => Tools.una") : term
   623 val vl = Free ("x","RealDef.real") : term 
   624 
   625   val (dsc,id) = (split_did o term_of o the o (parse thy)) "solveFor v_";
   626   pbl_ids ctxt dsc vl;
   627 val it = [Free ("x","RealDef.real")] : term list
   628    
   629   val (dsc,vl) = (split_dts o term_of o the o(parse thy))
   630 		       "errorBound (eps=#0)";
   631   val (dsc,id) = (split_did o term_of o the o(parse thy)) "errorBound err_";
   632   pbl_ids ctxt dsc vl;
   633 val it = [Free ("#0","RealDef.real"),Free ("eps","RealDef.real")] : term list     *)
   634 
   635 (*. given an already input itm, ((14.9.01: no difference to pbl_ids jet!!))
   636     make the value in a problem-env according to description-type .*)
   637 (*28.8.01: .nam and .una impl. properly, others copied .. TODO*)
   638 fun pbl_ids' (Const(_,Type("fun",[_,Type("Tools.nam",_)]))) vs =
   639     (case vs of 
   640 	 [] => error ("pbl_ids' Tools.nam called with []")
   641        | [t] => (case t of  (*eg. eps=#0*)
   642 		     (Const ("op =",_) $ l $ r) => [r,l]
   643 		   | _ => error ("pbl_ids' Tools.nam: no equality "
   644 				       ^(Syntax.string_of_term (thy2ctxt' "Isac")t)))
   645        | vs' => vs (*14.9.01: ???TODO *))
   646   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.una",_)]))) vs = vs
   647   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.unl",_)]))) vs = vs
   648   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.str",_)]))) vs = vs
   649   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.toreal",_)]))) vs = vs 
   650   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.toreall",_)])))vs = vs 
   651   | pbl_ids' (Const(_,Type("fun",[_,Type("Tools.unknown",_)])))vs = vs 
   652   | pbl_ids'  _ vs = 
   653     error ("pbl_ids': not implemented for "
   654 		 ^(terms2str vs));
   655 (*9.5.03 penv postponed: pbl_ids'*)
   656 fun pbl_ids' thy d vs = [comp_ts (d, vs)];
   657 
   658 
   659 (*14.9.01: not used after putting values for penv into itm_
   660   WN.5.5.03: used in upd .. upd_envv*)
   661 fun upd_penv ctxt penv dsc (id, vl) =
   662 (tracing"### upd_penv used !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
   663  tracing"### upd_penv used !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
   664  tracing"### upd_penv used !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
   665   overwrite (penv, (id, pbl_ids ctxt dsc vl))
   666 );
   667 (* 
   668   val penv = [];
   669   val (dsc,vl) = (split_did o term_of o the o (parse thy)) "solveFor x";
   670   val (dsc,id) = (split_did o term_of o the o (parse thy)) "solveFor v_";
   671   val penv = upd_penv thy penv dsc (id, vl);
   672 [(Free ("v_","RealDef.real"),
   673   [Const (#,#) $ Free (#,#) $ Free ("#0","RealDef.real")])]
   674 : (term * term list) list                                                     
   675 
   676   val (dsc,vl) = (split_did o term_of o the o(parse thy))"errorBound (eps=#0)";
   677   val (dsc,id) = (split_did o term_of o the o(parse thy))"errorBound err_";
   678   upd_penv thy penv dsc (id, vl);
   679 [(Free ("v_","RealDef.real"),
   680   [Const (#,#) $ Free (#,#) $ Free ("#0","RealDef.real")]),
   681  (Free ("err_","bool"),
   682   [Free ("#0","RealDef.real"),Free ("eps","RealDef.real")])]
   683 : (term * term list) list    ^.........!!!!
   684 *)
   685 
   686 (*WN.9.5.03: not reconsidered; looks strange !!!*)
   687 fun upd thy envv dsc (id, vl) i =
   688     let val penv = case assoc (envv, i) of
   689 		       SOME e => e
   690 		     | NONE => [];
   691         val penv' = upd_penv thy penv dsc (id, vl);
   692     in (i, penv') end;
   693 (*
   694   val i = 2;
   695   val envv = [(1,[]:penv),(2,[]:penv),(3,[]:penv)]:envv;
   696   val (dsc,vl) = (split_did o term_of o the o(parse thy))"boundVariable b";
   697   val (dsc,id) = (split_did o term_of o the o(parse thy))"boundVariable v_";
   698   upd thy envv dsc (id, vl) i;
   699 val it = (2,[(Free ("v_","RealDef.real"),[Free ("b","RealDef.real")])])
   700   : int * (term * term list) list*)
   701 
   702 
   703 (*14.9.01: not used after putting pre-penv into itm_*)
   704 fun upd_envv thy (envv:envv) (vats:vats) dsc id vl  =
   705     let val vats = if length vats = 0 
   706 		   then (*unknown id to _all_ variants*)
   707 		       if length envv = 0 then [1]
   708 		       else (intsto o length) envv 
   709 		   else vats
   710 	fun isin vats (i,_) = member op = vats i;
   711 	val envs_notin_vat = filter_out (isin vats) envv;
   712     in ((map (upd thy envv dsc (id, vl)) vats) @ envs_notin_vat):envv end;
   713 (*
   714   val envv = [(1,[]:penv),(2,[]:penv),(3,[]:penv)]:envv;
   715  
   716   val vats = [2] 
   717   val (dsc,vl) = (split_did o term_of o the o(parse thy))"boundVariable b";
   718   val (dsc,id) = (split_did o term_of o the o(parse thy))"boundVariable v_";
   719   val envv = upd_envv thy envv vats dsc id vl;
   720 val envv = [(2,[(Free ("v_","RealDef.real"),[Free ("b","RealDef.real")])])]
   721   : (int * (term * term list) list) list
   722 
   723   val vats = [1,2,3];
   724   val (dsc,vl) = (split_did o term_of o the o(parse thy))"maximum A";
   725   val (dsc,id) = (split_did o term_of o the o(parse thy))"maximum m_";
   726   upd_envv thy envv vats dsc id vl;
   727 [(1,[(Free ("m_","bool"),[Free ("A","bool")])]),
   728  (2,
   729   [(Free ("v_","RealDef.real"),[Free ("b","RealDef.real")]),
   730    (Free ("m_","bool"),[Free ("A","bool")])]),
   731  (3,[(Free ("m_","bool"),[Free ("A","bool")])])]
   732 : (int * (term * term list) list) list
   733 
   734 
   735   val env = []:envv;
   736   val (d,ts) = (split_dts o term_of o the o (parse thy))
   737 		   "fixedValues [r=Arbfix]";
   738   val (_,id) = (split_did o term_of o the o (parse thy))"fixedValues fix_";
   739   val vats = [1,2,3];
   740   val env = upd_envv thy env vats d id (mkval ts);
   741 *)
   742 
   743 (*. update envv by folding from a list of arguments .*)
   744 fun upds_envv thy envv [] = envv
   745   | upds_envv thy envv ((vs, dsc, id, vl)::ps) = 
   746     upds_envv thy (upd_envv thy envv vs dsc id vl) ps;
   747 (* eval test-maximum.sml until Specify_Method ...
   748   val PblObj{probl=(_,pbl),origin=(_,(_,_,mI),_),...} = get_obj I pt [];
   749   val met = (#ppc o get_met) mI;
   750 
   751   val envv = [];
   752   val eargs = flat eargs;
   753   val (vs, dsc, id, vl) = hd eargs;
   754   val envv = upds_envv thy envv [(vs, dsc, id, vl)];
   755 
   756   val (vs, dsc, id, vl) = hd (tl eargs);
   757   val envv = upds_envv thy envv [(vs, dsc, id, vl)];
   758 
   759   val (vs, dsc, id, vl) = hd (tl (tl eargs));
   760   val envv = upds_envv thy envv [(vs, dsc, id, vl)];
   761 
   762   val (vs, dsc, id, vl) = hd (tl (tl (tl eargs)));
   763   val envv = upds_envv thy envv [(vs, dsc, id, vl)];
   764 [(1,
   765   [(Free ("fix_","bool List.list"),[Const (#,#),Free (#,#)]),
   766    (Free ("m_","bool"),[Free (#,#)]),
   767    (Free ("vs_","bool List.list"),[# $ # $ Const #]),
   768    (Free ("rs_","bool List.list"),[# $ # $ (# $ #)])]),
   769  (2,
   770   [(Free ("fix_","bool List.list"),[Const (#,#),Free (#,#)]),
   771    (Free ("m_","bool"),[Free (#,#)]),
   772    (Free ("vs_","bool List.list"),[# $ # $ Const #]),
   773    (Free ("rs_","bool List.list"),[# $ # $ (# $ #)])]),
   774  (3,
   775   [(Free ("fix_","bool List.list"),[Const (#,#),Free (#,#)]),
   776    (Free ("m_","bool"),[Free (#,#)]),
   777    (Free ("vs_","bool List.list"),[# $ # $ Const #])])] : envv *)
   778 
   779 (*for _output_ of the items of a Model*)
   780 datatype item = 
   781     Correct of cterm' (*labels a correct formula (type cterm')*)
   782   | SyntaxE of string (**)
   783   | TypeE   of string (**)
   784   | False   of cterm' (*WN050618 notexistent in itm_: only used in Where*)
   785   | Incompl of cterm' (**)
   786   | Superfl of string (**)
   787   | Missing of cterm';
   788 fun item2str (Correct  s) ="Correct " ^ s
   789   | item2str (SyntaxE  s) ="SyntaxE " ^ s
   790   | item2str (TypeE    s) ="TypeE " ^ s
   791   | item2str (False    s) ="False " ^ s
   792   | item2str (Incompl  s) ="Incompl " ^ s
   793   | item2str (Superfl  s) ="Superfl " ^ s
   794   | item2str (Missing  s) ="Missing " ^ s;
   795 (*make string for error-msgs*)
   796 fun itm_2str_ ctxt (Cor ((d,ts), penv)) = 
   797     "Cor " ^ Syntax.string_of_term ctxt (comp_dts ctxt (d,ts)) ^ " ,"
   798     ^ pen2str ctxt penv
   799   | itm_2str_ ctxt (Syn c)      = "Syn " ^ c
   800   | itm_2str_ ctxt (Typ c)      = "Typ " ^ c
   801   | itm_2str_ ctxt (Inc ((d,ts), penv)) = 
   802     "Inc " ^ Syntax.string_of_term ctxt (comp_dts ctxt (d,ts)) ^ " ,"
   803     ^ pen2str ctxt penv
   804   | itm_2str_ ctxt (Sup (d,ts)) = 
   805     "Sup " ^ Syntax.string_of_term ctxt (comp_dts ctxt (d,ts))
   806   | itm_2str_ ctxt (Mis (d,pid))= 
   807     "Mis "^ Syntax.string_of_term ctxt d ^
   808     " "^ Syntax.string_of_term ctxt pid
   809   | itm_2str_ ctxt (Par s) = "Trm "^s;
   810 fun itm_2str t = itm_2str_ (thy2ctxt' "Isac") t;
   811 fun itm2str_ ctxt ((i,is,b,s,itm_):itm) = 
   812     "("^(string_of_int i)^" ,"^(ints2str' is)^" ,"^(bool2str b)^" ,"^
   813     s^" ,"^(itm_2str_ ctxt itm_)^")";
   814 fun itms2str_ ctxt itms = strs2str' (map (linefeed o (itm2str_ ctxt)) itms);
   815 fun w_itms2str_ ctxt itms = tracing (itms2str_ ctxt itms);
   816 
   817 fun init_item str = SyntaxE str;
   818 
   819 
   820 
   821 
   822 type 'a ppc = 
   823     {Given : 'a list,
   824      Where: 'a list,
   825      Find  : 'a list,
   826      With : 'a list,
   827      Relate: 'a list};
   828 fun ppc2str {Given=Given,Where=Where,Find=Find,With=With,Relate=Relate}=
   829     ("{Given =" ^ (strs2str Given ) ^
   830      ",Where=" ^ (strs2str Where) ^
   831      ",Find  =" ^ (strs2str Find  ) ^
   832      ",With =" ^ (strs2str With ) ^
   833      ",Relate=" ^ (strs2str Relate) ^ "}");
   834 
   835 
   836 
   837 
   838 fun item_ppc ({Given = gi,Where= wh,
   839 		 Find = fi,With = wi,Relate= re}: string ppc) =
   840   {Given = map init_item gi,Where= map init_item wh,
   841    Find = map init_item fi,With = map init_item wi,
   842    Relate= map init_item re}:item ppc;
   843 fun itemppc2str ({Given=Given,Where=Where,
   844 		 Find=Find,With=With,Relate=Relate}:item ppc)=
   845     ("{Given =" ^ ((strs2str' o (map item2str))	 Given ) ^
   846      ",Where=" ^ ((strs2str' o (map item2str))	 Where) ^
   847      ",Find  =" ^ ((strs2str' o (map item2str))	 Find  ) ^
   848      ",With =" ^ ((strs2str' o (map item2str))	 With ) ^
   849      ",Relate=" ^ ((strs2str' o (map item2str))	 Relate) ^ "}");
   850 
   851 fun de_item (Correct x) = x
   852   | de_item (SyntaxE x) = x
   853   | de_item (TypeE   x) = x
   854   | de_item (False   x) = x
   855   | de_item (Incompl x) = x
   856   | de_item (Superfl x) = x
   857   | de_item (Missing x) = x;
   858 val empty_ppc ={Given = [],
   859 		Where= [],
   860 		Find  = [], 
   861 		With = [],
   862 		Relate= []}:item ppc;
   863 val empty_ppc_ct' ={Given = [],
   864 		Where = [],
   865 		Find  = [], 
   866 		With  = [],
   867 		Relate= []}:cterm' ppc;
   868 
   869 
   870 datatype match = 
   871   Matches of pblID * item ppc
   872 | NoMatch of pblID * item ppc;
   873 fun match2str (Matches (pI, ppc)) = 
   874     "Matches ("^(strs2str pI)^", "^(itemppc2str ppc)^")"
   875   | match2str(NoMatch (pI, ppc)) = 
   876     "NoMatch ("^(strs2str pI)^", "^(itemppc2str ppc)^")";
   877 fun matchs2str ms = (strs2str o (map match2str)) ms;
   878 fun pblID_of_match (Matches (pI,_)) = pI
   879   | pblID_of_match (NoMatch (pI,_)) = pI;
   880 
   881 (*10.03 for Refine_Problem*)
   882 datatype match_ = 
   883   Match_ of pblID * ((itm list) * ((bool * term) list))
   884 | NoMatch_;
   885 
   886 (*. the refined pbt is the last_element Matches in the list .*)
   887 fun is_matches (Matches _) = true
   888   | is_matches _ = false;
   889 fun matches_pblID (Matches (pI,_)) = pI;
   890 fun refined ms = ((matches_pblID o the o (find_first is_matches) o rev) ms)
   891     handle _ => []:pblID;
   892 fun refined_IDitms ms = ((find_first is_matches) o rev) ms;
   893 
   894 (*. the refined pbt is the last_element Matches in the list,
   895     for Refine_Problem, tryrefine .*)
   896 fun is_matches_ (Match_ _) = true
   897   | is_matches_ _ = false;
   898 fun refined_ ms = ((find_first is_matches_) o rev) ms;
   899 
   900 
   901 fun ts_in (Cor ((_,ts),_)) = ts
   902   | ts_in (Syn  (c)) = []
   903   | ts_in (Typ  (c)) = []
   904   | ts_in (Inc ((_,ts),_)) = ts
   905   | ts_in (Sup (_,ts)) = ts
   906   | ts_in (Mis _) = [];
   907 (*WN050629 unused*)
   908 fun all_ts_in itm_s = (flat o (map ts_in)) itm_s;
   909 val unique = (term_of o the o (parse (theory "Real"))) "UnIqE_tErM";
   910 fun d_in (Cor ((d,_),_)) = d
   911   | d_in (Syn  (c)) = (tracing("*** d_in: Syn ("^c^")"); unique)
   912   | d_in (Typ  (c)) = (tracing("*** d_in: Typ ("^c^")"); unique)
   913   | d_in (Inc ((d,_),_)) = d
   914   | d_in (Sup (d,_)) = d
   915   | d_in (Mis (d,_)) = d;
   916 
   917 fun dts2str (d,ts) = pair2str (term2str d, terms2str ts);
   918 fun penvval_in (Cor ((d,_),(_,ts))) = [comp_ts (d,ts)]
   919   | penvval_in (Syn  (c)) = (tracing("*** penvval_in: Syn ("^c^")"); [])
   920   | penvval_in (Typ  (c)) = (tracing("*** penvval_in: Typ ("^c^")"); [])
   921   | penvval_in (Inc (_,(_,ts))) = ts
   922   | penvval_in (Sup dts) = (tracing("*** penvval_in: Sup "^(dts2str dts)); [])
   923   | penvval_in (Mis (d,t)) = (tracing("*** penvval_in: Mis "^
   924 				      (pair2str(term2str d, term2str t))); []);
   925 
   926 
   927 (*. check a predicate labelled with indication of incomplete substitution;
   928 rls ->    (*for eval_true*)
   929 bool * 	  (*have _all_ variables(Free) from the model-pattern 
   930             been substituted by a value from the pattern's environment ?*)
   931 term (*the precondition*)
   932 ->
   933 bool * 	  (*has the precondition evaluated to true*)
   934 term (*the precondition (for map)*)
   935 .*)
   936 fun evalprecond prls (false, pre) = 
   937   (*NOT ALL Free's have been substituted, eg. because of incomplete model*)
   938     (false, pre)
   939   | evalprecond prls (true, pre) =
   940 (* val (prls, pre) = (prls, hd pres');
   941    val (prls, pre) = (prls, hd (tl pres'));
   942    *)
   943     if eval_true (assoc_thy "Isac.thy") (*for Pattern.match   *)
   944 		 [pre] prls             (*pre parsed, prls.thy*)
   945     then (true , pre)
   946     else (false , pre);
   947 
   948 fun pre2str (b, t) = pair2str(bool2str b, term2str t);
   949 fun pres2str pres = strs2str' (map (linefeed o pre2str) pres);
   950 
   951 (*. check preconditions, return true if all true .*)
   952 fun check_preconds' _ [] _ _ = []  (*empty preconditions are true*)
   953   | check_preconds' prls pres pbl _(*FIXME.WN0308 mvat re-introduce*) =
   954 (* val (prls, pres, pbl, _) = (prls, where_, probl, 0);
   955    val (prls, pres, pbl, _) = (prls, pre, itms, mvat);
   956    *)
   957     let val env = mk_env pbl;
   958         val pres' = map (subst_atomic_all env) pres;
   959     in map (evalprecond prls) pres' end;
   960 
   961 fun check_preconds thy prls pres pbl = 
   962     check_preconds' prls pres pbl (max_vt pbl);
   963 
   964 (*----------------------------------------------------------*)
   965 end
   966 open SpecifyTools;
   967 (*----------------------------------------------------------*)