test/Tools/isac/Knowledge/poly.sml
author Walther Neuper <neuper@ist.tugraz.at>
Tue, 28 Sep 2010 09:06:56 +0200
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38022 e6d356fc4d38
child 38036 02a9b2540eb7
permissions -rw-r--r--
tuned error and writeln

# raise error --> error
# writeln in atomtyp, atomty, atomt and xmlsrc
     1 (* testexamples for Poly, polynomials
     2    author: Matthias Goldgruber 2003
     3    (c) due to copyright terms
     4 
     5 12345678901234567890123456789012345678901234567890123456789012345678901234567890
     6         10        20        30        40        50        60        70        80
     7 *)
     8 
     9 (*******************************************************************************
    10   WN060104 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
    11 	   'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
    12 *******************************************************************************)
    13 "--------------------------------------------------------";
    14 "--------------------------------------------------------";
    15 "table of contents --------------------------------------";
    16 "--------------------------------------------------------";
    17 "-------- check is'_polyexp is_polyexp ------------------";
    18 "-------- build Script Expand_binoms --------------------";
    19 "-------- investigate new uniary minus ------------------";
    20 "-------- Bsple aus Schalk I ----------------------------";
    21 "-------- Script 'simplification for_polynomials' -------";
    22 "-------- check pbl  'polynomial simplification' --------";
    23 "-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
    24 "-------- norm_Poly NOT COMPLETE ------------------------";
    25 "-------- ord_make_polynomial ---------------------------";
    26 "--------------------------------------------------------";
    27 "--------------------------------------------------------";
    28 "--------------------------------------------------------";
    29 
    30 
    31 "-------- check is'_polyexp is_polyexp ------------------";
    32 "-------- check is'_polyexp is_polyexp ------------------";
    33 "-------- check is'_polyexp is_polyexp ------------------";
    34 if is_polyexp @{term "x / x"} 
    35 then error "poly.sml: check is'_polyexp is_polyexp" else ();
    36 
    37 
    38 (*===== inhibit exn ?===========================================================
    39 "-------- build Script Expand_binoms -----------------------------";
    40 "-------- build Script Expand_binoms -----------------------------";
    41 "-------- build Script Expand_binoms -----------------------------";
    42 val scr_expand_binoms =
    43 "Script Expand_binoms t_t =" ^
    44 "(Repeat                       " ^
    45 "((Try (Repeat (Rewrite real_plus_binom_pow2    False))) @@ " ^
    46 " (Try (Repeat (Rewrite real_plus_binom_times   False))) @@ " ^
    47 " (Try (Repeat (Rewrite real_minus_binom_pow2   False))) @@ " ^
    48 " (Try (Repeat (Rewrite real_minus_binom_times  False))) @@ " ^
    49 " (Try (Repeat (Rewrite real_plus_minus_binom1  False))) @@ " ^
    50 " (Try (Repeat (Rewrite real_plus_minus_binom2  False))) @@ " ^
    51 
    52 " (Try (Repeat (Rewrite mult_1_left             False))) @@ " ^
    53 " (Try (Repeat (Rewrite mult_zero_left             False))) @@ " ^
    54 " (Try (Repeat (Rewrite add_0_left      False))) @@ " ^
    55 
    56 " (Try (Repeat (Calculate PLUS  ))) @@ " ^
    57 " (Try (Repeat (Calculate TIMES ))) @@ " ^
    58 " (Try (Repeat (Calculate POWER))) @@ " ^
    59 
    60 " (Try (Repeat (Rewrite sym_realpow_twoI        False))) @@ " ^
    61 " (Try (Repeat (Rewrite realpow_plus_1          False))) @@ " ^
    62 " (Try (Repeat (Rewrite sym_real_mult_2         False))) @@ " ^
    63 " (Try (Repeat (Rewrite real_mult_2_assoc       False))) @@ " ^
    64 
    65 " (Try (Repeat (Rewrite real_num_collect        False))) @@ " ^
    66 " (Try (Repeat (Rewrite real_num_collect_assoc  False))) @@ " ^
    67 
    68 " (Try (Repeat (Rewrite real_one_collect        False))) @@ " ^
    69 " (Try (Repeat (Rewrite real_one_collect_assoc  False))) @@ " ^ 
    70 
    71 " (Try (Repeat (Calculate PLUS  ))) @@ " ^
    72 " (Try (Repeat (Calculate TIMES ))) @@ " ^
    73 " (Try (Repeat (Calculate POWER)))) " ^  
    74 " t_t)";
    75 val scr_expand_binoms =
    76 "Script Expand_binoms t_t = t_t";
    77 
    78 val ---------------------------------------------- = "11111";
    79 parse thy scr_expand_binoms;
    80 val ---------------------------------------------- = "22222";
    81 (*----------------------------------------------
    82 
    83 "-------- investigate new uniary minus ---------------------------";
    84 "-------- investigate new uniary minus ---------------------------";
    85 "-------- investigate new uniary minus ---------------------------";
    86 val t = (#prop o rep_thm) real_diff_0; (*"0 - ?x = - ?x"*)
    87 atomty t;
    88 (*** -------------
    89 *** Const ( Trueprop, bool => prop)
    90 *** . Const ( op =, [real, real] => bool)
    91 *** . . Const ( op -, [real, real] => real)
    92 *** . . . Const ( 0, real)
    93 *** . . . Var ((x, 0), real)
    94 *** . . Const ( uminus, real => real)
    95 *** . . . Var ((x, 0), real)              *)
    96 
    97 val t = (term_of o the o (parse thy)) "-1";
    98 atomty t;
    99 (*** -------------
   100 *** Free ( -1, real)                      *)
   101 val t = (term_of o the o (parse thy)) "- 1";
   102 atomty t;
   103 (*** -------------
   104 *** Const ( uminus, real => real)
   105 *** . Free ( 1, real)                     *)
   106 
   107 val t = (term_of o the o (parse thy)) "-x"; (*1-x  syntyx error !!!*)
   108 atomty t;
   109 (**** -------------
   110 *** Free ( -x, real)*)
   111 val t = (term_of o the o (parse thy)) "- x";
   112 atomty t;
   113 (**** -------------
   114 *** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
   115 val t = (term_of o the o (parse thy)) "-(x)";
   116 atomty t;
   117 (**** -------------
   118 *** Free ( -x, real)*)
   119 
   120 
   121 "-------- Bsple aus Schalk I -------------------------------------";
   122 "-------- Bsple aus Schalk I -------------------------------------";
   123 "-------- Bsple aus Schalk I -------------------------------------";
   124 (*SPB Schalk I p.63 No.267b*)
   125 val t = str2term
   126  	    "(5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)";
   127 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   128 if (term2str t) = 
   129 "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
   130 then ()
   131 else error "poly.sml: diff.behav. in make_polynomial 1";
   132 
   133 (*SPB Schalk I p.63 No.275b*)
   134  val t = str2term
   135  	     "(3*x^^^2 - 2*x*y + y^^^2) * (x^^^2 - 2*y^^^2)";
   136  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   137  term2str t;
   138 if (term2str t) = 
   139 "3 * x ^^^ 4 + -2 * x ^^^ 3 * y + -5 * x ^^^ 2 * y ^^^ 2 + \
   140 \4 * x * y ^^^ 3 +\n-2 * y ^^^ 4"
   141 then ()
   142 else error "poly.sml: diff.behav. in make_polynomial 2";
   143 
   144 (*SPB Schalk I p.63 No.279b*)
   145  val t = str2term
   146  	     "(x-a)*(x-b)*(x-c)*(x-d)";
   147  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   148  term2str t;
   149 (* Richtig! *)
   150 if (term2str t) = 
   151 "a * b * c * d + -1 * a * b * c * x + -1 * a * b * d * x + a * b * x ^^^ 2 +\n-1 * a * c * d * x +\na * c * x ^^^ 2 +\na * d * x ^^^ 2 +\n-1 * a * x ^^^ 3 +\n-1 * b * c * d * x +\nb * c * x ^^^ 2 +\nb * d * x ^^^ 2 +\n-1 * b * x ^^^ 3 +\nc * d * x ^^^ 2 +\n-1 * c * x ^^^ 3 +\n-1 * d * x ^^^ 3 +\nx ^^^ 4"
   152 then ()
   153 else error "poly.sml: diff.behav. in make_polynomial 3";
   154 
   155 (*SPB Schalk I p.63 No.291*)
   156  val t = str2term
   157  "(5+96*x^^^3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (-15*x*(-8*x- 5)))";
   158  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   159  term2str t;
   160 if (term2str t) = 
   161 "50 + -770 * x + 4520 * x ^^^ 2 + -16320 * x ^^^ 3 + -26880 * x ^^^ 4"
   162 then ()
   163 else error "poly.sml: diff.behav. in make_polynomial 4";
   164 
   165 (*SPB Schalk I p.64 No.295c*)
   166  val t = str2term
   167  "(13*a^^^4*b^^^9*c - 12*a^^^3*b^^^6*c^^^9)^^^2";
   168  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   169  term2str t;
   170 if (term2str t) = 
   171 "169 * a ^^^ 8 * b ^^^ 18 * c ^^^ 2 + -312 * a ^^^ 7 * b ^^^ 15 * c ^^^ 10\
   172 \ +\n144 * a ^^^ 6 * b ^^^ 12 * c ^^^ 18"
   173 then ()
   174 else error "poly.sml: diff.behav. in make_polynomial 5";
   175 
   176 (*SPB Schalk I p.64 No.299a*)
   177  val t = str2term
   178  "(x - y)*(x + y)";
   179  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   180  term2str t;
   181 if (term2str t) = 
   182 "x ^^^ 2 + -1 * y ^^^ 2"
   183 then ()
   184 else error "poly.sml: diff.behav. in make_polynomial 6";
   185 
   186 (*SPB Schalk I p.64 No.300c*)
   187  val t = str2term
   188  "(3*x^^^2*y - 1)*(3*x^^^2*y + 1)";
   189  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   190  term2str t;
   191 if (term2str t) = 
   192 "-1 + 9 * x ^^^ 4 * y ^^^ 2"
   193 then ()
   194 else error "poly.sml: diff.behav. in make_polynomial 7";
   195 
   196 (*SPB Schalk I p.64 No.302*)
   197 val t = str2term
   198  "(13*x^^^2 + 5)*(13*x^^^2 - 5) - (5*x^^^2 + 3)*(5*x^^^2 - 3) - (12*x^^^2 + 4)*(12*x^^^2 - 4)";
   199 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   200 if term2str t = "0" then ()
   201 else error "poly.sml: diff.behav. in make_polynomial 8";
   202 (* Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
   203 
   204 
   205 (*SPB Schalk I p.64 No.306a*)
   206 val t = str2term "((x^^^2 + 1)*(x^^^2 - 1))^^^2";
   207 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   208 if (term2str t) = "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8" then ()
   209 else error "poly.sml: diff.behav. in make_polynomial: not confluent \
   210 		 \2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 = -2 * x ^^^ 4 works again";
   211 
   212 
   213 (*WN071729 when reducing "rls reduce_012_" for Schaerding,
   214 the above resulted in the term below ... but reduces from then correctly*)
   215 val t = str2term "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8";
   216 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   217 if (term2str t) = "1 + -2 * x ^^^ 4 + x ^^^ 8" then ()
   218 else error "poly.sml: diff.behav. in make_polynomial 9b";
   219 
   220 (*SPB Schalk I p.64 No.296a*)
   221 val t = str2term "(x - a)^^^3";
   222 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   223 if (term2str t) = "-1 * a ^^^ 3 + 3 * a ^^^ 2 * x + -3 * a * x ^^^ 2 + x ^^^ 3"
   224 then () else error "poly.sml: diff.behav. in make_polynomial 10";
   225 
   226 (*SPB Schalk I p.64 No.296c*)
   227 val t = str2term "(-3*x - 4*y)^^^3";
   228 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   229 if (term2str t) = 
   230 "-27 * x ^^^ 3 + -108 * x ^^^ 2 * y + -144 * x * y ^^^ 2 + -64 * y ^^^ 3"
   231 then () else error "poly.sml: diff.behav. in make_polynomial 11";
   232 
   233 (*SPB Schalk I p.62 No.242c*)
   234 val t = str2term "x^^^(-4)*(x^^^(-4)*y^^^(-2))^^^(-1)*y^^^(-2)";
   235 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   236 if (term2str t) = "1" then ()
   237 else error "poly.sml: diff.behav. in make_polynomial 12";
   238 
   239 (*SPB Schalk I p.60 No.209a*)
   240 val t = str2term "a^^^(7-x) * a^^^x";
   241 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   242 if term2str t = "a ^^^ 7" then ()
   243 else error "poly.sml: diff.behav. in make_polynomial 13";
   244 
   245 (*SPB Schalk I p.60 No.209d*)
   246 val t = str2term "d^^^x * d^^^(x+1) * d^^^(2 - 2*x)";
   247 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   248 if term2str t = "d ^^^ 3" then ()
   249 else error "poly.sml: diff.behav. in make_polynomial 14";
   250 
   251 
   252 (*---------------------------------------------------------------------*)
   253 (*------------------ Bsple bei denen es Probleme gibt------------------*)
   254 (*---------------------------------------------------------------------*)
   255 
   256 (*Schalk I p.64 No.303*)
   257 val t = str2term "(a + 2*b)*(a^^^2 + 4*b^^^2)*(a - 2*b) - (a - 6*b)*(a^^^2 + 36*b^^^2)*(a + 6*b)";
   258 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   259 if term2str t = "1280 * b ^^^ 4" then ()
   260 else error "poly.sml: diff.behav. in make_polynomial 14b";
   261 (* Richtig - aber Binomische Formel wurde nicht verwendet! *)
   262 
   263 
   264 (*--------------------------------------------------------------------*)
   265 (*----------------------- Eigene Beispiele ---------------------------*)
   266 (*--------------------------------------------------------------------*)
   267 (*SPO*)
   268 val t = str2term "a^^^2*a^^^(-2)";
   269 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   270 if term2str t = "1" then ()
   271 else error "poly.sml: diff.behav. in make_polynomial 15";
   272 (*SPO*)
   273 val t = str2term "a + a + a";
   274 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   275 if term2str t = "3 * a" then ()
   276 else error "poly.sml: diff.behav. in make_polynomial 16";
   277 (*SPO*)
   278 val t = str2term "a + b + b + b";
   279 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   280 if term2str t = "a + 3 * b" then ()
   281 else error "poly.sml: diff.behav. in make_polynomial 17";
   282 (*SPO*)
   283 val t = str2term "a^^^2*b*b^^^(-1)";
   284 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   285 if term2str t = "a ^^^ 2" then ()
   286 else error "poly.sml: diff.behav. in make_polynomial 18";
   287 (*SPO*)
   288 val t = str2term "a^^^2*a^^^(-2)";
   289 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   290 if (term2str t) = "1" then ()
   291 else error "poly.sml: diff.behav. in make_polynomial 19";
   292 (*SPO*)
   293 val t = str2term "b + a - b";
   294 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   295 if (term2str t) = "a" then ()
   296 else error "poly.sml: diff.behav. in make_polynomial 20";
   297 (*SPO*)
   298 val t = str2term "b * a * a";
   299 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   300 if term2str t = "a ^^^ 2 * b" then ()
   301 else error "poly.sml: diff.behav. in make_polynomial 21";
   302 (*SPO*)
   303 val t = str2term "(a^^^2)^^^3";
   304 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   305 if term2str t = "a ^^^ 6" then ()
   306 else error "poly.sml: diff.behav. in make_polynomial 22";
   307 (*SPO*)
   308 val t = str2term "x^^^2 * y^^^2 + x * x^^^2 * y";
   309 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   310 if term2str t = "x ^^^ 3 * y + x ^^^ 2 * y ^^^ 2" then ()
   311 else error "poly.sml: diff.behav. in make_polynomial 23";
   312 (*SPO*)
   313 val t = (term_of o the o (parse thy)) "a^^^2 * (-a)^^^2";
   314 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   315 if (term2str t) = "a ^^^ 4" then ()
   316 else error "poly.sml: diff.behav. in make_polynomial 24";
   317 (*SPO*)
   318 val t = str2term "a * b * b^^^(-1) + a";
   319 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   320 if (term2str t) = "2 * a" then ()
   321 else error "poly.sml: diff.behav. in make_polynomial 25";
   322 (*SPO*)
   323 val t = str2term "a*c*b^^^(2*n) + 3*a + 5*b^^^(2*n)*c*b";
   324 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
   325 if (term2str t) = "3 * a + 5 * b ^^^ (1 + 2 * n) * c + a * b ^^^ (2 * n) * c"
   326 then () else error "poly.sml: diff.behav. in make_polynomial 26";
   327 
   328 
   329 (*MG.27.6.03 -------------vvv-: Verschachtelte Terme -----------*)
   330 (*SPO*)
   331 val t = str2term "(1 + (x*y*a) + x)^^^(1 + (x*y*a) + x)";
   332  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   333  term2str t;
   334 if term2str t = "(1 + x + a * x * y) ^^^ (1 + x + a * x * y)"
   335  then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
   336 val t = str2term "(1 + x*(y*z)*zz)^^^(1 + x*(y*z)*zz)";
   337  val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
   338  term2str t;
   339 if term2str t = "(1 + x * y * z * zz) ^^^ (1 + x * y * z * zz)"
   340  then () else error "poly.sml: diff.behav. in make_polynomial 28";
   341 
   342 "-------- Script 'simplification for_polynomials' ----------------";
   343 "-------- Script 'simplification for_polynomials' ----------------";
   344 "-------- Script 'simplification for_polynomials' ----------------";
   345 val str = 
   346 "Script SimplifyScript (t_::real) =                \
   347 \  ((Rewrite_Set norm_Poly False) t_)";
   348 val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
   349 atomty sc;
   350 
   351 
   352 "-------- check pbl  'polynomial simplification' -----------------";
   353 "-------- check pbl  'polynomial simplification' -----------------";
   354 "-------- check pbl  'polynomial simplification' -----------------";
   355 val fmz = ["TERM ((5*x^^^2 + 3) * (2*x^^^7 + 3) \
   356 	   \- (3*x^^^5 + 8) * (6*x^^^4 - 1))",
   357 	   "normalform N"];
   358 (*0*)
   359 case refine fmz ["polynomial","simplification"]of
   360     [Matches (["polynomial", "simplification"], _)] => ()
   361   | _ => error "poly.sml diff.behav. in check pbl, refine";
   362 (*...if there is an error, then ...*)
   363 
   364 (*1*)
   365 print_depth 7;
   366 val pbt = get_pbt ["polynomial","simplification"];
   367 print_depth 3;
   368 (*if there is ...
   369 > val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
   370 ... then trace_rewrite:*)
   371 
   372 (*2*)
   373 trace_rewrite:=true; 
   374 match_pbl fmz pbt;
   375 trace_rewrite:=false;
   376 (*... if there is no rewrite, then there is something wrong with prls*)
   377 
   378 (*3*)
   379 print_depth 7;
   380 val prls = (#prls o get_pbt) ["polynomial","simplification"];
   381 print_depth 3;
   382 val t = str2term "((5*x^^^2 + 3) * (2*x^^^7 + 3) \
   383 		 \- (3*x^^^5 + 8) * (6*x^^^4 - 1)) is_polyexp";
   384 trace_rewrite:=true; 
   385 val SOME (t',_) = rewrite_set_ thy false prls t;
   386 trace_rewrite:=false;
   387 if t' = HOLogic.true_const then () 
   388 else error "poly.sml: diff.behav. in check pbl 'polynomial..";
   389 (*... if this works, but (*1*) does still NOT work, check types:*)
   390 
   391 (*4*)
   392 show_types:=true;
   393 (*
   394 > val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
   395 val wh = [False "(t_::real => real) (is_polyexp::real)"]
   396 ......................^^^^^^^^^^^^...............^^^^*)
   397 val Matches' _ = match_pbl fmz pbt;
   398 show_types:=false;
   399 
   400 
   401 "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
   402 "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
   403 "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
   404 val fmz = ["TERM ((5*x^^^2 + 3) * (2*x^^^7 + 3) \
   405 	   \- (3*x^^^5 + 8) * (6*x^^^4 - 1))",
   406 	   "normalform N"];
   407 val (dI',pI',mI') =
   408   ("Poly",["polynomial","simplification"],
   409    ["simplification","for_polynomials"]);
   410 val p = e_pos'; val c = []; 
   411 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   412 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   413 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   414 (writeln o (itms2str_ ctxt)) (get_obj g_pbl pt (fst p));
   415 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   416 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   417 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   418 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   419 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   420 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   421 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   422 if f2str f = 
   423 "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
   424 then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b";
   425 
   426 
   427 "-------- interSteps for Schalk 299a -----------------------------";
   428 "-------- interSteps for Schalk 299a -----------------------------";
   429 "-------- interSteps for Schalk 299a -----------------------------";
   430 states:=[];
   431 CalcTree
   432 [(["TERM ((x - y)*(x + y))", "normalform N"], 
   433   ("Poly",["polynomial","simplification"],
   434   ["simplification","for_polynomials"]))];
   435 Iterator 1;
   436 moveActiveRoot 1;
   437 autoCalculate 1 CompleteCalc;
   438 val ((pt,p),_) = get_calc 1; show_pt pt;
   439 
   440 interSteps 1 ([1],Res)(*<ERROR> syserror in detailstep </ERROR>*);
   441 val ((pt,p),_) = get_calc 1; show_pt pt;
   442 if existpt' ([1,1], Frm) pt then ()
   443 else error "poly.sml: interSteps doesnt work again 1";
   444 
   445 interSteps 1 ([1,1],Res)(*<ERROR> syserror in detailstep </ERROR>*);
   446 val ((pt,p),_) = get_calc 1; show_pt pt;
   447 if existpt' ([1,1,1], Frm) pt then ()
   448 else error "poly.sml: interSteps doesnt work again 2";
   449 
   450 
   451 "-------- norm_Poly NOT COMPLETE ---------------------------------";
   452 "-------- norm_Poly NOT COMPLETE ---------------------------------";
   453 "-------- norm_Poly NOT COMPLETE ---------------------------------";
   454 trace_rewrite:=true;
   455 val SOME (f',_) = rewrite_set_ thy false norm_Poly 
   456 (str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben")(*see poly.sml: -- norm_Poly NOT COMPLETE -- TODO MG*);
   457 trace_rewrite:=false;
   458 term2str f';
   459 
   460 "-------- ord_make_polynomial ------------------------------------";
   461 "-------- ord_make_polynomial ------------------------------------";
   462 "-------- ord_make_polynomial ------------------------------------";
   463 val t1 = str2term "2 * b + (3 * a + 3 * b)";
   464 val t2 = str2term "3 * a + 3 * b + 2 * b";
   465 
   466 if ord_make_polynomial true Poly.thy [] (t1, t2) then ()
   467 else error "poly.sml: diff.behav. in ord_make_polynomial";
   468 
   469 (*WN071202: ^^^ why then is there no rewriting ...*)
   470 val term = str2term "2*b + (3*a + 3*b)";
   471 val NONE = rewrite_set_ Isac.thy false order_add_mult term;
   472 
   473 (*or why is there no rewriting this way...*)
   474 val t1 = str2term "2 * b + (3 * a + 3 * b)";
   475 val t2 = str2term "3 * a + (2 * b + 3 * b)";
   476 
   477 
   478 ----------------------------------------------*)
   479 ===== inhibit exn ?===========================================================*)