test/Tools/isac/Knowledge/polyminus.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 37991 028442673981
child 38037 a51a70334191
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
    34 "----------- fun eval_ist_monom ----------------------------------";
    34 "----------- fun eval_ist_monom ----------------------------------";
    35 "----------- fun eval_ist_monom ----------------------------------";
    35 "----------- fun eval_ist_monom ----------------------------------";
    36 ist_monom (str2term "12");
    36 ist_monom (str2term "12");
    37 case eval_ist_monom 0 0 (str2term "12 ist_monom") 0 of
    37 case eval_ist_monom 0 0 (str2term "12 ist_monom") 0 of
    38     SOME ("12 ist_monom = True", _) => ()
    38     SOME ("12 ist_monom = True", _) => ()
    39   | _ => raise error "polyminus.sml: 12 ist_monom = True";
    39   | _ => error "polyminus.sml: 12 ist_monom = True";
    40 
    40 
    41 case eval_ist_monom 0 0 (str2term "a ist_monom") 0 of
    41 case eval_ist_monom 0 0 (str2term "a ist_monom") 0 of
    42     SOME ("a ist_monom = True", _) => ()
    42     SOME ("a ist_monom = True", _) => ()
    43   | _ => raise error "polyminus.sml: a ist_monom = True";
    43   | _ => error "polyminus.sml: a ist_monom = True";
    44 
    44 
    45 case eval_ist_monom 0 0 (str2term "(3*a) ist_monom") 0 of
    45 case eval_ist_monom 0 0 (str2term "(3*a) ist_monom") 0 of
    46     SOME ("3 * a ist_monom = True", _) => ()
    46     SOME ("3 * a ist_monom = True", _) => ()
    47   | _ => raise error "polyminus.sml: 3 * a ist_monom = True";
    47   | _ => error "polyminus.sml: 3 * a ist_monom = True";
    48 
    48 
    49 case eval_ist_monom 0 0 (str2term "(a^^^2) ist_monom") 0 of 
    49 case eval_ist_monom 0 0 (str2term "(a^^^2) ist_monom") 0 of 
    50    SOME ("a ^^^ 2 ist_monom = True", _) => ()
    50    SOME ("a ^^^ 2 ist_monom = True", _) => ()
    51   | _ => raise error "polyminus.sml: a^^^2 ist_monom = True";
    51   | _ => error "polyminus.sml: a^^^2 ist_monom = True";
    52 
    52 
    53 case eval_ist_monom 0 0 (str2term "(3*a^^^2) ist_monom") 0 of
    53 case eval_ist_monom 0 0 (str2term "(3*a^^^2) ist_monom") 0 of
    54     SOME ("3 * a ^^^ 2 ist_monom = True", _) => ()
    54     SOME ("3 * a ^^^ 2 ist_monom = True", _) => ()
    55   | _ => raise error "polyminus.sml: 3*a^^^2 ist_monom = True";
    55   | _ => error "polyminus.sml: 3*a^^^2 ist_monom = True";
    56 
    56 
    57 case eval_ist_monom 0 0 (str2term "(a*b) ist_monom") 0 of
    57 case eval_ist_monom 0 0 (str2term "(a*b) ist_monom") 0 of
    58     SOME ("a * b ist_monom = True", _) => ()
    58     SOME ("a * b ist_monom = True", _) => ()
    59   | _ => raise error "polyminus.sml: a*b ist_monom = True";
    59   | _ => error "polyminus.sml: a*b ist_monom = True";
    60 
    60 
    61 case eval_ist_monom 0 0 (str2term "(3*a*b) ist_monom") 0 of
    61 case eval_ist_monom 0 0 (str2term "(3*a*b) ist_monom") 0 of
    62     SOME ("3 * a * b ist_monom = True", _) => ()
    62     SOME ("3 * a * b ist_monom = True", _) => ()
    63   | _ => raise error "polyminus.sml: 3*a*b ist_monom = True";
    63   | _ => error "polyminus.sml: 3*a*b ist_monom = True";
    64 
    64 
    65 
    65 
    66 "----------- watch order_add_mult  -------------------------------";
    66 "----------- watch order_add_mult  -------------------------------";
    67 "----------- watch order_add_mult  -------------------------------";
    67 "----------- watch order_add_mult  -------------------------------";
    68 "----------- watch order_add_mult  -------------------------------";
    68 "----------- watch order_add_mult  -------------------------------";
    70 trace_rewrite:=true;
    70 trace_rewrite:=true;
    71 trace_rewrite:=false;
    71 trace_rewrite:=false;
    72 val t = str2term "((a + d) + c) + b";
    72 val t = str2term "((a + d) + c) + b";
    73 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
    73 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
    74 if term2str t = "a + (b + (c + d))" then ()
    74 if term2str t = "a + (b + (c + d))" then ()
    75 else raise error "polyminus.sml 1 watch order_add_mult";
    75 else error "polyminus.sml 1 watch order_add_mult";
    76 trace_rewrite:=false;
    76 trace_rewrite:=false;
    77 
    77 
    78 "----- the same stepwise...";
    78 "----- the same stepwise...";
    79 val od = ord_make_polynomial true Poly.thy;
    79 val od = ord_make_polynomial true Poly.thy;
    80 val t = str2term "((a + d) + c) + b";
    80 val t = str2term "((a + d) + c) + b";
    86 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
    86 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
    87 "b + (a + (c + d))";
    87 "b + (a + (c + d))";
    88 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
    88 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
    89 "a + (b + (c + d))";
    89 "a + (b + (c + d))";
    90 if term2str t = "a + (b + (c + d))" then ()
    90 if term2str t = "a + (b + (c + d))" then ()
    91 else raise error "polyminus.sml 2 watch order_add_mult";
    91 else error "polyminus.sml 2 watch order_add_mult";
    92 
    92 
    93 "----- if parentheses are right, left_commute is (almost) sufficient...";
    93 "----- if parentheses are right, left_commute is (almost) sufficient...";
    94 val t = str2term "a + (d + (c + b))";
    94 val t = str2term "a + (d + (c + b))";
    95 "a + (d + (c + b))";
    95 "a + (d + (c + b))";
    96 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
    96 val SOME (t,_) = rewrite_ thy od e_rls true add_left_commute t;term2str t;
   103 "----- but we do not want the parentheses at right; thus: cond.rew.";
   103 "----- but we do not want the parentheses at right; thus: cond.rew.";
   104 "WN0712707 complicated monomials do not yet work ...";
   104 "WN0712707 complicated monomials do not yet work ...";
   105 val t = str2term "((5*a + 4*d) + 3*c) + 2*b";
   105 val t = str2term "((5*a + 4*d) + 3*c) + 2*b";
   106 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
   106 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
   107 if term2str t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
   107 if term2str t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
   108 else raise error "polyminus.sml: order_add_mult changed";
   108 else error "polyminus.sml: order_add_mult changed";
   109 
   109 
   110 "----- here we see rew_sub going into subterm with ord.rew....";
   110 "----- here we see rew_sub going into subterm with ord.rew....";
   111 val od = ord_make_polynomial false Poly.thy;
   111 val od = ord_make_polynomial false Poly.thy;
   112 val t = str2term "b + a + c + d";
   112 val t = str2term "b + a + c + d";
   113 val SOME (t,_) = rewrite_ thy od e_rls false add_commute t; term2str t;
   113 val SOME (t,_) = rewrite_ thy od e_rls false add_commute t; term2str t;
   128 str2term "aaa";
   128 str2term "aaa";
   129 str2term "222 * aaa";
   129 str2term "222 * aaa";
   130 (*
   130 (*
   131 case eval_kleiner 0 0 (str2term "123 kleiner 32") 0 of
   131 case eval_kleiner 0 0 (str2term "123 kleiner 32") 0 of
   132     SOME ("12 kleiner 9 = False", _) => ()
   132     SOME ("12 kleiner 9 = False", _) => ()
   133   | _ => raise error "polyminus.sml: 12 kleiner 9 = False";
   133   | _ => error "polyminus.sml: 12 kleiner 9 = False";
   134 *)
   134 *)
   135 case eval_kleiner 0 0 (str2term "a kleiner b") 0 of
   135 case eval_kleiner 0 0 (str2term "a kleiner b") 0 of
   136     SOME ("a kleiner b = True", _) => ()
   136     SOME ("a kleiner b = True", _) => ()
   137   | _ => raise error "polyminus.sml: a kleiner b = True";
   137   | _ => error "polyminus.sml: a kleiner b = True";
   138 
   138 
   139 case eval_kleiner 0 0 (str2term "(10*g) kleiner f") 0 of
   139 case eval_kleiner 0 0 (str2term "(10*g) kleiner f") 0 of
   140     SOME ("10 * g kleiner f = False", _) => ()
   140     SOME ("10 * g kleiner f = False", _) => ()
   141   | _ => raise error "polyminus.sml: 10 * g kleiner f = False";
   141   | _ => error "polyminus.sml: 10 * g kleiner f = False";
   142 
   142 
   143 case eval_kleiner 0 0 (str2term "(a^^^2) kleiner b") 0 of
   143 case eval_kleiner 0 0 (str2term "(a^^^2) kleiner b") 0 of
   144     SOME ("a ^^^ 2 kleiner b = True", _) => ()
   144     SOME ("a ^^^ 2 kleiner b = True", _) => ()
   145   | _ => raise error "polyminus.sml: a ^^^ 2 kleiner b = True";
   145   | _ => error "polyminus.sml: a ^^^ 2 kleiner b = True";
   146 
   146 
   147 case eval_kleiner 0 0 (str2term "(3*a^^^2) kleiner b") 0 of
   147 case eval_kleiner 0 0 (str2term "(3*a^^^2) kleiner b") 0 of
   148     SOME ("3 * a ^^^ 2 kleiner b = True", _) => ()
   148     SOME ("3 * a ^^^ 2 kleiner b = True", _) => ()
   149   | _ => raise error "polyminus.sml: 3 * a ^^^ 2 kleiner b = True";
   149   | _ => error "polyminus.sml: 3 * a ^^^ 2 kleiner b = True";
   150 
   150 
   151 case eval_kleiner 0 0 (str2term "(a*b) kleiner c") 0 of
   151 case eval_kleiner 0 0 (str2term "(a*b) kleiner c") 0 of
   152     SOME ("a * b kleiner c = True", _) => ()
   152     SOME ("a * b kleiner c = True", _) => ()
   153   | _ => raise error "polyminus.sml: a * b kleiner b = True";
   153   | _ => error "polyminus.sml: a * b kleiner b = True";
   154 
   154 
   155 case eval_kleiner 0 0 (str2term "(3*a*b) kleiner c") 0 of
   155 case eval_kleiner 0 0 (str2term "(3*a*b) kleiner c") 0 of
   156     SOME ("3 * a * b kleiner c = True", _) => ()
   156     SOME ("3 * a * b kleiner c = True", _) => ()
   157   | _ => raise error "polyminus.sml: 3 * a * b kleiner b = True";
   157   | _ => error "polyminus.sml: 3 * a * b kleiner b = True";
   158 
   158 
   159 
   159 
   160 
   160 
   161 "----- compare tausche_plus with real_num_collect";
   161 "----- compare tausche_plus with real_num_collect";
   162 val od = dummy_ord;
   162 val od = dummy_ord;
   163 
   163 
   164 val erls = erls_ordne_alphabetisch;
   164 val erls = erls_ordne_alphabetisch;
   165 val t = str2term "b + a";
   165 val t = str2term "b + a";
   166 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
   166 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
   167 if term2str t = "a + b" then ()
   167 if term2str t = "a + b" then ()
   168 else raise error "polyminus.sml: ordne_alphabetisch1 b + a";
   168 else error "polyminus.sml: ordne_alphabetisch1 b + a";
   169 
   169 
   170 val erls = Atools_erls;
   170 val erls = Atools_erls;
   171 val t = str2term "2*a + 3*a";
   171 val t = str2term "2*a + 3*a";
   172 val SOME (t,_) = rewrite_ thy od erls false real_num_collect t; term2str t;
   172 val SOME (t,_) = rewrite_ thy od erls false real_num_collect t; term2str t;
   173 
   173 
   175 trace_rewrite:=true;
   175 trace_rewrite:=true;
   176 val erls = erls_ordne_alphabetisch;
   176 val erls = erls_ordne_alphabetisch;
   177 val t = str2term "b + a";
   177 val t = str2term "b + a";
   178 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   178 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   179 if term2str t = "a + b" then ()
   179 if term2str t = "a + b" then ()
   180 else raise error "polyminus.sml: ordne_alphabetisch a + b";
   180 else error "polyminus.sml: ordne_alphabetisch a + b";
   181 
   181 
   182 val t = str2term "2*b + a";
   182 val t = str2term "2*b + a";
   183 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   183 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   184 if term2str t = "a + 2 * b" then ()
   184 if term2str t = "a + 2 * b" then ()
   185 else raise error "polyminus.sml: ordne_alphabetisch a + 2 * b";
   185 else error "polyminus.sml: ordne_alphabetisch a + 2 * b";
   186 
   186 
   187 val t = str2term "a + c + b";
   187 val t = str2term "a + c + b";
   188 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   188 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   189 if term2str t = "a + b + c" then ()
   189 if term2str t = "a + b + c" then ()
   190 else raise error "polyminus.sml: ordne_alphabetisch a + b + c";
   190 else error "polyminus.sml: ordne_alphabetisch a + b + c";
   191 
   191 
   192 "----- rewrite goes into subterms";
   192 "----- rewrite goes into subterms";
   193 val t = str2term "a + c + b + d";
   193 val t = str2term "a + c + b + d";
   194 val SOME (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
   194 val SOME (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
   195 if term2str t = "a + b + c + d" then ()
   195 if term2str t = "a + b + c + d" then ()
   196 else raise error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
   196 else error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
   197 
   197 
   198 val t = str2term "a + c + d + b";
   198 val t = str2term "a + c + d + b";
   199 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   199 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   200 if term2str t = "a + b + c + d" then ()
   200 if term2str t = "a + b + c + d" then ()
   201 else raise error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
   201 else error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
   202 
   202 
   203 "----- here we see rew_sub going into subterm with cond.rew....";
   203 "----- here we see rew_sub going into subterm with cond.rew....";
   204 val t = str2term "b + a + c + d";
   204 val t = str2term "b + a + c + d";
   205 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
   205 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
   206 if term2str t = "a + b + c + d" then ()
   206 if term2str t = "a + b + c + d" then ()
   207 else raise error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
   207 else error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
   208 
   208 
   209 "----- compile rls for the most complicated terms";
   209 "----- compile rls for the most complicated terms";
   210 val t = str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
   210 val t = str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
   211 "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
   211 "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
   212 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; 
   212 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; 
   213 if term2str t = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"
   213 if term2str t = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"
   214 then () else raise error "polyminus.sml: ordne_alphabetisch finished";
   214 then () else error "polyminus.sml: ordne_alphabetisch finished";
   215 
   215 
   216 
   216 
   217 "----------- build fasse_zusammen --------------------------------";
   217 "----------- build fasse_zusammen --------------------------------";
   218 "----------- build fasse_zusammen --------------------------------";
   218 "----------- build fasse_zusammen --------------------------------";
   219 "----------- build fasse_zusammen --------------------------------";
   219 "----------- build fasse_zusammen --------------------------------";
   220 val t = str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";
   220 val t = str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";
   221 val SOME (t,_) = rewrite_set_ thy false fasse_zusammen t;
   221 val SOME (t,_) = rewrite_set_ thy false fasse_zusammen t;
   222 if term2str t = "3 + -2 * e + 2 * f + 2 * g" then ()
   222 if term2str t = "3 + -2 * e + 2 * f + 2 * g" then ()
   223 else raise error "polyminus.sml: fasse_zusammen finished";
   223 else error "polyminus.sml: fasse_zusammen finished";
   224 
   224 
   225 "----------- build verschoenere ----------------------------------";
   225 "----------- build verschoenere ----------------------------------";
   226 "----------- build verschoenere ----------------------------------";
   226 "----------- build verschoenere ----------------------------------";
   227 "----------- build verschoenere ----------------------------------";
   227 "----------- build verschoenere ----------------------------------";
   228 val t = str2term "3 + -2 * e + 2 * f + 2 * g";
   228 val t = str2term "3 + -2 * e + 2 * f + 2 * g";
   229 val SOME (t,_) = rewrite_set_ thy false verschoenere t;
   229 val SOME (t,_) = rewrite_set_ thy false verschoenere t;
   230 if term2str t = "3 - 2 * e + 2 * f + 2 * g" then ()
   230 if term2str t = "3 - 2 * e + 2 * f + 2 * g" then ()
   231 else raise error "polyminus.sml: verschoenere 3 + -2 * e ...";
   231 else error "polyminus.sml: verschoenere 3 + -2 * e ...";
   232 
   232 
   233 trace_rewrite:=true;
   233 trace_rewrite:=true;
   234 trace_rewrite:=false;
   234 trace_rewrite:=false;
   235 
   235 
   236 "----------- met simplification for_polynomials with_minus -------";
   236 "----------- met simplification for_polynomials with_minus -------";
   257 moveActiveRoot 1;
   257 moveActiveRoot 1;
   258 autoCalculate 1 CompleteCalc;
   258 autoCalculate 1 CompleteCalc;
   259 val ((pt,p),_) = get_calc 1; show_pt pt;
   259 val ((pt,p),_) = get_calc 1; show_pt pt;
   260 if p = ([], Res) andalso 
   260 if p = ([], Res) andalso 
   261    term2str (get_obj g_res pt (fst p)) = "3 - 2 * e + 2 * f + 2 * g"
   261    term2str (get_obj g_res pt (fst p)) = "3 - 2 * e + 2 * f + 2 * g"
   262 then () else raise error "polyminus.sml: Vereinfache (3 - 2 * e + 2 * f...";
   262 then () else error "polyminus.sml: Vereinfache (3 - 2 * e + 2 * f...";
   263 
   263 
   264 "----------- 140 d ---";
   264 "----------- 140 d ---";
   265 states:=[];
   265 states:=[];
   266 CalcTree [(["TERM (-r - 2*s - 3*t + 5 + 4*r + 8*s - 5*t - 2)",
   266 CalcTree [(["TERM (-r - 2*s - 3*t + 5 + 4*r + 8*s - 5*t - 2)",
   267 	    "normalform N"],
   267 	    "normalform N"],
   270 moveActiveRoot 1;
   270 moveActiveRoot 1;
   271 autoCalculate 1 CompleteCalc;
   271 autoCalculate 1 CompleteCalc;
   272 val ((pt,p),_) = get_calc 1; show_pt pt;
   272 val ((pt,p),_) = get_calc 1; show_pt pt;
   273 if p = ([], Res) andalso 
   273 if p = ([], Res) andalso 
   274    term2str (get_obj g_res pt (fst p)) = "3 + 3 * r + 6 * s - 8 * t"
   274    term2str (get_obj g_res pt (fst p)) = "3 + 3 * r + 6 * s - 8 * t"
   275 then () else raise error "polyminus.sml: Vereinfache 140 d)";
   275 then () else error "polyminus.sml: Vereinfache 140 d)";
   276 
   276 
   277 
   277 
   278 "----------- 139 c ---";
   278 "----------- 139 c ---";
   279 states:=[];
   279 states:=[];
   280 CalcTree [(["TERM (3*e - 6*f - 8*e - 4*f + 5*e + 7*f)",
   280 CalcTree [(["TERM (3*e - 6*f - 8*e - 4*f + 5*e + 7*f)",
   284 moveActiveRoot 1;
   284 moveActiveRoot 1;
   285 autoCalculate 1 CompleteCalc;
   285 autoCalculate 1 CompleteCalc;
   286 val ((pt,p),_) = get_calc 1; show_pt pt;
   286 val ((pt,p),_) = get_calc 1; show_pt pt;
   287 if p = ([], Res) andalso 
   287 if p = ([], Res) andalso 
   288    term2str (get_obj g_res pt (fst p)) = "- (3 * f)"
   288    term2str (get_obj g_res pt (fst p)) = "- (3 * f)"
   289 then () else raise error "polyminus.sml: Vereinfache 139 c)";
   289 then () else error "polyminus.sml: Vereinfache 139 c)";
   290 
   290 
   291 "----------- 139 b ---";
   291 "----------- 139 b ---";
   292 states:=[];
   292 states:=[];
   293 CalcTree [(["TERM (8*u - 5*v - 5*u + 7*v - 6*u - 3*v)",
   293 CalcTree [(["TERM (8*u - 5*v - 5*u + 7*v - 6*u - 3*v)",
   294 	    "normalform N"],
   294 	    "normalform N"],
   297 moveActiveRoot 1;
   297 moveActiveRoot 1;
   298 autoCalculate 1 CompleteCalc;
   298 autoCalculate 1 CompleteCalc;
   299 val ((pt,p),_) = get_calc 1; show_pt pt;
   299 val ((pt,p),_) = get_calc 1; show_pt pt;
   300 if p = ([], Res) andalso 
   300 if p = ([], Res) andalso 
   301    term2str (get_obj g_res pt (fst p)) = "-3 * u - v"
   301    term2str (get_obj g_res pt (fst p)) = "-3 * u - v"
   302 then () else raise error "polyminus.sml: Vereinfache 139 b)";
   302 then () else error "polyminus.sml: Vereinfache 139 b)";
   303 
   303 
   304 "----------- 138 a ---";
   304 "----------- 138 a ---";
   305 states:=[];
   305 states:=[];
   306 CalcTree [(["TERM (2*u - 3*v - 6*u + 5*v)",
   306 CalcTree [(["TERM (2*u - 3*v - 6*u + 5*v)",
   307 	    "normalform N"],
   307 	    "normalform N"],
   310 moveActiveRoot 1;
   310 moveActiveRoot 1;
   311 autoCalculate 1 CompleteCalc;
   311 autoCalculate 1 CompleteCalc;
   312 val ((pt,p),_) = get_calc 1; show_pt pt;
   312 val ((pt,p),_) = get_calc 1; show_pt pt;
   313 if p = ([], Res) andalso 
   313 if p = ([], Res) andalso 
   314    term2str (get_obj g_res pt (fst p)) = "-4 * u + 2 * v"
   314    term2str (get_obj g_res pt (fst p)) = "-4 * u + 2 * v"
   315 then () else raise error "polyminus.sml: Vereinfache 138 a)";
   315 then () else error "polyminus.sml: Vereinfache 138 a)";
   316 
   316 
   317 
   317 
   318 "----------- met probe fuer_polynom ------------------------------";
   318 "----------- met probe fuer_polynom ------------------------------";
   319 "----------- met probe fuer_polynom ------------------------------";
   319 "----------- met probe fuer_polynom ------------------------------";
   320 "----------- met probe fuer_polynom ------------------------------";
   320 "----------- met probe fuer_polynom ------------------------------";
   347    val ((pt,p),_) = get_calc 1; term2str (get_obj g_res pt (fst p));
   347    val ((pt,p),_) = get_calc 1; term2str (get_obj g_res pt (fst p));
   348 @@@@@WN081114 gives "??.empty", all "Pruefe" are the same,
   348 @@@@@WN081114 gives "??.empty", all "Pruefe" are the same,
   349 although analogies work in interface.sml: FIXME.WN081114 in "Pruefe"*)
   349 although analogies work in interface.sml: FIXME.WN081114 in "Pruefe"*)
   350 val ((pt,p),_) = get_calc 1;
   350 val ((pt,p),_) = get_calc 1;
   351 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "11 = 11"
   351 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "11 = 11"
   352 then () else raise error "polyminus.sml: Probe 11 = 11";
   352 then () else error "polyminus.sml: Probe 11 = 11";
   353 show_pt pt;
   353 show_pt pt;
   354 
   354 
   355 
   355 
   356 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
   356 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
   357 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
   357 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
   364 moveActiveRoot 1;
   364 moveActiveRoot 1;
   365 autoCalculate 1 CompleteCalc;
   365 autoCalculate 1 CompleteCalc;
   366 val ((pt,p),_) = get_calc 1;
   366 val ((pt,p),_) = get_calc 1;
   367 if p = ([], Res) andalso 
   367 if p = ([], Res) andalso 
   368    term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
   368    term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
   369 then () else raise error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
   369 then () else error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
   370 show_pt pt;
   370 show_pt pt;
   371 
   371 
   372 "----- probe p.34 -----";
   372 "----- probe p.34 -----";
   373 states:=[];
   373 states:=[];
   374 CalcTree [(["Pruefe (2*u - 5 - (3 - 4*u) + (8*u + 9) = 1 + 14 * u)",
   374 CalcTree [(["Pruefe (2*u - 5 - (3 - 4*u) + (8*u + 9) = 1 + 14 * u)",
   378 	    ["probe","fuer_polynom"]))];
   378 	    ["probe","fuer_polynom"]))];
   379 moveActiveRoot 1;
   379 moveActiveRoot 1;
   380 autoCalculate 1 CompleteCalc;
   380 autoCalculate 1 CompleteCalc;
   381 val ((pt,p),_) = get_calc 1;
   381 val ((pt,p),_) = get_calc 1;
   382 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "29 = 29"
   382 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "29 = 29"
   383 then () else raise error "polyminus.sml: Probe 29 = 29";
   383 then () else error "polyminus.sml: Probe 29 = 29";
   384 show_pt pt;
   384 show_pt pt;
   385 
   385 
   386 
   386 
   387 "----------- try fun applyTactics --------------------------------";
   387 "----------- try fun applyTactics --------------------------------";
   388 "----------- try fun applyTactics --------------------------------";
   388 "----------- try fun applyTactics --------------------------------";
   454 	    ["simplification","for_polynomials","with_minus"]))];
   454 	    ["simplification","for_polynomials","with_minus"]))];
   455 moveActiveRoot 1;
   455 moveActiveRoot 1;
   456 autoCalculate 1 CompleteCalc;
   456 autoCalculate 1 CompleteCalc;
   457 val ((pt,p),_) = get_calc 1; show_pt pt;
   457 val ((pt,p),_) = get_calc 1; show_pt pt;
   458 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "2 * g + h"
   458 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "2 * g + h"
   459 then () else raise error "polyminus.sml: addiere_vor_minus";
   459 then () else error "polyminus.sml: addiere_vor_minus";
   460 
   460 
   461 
   461 
   462 states:=[];
   462 states:=[];
   463 CalcTree [(["TERM (- (8 * g) + 10 * g + f)",
   463 CalcTree [(["TERM (- (8 * g) + 10 * g + f)",
   464 	    "normalform N"],
   464 	    "normalform N"],
   466 	    ["simplification","for_polynomials","with_minus"]))];
   466 	    ["simplification","for_polynomials","with_minus"]))];
   467 moveActiveRoot 1;
   467 moveActiveRoot 1;
   468 autoCalculate 1 CompleteCalc;
   468 autoCalculate 1 CompleteCalc;
   469 val ((pt,p),_) = get_calc 1; show_pt pt;
   469 val ((pt,p),_) = get_calc 1; show_pt pt;
   470 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "f + 2 * g"
   470 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "f + 2 * g"
   471 then () else raise error "polyminus.sml: tausche_vor_plus";
   471 then () else error "polyminus.sml: tausche_vor_plus";
   472 
   472 
   473 
   473 
   474 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   474 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   475 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   475 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   476 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   476 "----------- pbl binom polynom vereinfachen p.39 -----------------";
   518 val ((pt,p),_) = get_calc 1; show_pt pt;
   518 val ((pt,p),_) = get_calc 1; show_pt pt;
   519 
   519 
   520 (*
   520 (*
   521 if p = ([], Res) andalso 
   521 if p = ([], Res) andalso 
   522    term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
   522    term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
   523 then () else raise error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
   523 then () else error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
   524 *)
   524 *)
   525 
   525 
   526 
   526 
   527 "----------- pbl binom polynom vereinfachen: cube ----------------";
   527 "----------- pbl binom polynom vereinfachen: cube ----------------";
   528 "----------- pbl binom polynom vereinfachen: cube ----------------";
   528 "----------- pbl binom polynom vereinfachen: cube ----------------";
   553 	    \3 * (a - 2 * q))";
   553 	    \3 * (a - 2 * q))";
   554 val ma = eval_matchsub "" "Tools.matchsub" t thy;
   554 val ma = eval_matchsub "" "Tools.matchsub" t thy;
   555 case ma of
   555 case ma of
   556     SOME ("matchsub (?a * (?b - ?c)) (8 * (a - q) + \
   556     SOME ("matchsub (?a * (?b - ?c)) (8 * (a - q) + \
   557 	  \a - 2 * q + 3 * (a - 2 * q)) = True", _) => ()
   557 	  \a - 2 * q + 3 * (a - 2 * q)) = True", _) => ()
   558   | _ => raise error "polyminus.sml matchsub (?a * (?b - ?c)...A";
   558   | _ => error "polyminus.sml matchsub (?a * (?b - ?c)...A";
   559 
   559 
   560 "--- does the respective prls rewrite ?";
   560 "--- does the respective prls rewrite ?";
   561 val prls = append_rls "prls_pbl_vereinf_poly" e_rls 
   561 val prls = append_rls "prls_pbl_vereinf_poly" e_rls 
   562 	     [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
   562 	     [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
   563 	      Calc ("Tools.matchsub", eval_matchsub ""),
   563 	      Calc ("Tools.matchsub", eval_matchsub ""),
   581 	    \     matchsub ((?b - ?c) * ?a) (8 * (a - q) + a - 2 * q) )";
   581 	    \     matchsub ((?b - ?c) * ?a) (8 * (a - q) + a - 2 * q) )";
   582 trace_rewrite := true;
   582 trace_rewrite := true;
   583 val SOME (t', _) = rewrite_set_ thy false prls t;
   583 val SOME (t', _) = rewrite_set_ thy false prls t;
   584 trace_rewrite := false;
   584 trace_rewrite := false;
   585 if term2str t' = "False" then ()
   585 if term2str t' = "False" then ()
   586 else raise error "polyminus.sml Not (matchsub (?a * (?b + ?c)) (8 ...";
   586 else error "polyminus.sml Not (matchsub (?a * (?b + ?c)) (8 ...";
   587 
   587 
   588 
   588 
   589 
   589 
   590 
   590 
   591 
   591