109 \<close> ML \<open> |
109 \<close> ML \<open> |
110 \<close> ML \<open> |
110 \<close> ML \<open> |
111 \<close> ML \<open> |
111 \<close> ML \<open> |
112 \<close> |
112 \<close> |
113 |
113 |
114 section \<open>========== check integrate.sml ====================================================\<close> |
114 section \<open>===================================================================================\<close> |
115 ML \<open> |
115 ML \<open> |
116 \<close> ML \<open> |
116 \<close> ML \<open> |
117 (* Title: test/Tools/isac/Knowledge/integrate.sml |
|
118 Author: Walther Neuper 050826 |
|
119 (c) due to copyright terms |
|
120 *) |
|
121 "--------------------------------------------------------"; |
|
122 "table of contents --------------------------------------"; |
|
123 "--------------------------------------------------------"; |
|
124 "----------- parsing ------------------------------------"; |
|
125 "----------- integrate by rewriting ---------------------"; |
|
126 "----------- test add_new_c, TermC.is_f_x ---------------------"; |
|
127 "----------- simplify by ruleset reducing make_ratpoly_in"; |
|
128 "----------- integrate by ruleset -----------------------"; |
|
129 "----------- rewrite 3rd integration in 7.27 ------------"; |
|
130 "----------- check probem type --------------------------"; |
|
131 "----------- me method [diff,integration] ---------------"; |
|
132 "----------- autoCalculate [diff,integration] -----------"; |
|
133 "----------- me method [diff,integration,named] ---------"; |
|
134 "----------- me met [diff,integration,named] Biegelinie.Q"; |
|
135 "----------- method analog to rls 'integration' ---------"; |
|
136 "--------------------------------------------------------"; |
|
137 "--------------------------------------------------------"; |
|
138 "--------------------------------------------------------"; |
|
139 |
|
140 (*these val/fun provide for exact parsing in Integrate.thy, not Isac.thy; |
|
141 they are used several times below; TODO remove duplicates*) |
|
142 val thy = @{theory "Integrate"}; |
|
143 val ctxt = ThyC.to_ctxt thy; |
|
144 |
|
145 fun str2t str = parseNEW ctxt str |> the; |
|
146 fun term2s t = UnparseC.term_in_ctxt ctxt t; |
|
147 |
|
148 val conditions_in_integration_rules = |
|
149 Rule_Set.Repeat {id="conditions_in_integration_rules", |
|
150 preconds = [], |
|
151 rew_ord = ("termlessI",termlessI), |
|
152 erls = Rule_Set.Empty, |
|
153 srls = Rule_Set.Empty, calc = [], errpatts = [], |
|
154 rules = [(*for rewriting conditions in Thm's*) |
|
155 Eval ("Prog_Expr.occurs_in", |
|
156 eval_occurs_in "#occurs_in_"), |
|
157 Thm ("not_true", @{thm not_true}), |
|
158 Thm ("not_false", @{thm not_false})], |
|
159 scr = Empty_Prog}; |
|
160 val subs = [(str2t "bdv::real", str2t "x::real")]; |
|
161 fun rewrit thm str = |
|
162 fst (the (rewrite_inst_ thy tless_true |
|
163 conditions_in_integration_rules |
|
164 true subs thm str)); |
|
165 |
|
166 |
|
167 "----------- parsing ------------------------------------"; |
|
168 "----------- parsing ------------------------------------"; |
|
169 "----------- parsing ------------------------------------"; |
|
170 val t = TermC.str2term "Integral x D x"; |
|
171 val t = TermC.str2term "Integral x \<up> 2 D x"; |
|
172 case t of |
|
173 Const (\<^const_name>\<open>Integral\<close>, _) $ |
|
174 (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ _) $ Free ("x", _) => () |
|
175 | _ => error "integrate.sml: parsing: Integral x \<up> 2 D x"; |
|
176 |
|
177 val t = TermC.str2term "ff x is_f_x"; |
|
178 case t of Const (\<^const_name>\<open>is_f_x\<close>, _) $ _ => () |
|
179 | _ => error "integrate.sml: parsing: ff x is_f_x"; |
|
180 |
|
181 |
|
182 "----------- integrate by rewriting ---------------------"; |
|
183 "----------- integrate by rewriting ---------------------"; |
|
184 "----------- integrate by rewriting ---------------------"; |
|
185 val str = rewrit @{thm "integral_const"} (TermC.str2term "Integral 1 D x"); |
|
186 if term2s str = "1 * x" then () else error "integrate.sml Integral 1 D x"; |
|
187 |
|
188 val str = rewrit @{thm "integral_const"} (TermC.str2term "Integral M'/EJ D x"); |
|
189 if term2s str = "M' / EJ * x" then () |
|
190 else error "Integral M'/EJ D x BY integral_const"; |
|
191 |
|
192 val str = rewrit @{thm "integral_var"} (TermC.str2term "Integral x D x"); |
|
193 if term2s str = "x \<up> 2 / 2" then () |
|
194 else error "Integral x D x BY integral_var"; |
|
195 |
|
196 val str = rewrit @{thm "integral_add"} (TermC.str2term "Integral x + 1 D x"); |
|
197 if term2s str = "Integral x D x + Integral 1 D x" then () |
|
198 else error "Integral x + 1 D x BY integral_add"; |
|
199 |
|
200 val str = rewrit @{thm "integral_mult"} (TermC.str2term "Integral M'/EJ * x \<up> 3 D x"); |
|
201 if term2s str = "M' / EJ * Integral x \<up> 3 D x" then () |
|
202 else error "Integral M'/EJ * x \<up> 3 D x BY integral_mult"; |
|
203 |
|
204 val str = rewrit @{thm "integral_pow"} (TermC.str2term "Integral x \<up> 3 D x"); |
|
205 if term2s str = "x \<up> (3 + 1) / (3 + 1)" then () |
|
206 else error "integrate.sml Integral x \<up> 3 D x"; |
|
207 |
|
208 |
|
209 "----------- test add_new_c, TermC.is_f_x ---------------------"; |
|
210 "----------- test add_new_c, TermC.is_f_x ---------------------"; |
|
211 "----------- test add_new_c, TermC.is_f_x ---------------------"; |
|
212 val term = TermC.str2term "x \<up> 2 * c + c_2"; |
|
213 val cc = new_c term; |
|
214 if UnparseC.term cc = "c_3" then () else error "integrate.sml: new_c ???"; |
|
215 |
|
216 val SOME (id,t') = eval_add_new_c "" "Integrate.add_new_c" term thy; |
|
217 if UnparseC.term t' = "x \<up> 2 * c + c_2 = x \<up> 2 * c + c_2 + c_3" then () |
|
218 else error "intergrate.sml: diff. eval_add_new_c"; |
|
219 |
|
220 val cc = ("Integrate.add_new_c", eval_add_new_c "add_new_c_"); |
|
221 val SOME (thmstr, thm) = adhoc_thm1_ thy cc term; |
|
222 |
|
223 val SOME (t',_) = rewrite_set_ thy true add_new_c term; |
|
224 if UnparseC.term t' = "x \<up> 2 * c + c_2 + c_3" then () |
|
225 else error "intergrate.sml: diff. rewrite_set add_new_c 1"; |
|
226 |
|
227 val term = TermC.str2term "ff x = x \<up> 2*c + c_2"; |
|
228 val SOME (t',_) = rewrite_set_ thy true add_new_c term; |
|
229 if UnparseC.term t' = "ff x = x \<up> 2 * c + c_2 + c_3" then () |
|
230 else error "intergrate.sml: diff. rewrite_set add_new_c 2"; |
|
231 |
|
232 |
|
233 (*WN080222 replace call_new_c with add_new_c---------------------- |
|
234 val term = str2t "new_c (c * x \<up> 2 + c_2)"; |
|
235 val SOME (_,t') = eval_new_c 0 0 term 0; |
|
236 if term2s t' = "new_c c * x \<up> 2 + c_2 = c_3" then () |
|
237 else error "integrate.sml: eval_new_c ???"; |
|
238 |
|
239 val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2)"; |
|
240 val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t'; |
|
241 if term2s t' = "matches (?u + new_c ?v) (x \<up> 2 / 2) = False" then () |
|
242 else error "integrate.sml: matches new_c = False"; |
|
243 |
|
244 val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2)"; |
|
245 val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t'; |
|
246 if term2s t'="matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2) = True" |
|
247 then () else error "integrate.sml: matches new_c = True"; |
|
248 |
|
249 val t = str2t "ff x TermC.is_f_x"; |
|
250 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t'; |
|
251 if term2s t' = "(ff x TermC.is_f_x) = True" then () |
|
252 else error "integrate.sml: eval_is_f_x --> true"; |
|
253 |
|
254 val t = str2t "q_0/2 * L * x TermC.is_f_x"; |
|
255 val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t'; |
|
256 if term2s t' = "(q_0 / 2 * L * x TermC.is_f_x) = False" then () |
|
257 else error "integrate.sml: eval_is_f_x --> false"; |
|
258 |
|
259 val conditions_in_integration = |
|
260 Rule_Set.Repeat {id="conditions_in_integration", |
|
261 preconds = [], |
|
262 rew_ord = ("termlessI",termlessI), |
|
263 erls = Rule_Set.Empty, |
|
264 srls = Rule_Set.Empty, calc = [], errpatts = [], |
|
265 rules = [Eval ("Prog_Expr.matches",eval_matches ""), |
|
266 Eval ("Integrate.is_f_x", |
|
267 eval_is_f_x "is_f_x_"), |
|
268 Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}), |
|
269 Thm ("not_false",ThmC.numerals_to_Free @{thm not_false}) |
|
270 ], |
|
271 scr = Empty_Prog}; |
|
272 fun rewrit thm t = |
|
273 fst (the (rewrite_inst_ thy tless_true |
|
274 conditions_in_integration true subs thm t)); |
|
275 val t = rewrit call_for_new_c (str2t "x \<up> 2 / 2"); term2s t; |
|
276 val t = (rewrit call_for_new_c t) |
|
277 handle OPTION => str2t "no_rewrite"; |
|
278 |
|
279 val t = rewrit call_for_new_c |
|
280 (str2t "ff x = q_0/2 *L*x"); term2s t; |
|
281 val t = (rewrit call_for_new_c |
|
282 (str2t "ff x = q_0 / 2 * L * x + new_c q_0 / 2 * L * x")) |
|
283 handle OPTION => (*NOT: + new_c ..=..!!*)str2t "no_rewrite"; |
|
284 --------------------------------------------------------------------*) |
|
285 |
|
286 |
|
287 "----------- simplify by ruleset reducing make_ratpoly_in"; |
|
288 "----------- simplify by ruleset reducing make_ratpoly_in"; |
|
289 "----------- simplify by ruleset reducing make_ratpoly_in"; |
|
290 \<close> ML \<open> |
|
291 val subst = [(TermC.str2term "bdv ::real", TermC.str2term "x ::real")] |
|
292 \<close> ML \<open> |
|
293 val thy = @{theory "Isac_Knowledge"}; |
|
294 "===== test 1"; |
|
295 val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)"; |
|
296 |
|
297 "----- stepwise from the rulesets in simplify_Integral and below-----"; |
|
298 val rls = norm_Rational_noadd_fractions; |
|
299 case rewrite_set_inst_ thy true subs rls t of |
|
300 SOME _ => error "integrate.sml simplify by ruleset norm_Rational_.#2" |
|
301 | NONE => (); |
|
302 |
|
303 "===== test 2"; |
|
304 \<close> ML \<open> |
|
305 val rls = order_add_mult_in; |
|
306 \<close> text \<open> (*GOON*) |
|
307 (*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite TOODOO\\*) |
|
308 assume flawed test setup hidden by "handle _ => ..." |
|
309 ERROR ord_make_polynomial_in called with subst = [] |
|
310 \<close> text \<open> |
|
311 val SOME (t, []) = rewrite_set_ thy true rls t; |
|
312 |
|
313 UnparseC.term t |
|
314 |
|
315 if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + - 1 * (q_0 * x \<up> 2) / 2)" then() |
|
316 else error "integrate.sml simplify by ruleset order_add_mult_in #2"; |
|
317 (*\\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*) |
|
318 |
|
319 "===== test 3"; |
|
320 \<close> ML \<open> |
|
321 val rls = discard_parentheses; |
|
322 (*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite TOODOO\\ |
|
323 assume flawed test setup hidden by "handle _ => ..." |
|
324 ERROR ord_make_polynomial_in called with subst = [] |
|
325 val SOME (t,[]) = rewrite_set_ thy true rls t; |
|
326 if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" then () |
|
327 else error "integrate.sml simplify by ruleset discard_parenth.. #3"; |
|
328 \\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite TOODOO//*) |
|
329 |
|
330 "===== test 4"; |
|
331 val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")]; |
|
332 val rls = |
|
333 (Rule_Set.append_rules "separate_bdv" collect_bdv |
|
334 [Thm ("separate_bdv", @{thm separate_bdv}), |
|
335 (*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*) |
|
336 Thm ("separate_bdv_n", @{thm separate_bdv_n}), |
|
337 (*"?a * ?bdv \<up> ?n / ?b = ?a / ?b * ?bdv \<up> ?n"*) |
|
338 Thm ("separate_1_bdv", @{thm separate_1_bdv}), |
|
339 (*"?bdv / ?b = (1 / ?b) * ?bdv"*) |
|
340 Thm ("separate_1_bdv_n", @{thm separate_1_bdv_n}) |
|
341 (*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*) |
|
342 ]); |
|
343 (*show_types := true; --- do we need type-constraint in thms? *) |
|
344 @{thm separate_bdv}; (*::?'a does NOT rewrite here WITHOUT type constraint*) |
|
345 @{thm separate_bdv_n}; (*::real ..because of \<up> , rewrites*) |
|
346 @{thm separate_1_bdv}; (*::?'a*) |
|
347 val xxx = @{thm separate_1_bdv}; (*::?'a*) |
|
348 @{thm separate_1_bdv_n}; (*::real ..because of \<up> *) |
|
349 (*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*) |
|
350 |
|
351 val SOME (t, []) = rewrite_set_inst_ thy true subs rls t; |
|
352 if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then () |
|
353 else error "integrate.sml simplify by ruleset separate_bdv.. #4"; |
|
354 |
|
355 "===== test 5"; |
|
356 val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)"; |
|
357 val rls = simplify_Integral; |
|
358 val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t; |
|
359 (* given was: "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" *) |
|
360 if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then () |
|
361 else error "integrate.sml, simplify_Integral #99"; |
|
362 |
|
363 "........... 2nd integral ........................................"; |
|
364 "........... 2nd integral ........................................"; |
|
365 "........... 2nd integral ........................................"; |
|
366 val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")]; |
|
367 |
|
368 val thy = @{theory Biegelinie}; |
|
369 val t = TermC.str2term |
|
370 "Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x"; |
|
371 |
|
372 val rls = simplify_Integral; |
|
373 val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t; |
|
374 if UnparseC.term t = "Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x" |
|
375 then () else raise error "integrate.sml, simplify_Integral #198"; |
|
376 |
|
377 val rls = integration_rules; |
|
378 val SOME (t, []) = rewrite_set_ thy true rls t; |
|
379 if UnparseC.term t = "1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + - 1 * q_0 / 6 * (x \<up> 4 / 4))" |
|
380 then () else error "integrate.sml, simplify_Integral #199"; |
|
381 |
|
382 |
|
383 "----------- integrate by ruleset -----------------------"; |
|
384 "----------- integrate by ruleset -----------------------"; |
|
385 "----------- integrate by ruleset -----------------------"; |
|
386 val thy = @{theory "Integrate"}; |
|
387 val rls = integration_rules; |
|
388 val subs = [(@{term "bdv::real"}, @{term "x::real"})]; |
|
389 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*) |
|
390 |
|
391 val t = (Thm.term_of o the o (TermC.parse thy)) "Integral x D x"; |
|
392 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
393 if UnparseC.term res = "x \<up> 2 / 2" then () else error "Integral x D x changed"; |
|
394 |
|
395 val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x"; |
|
396 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
397 if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x" then () else error "Integral c * x \<up> 2 + c_2 D x"; |
|
398 |
|
399 val rls = add_new_c; |
|
400 val t = (Thm.term_of o the o (TermC.parse thy)) "c * (x \<up> 3 / 3) + c_2 * x"; |
|
401 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
402 if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x + c_3" then () |
|
403 else error "integrate.sml: diff.behav. in add_new_c simpl."; |
|
404 |
|
405 val t = (Thm.term_of o the o (TermC.parse thy)) "F x = x \<up> 3 / 3 + x"; |
|
406 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
407 if UnparseC.term res = "F x = x \<up> 3 / 3 + x + c"(*not "F x + c =..."*) then () |
|
408 else error "integrate.sml: diff.behav. in add_new_c equation"; |
|
409 |
|
410 val rls = simplify_Integral; |
|
411 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*) |
|
412 val t = (Thm.term_of o the o (TermC.parse thy)) "ff x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2"; |
|
413 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
414 if UnparseC.term res = "ff x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2" |
|
415 then () else error "integrate.sml: diff.behav. in simplify_I #1"; |
|
416 |
|
417 val rls = integration; |
|
418 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*) |
|
419 val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x"; |
|
420 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
421 if UnparseC.term res = "c_3 + c_2 * x + c / 3 * x \<up> 3" |
|
422 then () else error "integrate.sml: diff.behav. in integration #1"; |
|
423 |
|
424 val t = (Thm.term_of o the o (TermC.parse thy)) "Integral 3*x \<up> 2 + 2*x + 1 D x"; |
|
425 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
426 if UnparseC.term res = "c + x + x \<up> 2 + x \<up> 3" then () |
|
427 else error "integrate.sml: diff.behav. in integration #2"; |
|
428 |
|
429 val t = (Thm.term_of o the o (TermC.parse thy)) |
|
430 "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"; |
|
431 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
432 "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"; |
|
433 if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)" |
|
434 then () else error "integrate.sml: diff.behav. in integration #3"; |
|
435 |
|
436 val t = (Thm.term_of o the o (TermC.parse thy)) ("Integral " ^ UnparseC.term res ^ " D x"); |
|
437 val SOME (res, _) = rewrite_set_inst_ thy true subs rls t; |
|
438 if UnparseC.term res = "c_2 + c * x +\n1 / EI * (L * q_0 / 12 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)" |
|
439 then () else error "integrate.sml: diff.behav. in integration #4"; |
|
440 |
|
441 "----------- rewrite 3rd integration in 7.27 ------------"; |
|
442 "----------- rewrite 3rd integration in 7.27 ------------"; |
|
443 "----------- rewrite 3rd integration in 7.27 ------------"; |
|
444 val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*); |
|
445 val t = TermC.str2term "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \<up> 2) / 2) D x"; |
|
446 val SOME(t, _)= rewrite_set_inst_ thy true subs simplify_Integral t; |
|
447 if UnparseC.term t = |
|
448 "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x" |
|
449 then () else error "integrate.sml 3rd integration in 7.27, simplify_Integral"; |
|
450 |
|
451 val SOME(t, _) = rewrite_set_inst_ thy true subs integration t; |
|
452 if UnparseC.term t = |
|
453 "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)" |
|
454 then () else error "integrate.sml 3rd integration in 7.27, integration"; |
|
455 |
|
456 |
|
457 "----------- check probem type --------------------------"; |
|
458 "----------- check probem type --------------------------"; |
|
459 "----------- check probem type --------------------------"; |
|
460 val thy = @{theory Integrate}; |
|
461 val model = {Given =["functionTerm f_f", "integrateBy v_v"], |
|
462 Where =[], |
|
463 Find =["antiDerivative F_F"], |
|
464 With =[], |
|
465 Relate=[]}:string ppc; |
|
466 val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model; |
|
467 val t1 = (Thm.term_of o hd) chkmodel; |
|
468 val t2 = (Thm.term_of o hd o tl) chkmodel; |
|
469 val t3 = (Thm.term_of o hd o tl o tl) chkmodel; |
|
470 case t3 of Const (\<^const_name>\<open>antiDerivative\<close>, _) $ _ => () |
|
471 | _ => error "integrate.sml: Integrate.antiDerivative ???"; |
|
472 |
|
473 val model = {Given =["functionTerm f_f", "integrateBy v_v"], |
|
474 Where =[], |
|
475 Find =["antiDerivativeName F_F"], |
|
476 With =[], |
|
477 Relate=[]}:string ppc; |
|
478 val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model; |
|
479 val t1 = (Thm.term_of o hd) chkmodel; |
|
480 val t2 = (Thm.term_of o hd o tl) chkmodel; |
|
481 val t3 = (Thm.term_of o hd o tl o tl) chkmodel; |
|
482 case t3 of Const (\<^const_name>\<open>antiDerivativeName\<close>, _) $ _ => () |
|
483 | _ => error "integrate.sml: Integrate.antiDerivativeName"; |
|
484 |
|
485 "----- compare 'Find's from problem, script, formalization -------"; |
|
486 val {ppc,...} = Problem.from_store ["named", "integrate", "function"]; |
|
487 val ("#Find", (Const (\<^const_name>\<open>antiDerivativeName\<close>, _), |
|
488 F1_ as Free ("F_F", F1_type))) = last_elem ppc; |
|
489 val {scr = Prog sc,... } = MethodC.from_store ["diff", "integration", "named"]; |
|
490 val [_,_, F2_] = formal_args sc; |
|
491 if F1_ = F2_ then () else error "integrate.sml: unequal find's"; |
|
492 |
|
493 val ((dsc as Const (\<^const_name>\<open>antiDerivativeName\<close>, _)) |
|
494 $ Free ("ff", F3_type)) = TermC.str2term "antiDerivativeName ff"; |
|
495 if Input_Descript.is_a dsc then () else error "integrate.sml: no description"; |
|
496 if F1_type = F3_type then () |
|
497 else error "integrate.sml: unequal types in find's"; |
|
498 |
|
499 Test_Tool.show_ptyps(); |
|
500 val pbl = Problem.from_store ["integrate", "function"]; |
|
501 case #cas pbl of SOME (Const (\<^const_name>\<open>Integrate\<close>, _) $ _) => () |
|
502 | _ => error "integrate.sml: Integrate.Integrate ???"; |
|
503 |
|
504 |
|
505 "----------- me method [diff,integration] ---------------"; |
|
506 "----------- me method [diff,integration] ---------------"; |
|
507 "----------- me method [diff,integration] ---------------"; |
|
508 (*exp_CalcInt_No- 1.xml*) |
|
509 val p = e_pos'; val c = []; |
|
510 "----- step 0: returns nxt = Model_Problem ---"; |
|
511 val (p,_,f,nxt,_,pt) = |
|
512 CalcTreeTEST |
|
513 [(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"], |
|
514 ("Integrate", ["integrate", "function"], ["diff", "integration"]))]; |
|
515 "----- step 1: returns nxt = Add_Given \"functionTerm (x \<up> 2 + 1)\" ---"; |
|
516 val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*) |
|
517 "----- step 2: returns nxt = Add_Given \"integrateBy x\" ---"; |
|
518 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
519 "----- step 3: returns nxt = Add_Find \"Integrate.antiDerivative FF\" ---"; |
|
520 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
521 "----- step 4: returns nxt = Specify_Theory \"Integrate\" ---"; |
|
522 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
523 "----- step 5: returns nxt = Specify_Problem [\"integrate\", \"function\"] ---"; |
|
524 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
525 "----- step 6: returns nxt = Specify_Method [\"diff\", \"integration\"] ---"; |
|
526 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
527 "----- step 7: returns nxt = Apply_Method [\"diff\", \"integration\"] ---"; |
|
528 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
529 case nxt of (Apply_Method ["diff", "integration"]) => () |
|
530 | _ => error "integrate.sml -- me method [diff,integration] -- spec"; |
|
531 "----- step 8: returns nxt = Rewrite_Set_Inst ([\"(''bdv'', x)\"],\"integration\")"; |
|
532 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f; |
|
533 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f; |
|
534 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f; |
|
535 if f2str f = "c + x + 1 / 3 * x \<up> 3" then () |
|
536 else error "integrate.sml -- me method [diff,integration] -- end"; |
|
537 |
|
538 |
|
539 "----------- autoCalculate [diff,integration] -----------"; |
|
540 "----------- autoCalculate [diff,integration] -----------"; |
|
541 "----------- autoCalculate [diff,integration] -----------"; |
|
542 reset_states (); |
|
543 CalcTree |
|
544 [(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"], |
|
545 ("Integrate", ["integrate", "function"], ["diff", "integration"]))]; |
|
546 Iterator 1; |
|
547 moveActiveRoot 1; |
|
548 autoCalculate 1 CompleteCalc; |
|
549 val ((pt,p),_) = get_calc 1; @{make_string} p; Test_Tool.show_pt pt; |
|
550 val (Form t,_,_) = ME_Misc.pt_extract (pt, p); |
|
551 if UnparseC.term t = "c + x + 1 / 3 * x \<up> 3" then () |
|
552 else error "integrate.sml -- interSteps [diff,integration] -- result"; |
|
553 |
|
554 |
|
555 "----------- me method [diff,integration,named] ---------"; |
|
556 "----------- me method [diff,integration,named] ---------"; |
|
557 "----------- me method [diff,integration,named] ---------"; |
|
558 (*exp_CalcInt_No- 2.xml*) |
|
559 val fmz = ["functionTerm (x \<up> 2 + (1::real))", |
|
560 "integrateBy x", "antiDerivativeName F"]; |
|
561 val (dI',pI',mI') = |
|
562 ("Integrate",["named", "integrate", "function"], |
|
563 ["diff", "integration", "named"]); |
|
564 val p = e_pos'; val c = []; |
|
565 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; |
|
566 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
567 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
568 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *); |
|
569 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
570 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
571 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
572 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*); |
|
573 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
574 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
575 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f; |
|
576 if f2str f = "F x = c + x + 1 / 3 * x \<up> 3" then() |
|
577 else error "integrate.sml: method [diff,integration,named]"; |
|
578 |
|
579 |
|
580 "----------- me met [diff,integration,named] Biegelinie.Q"; |
|
581 "----------- me met [diff,integration,named] Biegelinie.Q"; |
|
582 "----------- me met [diff,integration,named] Biegelinie.Q"; |
|
583 (*exp_CalcInt_No-3.xml*) |
|
584 val fmz = ["functionTerm (- q_0)", |
|
585 "integrateBy x", "antiDerivativeName Q"]; |
|
586 val (dI',pI',mI') = |
|
587 ("Biegelinie",["named", "integrate", "function"], |
|
588 ["diff", "integration", "named"]); |
|
589 val p = e_pos'; val c = []; |
|
590 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; |
|
591 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
592 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
593 (*Error Tac Q not in ...*) |
|
594 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *); |
|
595 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
596 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
597 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
598 val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*); |
|
599 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
600 val (p,_,f,nxt,_,pt) = me nxt p c pt; |
|
601 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f; |
|
602 if f2str f = "Q x = c + - 1 * q_0 * x" then() |
|
603 else error "integrate.sml: method [diff,integration,named] .Q"; |
|
604 |
|
605 |
|
606 \<close> ML \<open> |
117 \<close> ML \<open> |
607 \<close> ML \<open> |
118 \<close> ML \<open> |
608 \<close> |
119 \<close> |
609 |
120 |
610 section \<open>===================================================================================\<close> |
121 section \<open>===================================================================================\<close> |