test/Tools/isac/Knowledge/integrate.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38030 95d956108461
child 38048 377d9061ec3e
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
    44 val t = str2term "Integral x^^^2 D x";
    44 val t = str2term "Integral x^^^2 D x";
    45 atomty t;
    45 atomty t;
    46 
    46 
    47 val t = str2term "ff x is_f_x";
    47 val t = str2term "ff x is_f_x";
    48 case t of Const ("Integrate.is'_f'_x", _) $ _ => ()
    48 case t of Const ("Integrate.is'_f'_x", _) $ _ => ()
    49 	| _ => raise error "integrate.sml: parsing: ff x is_f_x";
    49 	| _ => error "integrate.sml: parsing: ff x is_f_x";
    50 
    50 
    51 
    51 
    52 "----------- integrate by rewriting ---------------------";
    52 "----------- integrate by rewriting ---------------------";
    53 "----------- integrate by rewriting ---------------------";
    53 "----------- integrate by rewriting ---------------------";
    54 "----------- integrate by rewriting ---------------------";
    54 "----------- integrate by rewriting ---------------------";
    97 "----------- test add_new_c, is_f_x ---------------------";
    97 "----------- test add_new_c, is_f_x ---------------------";
    98 "----------- test add_new_c, is_f_x ---------------------";
    98 "----------- test add_new_c, is_f_x ---------------------";
    99 "----------- test add_new_c, is_f_x ---------------------";
    99 "----------- test add_new_c, is_f_x ---------------------";
   100 val term = str2term "x^^^2*c + c_2";
   100 val term = str2term "x^^^2*c + c_2";
   101 val cc = new_c term;
   101 val cc = new_c term;
   102 if term2str cc = "c_3" then () else raise error "integrate.sml: new_c ???";
   102 if term2str cc = "c_3" then () else error "integrate.sml: new_c ???";
   103 
   103 
   104 val SOME (id,t') = eval_add_new_c "" "Integrate.add'_new'_c" term thy;
   104 val SOME (id,t') = eval_add_new_c "" "Integrate.add'_new'_c" term thy;
   105 if term2str t' = "x ^^^ 2 * c + c_2 = x ^^^ 2 * c + c_2 + c_3" then ()
   105 if term2str t' = "x ^^^ 2 * c + c_2 = x ^^^ 2 * c + c_2 + c_3" then ()
   106 else raise error "intergrate.sml: diff. eval_add_new_c";
   106 else error "intergrate.sml: diff. eval_add_new_c";
   107 
   107 
   108 val cc = ("Integrate.add'_new'_c", eval_add_new_c "add_new_c_");
   108 val cc = ("Integrate.add'_new'_c", eval_add_new_c "add_new_c_");
   109 val SOME (thmstr, thm) = get_calculation1_ thy cc term;
   109 val SOME (thmstr, thm) = get_calculation1_ thy cc term;
   110 
   110 
   111 val SOME (t',_) = rewrite_set_ thy true add_new_c term;
   111 val SOME (t',_) = rewrite_set_ thy true add_new_c term;
   112 if term2str t' = "x ^^^ 2 * c + c_2 + c_3" then ()
   112 if term2str t' = "x ^^^ 2 * c + c_2 + c_3" then ()
   113 else raise error "intergrate.sml: diff. rewrite_set add_new_c 1";
   113 else error "intergrate.sml: diff. rewrite_set add_new_c 1";
   114 
   114 
   115 val term = str2term "ff x = x^^^2*c + c_2";
   115 val term = str2term "ff x = x^^^2*c + c_2";
   116 val SOME (t',_) = rewrite_set_ thy true add_new_c term;
   116 val SOME (t',_) = rewrite_set_ thy true add_new_c term;
   117 if term2str t' = "ff x = x ^^^ 2 * c + c_2 + c_3" then ()
   117 if term2str t' = "ff x = x ^^^ 2 * c + c_2 + c_3" then ()
   118 else raise error "intergrate.sml: diff. rewrite_set add_new_c 2";
   118 else error "intergrate.sml: diff. rewrite_set add_new_c 2";
   119 
   119 
   120 
   120 
   121 (*WN080222 replace call_new_c with add_new_c----------------------
   121 (*WN080222 replace call_new_c with add_new_c----------------------
   122 val term = str2term "new_c (c * x^^^2 + c_2)";
   122 val term = str2term "new_c (c * x^^^2 + c_2)";
   123 val SOME (_,t') = eval_new_c 0 0 term 0;
   123 val SOME (_,t') = eval_new_c 0 0 term 0;
   124 if term2s t' = "new_c c * x ^^^ 2 + c_2 = c_3" then ()
   124 if term2s t' = "new_c c * x ^^^ 2 + c_2 = c_3" then ()
   125 else raise error "integrate.sml: eval_new_c ???";
   125 else error "integrate.sml: eval_new_c ???";
   126 
   126 
   127 val t = str2term "matches (?u + new_c ?v) (x ^^^ 2 / 2)";
   127 val t = str2term "matches (?u + new_c ?v) (x ^^^ 2 / 2)";
   128 val SOME (_,t') = eval_matches "" "Tools.matches" t thy; term2s t';
   128 val SOME (_,t') = eval_matches "" "Tools.matches" t thy; term2s t';
   129 if term2s t' = "matches (?u + new_c ?v) (x ^^^ 2 / 2) = False" then ()
   129 if term2s t' = "matches (?u + new_c ?v) (x ^^^ 2 / 2) = False" then ()
   130 else raise error "integrate.sml: matches new_c = False";
   130 else error "integrate.sml: matches new_c = False";
   131 
   131 
   132 val t = str2term "matches (?u + new_c ?v) (x ^^^ 2 / 2 + new_c x ^^^ 2 / 2)";
   132 val t = str2term "matches (?u + new_c ?v) (x ^^^ 2 / 2 + new_c x ^^^ 2 / 2)";
   133 val SOME (_,t') = eval_matches "" "Tools.matches" t thy; term2s t';
   133 val SOME (_,t') = eval_matches "" "Tools.matches" t thy; term2s t';
   134 if term2s t'="matches (?u + new_c ?v) (x ^^^ 2 / 2 + new_c x ^^^ 2 / 2) = True"
   134 if term2s t'="matches (?u + new_c ?v) (x ^^^ 2 / 2 + new_c x ^^^ 2 / 2) = True"
   135 then () else raise error "integrate.sml: matches new_c = True";
   135 then () else error "integrate.sml: matches new_c = True";
   136 
   136 
   137 val t = str2term "ff x is_f_x";
   137 val t = str2term "ff x is_f_x";
   138 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
   138 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
   139 if term2s t' = "(ff x is_f_x) = True" then ()
   139 if term2s t' = "(ff x is_f_x) = True" then ()
   140 else raise error "integrate.sml: eval_is_f_x --> true";
   140 else error "integrate.sml: eval_is_f_x --> true";
   141 
   141 
   142 val t = str2term "q_0/2 * L * x is_f_x";
   142 val t = str2term "q_0/2 * L * x is_f_x";
   143 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
   143 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
   144 if term2s t' = "(q_0 / 2 * L * x is_f_x) = False" then ()
   144 if term2s t' = "(q_0 / 2 * L * x is_f_x) = False" then ()
   145 else raise error "integrate.sml: eval_is_f_x --> false";
   145 else error "integrate.sml: eval_is_f_x --> false";
   146 
   146 
   147 val conditions_in_integration =
   147 val conditions_in_integration =
   148 Rls {id="conditions_in_integration", 
   148 Rls {id="conditions_in_integration", 
   149      preconds = [], 
   149      preconds = [], 
   150      rew_ord = ("termlessI",termlessI), 
   150      rew_ord = ("termlessI",termlessI), 
   181 val t = str2term "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x^^^2 / 2)";
   181 val t = str2term "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x^^^2 / 2)";
   182 
   182 
   183 "----- stepwise from the rulesets in simplify_Integral and below-----";
   183 "----- stepwise from the rulesets in simplify_Integral and below-----";
   184 val rls = norm_Rational_noadd_fractions;
   184 val rls = norm_Rational_noadd_fractions;
   185 case rewrite_set_inst_ thy true subs rls t of
   185 case rewrite_set_inst_ thy true subs rls t of
   186     SOME _ => raise error "integrate.sml simplify by ruleset norm_Rational_.#2"
   186     SOME _ => error "integrate.sml simplify by ruleset norm_Rational_.#2"
   187   | NONE => ();
   187   | NONE => ();
   188 
   188 
   189 "===== test 2";
   189 "===== test 2";
   190 val rls = order_add_mult_in;
   190 val rls = order_add_mult_in;
   191 val SOME (t,[]) = rewrite_set_ thy true rls t;
   191 val SOME (t,[]) = rewrite_set_ thy true rls t;
   192 if term2str t = "1 / EI * (L * (q_0 * x) / 2 + -1 * (q_0 * x ^^^ 2) / 2)" then()
   192 if term2str t = "1 / EI * (L * (q_0 * x) / 2 + -1 * (q_0 * x ^^^ 2) / 2)" then()
   193 else raise error "integrate.sml simplify by ruleset order_add_mult_in #2";
   193 else error "integrate.sml simplify by ruleset order_add_mult_in #2";
   194 
   194 
   195 "===== test 3";
   195 "===== test 3";
   196 val rls = discard_parentheses;
   196 val rls = discard_parentheses;
   197 val SOME (t,[]) = rewrite_set_ thy true rls t;
   197 val SOME (t,[]) = rewrite_set_ thy true rls t;
   198 if term2str t = "1 / EI * (L * q_0 * x / 2 + -1 * q_0 * x ^^^ 2 / 2)" then ()
   198 if term2str t = "1 / EI * (L * q_0 * x / 2 + -1 * q_0 * x ^^^ 2 / 2)" then ()
   199 else raise error "integrate.sml simplify by ruleset discard_parenth.. #3";
   199 else error "integrate.sml simplify by ruleset discard_parenth.. #3";
   200 
   200 
   201 "===== test 4";
   201 "===== test 4";
   202 val rls = 
   202 val rls = 
   203     (append_rls "separate_bdv"
   203     (append_rls "separate_bdv"
   204  	       collect_bdv
   204  	       collect_bdv
   221 @{thm separate_1_bdv_n}; (*::real ..because of ^^^*)
   221 @{thm separate_1_bdv_n}; (*::real ..because of ^^^*)
   222 (*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
   222 (*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
   223 
   223 
   224 val SOME (t, []) = rewrite_set_inst_ thy true subs rls t;
   224 val SOME (t, []) = rewrite_set_inst_ thy true subs rls t;
   225 if term2str t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2)" then ()
   225 if term2str t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2)" then ()
   226 else raise error "integrate.sml simplify by ruleset separate_bdv.. #4";
   226 else error "integrate.sml simplify by ruleset separate_bdv.. #4";
   227 
   227 
   228 "===== test 5";
   228 "===== test 5";
   229 val t = str2term "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x^^^2 / 2)";
   229 val t = str2term "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x^^^2 / 2)";
   230 val rls = simplify_Integral;
   230 val rls = simplify_Integral;
   231 val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
   231 val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
   232 if term2str t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2)" then ()
   232 if term2str t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2)" then ()
   233 else raise error "integrate.sml, simplify_Integral #99";
   233 else error "integrate.sml, simplify_Integral #99";
   234 
   234 
   235 
   235 
   236 "........... 2nd integral ........................................";
   236 "........... 2nd integral ........................................";
   237 "........... 2nd integral ........................................";
   237 "........... 2nd integral ........................................";
   238 "........... 2nd integral ........................................";
   238 "........... 2nd integral ........................................";
   245 (*===== inhibit exn ============================================================
   245 (*===== inhibit exn ============================================================
   246 if term2str t = 
   246 if term2str t = 
   247  "Integral 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3) D x"
   247  "Integral 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3) D x"
   248 GOON: still 2*3 TODO...
   248 GOON: still 2*3 TODO...
   249  "Integral 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / (2 * 3) * x ^^^ 3) D x"
   249  "Integral 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / (2 * 3) * x ^^^ 3) D x"
   250 then () else raise error "integrate.sml, simplify_Integral #198";
   250 then () else error "integrate.sml, simplify_Integral #198";
   251 
   251 
   252 
   252 
   253 trace_rewrite := true;
   253 trace_rewrite := true;
   254 tracing "====== test 4 =============================";
   254 tracing "====== test 4 =============================";
   255 tracing "====== test 4 =============================";
   255 tracing "====== test 4 =============================";
   261 
   261 
   262 val rls = integration_rules;
   262 val rls = integration_rules;
   263 val SOME (t,[]) = rewrite_set_ thy true rls t;
   263 val SOME (t,[]) = rewrite_set_ thy true rls t;
   264 if term2str t = 
   264 if term2str t = 
   265    "1 / EI * (L * q_0 / 4 * (x ^^^ 3 / 3) + -1 * q_0 / 6 * (x ^^^ 4 / 4))"
   265    "1 / EI * (L * q_0 / 4 * (x ^^^ 3 / 3) + -1 * q_0 / 6 * (x ^^^ 4 / 4))"
   266 then () else raise error "integrate.sml, simplify_Integral #199";
   266 then () else error "integrate.sml, simplify_Integral #199";
   267 
   267 
   268 
   268 
   269 
   269 
   270 "----------- simplify by extending make_polynomial_in ---";
   270 "----------- simplify by extending make_polynomial_in ---";
   271 "----------- simplify by extending make_polynomial_in ---";
   271 "----------- simplify by extending make_polynomial_in ---";
   284     fst (the (rewrite_set_inst "Integrate" true subs rls str));
   284     fst (the (rewrite_set_inst "Integrate" true subs rls str));
   285 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   285 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   286 val str = rewrit_sinst subs rls "Integral x D x";
   286 val str = rewrit_sinst subs rls "Integral x D x";
   287 val str = rewrit_sinst subs rls "Integral c * x ^^^ 2 + c_2 D x";
   287 val str = rewrit_sinst subs rls "Integral c * x ^^^ 2 + c_2 D x";
   288 if str = "c * (x ^^^ 3 / 3) + c_2 * x"
   288 if str = "c * (x ^^^ 3 / 3) + c_2 * x"
   289 then () else raise error "integrate.sml: diff.behav. in integration_rules";
   289 then () else error "integrate.sml: diff.behav. in integration_rules";
   290 
   290 
   291 val rls = "add_new_c";
   291 val rls = "add_new_c";
   292 val str = rewrit_sinst subs rls "c * (x ^^^ 3 / 3) + c_2 * x";
   292 val str = rewrit_sinst subs rls "c * (x ^^^ 3 / 3) + c_2 * x";
   293 if str = "c * (x ^^^ 3 / 3) + c_2 * x + c_3" then () 
   293 if str = "c * (x ^^^ 3 / 3) + c_2 * x + c_3" then () 
   294 else raise error "integrate.sml: diff.behav. in add_new_c simpl.";
   294 else error "integrate.sml: diff.behav. in add_new_c simpl.";
   295 
   295 
   296 val str = rewrit_sinst subs rls "F x = x ^^^ 3 / 3 + x";
   296 val str = rewrit_sinst subs rls "F x = x ^^^ 3 / 3 + x";
   297 if str = "F x = x ^^^ 3 / 3 + x + c"(*not "F x + c =..."*) then () 
   297 if str = "F x = x ^^^ 3 / 3 + x + c"(*not "F x + c =..."*) then () 
   298 else raise error "integrate.sml: diff.behav. in add_new_c equation";
   298 else error "integrate.sml: diff.behav. in add_new_c equation";
   299 
   299 
   300 val rls = "simplify_Integral";
   300 val rls = "simplify_Integral";
   301 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   301 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   302 val str = "ff x = c * x + -1 * q_0 * (x ^^^ 2 / 2) + c_2";
   302 val str = "ff x = c * x + -1 * q_0 * (x ^^^ 2 / 2) + c_2";
   303 val str = rewrit_sinst subs rls str;
   303 val str = rewrit_sinst subs rls str;
   304 if str = "ff x = c_2 + c * x + -1 * q_0 / 2 * x ^^^ 2"
   304 if str = "ff x = c_2 + c * x + -1 * q_0 / 2 * x ^^^ 2"
   305 then () else raise error "integrate.sml: diff.behav. in simplify_I #1";
   305 then () else error "integrate.sml: diff.behav. in simplify_I #1";
   306 
   306 
   307 val rls = "integration";
   307 val rls = "integration";
   308 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   308 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   309 val str = rewrit_sinst subs rls "Integral c * x ^^^ 2 + c_2 D x";
   309 val str = rewrit_sinst subs rls "Integral c * x ^^^ 2 + c_2 D x";
   310 if str = "c_3 + c_2 * x + c / 3 * x ^^^ 3"
   310 if str = "c_3 + c_2 * x + c / 3 * x ^^^ 3"
   311 then () else raise error "integrate.sml: diff.behav. in integration #1";
   311 then () else error "integrate.sml: diff.behav. in integration #1";
   312 
   312 
   313 val str = rewrit_sinst subs rls "Integral 3*x^^^2 + 2*x + 1 D x";
   313 val str = rewrit_sinst subs rls "Integral 3*x^^^2 + 2*x + 1 D x";
   314 if str = "c + x + x ^^^ 2 + x ^^^ 3" then () 
   314 if str = "c + x + x ^^^ 2 + x ^^^ 3" then () 
   315 else raise error "integrate.sml: diff.behav. in integration #2";
   315 else error "integrate.sml: diff.behav. in integration #2";
   316 
   316 
   317 val str = rewrit_sinst subs rls 
   317 val str = rewrit_sinst subs rls 
   318 "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2) D x";
   318 "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2) D x";
   319 if str =
   319 if str =
   320    "c + 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3)"
   320    "c + 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3)"
   321 then () else raise error "integrate.sml: diff.behav. in integration #3";
   321 then () else error "integrate.sml: diff.behav. in integration #3";
   322 
   322 
   323 val str = "Integral "^str^" D x";
   323 val str = "Integral "^str^" D x";
   324 val str = rewrit_sinst subs rls str;
   324 val str = rewrit_sinst subs rls str;
   325 if str =
   325 if str =
   326    "c_2 + c * x + 1 / EI * (L * q_0 / 12 * x ^^^ 3 + -1 * q_0 / 24 * x ^^^ 4)"
   326    "c_2 + c * x + 1 / EI * (L * q_0 / 12 * x ^^^ 3 + -1 * q_0 / 24 * x ^^^ 4)"
   327 then () else raise error "integrate.sml: diff.behav. in integration #4";
   327 then () else error "integrate.sml: diff.behav. in integration #4";
   328 
   328 
   329 
   329 
   330 "----------- rewrite 3rd integration in 7.27 ------------";
   330 "----------- rewrite 3rd integration in 7.27 ------------";
   331 "----------- rewrite 3rd integration in 7.27 ------------";
   331 "----------- rewrite 3rd integration in 7.27 ------------";
   332 "----------- rewrite 3rd integration in 7.27 ------------";
   332 "----------- rewrite 3rd integration in 7.27 ------------";
   335 val t = str2term
   335 val t = str2term
   336 	    "Integral 1 / EI * ((L * q_0 * x + -1 * q_0 * x ^^^ 2) / 2) D x";
   336 	    "Integral 1 / EI * ((L * q_0 * x + -1 * q_0 * x ^^^ 2) / 2) D x";
   337 val SOME(t,_)= rewrite_set_inst_ thy true bdv simplify_Integral t;
   337 val SOME(t,_)= rewrite_set_inst_ thy true bdv simplify_Integral t;
   338 if term2str t = 
   338 if term2str t = 
   339    "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2) D x" then ()
   339    "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x ^^^ 2) D x" then ()
   340 else raise error "integrate.sml 3rd integration in 7.27, simplify_Integral";
   340 else error "integrate.sml 3rd integration in 7.27, simplify_Integral";
   341 
   341 
   342 val SOME(t,_)= rewrite_set_inst_ thy true bdv integration t;
   342 val SOME(t,_)= rewrite_set_inst_ thy true bdv integration t;
   343 if term2str t = "c + 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3)"
   343 if term2str t = "c + 1 / EI * (L * q_0 / 4 * x ^^^ 2 + -1 * q_0 / 6 * x ^^^ 3)"
   344 then () else raise error "integrate.sml 3rd integration in 7.27, integration";
   344 then () else error "integrate.sml 3rd integration in 7.27, integration";
   345 
   345 
   346 
   346 
   347 "----------- check probem type --------------------------";
   347 "----------- check probem type --------------------------";
   348 "----------- check probem type --------------------------";
   348 "----------- check probem type --------------------------";
   349 "----------- check probem type --------------------------";
   349 "----------- check probem type --------------------------";
   355 val chkmodel = ((map (the o (parse thy))) o ppc2list) model;
   355 val chkmodel = ((map (the o (parse thy))) o ppc2list) model;
   356 val t1 = (term_of o hd) chkmodel;
   356 val t1 = (term_of o hd) chkmodel;
   357 val t2 = (term_of o hd o tl) chkmodel;
   357 val t2 = (term_of o hd o tl) chkmodel;
   358 val t3 = (term_of o hd o tl o tl) chkmodel;
   358 val t3 = (term_of o hd o tl o tl) chkmodel;
   359 case t3 of Const ("Integrate.antiDerivative", _) $ _ => ()
   359 case t3 of Const ("Integrate.antiDerivative", _) $ _ => ()
   360 	 | _ => raise error "integrate.sml: Integrate.antiDerivative ???";
   360 	 | _ => error "integrate.sml: Integrate.antiDerivative ???";
   361 
   361 
   362 val model = {Given =["functionTerm f_f", "integrateBy v_v"],
   362 val model = {Given =["functionTerm f_f", "integrateBy v_v"],
   363 	     Where =[],
   363 	     Where =[],
   364 	     Find  =["antiDerivativeName F_"],
   364 	     Find  =["antiDerivativeName F_"],
   365 	     With  =[],
   365 	     With  =[],
   367 val chkmodel = ((map (the o (parse thy))) o ppc2list) model;
   367 val chkmodel = ((map (the o (parse thy))) o ppc2list) model;
   368 val t1 = (term_of o hd) chkmodel;
   368 val t1 = (term_of o hd) chkmodel;
   369 val t2 = (term_of o hd o tl) chkmodel;
   369 val t2 = (term_of o hd o tl) chkmodel;
   370 val t3 = (term_of o hd o tl o tl) chkmodel;
   370 val t3 = (term_of o hd o tl o tl) chkmodel;
   371 case t3 of Const ("Integrate.antiDerivativeName", _) $ _ => ()
   371 case t3 of Const ("Integrate.antiDerivativeName", _) $ _ => ()
   372 	 | _ => raise error "integrate.sml: Integrate.antiDerivativeName";
   372 	 | _ => error "integrate.sml: Integrate.antiDerivativeName";
   373 
   373 
   374 "----- compare 'Find's from problem, script, formalization -------";
   374 "----- compare 'Find's from problem, script, formalization -------";
   375 val {ppc,...} = get_pbt ["named","integrate","function"];
   375 val {ppc,...} = get_pbt ["named","integrate","function"];
   376 val ("#Find", (Const ("Integrate.antiDerivativeName", _),
   376 val ("#Find", (Const ("Integrate.antiDerivativeName", _),
   377 	       F1_ as Free ("F_", F1_type))) = last_elem ppc;
   377 	       F1_ as Free ("F_", F1_type))) = last_elem ppc;
   378 val {scr = Script sc,... } = get_met ["diff","integration","named"];
   378 val {scr = Script sc,... } = get_met ["diff","integration","named"];
   379 val [_,_, F2_] = formal_args sc;
   379 val [_,_, F2_] = formal_args sc;
   380 if F1_ = F2_ then () else raise error "integrate.sml: unequal find's";
   380 if F1_ = F2_ then () else error "integrate.sml: unequal find's";
   381 
   381 
   382 val ((dsc as Const ("Integrate.antiDerivativeName", _)) 
   382 val ((dsc as Const ("Integrate.antiDerivativeName", _)) 
   383 	 $ Free ("ff", F3_type)) = str2term "antiDerivativeName ff";
   383 	 $ Free ("ff", F3_type)) = str2term "antiDerivativeName ff";
   384 if is_dsc dsc then () else raise error "integrate.sml: no description";
   384 if is_dsc dsc then () else error "integrate.sml: no description";
   385 if F1_type = F3_type then () 
   385 if F1_type = F3_type then () 
   386 else raise error "integrate.sml: unequal types in find's";
   386 else error "integrate.sml: unequal types in find's";
   387 
   387 
   388 show_ptyps();
   388 show_ptyps();
   389 val pbl = get_pbt ["integrate","function"];
   389 val pbl = get_pbt ["integrate","function"];
   390 case #cas pbl of SOME (Const ("Integrate.Integrate",_) $ _) => ()
   390 case #cas pbl of SOME (Const ("Integrate.Integrate",_) $ _) => ()
   391 	 | _ => raise error "integrate.sml: Integrate.Integrate ???";
   391 	 | _ => error "integrate.sml: Integrate.Integrate ???";
   392 
   392 
   393 
   393 
   394 "----------- check Scripts ------------------------------";
   394 "----------- check Scripts ------------------------------";
   395 "----------- check Scripts ------------------------------";
   395 "----------- check Scripts ------------------------------";
   396 "----------- check Scripts ------------------------------";
   396 "----------- check Scripts ------------------------------";
   430 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
   430 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
   431 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   431 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   432 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   432 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   433 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   433 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   434 if f2str f = "c + x + 1 / 3 * x ^^^ 3" then ()
   434 if f2str f = "c + x + 1 / 3 * x ^^^ 3" then ()
   435 else raise error "integrate.sml: method [diff,integration]";
   435 else error "integrate.sml: method [diff,integration]";
   436 
   436 
   437 
   437 
   438 "----------- me method [diff,integration,named] ---------";
   438 "----------- me method [diff,integration,named] ---------";
   439 "----------- me method [diff,integration,named] ---------";
   439 "----------- me method [diff,integration,named] ---------";
   440 "----------- me method [diff,integration,named] ---------";
   440 "----------- me method [diff,integration,named] ---------";
   455 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
   455 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
   456 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   456 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   457 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   457 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   458 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   458 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   459 if f2str f = "F x = c + x + 1 / 3 * x ^^^ 3" then() 
   459 if f2str f = "F x = c + x + 1 / 3 * x ^^^ 3" then() 
   460 else raise error "integrate.sml: method [diff,integration,named]";
   460 else error "integrate.sml: method [diff,integration,named]";
   461 
   461 
   462 
   462 
   463 "----------- me met [diff,integration,named] Biegelinie.Q";
   463 "----------- me met [diff,integration,named] Biegelinie.Q";
   464 "----------- me met [diff,integration,named] Biegelinie.Q";
   464 "----------- me met [diff,integration,named] Biegelinie.Q";
   465 "----------- me met [diff,integration,named] Biegelinie.Q";
   465 "----------- me met [diff,integration,named] Biegelinie.Q";
   482 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   482 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   483 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   483 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   484 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   484 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   485 
   485 
   486 if f2str f = "Q x = c + -1 * q_0 * x" then() 
   486 if f2str f = "Q x = c + -1 * q_0 * x" then() 
   487 else raise error "integrate.sml: method [diff,integration,named] .Q";
   487 else error "integrate.sml: method [diff,integration,named] .Q";
   488 
   488 
   489 
   489 
   490 "----------- interSteps [diff,integration] --------------";
   490 "----------- interSteps [diff,integration] --------------";
   491 "----------- interSteps [diff,integration] --------------";
   491 "----------- interSteps [diff,integration] --------------";
   492 "----------- interSteps [diff,integration] --------------";
   492 "----------- interSteps [diff,integration] --------------";
   501 val ((pt,p),_) = get_calc 1; show_pt pt;
   501 val ((pt,p),_) = get_calc 1; show_pt pt;
   502 
   502 
   503 interSteps 1 ([1],Res);
   503 interSteps 1 ([1],Res);
   504 val ((pt,p),_) = get_calc 1; show_pt pt;
   504 val ((pt,p),_) = get_calc 1; show_pt pt;
   505 if existpt' ([1,3], Res) pt then ()
   505 if existpt' ([1,3], Res) pt then ()
   506 else raise error "integrate.sml: interSteps on Rewrite_Set_Inst 1";
   506 else error "integrate.sml: interSteps on Rewrite_Set_Inst 1";
   507 
   507 
   508 
   508 
   509 "----------- method analog to rls 'integration' ---------";
   509 "----------- method analog to rls 'integration' ---------";
   510 "----------- method analog to rls 'integration' ---------";
   510 "----------- method analog to rls 'integration' ---------";
   511 "----------- method analog to rls 'integration' ---------";
   511 "----------- method analog to rls 'integration' ---------";
   549 autoCalculate 1 (Step 1);
   549 autoCalculate 1 (Step 1);
   550 
   550 
   551 autoCalculate 1 CompleteCalc;
   551 autoCalculate 1 CompleteCalc;
   552 val ((pt,p),_) = get_calc 1; show_pt pt;
   552 val ((pt,p),_) = get_calc 1; show_pt pt;
   553 if existpt' ([3], Res) pt then ()
   553 if existpt' ([3], Res) pt then ()
   554 else raise error  "integrate.sml: test-script doesnt work";
   554 else error  "integrate.sml: test-script doesnt work";
   555 
   555 
   556 
   556 
   557 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   557 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   558 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   558 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   559 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   559 "----------- Ambiguous input: Integral ?u + ?v D ?bdv = .";
   585 *** ((Integral (?u + ?v) D ?bdv) =
   585 *** ((Integral (?u + ?v) D ?bdv) =
   586 ***  ((Integral ?u D ?bdv) + (Integral ?v D ?bdv)))
   586 ***  ((Integral ?u D ?bdv) + (Integral ?v D ?bdv)))
   587 *)
   587 *)
   588 
   588 
   589 if existpt' ([1,1,5], Res) pt then ()
   589 if existpt' ([1,1,5], Res) pt then ()
   590 else raise error "integrate.sml: interSteps on Rewrite_Set_Inst 2";
   590 else error "integrate.sml: interSteps on Rewrite_Set_Inst 2";
   591 
   591 
   592 
   592 
   593 "----------- CAS input ----------------------------------";
   593 "----------- CAS input ----------------------------------";
   594 "----------- CAS input ----------------------------------";
   594 "----------- CAS input ----------------------------------";
   595 "----------- CAS input ----------------------------------";
   595 "----------- CAS input ----------------------------------";
   596 val t = str2term "Integrate (x^^^2 + x + 1, x)";
   596 val t = str2term "Integrate (x^^^2 + x + 1, x)";
   597 case t of Const ("Integrate.Integrate", _) $ _ => ()
   597 case t of Const ("Integrate.Integrate", _) $ _ => ()
   598 	| _ => raise error "diff.sml behav.changed for Integrate (..., x)";
   598 	| _ => error "diff.sml behav.changed for Integrate (..., x)";
   599 atomty t;
   599 atomty t;
   600 
   600 
   601 states:=[];
   601 states:=[];
   602 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   602 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   603 Iterator 1;
   603 Iterator 1;
   607 val ((pt,p),_) = get_calc 1;
   607 val ((pt,p),_) = get_calc 1;
   608 val Form res = (#1 o pt_extract) (pt, ([],Res));
   608 val Form res = (#1 o pt_extract) (pt, ([],Res));
   609 show_pt pt;
   609 show_pt pt;
   610 (* WN070703 does not work like Diff due to error in next-pos
   610 (* WN070703 does not work like Diff due to error in next-pos
   611 if p = ([], Res) andalso term2str res = "5 * a" then ()
   611 if p = ([], Res) andalso term2str res = "5 * a" then ()
   612 else raise error "diff.sml behav.changed for Integrate (x^2 + x + 1, x)";
   612 else error "diff.sml behav.changed for Integrate (x^2 + x + 1, x)";
   613 *)
   613 *)
   614 
   614 
   615 ===== inhibit exn ============================================================*)
   615 ===== inhibit exn ============================================================*)