PIDE: more interactions in frontend interface:
authorWalther Neuper <wneuper@ist.tugraz.at>
Thu, 28 May 2015 14:23:18 +0200
changeset 5912734f296390b60
parent 59126 55c3e6c7b9c4
child 59128 082d228593a1
PIDE: more interactions in frontend interface:

CalcTree, getActiveFormula, moveActiveCalcHead, moveActiveDown,
moveActiveFormula, ...
... all concerning iteratorOK2xml.

We leave the old code until libisabelle is integrated.
src/Tools/isac/Frontend/interface.sml
src/Tools/isac/xmlsrc/datatypes.sml
src/Tools/isac/xmlsrc/interface-xml.sml
src/Tools/isac/xmlsrc/mathml.sml
test/Tools/isac/Frontend/use-cases.sml
test/Tools/isac/xmlsrc/datatypes.sml
     1.1 --- a/src/Tools/isac/Frontend/interface.sml	Tue May 19 12:38:32 2015 +0200
     1.2 +++ b/src/Tools/isac/Frontend/interface.sml	Thu May 28 14:23:18 2015 +0200
     1.3 @@ -25,7 +25,7 @@
     1.4      val getActiveFormula : calcID -> XML.tree
     1.5      val getAssumptions : calcID -> pos' -> unit
     1.6      val initContext : calcID -> ketype -> pos' -> unit
     1.7 -    val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> unit
     1.8 +    val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> XML.tree
     1.9      val getTactic : calcID -> pos' -> unit
    1.10      val interSteps : calcID -> pos' -> unit
    1.11      val modifyCalcHead : calcID -> icalhd -> unit
    1.12 @@ -44,7 +44,7 @@
    1.13      val moveLevelUp : calcID -> pos' -> XML.tree
    1.14      val moveRoot : calcID -> XML.tree
    1.15      val moveUp : calcID -> pos' -> XML.tree
    1.16 -    val refFormula : calcID -> pos' -> unit
    1.17 +    val refFormula : calcID -> pos' -> XML.tree
    1.18      val replaceFormula : calcID -> cterm' -> unit
    1.19      val resetCalcHead : calcID -> unit
    1.20      val modelProblem : calcID -> unit
    1.21 @@ -293,7 +293,7 @@
    1.22      (let val ((pt,_),_) = get_calc cI
    1.23  	 val (form, tac, asms) = pt_extract (pt, p)
    1.24      in refformulaOK2xml cI p form end)
    1.25 -    handle _ => sysERROR2xml cI "error in kernel";
    1.26 +    handle _ => sysERROR2xmlTODO cI "error in kernel";
    1.27  
    1.28  (*.get formulae 'from' 'to' w.r.t. ordering in Position#compareTo(Position p);
    1.29     in case of CalcHeads only the headline is taken
    1.30 @@ -302,38 +302,31 @@
    1.31     'from' 'to' are designed for use by iterators of calcChangedEvent;
    1.32     thus 'from' is the last unchanged position.*)
    1.33  fun getFormulaeFromTo cI (from as ([],Pbl):pos') (to as ([],Pbl):pos')_ false =
    1.34 -(*special case because 'from' is _before_ the first elements to be returned*)
    1.35 -(* val (cI, from, to, level) = (1, ([],Pbl), ([],Pbl), 1);
    1.36 -   *)
    1.37 -    ((let val ((pt,_),_) = get_calc cI
    1.38 -	val (ModSpec (_,_,headline,_,_,_),_,_) = pt_extract (pt, to)
    1.39 -    in getintervalOK cI [(to, headline)] end)
    1.40 -    handle _ => sysERROR2xml cI "error in kernel")
    1.41 -
    1.42 +  (*special case because 'from' is _before_ the first elements to be returned*)
    1.43 +    ((let 
    1.44 +      val ((pt,_),_) = get_calc cI
    1.45 +      val (ModSpec (_,_,headline,_,_,_),_,_) = pt_extract (pt, to)
    1.46 +      in getintervalOK cI [(to, headline)] end)
    1.47 +    handle _ => sysERROR2xmlTODO cI "error in kernel")
    1.48    | getFormulaeFromTo cI (from as ([],Pbl):pos') (to as ([],Met):pos')_ false =
    1.49      getFormulaeFromTo cI ([],Pbl) ([],Pbl) (~00000) false
    1.50 -
    1.51    | getFormulaeFromTo cI (from:pos') (to:pos') level false =
    1.52 -(* val (cI, from, to, level) = (1, unc, gen, 0);
    1.53 -   val (cI, from, to, level) = (1, unc, gen, 1);
    1.54 -   val (cI, from, to, level) = (1, ([],Pbl), ([],Met), 1);
    1.55 -   *)
    1.56 -    (if from = to then sysERROR2xml cI "getFormulaeFromTo: From = To"
    1.57 +    (if from = to then sysERROR2xmlTODO cI "getFormulaeFromTo: From = To"
    1.58       else
    1.59 -	 (case from of
    1.60 -	      ([],Res) => sysERROR2xml cI "getFormulaeFromTo does: moveDown \
    1.61 -					  \from=([],Res) .. goes beyond result"
    1.62 -	    | _ => let val ((pt,_),_) = get_calc cI
    1.63 -		       val f = move_dn [] pt from
    1.64 -		       fun max (a,b) = if a < b then b else a
    1.65 -		       (*must reach margins ...*)
    1.66 -		       val lev = max (level, max (lev_of from, lev_of to))
    1.67 -		   in getintervalOK cI (get_interval f to lev pt) end)
    1.68 -	 handle _ => sysERROR2xml cI "error in getFormulaeFromTo")
    1.69 -
    1.70 +       (case from of
    1.71 +          ([],Res) => sysERROR2xmlTODO cI ("getFormulaeFromTo does: moveDown " ^ 
    1.72 +            "from=([],Res) .. goes beyond result")
    1.73 +        | _ => 
    1.74 +          let val ((pt,_),_) = get_calc cI
    1.75 +            val f = move_dn [] pt from
    1.76 +            fun max (a,b) = if a < b then b else a
    1.77 +            (*must reach margins ...*)
    1.78 +            val lev = max (level, max (lev_of from, lev_of to))
    1.79 +          in getintervalOK cI (get_interval f to lev pt) end)
    1.80 +    handle _ => sysERROR2xmlTODO cI "error in getFormulaeFromTo")
    1.81    | getFormulaeFromTo cI from to level true =
    1.82 -    sysERROR2xml cI "getFormulaeFromTo impl.for formulae only,\
    1.83 -		    \i.e. last arg only impl. for false, _NOT_ true";
    1.84 +    sysERROR2xmlTODO cI ("getFormulaeFromTo impl.for formulae only, " ^ 
    1.85 +      "i.e. last arg only impl. for false, _NOT_ true");
    1.86  
    1.87  fun interSteps cI ip =
    1.88    (let val ((pt,p), tacis) = get_calc cI
     2.1 --- a/src/Tools/isac/xmlsrc/datatypes.sml	Tue May 19 12:38:32 2015 +0200
     2.2 +++ b/src/Tools/isac/xmlsrc/datatypes.sml	Thu May 28 14:23:18 2015 +0200
     2.3 @@ -70,7 +70,7 @@
     2.4  val i = indentation;
     2.5  
     2.6  local
     2.7 -fun indent i = fold (curry op ^) (replicate i "  ") ""
     2.8 +fun indent i = fold (curry op ^) (replicate i ". ") ""
     2.9  in
    2.10  fun xmlstr i (XML.Text str) = indent i ^ str ^ "\n"
    2.11    | xmlstr i (XML.Elem ((str, []), trees)) = 
    2.12 @@ -303,7 +303,7 @@
    2.13    *)
    2.14  
    2.15  (*see itm_2item*)
    2.16 -fun itm_2xml j (Cor (dts,_))= 
    2.17 +fun itm_2xml j (Cor (dts,_)) =
    2.18      (indt j ^"<ITEM status=\"correct\">\n"^    
    2.19      term2xml (j) (comp_dts' dts)^"\n"^    
    2.20      indt j ^"</ITEM>\n"):xml
    2.21 @@ -328,12 +328,30 @@
    2.22      indt j ^"<ITEM status=\"missing\">\n"^    
    2.23      term2xml (j) (d $ pid)^"\n"^    
    2.24      indt j ^"</ITEM>\n";
    2.25 +fun xml_of_itm_ (Cor (dts, _)) =
    2.26 +    XML.Elem (("ITEM", [("status", "correct")]), [xml_of_term (comp_dts' dts)])
    2.27 +  | xml_of_itm_ (Syn c) =
    2.28 +    XML.Elem (("ITEM", [("status", "syntaxerror")]), [XML.Text c])
    2.29 +  | xml_of_itm_ (Typ c) =
    2.30 +    XML.Elem (("ITEM", [("status", "typeerror")]), [XML.Text c])
    2.31 +  (*type item also has 'False of cterm' set in preconds2xml WN 050618*)
    2.32 +  | xml_of_itm_ (Inc (dts, _)) = 
    2.33 +    XML.Elem (("ITEM", [("status", "incomplete")]), [xml_of_term (comp_dts' dts)])
    2.34 +  | xml_of_itm_ (Sup dts) = 
    2.35 +    XML.Elem (("ITEM", [("status", "superfluous")]), [xml_of_term (comp_dts' dts)])
    2.36 +  | xml_of_itm_ (Mis (d, pid)) = 
    2.37 +    XML.Elem (("ITEM", [("status", "missing")]), [xml_of_term (d $ pid)])
    2.38  
    2.39  (*see terms2xml' fpr \n*)
    2.40  fun itms2xml _ [] = ""
    2.41    | itms2xml j [(_,_,_,_,itm_)] = itm_2xml j itm_
    2.42    | itms2xml j (((_,_,_,_,itm_):itm)::itms) =
    2.43      itm_2xml j itm_ ^ itms2xml j itms;
    2.44 +fun xml_of_itms itms =
    2.45 +  let 
    2.46 +    fun extract (_, _, _, _, itm_) = itm_
    2.47 +      | extract _ = error "xml_of_itms.extract: wrong argument" 
    2.48 +  in map (xml_of_itm_ o extract) itms end
    2.49  
    2.50  fun precond2xml j (true, term) =
    2.51      (indt j ^"<ITEM status=\"correct\">\n"^
    2.52 @@ -343,37 +361,54 @@
    2.53      indt j ^"<ITEM status=\"false\">\n"^
    2.54      term2xml (j+i) term^"\n"^
    2.55      indt j ^"</ITEM>\n";
    2.56 +fun xml_of_precond (status, term) =
    2.57 +    XML.Elem (("ITEM", [("status", if status then "correct" else "false")]), [xml_of_term term])
    2.58  
    2.59  fun preconds2xml _ [] = ("":xml)
    2.60    | preconds2xml j (p::ps) = precond2xml j p ^ preconds2xml j ps;
    2.61 +fun xml_of_preconds ps = map xml_of_precond ps
    2.62  
    2.63  (*FIXME.WN040831 model2xml <--?--> pattern2xml*)
    2.64  fun model2xml j (itms:itm list) where_ =
    2.65 -    let fun eq4 str (_,_,_,field,_) = str = field
    2.66 -    in  (indt j ^"<MODEL>\n"^
    2.67 -	(case filter (eq4 "#Given") itms of
    2.68 -	     [] =>  (indt (j+i)) ^ "<GIVEN>  </GIVEN>\n"
    2.69 -	   | gis => (indt (j+i)) ^ "<GIVEN>\n" ^ itms2xml (j+2*i) gis ^
    2.70 -		    (indt (j+i)) ^ "</GIVEN>\n")
    2.71 -	^
    2.72 -	(case where_ of
    2.73 -	     [] =>  (indt (j+i)) ^ "<WHERE>  </WHERE>\n"
    2.74 -	   | whs => (indt (j+i)) ^ "<WHERE>\n" ^ preconds2xml (j+2*i) whs ^
    2.75 -		    (indt (j+i)) ^ "</WHERE>\n")
    2.76 -	^
    2.77 -	(case filter (eq4 "#Find") itms of
    2.78 -	     [] =>  (indt (j+i)) ^ "<FIND>  </FIND>\n"
    2.79 -	   | fis => (indt (j+i)) ^ "<FIND>\n" ^ itms2xml (j+2*i) fis ^
    2.80 -		    (indt (j+i)) ^ "</FIND>\n")
    2.81 -	^
    2.82 -	(case filter (eq4 "#Relate") itms of
    2.83 -	     [] =>  (indt (j+i)) ^ "<RELATE>  </RELATE>\n"
    2.84 -	   | res => (indt (j+i)) ^ "<RELATE>\n" ^ itms2xml (j+2*i) res ^
    2.85 -		    (indt (j+i)) ^ "</RELATE>\n")^
    2.86 -	    indt j ^"</MODEL>\n"):xml
    2.87 -    end;
    2.88 +  let fun eq4 str (_,_,_,field,_) = str = field
    2.89 +  in  (indt j ^"<MODEL>\n"^
    2.90 +    (case filter (eq4 "#Given") itms of
    2.91 +         [] =>  (indt (j+i)) ^ "<GIVEN>  </GIVEN>\n"
    2.92 +       | gis => (indt (j+i)) ^ "<GIVEN>\n" ^ itms2xml (j+2*i) gis ^
    2.93 +          (indt (j+i)) ^ "</GIVEN>\n")
    2.94 +    ^
    2.95 +    (case where_ of
    2.96 +         [] =>  (indt (j+i)) ^ "<WHERE>  </WHERE>\n"
    2.97 +       | whs => (indt (j+i)) ^ "<WHERE>\n" ^ preconds2xml (j+2*i) whs ^
    2.98 +          (indt (j+i)) ^ "</WHERE>\n")
    2.99 +    ^
   2.100 +    (case filter (eq4 "#Find") itms of
   2.101 +         [] =>  (indt (j+i)) ^ "<FIND>  </FIND>\n"
   2.102 +       | fis => (indt (j+i)) ^ "<FIND>\n" ^ itms2xml (j+2*i) fis ^
   2.103 +          (indt (j+i)) ^ "</FIND>\n")
   2.104 +    ^
   2.105 +    (case filter (eq4 "#Relate") itms of
   2.106 +         [] =>  (indt (j+i)) ^ "<RELATE>  </RELATE>\n"
   2.107 +       | res => (indt (j+i)) ^ "<RELATE>\n" ^ itms2xml (j+2*i) res ^
   2.108 +          (indt (j+i)) ^ "</RELATE>\n")^
   2.109 +        indt j ^"</MODEL>\n"):xml
   2.110 +  end;
   2.111  (* writeln(model2xml 3 itms []);
   2.112     *)
   2.113 +fun xml_of_model itms where_ =
   2.114 +  let
   2.115 +    fun eq str (_, _, _,field, _) = str = field
   2.116 +  in 
   2.117 +    XML.Elem (("MODEL", []), [
   2.118 +      XML.Elem (("GIVEN", []), 
   2.119 +        filter (eq "#Given") itms |> xml_of_itms),
   2.120 +      XML.Elem (("WHERE", []), 
   2.121 +        xml_of_preconds where_),
   2.122 +      XML.Elem (("FIND", []), 
   2.123 +        filter (eq "#Find") itms |> xml_of_itms),
   2.124 +      XML.Elem (("RELATE", []), 
   2.125 +        filter (eq "#Relate") itms |> xml_of_itms)])
   2.126 +  end 
   2.127  
   2.128  fun spec2xml j ((dI,pI,mI):spec) =
   2.129      (indt j ^"<SPECIFICATION>\n"^
   2.130 @@ -696,6 +731,13 @@
   2.131       else term2xml (j+i) t)^"\n" ^
   2.132      indt (j+i) ^"</FORMULA>\n"^
   2.133      indt j ^"</CALCFORMULA>\n";
   2.134 +fun xml_of_posterm ((p : pos'), t) = 
   2.135 +  XML.Elem (("CALCFORMULA", []),
   2.136 +    [xml_of_pos "POSITION" p,
   2.137 +    XML.Elem (("FORMULA", []), [
   2.138 +      if t = e_pblterm (*headline in pbl is e_ <- _root_pbl for CAS-command*)
   2.139 +      then xml_of_cterm "________________________________________________"
   2.140 +      else xml_of_term t])])
   2.141  
   2.142  fun posterms2xml j [] = ("":xml)
   2.143    | posterms2xml j (r::rs) = posterm2xml j r ^ posterms2xml j rs;
     3.1 --- a/src/Tools/isac/xmlsrc/interface-xml.sml	Tue May 19 12:38:32 2015 +0200
     3.2 +++ b/src/Tools/isac/xmlsrc/interface-xml.sml	Thu May 28 14:23:18 2015 +0200
     3.3 @@ -21,6 +21,13 @@
     3.4  
     3.5  (** add and delete users -----------------------------------------------
     3.6   FIXXME.8.03 addUser: clear code, because only CalcTrees distinguished**)
     3.7 +fun adduserOK2xml (cI:calcID) (uI:iterID) = 
     3.8 +    writeln ("@@@@@begin@@@@@\n "^string_of_int uI^" \n" ^
     3.9 +	     "<ADDUSER>\n" ^
    3.10 +	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    3.11 +	     "  <USERID> "^string_of_int uI^" </USERID>\n" ^
    3.12 +	     "</ADDUSER>\n" ^
    3.13 +	     "@@@@@end@@@@@");
    3.14  fun adduserOK2xml (calcid : calcID) (userid : iterID) =
    3.15    XML.Elem (("ADDUSER", []),
    3.16      [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    3.17 @@ -34,6 +41,12 @@
    3.18  	     "@@@@@end@@@@@");
    3.19  (*---------------------------------------------------------------------*)
    3.20  
    3.21 +fun calctreeOK2xml (*uI:iterID*) (cI:calcID) = 
    3.22 +    writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    3.23 +	     "<CALCTREE>\n" ^
    3.24 +	     "   <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    3.25 +	     "</CALCTREE>\n" ^
    3.26 +	     "@@@@@end@@@@@");
    3.27  fun calctreeOK2xml (calcid : calcID) = 
    3.28    XML.Elem (("CALCTREE", []),
    3.29      [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)])])    
    3.30 @@ -44,6 +57,20 @@
    3.31  	     "</DELCALC>\n" ^
    3.32  	     "@@@@@end@@@@@");
    3.33  
    3.34 +fun iteratorOK2xml (cI:calcID) (p:pos')= 
    3.35 +    writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    3.36 +	     "<CALCITERATOR>\n" ^
    3.37 +	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    3.38 +	     pos'2xml i ("POSITION", p) ^
    3.39 +	     "</CALCITERATOR>\n" ^
    3.40 +	     "@@@@@end@@@@@");
    3.41 +fun iteratorERROR2xml (cI:calcID) = 
    3.42 +    writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    3.43 +	     "<CALCITERATOR>\n" ^
    3.44 +	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    3.45 +	     "  <ERROR> pos does not exist </ERROR>\n" ^
    3.46 +	     "</CALCITERATOR>\n" ^
    3.47 +	     "@@@@@end@@@@@");
    3.48  fun iteratorOK2xml (calcid : calcID) (p : pos')= 
    3.49    XML.Elem (("CALCITERATOR", []),
    3.50      [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    3.51 @@ -91,6 +118,16 @@
    3.52  	     pos'calchead2xml i (p, modspec)^ 
    3.53  	     "</REFFORMULA>\n" ^
    3.54  	     "@@@@@end@@@@@"); 
    3.55 +fun refformulaOK2xml (calcid : calcID) p (Form t) = 
    3.56 +      XML.Elem (("REFFORMULA", []),
    3.57 +        [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    3.58 +        XML.Elem (("CALCFORMULA", []), [
    3.59 +          xml_of_pos "POSITION" p,
    3.60 +          XML.Elem (("FORMULA", []), [xml_of_term t])])])
    3.61 +  | refformulaOK2xml (calcid : calcID) p (ModSpec modspec) = 
    3.62 +      XML.Elem (("REFFORMULA", []),
    3.63 +        [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    3.64 +        XML.Elem (("ERROR", []), [XML.Text " pos does not exist "])])
    3.65  
    3.66  fun refformulaERROR2xml (cI:calcID) = (*FIXME.WN.29.8.03 unused*)
    3.67      writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    3.68 @@ -162,7 +199,10 @@
    3.69  	     "  </FORMHEADS>\n" ^	     
    3.70  	     "</GETELEMENTSFROMTO>\n" ^
    3.71  	     "@@@@@end@@@@@");
    3.72 -
    3.73 +fun getintervalOK (calcid : calcID) fs = 
    3.74 +      XML.Elem (("GETELEMENTSFROMTO", []),
    3.75 +        [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    3.76 +        XML.Elem (("FORMHEADS", []), map xml_of_posterm fs)])
    3.77  
    3.78  fun matchpbl2xml (cI:calcID) (model_ok, pI, hdl, pbl, pre) =
    3.79      writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
     4.1 --- a/src/Tools/isac/xmlsrc/mathml.sml	Tue May 19 12:38:32 2015 +0200
     4.2 +++ b/src/Tools/isac/xmlsrc/mathml.sml	Thu May 28 14:23:18 2015 +0200
     4.3 @@ -45,6 +45,10 @@
     4.4            <MATHML>
     4.5              <ISA> equality e_ </ISA>
     4.6            <MATHML> *)
     4.7 +fun xml_of_term t =
     4.8 +  XML.Elem (("MATHML", []),
     4.9 +    [XML.Elem (("ISA", []), [XML.Text ((decode o term2str) t)])])
    4.10 +fun xml_of_terms ts = map xml_of_term ts
    4.11  
    4.12  (*version for TextIO*)                                                         
    4.13  fun terms2xml j [] = ""
    4.14 @@ -59,6 +63,10 @@
    4.15      indt (j+i) ^ "<MATHML>\n" ^ 
    4.16      indt (j+2*i) ^ "<ISA> " ^ ct ^ " </ISA>\n" ^
    4.17      indt (j+i) ^ "</MATHML>\n";
    4.18 +fun xml_of_cterm ct = 
    4.19 +  XML.Elem (("MATHML", []),
    4.20 +    [XML.Elem (("ISA", []), [XML.Text ct])])
    4.21 +
    4.22  (*version for TextIO*)                                                         
    4.23  fun cterms2xml j [] = ""
    4.24    | cterms2xml j (t::ts) = cterm2xml j t ^ cterms2xml j ts;
     5.1 --- a/test/Tools/isac/Frontend/use-cases.sml	Tue May 19 12:38:32 2015 +0200
     5.2 +++ b/test/Tools/isac/Frontend/use-cases.sml	Thu May 28 14:23:18 2015 +0200
     5.3 @@ -7,6 +7,11 @@
     5.4  to the same UC in isac-docu.tex as the JUnit testcase.
     5.5  WN120210?not ME: added some labels, which are not among the above,
     5.6  repaired lost \label (s).
     5.7 +
     5.8 +theory Test_Some imports Build_Thydata begin 
     5.9 +ML {* KEStore_Elems.set_ref_thy @{theory};
    5.10 +  fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*) *}
    5.11 +ML_file "Frontend/use-cases.sml"
    5.12  *)
    5.13  
    5.14  "--------------------------------------------------------";
     6.1 --- a/test/Tools/isac/xmlsrc/datatypes.sml	Tue May 19 12:38:32 2015 +0200
     6.2 +++ b/test/Tools/isac/xmlsrc/datatypes.sml	Thu May 28 14:23:18 2015 +0200
     6.3 @@ -11,6 +11,7 @@
     6.4  "-----------------------------------------------------------------";
     6.5  "----------- fun rules2xml ---------------------------------------";
     6.6  "----------- fun thm''2xml ---------------------------------------";
     6.7 +"----------- fun xml_of_model ------------------------------------------------------------------";
     6.8  "-----------------------------------------------------------------";
     6.9  "-----------------------------------------------------------------";
    6.10  "-----------------------------------------------------------------";
    6.11 @@ -67,3 +68,31 @@
    6.12  (* use"../smltest/xmlsrc/datatypes.sml";
    6.13     *)
    6.14  ============ inhibit exn AK110725 ==============================================*)
    6.15 +
    6.16 +"----------- fun xml_of_model ------------------------------------------------------------------";
    6.17 +"----------- fun xml_of_model ------------------------------------------------------------------";
    6.18 +"----------- fun xml_of_model ------------------------------------------------------------------";
    6.19 +(*create testdata: see --- tryrefine --- 
    6.20 +  xml_of_model used via refineProblem \<longrightarrow> matchpbl2xml \<longrightarrow> model2xml*)
    6.21 +reset_states ();
    6.22 +CalcTree [(["equality (x/(x^2 - 6*x+9) - 1/(x^2 - 3*x) =1/x)", 
    6.23 +	    "solveFor x", "solutions L"],
    6.24 +	   ("RatEq",["univariate","equation"],["no_met"]))];
    6.25 +Iterator 1;
    6.26 +moveActiveRoot 1; autoCalculate 1 CompleteCalc;
    6.27 +refineProblem 1 ([1],Res) "pbl_equ_univ"; 
    6.28 +"~~~~~ fun refineProblem, args:"; val (cI, ((p,p_) : pos'), (guh : guh)) = 
    6.29 +  (1, ([1],Res), "pbl_equ_univ");
    6.30 +val pblID = guh2kestoreID guh
    6.31 +	 val ((pt,_),_) = get_calc cI
    6.32 +	 val pp = par_pblobj pt p
    6.33 +	 val chd = tryrefine pblID pt (pp, p_);
    6.34 +"~~~~~ fun matchpbl2xml, args:"; val ((cI:calcID), (model_ok, pI, hdl, pbl, pre)) = (cI, chd);
    6.35 +"~~~~~ fun model2xml, args:"; val (j, (itms:itm list), where_) = (i, pbl, pre);
    6.36 +"~~~~~ fun xml_of_model, args:"; val (itms, where_) = (pbl, pre);
    6.37 +val xxx = xml_of_model itms where_;
    6.38 +(xmlstr 0 xxx);
    6.39 +writeln(xmlstr 0 xxx);
    6.40 +if xmlstr 0 xxx = "<MODEL>\n. <GIVEN>\n. . <ITEM status correct>\n. . . <MATHML>\n. . . . <ISA>\n. . . . . equality (x / (x ^ 2 - 6 * x + 9) - 1 / (x ^ 2 - 3 * x) = 1 / x)\n. . . . </ISA>\n. . . </MATHML>\n. . </ITEM>\n. . <ITEM status correct>\n. . . <MATHML>\n. . . . <ISA>\n. . . . . solveFor x\n. . . . </ISA>\n. . . </MATHML>\n. . </ITEM>\n. </GIVEN>\n. <WHERE>\n. . <ITEM status correct>\n. . . <MATHML>\n. . . . <ISA>\n. . . . . x / (x ^ 2 - 6 * x + 9) - 1 / (x ^ 2 - 3 * x) =\n1 / x is_ratequation_in x\n. . . . </ISA>\n. . . </MATHML>\n. . </ITEM>\n. </WHERE>\n. <FIND>\n. . <ITEM status correct>\n. . . <MATHML>\n. . . . <ISA>\n. . . . . solutions L\n. . . . </ISA>\n. . . </MATHML>\n. . </ITEM>\n. </FIND>\n. <RELATE>\n. </RELATE>\n</MODEL>\n"
    6.41 +then () else error ("xml_of_model changed = " ^ xmlstr 0 xxx);
    6.42 +