walther@60330
|
1 |
(* Title: test/Tools/isac/Knowledge/integrate.sml
|
walther@60330
|
2 |
Author: Walther Neuper 050826
|
neuper@37906
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
*)
|
neuper@38013
|
5 |
"--------------------------------------------------------";
|
neuper@38013
|
6 |
"table of contents --------------------------------------";
|
neuper@38013
|
7 |
"--------------------------------------------------------";
|
neuper@38013
|
8 |
"----------- parsing ------------------------------------";
|
neuper@38013
|
9 |
"----------- integrate by rewriting ---------------------";
|
walther@60230
|
10 |
"----------- test add_new_c, TermC.is_f_x ---------------------";
|
neuper@38013
|
11 |
"----------- simplify by ruleset reducing make_ratpoly_in";
|
neuper@38013
|
12 |
"----------- integrate by ruleset -----------------------";
|
neuper@38013
|
13 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
neuper@38013
|
14 |
"----------- check probem type --------------------------";
|
neuper@38013
|
15 |
"----------- me method [diff,integration] ---------------";
|
wneuper@59248
|
16 |
"----------- autoCalculate [diff,integration] -----------";
|
neuper@38013
|
17 |
"----------- me method [diff,integration,named] ---------";
|
neuper@38013
|
18 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@38013
|
19 |
"----------- method analog to rls 'integration' ---------";
|
neuper@38013
|
20 |
"--------------------------------------------------------";
|
neuper@38013
|
21 |
"--------------------------------------------------------";
|
neuper@38013
|
22 |
"--------------------------------------------------------";
|
neuper@37906
|
23 |
|
neuper@42067
|
24 |
(*these val/fun provide for exact parsing in Integrate.thy, not Isac.thy;
|
neuper@42067
|
25 |
they are used several times below; TODO remove duplicates*)
|
neuper@42067
|
26 |
val thy = @{theory "Integrate"};
|
walther@60360
|
27 |
val ctxt = Proof_Context.init_global thy;
|
neuper@42067
|
28 |
|
neuper@42067
|
29 |
fun str2t str = parseNEW ctxt str |> the;
|
walther@59870
|
30 |
fun term2s t = UnparseC.term_in_ctxt ctxt t;
|
neuper@42067
|
31 |
|
neuper@42067
|
32 |
val conditions_in_integration_rules =
|
walther@59851
|
33 |
Rule_Set.Repeat {id="conditions_in_integration_rules",
|
neuper@42067
|
34 |
preconds = [],
|
neuper@42067
|
35 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
36 |
erls = Rule_Set.Empty,
|
walther@59851
|
37 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@42067
|
38 |
rules = [(*for rewriting conditions in Thm's*)
|
walther@60278
|
39 |
Eval ("Prog_Expr.occurs_in",
|
neuper@42067
|
40 |
eval_occurs_in "#occurs_in_"),
|
walther@60342
|
41 |
Thm ("not_true", @{thm not_true}),
|
walther@60342
|
42 |
Thm ("not_false", @{thm not_false})],
|
walther@59878
|
43 |
scr = Empty_Prog};
|
neuper@42321
|
44 |
val subs = [(str2t "bdv::real", str2t "x::real")];
|
neuper@42067
|
45 |
fun rewrit thm str =
|
Walther@60500
|
46 |
fst (the (rewrite_inst_ ctxt tless_true
|
neuper@42067
|
47 |
conditions_in_integration_rules
|
neuper@42067
|
48 |
true subs thm str));
|
neuper@42067
|
49 |
|
neuper@37906
|
50 |
|
neuper@38013
|
51 |
"----------- parsing ------------------------------------";
|
neuper@38013
|
52 |
"----------- parsing ------------------------------------";
|
neuper@38013
|
53 |
"----------- parsing ------------------------------------";
|
Walther@60565
|
54 |
val t = TermC.parse_test @{context} "Integral x D x";
|
Walther@60565
|
55 |
val t = TermC.parse_test @{context} "Integral x \<up> 2 D x";
|
neuper@38048
|
56 |
case t of
|
walther@60336
|
57 |
Const (\<^const_name>\<open>Integral\<close>, _) $
|
wenzelm@60405
|
58 |
(Const (\<^const_name>\<open>realpow\<close>, _) $ Free _ $ _) $ Free ("x", _) => ()
|
walther@60242
|
59 |
| _ => error "integrate.sml: parsing: Integral x \<up> 2 D x";
|
neuper@37906
|
60 |
|
Walther@60565
|
61 |
val t = TermC.parse_test @{context} "ff x is_f_x";
|
walther@60336
|
62 |
case t of Const (\<^const_name>\<open>is_f_x\<close>, _) $ _ => ()
|
wenzelm@60237
|
63 |
| _ => error "integrate.sml: parsing: ff x is_f_x";
|
neuper@37906
|
64 |
|
neuper@37906
|
65 |
|
neuper@38013
|
66 |
"----------- integrate by rewriting ---------------------";
|
neuper@38013
|
67 |
"----------- integrate by rewriting ---------------------";
|
neuper@38013
|
68 |
"----------- integrate by rewriting ---------------------";
|
Walther@60565
|
69 |
val str = rewrit @{thm "integral_const"} (TermC.parse_test @{context} "Integral 1 D x");
|
neuper@38048
|
70 |
if term2s str = "1 * x" then () else error "integrate.sml Integral 1 D x";
|
neuper@38048
|
71 |
|
Walther@60565
|
72 |
val str = rewrit @{thm "integral_const"} (TermC.parse_test @{context} "Integral M'/EJ D x");
|
neuper@42321
|
73 |
if term2s str = "M' / EJ * x" then ()
|
neuper@42321
|
74 |
else error "Integral M'/EJ D x BY integral_const";
|
neuper@37906
|
75 |
|
Walther@60565
|
76 |
val str = rewrit @{thm "integral_var"} (TermC.parse_test @{context} "Integral x D x");
|
walther@60242
|
77 |
if term2s str = "x \<up> 2 / 2" then ()
|
neuper@42321
|
78 |
else error "Integral x D x BY integral_var";
|
neuper@37906
|
79 |
|
Walther@60565
|
80 |
val str = rewrit @{thm "integral_add"} (TermC.parse_test @{context} "Integral x + 1 D x");
|
neuper@42321
|
81 |
if term2s str = "Integral x D x + Integral 1 D x" then ()
|
neuper@42321
|
82 |
else error "Integral x + 1 D x BY integral_add";
|
neuper@37906
|
83 |
|
Walther@60565
|
84 |
val str = rewrit @{thm "integral_mult"} (TermC.parse_test @{context} "Integral M'/EJ * x \<up> 3 D x");
|
walther@60242
|
85 |
if term2s str = "M' / EJ * Integral x \<up> 3 D x" then ()
|
walther@60242
|
86 |
else error "Integral M'/EJ * x \<up> 3 D x BY integral_mult";
|
neuper@37906
|
87 |
|
Walther@60565
|
88 |
val str = rewrit @{thm "integral_pow"} (TermC.parse_test @{context} "Integral x \<up> 3 D x");
|
walther@60242
|
89 |
if term2s str = "x \<up> (3 + 1) / (3 + 1)" then ()
|
walther@60242
|
90 |
else error "integrate.sml Integral x \<up> 3 D x";
|
neuper@37906
|
91 |
|
neuper@37906
|
92 |
|
walther@60230
|
93 |
"----------- test add_new_c, TermC.is_f_x ---------------------";
|
walther@60230
|
94 |
"----------- test add_new_c, TermC.is_f_x ---------------------";
|
walther@60230
|
95 |
"----------- test add_new_c, TermC.is_f_x ---------------------";
|
Walther@60565
|
96 |
val term = TermC.parse_test @{context} "x \<up> 2 * c + c_2";
|
neuper@37906
|
97 |
val cc = new_c term;
|
walther@59868
|
98 |
if UnparseC.term cc = "c_3" then () else error "integrate.sml: new_c ???";
|
neuper@37906
|
99 |
|
Walther@60504
|
100 |
val SOME (id,t') = eval_add_new_c "" "Integrate.add_new_c" term ctxt;
|
walther@60242
|
101 |
if UnparseC.term t' = "x \<up> 2 * c + c_2 = x \<up> 2 * c + c_2 + c_3" then ()
|
neuper@38031
|
102 |
else error "intergrate.sml: diff. eval_add_new_c";
|
neuper@37906
|
103 |
|
walther@60278
|
104 |
val cc = ("Integrate.add_new_c", eval_add_new_c "add_new_c_");
|
Walther@60519
|
105 |
val SOME (thmstr, thm) = adhoc_thm1_ @{context} cc term;
|
neuper@37906
|
106 |
|
Walther@60500
|
107 |
val SOME (t',_) = rewrite_set_ ctxt true add_new_c term;
|
walther@60242
|
108 |
if UnparseC.term t' = "x \<up> 2 * c + c_2 + c_3" then ()
|
neuper@38031
|
109 |
else error "intergrate.sml: diff. rewrite_set add_new_c 1";
|
neuper@37906
|
110 |
|
Walther@60565
|
111 |
val term = TermC.parse_test @{context} "ff x = x \<up> 2*c + c_2";
|
Walther@60500
|
112 |
val SOME (t',_) = rewrite_set_ ctxt true add_new_c term;
|
walther@60242
|
113 |
if UnparseC.term t' = "ff x = x \<up> 2 * c + c_2 + c_3" then ()
|
neuper@38031
|
114 |
else error "intergrate.sml: diff. rewrite_set add_new_c 2";
|
neuper@37906
|
115 |
|
neuper@37906
|
116 |
|
neuper@37906
|
117 |
(*WN080222 replace call_new_c with add_new_c----------------------
|
walther@60242
|
118 |
val term = str2t "new_c (c * x \<up> 2 + c_2)";
|
neuper@37926
|
119 |
val SOME (_,t') = eval_new_c 0 0 term 0;
|
walther@60242
|
120 |
if term2s t' = "new_c c * x \<up> 2 + c_2 = c_3" then ()
|
neuper@38031
|
121 |
else error "integrate.sml: eval_new_c ???";
|
neuper@37906
|
122 |
|
walther@60242
|
123 |
val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2)";
|
wenzelm@60237
|
124 |
val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t';
|
walther@60242
|
125 |
if term2s t' = "matches (?u + new_c ?v) (x \<up> 2 / 2) = False" then ()
|
wenzelm@60237
|
126 |
else error "integrate.sml: matches new_c = False";
|
neuper@37906
|
127 |
|
walther@60242
|
128 |
val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2)";
|
wenzelm@60237
|
129 |
val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t';
|
walther@60242
|
130 |
if term2s t'="matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2) = True"
|
wenzelm@60237
|
131 |
then () else error "integrate.sml: matches new_c = True";
|
neuper@37906
|
132 |
|
walther@60230
|
133 |
val t = str2t "ff x TermC.is_f_x";
|
neuper@37926
|
134 |
val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
|
walther@60230
|
135 |
if term2s t' = "(ff x TermC.is_f_x) = True" then ()
|
neuper@38031
|
136 |
else error "integrate.sml: eval_is_f_x --> true";
|
neuper@37906
|
137 |
|
walther@60230
|
138 |
val t = str2t "q_0/2 * L * x TermC.is_f_x";
|
neuper@37926
|
139 |
val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
|
walther@60230
|
140 |
if term2s t' = "(q_0 / 2 * L * x TermC.is_f_x) = False" then ()
|
neuper@38031
|
141 |
else error "integrate.sml: eval_is_f_x --> false";
|
neuper@37906
|
142 |
|
neuper@37906
|
143 |
val conditions_in_integration =
|
walther@59851
|
144 |
Rule_Set.Repeat {id="conditions_in_integration",
|
neuper@37970
|
145 |
preconds = [],
|
neuper@37970
|
146 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
147 |
erls = Rule_Set.Empty,
|
walther@59851
|
148 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wenzelm@60237
|
149 |
rules = [Eval ("Prog_Expr.matches",eval_matches ""),
|
walther@60278
|
150 |
Eval ("Integrate.is_f_x",
|
neuper@37970
|
151 |
eval_is_f_x "is_f_x_"),
|
walther@59871
|
152 |
Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
|
walther@59871
|
153 |
Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
|
neuper@37970
|
154 |
],
|
walther@59878
|
155 |
scr = Empty_Prog};
|
neuper@37906
|
156 |
fun rewrit thm t =
|
neuper@38013
|
157 |
fst (the (rewrite_inst_ thy tless_true
|
neuper@37906
|
158 |
conditions_in_integration true subs thm t));
|
walther@60242
|
159 |
val t = rewrit call_for_new_c (str2t "x \<up> 2 / 2"); term2s t;
|
neuper@37906
|
160 |
val t = (rewrit call_for_new_c t)
|
neuper@42067
|
161 |
handle OPTION => str2t "no_rewrite";
|
neuper@37906
|
162 |
|
neuper@37906
|
163 |
val t = rewrit call_for_new_c
|
neuper@42067
|
164 |
(str2t "ff x = q_0/2 *L*x"); term2s t;
|
neuper@37906
|
165 |
val t = (rewrit call_for_new_c
|
neuper@42067
|
166 |
(str2t "ff x = q_0 / 2 * L * x + new_c q_0 / 2 * L * x"))
|
neuper@42067
|
167 |
handle OPTION => (*NOT: + new_c ..=..!!*)str2t "no_rewrite";
|
neuper@37906
|
168 |
--------------------------------------------------------------------*)
|
neuper@37906
|
169 |
|
neuper@37906
|
170 |
|
neuper@38013
|
171 |
"----------- simplify by ruleset reducing make_ratpoly_in";
|
neuper@38013
|
172 |
"----------- simplify by ruleset reducing make_ratpoly_in";
|
neuper@38013
|
173 |
"----------- simplify by ruleset reducing make_ratpoly_in";
|
wneuper@59592
|
174 |
val thy = @{theory "Isac_Knowledge"};
|
Walther@60500
|
175 |
val ctxt = Proof_Context.init_global thy;
|
Walther@60565
|
176 |
val subst = [(TermC.parse_test @{context} "bdv ::real", TermC.parse_test @{context} "x ::real")]; (*DOESN'T HELP*)
|
neuper@38030
|
177 |
"===== test 1";
|
Walther@60565
|
178 |
val t = TermC.parse_test @{context} "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
|
neuper@37906
|
179 |
|
neuper@37906
|
180 |
"----- stepwise from the rulesets in simplify_Integral and below-----";
|
neuper@38030
|
181 |
val rls = norm_Rational_noadd_fractions;
|
Walther@60500
|
182 |
case rewrite_set_inst_ ctxt true subs rls t of
|
neuper@38031
|
183 |
SOME _ => error "integrate.sml simplify by ruleset norm_Rational_.#2"
|
neuper@37926
|
184 |
| NONE => ();
|
neuper@37906
|
185 |
|
neuper@38030
|
186 |
"===== test 2";
|
neuper@38030
|
187 |
val rls = order_add_mult_in;
|
Walther@60500
|
188 |
val SOME (t, []) = rewrite_set_inst_ ctxt true subst rls t;
|
walther@60329
|
189 |
if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + - 1 * (q_0 * x \<up> 2) / 2)" then()
|
neuper@38031
|
190 |
else error "integrate.sml simplify by ruleset order_add_mult_in #2";
|
neuper@37906
|
191 |
|
neuper@38030
|
192 |
"===== test 3";
|
neuper@38030
|
193 |
val rls = discard_parentheses;
|
Walther@60500
|
194 |
val SOME (t, []) = rewrite_set_ ctxt true rls t;
|
walther@60329
|
195 |
if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" then ()
|
neuper@38031
|
196 |
else error "integrate.sml simplify by ruleset discard_parenth.. #3";
|
neuper@37906
|
197 |
|
neuper@38030
|
198 |
"===== test 4";
|
Walther@60565
|
199 |
val subs = [(TermC.parse_test @{context} "bdv::real", TermC.parse_test @{context} "x::real")];
|
neuper@37970
|
200 |
val rls =
|
walther@59852
|
201 |
(Rule_Set.append_rules "separate_bdv" collect_bdv
|
walther@60342
|
202 |
[Thm ("separate_bdv", @{thm separate_bdv}),
|
neuper@42321
|
203 |
(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
|
walther@60342
|
204 |
Thm ("separate_bdv_n", @{thm separate_bdv_n}),
|
walther@60242
|
205 |
(*"?a * ?bdv \<up> ?n / ?b = ?a / ?b * ?bdv \<up> ?n"*)
|
walther@60342
|
206 |
Thm ("separate_1_bdv", @{thm separate_1_bdv}),
|
neuper@42321
|
207 |
(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
|
walther@60342
|
208 |
Thm ("separate_1_bdv_n", @{thm separate_1_bdv_n})
|
walther@60242
|
209 |
(*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
|
neuper@42321
|
210 |
]);
|
neuper@38030
|
211 |
(*show_types := true; --- do we need type-constraint in thms? *)
|
neuper@38030
|
212 |
@{thm separate_bdv}; (*::?'a does NOT rewrite here WITHOUT type constraint*)
|
walther@60242
|
213 |
@{thm separate_bdv_n}; (*::real ..because of \<up> , rewrites*)
|
neuper@38030
|
214 |
@{thm separate_1_bdv}; (*::?'a*)
|
walther@60342
|
215 |
val xxx = @{thm separate_1_bdv}; (*::?'a*)
|
walther@60242
|
216 |
@{thm separate_1_bdv_n}; (*::real ..because of \<up> *)
|
neuper@38030
|
217 |
(*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
|
neuper@38030
|
218 |
|
Walther@60500
|
219 |
val SOME (t, []) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60329
|
220 |
if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
|
neuper@38031
|
221 |
else error "integrate.sml simplify by ruleset separate_bdv.. #4";
|
neuper@37906
|
222 |
|
neuper@38030
|
223 |
"===== test 5";
|
Walther@60565
|
224 |
val t = TermC.parse_test @{context} "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
|
neuper@37906
|
225 |
val rls = simplify_Integral;
|
Walther@60500
|
226 |
val SOME (t,[]) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60329
|
227 |
(* given was: "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" *)
|
walther@60329
|
228 |
if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
|
neuper@38031
|
229 |
else error "integrate.sml, simplify_Integral #99";
|
neuper@37906
|
230 |
|
neuper@37906
|
231 |
"........... 2nd integral ........................................";
|
neuper@37906
|
232 |
"........... 2nd integral ........................................";
|
neuper@37906
|
233 |
"........... 2nd integral ........................................";
|
Walther@60565
|
234 |
val subs = [(TermC.parse_test @{context} "bdv::real", TermC.parse_test @{context} "x::real")];
|
walther@60342
|
235 |
|
walther@60342
|
236 |
val thy = @{theory Biegelinie};
|
Walther@60565
|
237 |
val t = TermC.parse_test @{context}
|
walther@60342
|
238 |
"Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
|
walther@60342
|
239 |
|
neuper@37906
|
240 |
val rls = simplify_Integral;
|
Walther@60500
|
241 |
val SOME (t,[]) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60342
|
242 |
if UnparseC.term t = "Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x"
|
neuper@38048
|
243 |
then () else raise error "integrate.sml, simplify_Integral #198";
|
neuper@38030
|
244 |
|
neuper@37906
|
245 |
val rls = integration_rules;
|
Walther@60500
|
246 |
val SOME (t, []) = rewrite_set_ ctxt true rls t;
|
walther@60342
|
247 |
if UnparseC.term t = "1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + - 1 * q_0 / 6 * (x \<up> 4 / 4))"
|
neuper@38031
|
248 |
then () else error "integrate.sml, simplify_Integral #199";
|
neuper@37906
|
249 |
|
neuper@37906
|
250 |
|
neuper@38013
|
251 |
"----------- integrate by ruleset -----------------------";
|
neuper@38013
|
252 |
"----------- integrate by ruleset -----------------------";
|
neuper@38013
|
253 |
"----------- integrate by ruleset -----------------------";
|
wneuper@59384
|
254 |
val thy = @{theory "Integrate"};
|
wneuper@59384
|
255 |
val rls = integration_rules;
|
wneuper@59384
|
256 |
val subs = [(@{term "bdv::real"}, @{term "x::real"})];
|
neuper@37906
|
257 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
neuper@37906
|
258 |
|
Walther@60424
|
259 |
val t = TermC.parseNEW' ctxt "Integral x D x";
|
Walther@60500
|
260 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
261 |
if UnparseC.term res = "x \<up> 2 / 2" then () else error "Integral x D x changed";
|
wneuper@59384
|
262 |
|
Walther@60424
|
263 |
val t = TermC.parseNEW' ctxt "Integral c * x \<up> 2 + c_2 D x";
|
Walther@60500
|
264 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
265 |
if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x" then () else error "Integral c * x \<up> 2 + c_2 D x";
|
wneuper@59384
|
266 |
|
wneuper@59384
|
267 |
val rls = add_new_c;
|
Walther@60424
|
268 |
val t = TermC.parseNEW' ctxt "c * (x \<up> 3 / 3) + c_2 * x";
|
Walther@60500
|
269 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
270 |
if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x + c_3" then ()
|
neuper@38031
|
271 |
else error "integrate.sml: diff.behav. in add_new_c simpl.";
|
neuper@37906
|
272 |
|
Walther@60424
|
273 |
val t = TermC.parseNEW' ctxt "F x = x \<up> 3 / 3 + x";
|
Walther@60500
|
274 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
275 |
if UnparseC.term res = "F x = x \<up> 3 / 3 + x + c"(*not "F x + c =..."*) then ()
|
neuper@38031
|
276 |
else error "integrate.sml: diff.behav. in add_new_c equation";
|
neuper@37906
|
277 |
|
wneuper@59384
|
278 |
val rls = simplify_Integral;
|
neuper@37906
|
279 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
Walther@60424
|
280 |
val t = TermC.parseNEW' ctxt "ff x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
|
Walther@60500
|
281 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60329
|
282 |
if UnparseC.term res = "ff x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2"
|
neuper@38031
|
283 |
then () else error "integrate.sml: diff.behav. in simplify_I #1";
|
neuper@37906
|
284 |
|
wneuper@59384
|
285 |
val rls = integration;
|
neuper@37906
|
286 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
Walther@60424
|
287 |
val t = TermC.parseNEW' ctxt "Integral c * x \<up> 2 + c_2 D x";
|
Walther@60500
|
288 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
289 |
if UnparseC.term res = "c_3 + c_2 * x + c / 3 * x \<up> 3"
|
neuper@38031
|
290 |
then () else error "integrate.sml: diff.behav. in integration #1";
|
neuper@37906
|
291 |
|
Walther@60424
|
292 |
val t = TermC.parseNEW' ctxt "Integral 3*x \<up> 2 + 2*x + 1 D x";
|
Walther@60500
|
293 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60242
|
294 |
if UnparseC.term res = "c + x + x \<up> 2 + x \<up> 3" then ()
|
neuper@38031
|
295 |
else error "integrate.sml: diff.behav. in integration #2";
|
neuper@37906
|
296 |
|
Walther@60424
|
297 |
val t = TermC.parseNEW' ctxt
|
walther@60329
|
298 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
|
Walther@60500
|
299 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60329
|
300 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
|
walther@60329
|
301 |
if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
|
neuper@38031
|
302 |
then () else error "integrate.sml: diff.behav. in integration #3";
|
neuper@37906
|
303 |
|
Walther@60424
|
304 |
val t = TermC.parseNEW' ctxt ("Integral " ^ UnparseC.term res ^ " D x");
|
Walther@60500
|
305 |
val SOME (res, _) = rewrite_set_inst_ ctxt true subs rls t;
|
walther@60329
|
306 |
if UnparseC.term res = "c_2 + c * x +\n1 / EI * (L * q_0 / 12 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)"
|
neuper@38031
|
307 |
then () else error "integrate.sml: diff.behav. in integration #4";
|
neuper@37906
|
308 |
|
neuper@38013
|
309 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
neuper@38013
|
310 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
neuper@38013
|
311 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
Walther@60565
|
312 |
val t = TermC.parse_test @{context} "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \<up> 2) / 2) D x";
|
Walther@60500
|
313 |
val SOME(t, _)= rewrite_set_inst_ ctxt true subs simplify_Integral t;
|
walther@59868
|
314 |
if UnparseC.term t =
|
walther@60329
|
315 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"
|
neuper@41931
|
316 |
then () else error "integrate.sml 3rd integration in 7.27, simplify_Integral";
|
neuper@37906
|
317 |
|
Walther@60500
|
318 |
val SOME(t, _) = rewrite_set_inst_ ctxt true subs integration t;
|
walther@59868
|
319 |
if UnparseC.term t =
|
walther@60329
|
320 |
"c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
|
neuper@38031
|
321 |
then () else error "integrate.sml 3rd integration in 7.27, integration";
|
neuper@37906
|
322 |
|
neuper@37906
|
323 |
|
neuper@38013
|
324 |
"----------- check probem type --------------------------";
|
neuper@38013
|
325 |
"----------- check probem type --------------------------";
|
neuper@38013
|
326 |
"----------- check probem type --------------------------";
|
walther@60342
|
327 |
val thy = @{theory Integrate};
|
neuper@37994
|
328 |
val model = {Given =["functionTerm f_f", "integrateBy v_v"],
|
neuper@37906
|
329 |
Where =[],
|
neuper@38048
|
330 |
Find =["antiDerivative F_F"],
|
neuper@37906
|
331 |
With =[],
|
neuper@37906
|
332 |
Relate=[]}:string ppc;
|
Walther@60424
|
333 |
val chkmodel = ((map (TermC.parseNEW' ctxt)) o P_Model.to_list) model;
|
Walther@60424
|
334 |
val t1 = (hd) chkmodel;
|
Walther@60424
|
335 |
val t2 = (hd o tl) chkmodel;
|
Walther@60424
|
336 |
val t3 = (hd o tl o tl) chkmodel;
|
walther@60336
|
337 |
case t3 of Const (\<^const_name>\<open>antiDerivative\<close>, _) $ _ => ()
|
neuper@38031
|
338 |
| _ => error "integrate.sml: Integrate.antiDerivative ???";
|
neuper@37906
|
339 |
|
neuper@37994
|
340 |
val model = {Given =["functionTerm f_f", "integrateBy v_v"],
|
neuper@37906
|
341 |
Where =[],
|
neuper@38049
|
342 |
Find =["antiDerivativeName F_F"],
|
neuper@37906
|
343 |
With =[],
|
neuper@37906
|
344 |
Relate=[]}:string ppc;
|
Walther@60424
|
345 |
val chkmodel = ((map (TermC.parseNEW' ctxt)) o P_Model.to_list) model;
|
Walther@60424
|
346 |
val t1 = (hd) chkmodel;
|
Walther@60424
|
347 |
val t2 = (hd o tl) chkmodel;
|
Walther@60424
|
348 |
val t3 = (hd o tl o tl) chkmodel;
|
walther@60336
|
349 |
case t3 of Const (\<^const_name>\<open>antiDerivativeName\<close>, _) $ _ => ()
|
neuper@38031
|
350 |
| _ => error "integrate.sml: Integrate.antiDerivativeName";
|
neuper@37906
|
351 |
|
neuper@37906
|
352 |
"----- compare 'Find's from problem, script, formalization -------";
|
Walther@60559
|
353 |
val {ppc,...} = Problem.from_store @{context} ["named", "integrate", "function"];
|
walther@60336
|
354 |
val ("#Find", (Const (\<^const_name>\<open>antiDerivativeName\<close>, _),
|
neuper@38049
|
355 |
F1_ as Free ("F_F", F1_type))) = last_elem ppc;
|
Walther@60559
|
356 |
val {scr = Prog sc,... } = MethodC.from_store ctxt ["diff", "integration", "named"];
|
neuper@37906
|
357 |
val [_,_, F2_] = formal_args sc;
|
neuper@38031
|
358 |
if F1_ = F2_ then () else error "integrate.sml: unequal find's";
|
neuper@37906
|
359 |
|
walther@60336
|
360 |
val ((dsc as Const (\<^const_name>\<open>antiDerivativeName\<close>, _))
|
Walther@60565
|
361 |
$ Free ("ff", F3_type)) = TermC.parse_test @{context} "antiDerivativeName ff";
|
walther@59953
|
362 |
if Input_Descript.is_a dsc then () else error "integrate.sml: no description";
|
neuper@37906
|
363 |
if F1_type = F3_type then ()
|
neuper@38031
|
364 |
else error "integrate.sml: unequal types in find's";
|
neuper@37906
|
365 |
|
walther@59971
|
366 |
Test_Tool.show_ptyps();
|
Walther@60559
|
367 |
val pbl = Problem.from_store @{context} ["integrate", "function"];
|
walther@60342
|
368 |
case #cas pbl of SOME (Const (\<^const_name>\<open>Integrate\<close>, _) $ _) => ()
|
neuper@38031
|
369 |
| _ => error "integrate.sml: Integrate.Integrate ???";
|
neuper@37906
|
370 |
|
neuper@37906
|
371 |
|
neuper@38013
|
372 |
"----------- me method [diff,integration] ---------------";
|
neuper@38013
|
373 |
"----------- me method [diff,integration] ---------------";
|
neuper@38013
|
374 |
"----------- me method [diff,integration] ---------------";
|
walther@60329
|
375 |
(*exp_CalcInt_No- 1.xml*)
|
neuper@37906
|
376 |
val p = e_pos'; val c = [];
|
neuper@38065
|
377 |
"----- step 0: returns nxt = Model_Problem ---";
|
neuper@38065
|
378 |
val (p,_,f,nxt,_,pt) =
|
neuper@38065
|
379 |
CalcTreeTEST
|
walther@60242
|
380 |
[(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
|
walther@59997
|
381 |
("Integrate", ["integrate", "function"], ["diff", "integration"]))];
|
walther@60242
|
382 |
"----- step 1: returns nxt = Add_Given \"functionTerm (x \<up> 2 + 1)\" ---";
|
neuper@38051
|
383 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
|
neuper@38065
|
384 |
"----- step 2: returns nxt = Add_Given \"integrateBy x\" ---";
|
neuper@37906
|
385 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
386 |
"----- step 3: returns nxt = Add_Find \"Integrate.antiDerivative FF\" ---";
|
neuper@37906
|
387 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
388 |
"----- step 4: returns nxt = Specify_Theory \"Integrate\" ---";
|
neuper@37906
|
389 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
390 |
"----- step 5: returns nxt = Specify_Problem [\"integrate\", \"function\"] ---";
|
neuper@37906
|
391 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
392 |
"----- step 6: returns nxt = Specify_Method [\"diff\", \"integration\"] ---";
|
neuper@37906
|
393 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
394 |
"----- step 7: returns nxt = Apply_Method [\"diff\", \"integration\"] ---";
|
neuper@38065
|
395 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59749
|
396 |
case nxt of (Apply_Method ["diff", "integration"]) => ()
|
neuper@38065
|
397 |
| _ => error "integrate.sml -- me method [diff,integration] -- spec";
|
wneuper@59497
|
398 |
"----- step 8: returns nxt = Rewrite_Set_Inst ([\"(''bdv'', x)\"],\"integration\")";
|
neuper@37906
|
399 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
400 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
401 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
walther@60242
|
402 |
if f2str f = "c + x + 1 / 3 * x \<up> 3" then ()
|
neuper@38065
|
403 |
else error "integrate.sml -- me method [diff,integration] -- end";
|
neuper@37906
|
404 |
|
neuper@37906
|
405 |
|
wneuper@59248
|
406 |
"----------- autoCalculate [diff,integration] -----------";
|
wneuper@59248
|
407 |
"----------- autoCalculate [diff,integration] -----------";
|
wneuper@59248
|
408 |
"----------- autoCalculate [diff,integration] -----------";
|
Walther@60549
|
409 |
States.reset ();
|
neuper@38064
|
410 |
CalcTree
|
walther@60242
|
411 |
[(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
|
walther@59997
|
412 |
("Integrate", ["integrate", "function"], ["diff", "integration"]))];
|
neuper@38064
|
413 |
Iterator 1;
|
neuper@38064
|
414 |
moveActiveRoot 1;
|
wneuper@59248
|
415 |
autoCalculate 1 CompleteCalc;
|
Walther@60549
|
416 |
val ((pt,p),_) = States.get_calc 1; @{make_string} p; Test_Tool.show_pt pt;
|
walther@59983
|
417 |
val (Form t,_,_) = ME_Misc.pt_extract (pt, p);
|
walther@60242
|
418 |
if UnparseC.term t = "c + x + 1 / 3 * x \<up> 3" then ()
|
neuper@38065
|
419 |
else error "integrate.sml -- interSteps [diff,integration] -- result";
|
neuper@38064
|
420 |
|
neuper@38064
|
421 |
|
neuper@38013
|
422 |
"----------- me method [diff,integration,named] ---------";
|
neuper@38013
|
423 |
"----------- me method [diff,integration,named] ---------";
|
neuper@38013
|
424 |
"----------- me method [diff,integration,named] ---------";
|
walther@60329
|
425 |
(*exp_CalcInt_No- 2.xml*)
|
walther@60242
|
426 |
val fmz = ["functionTerm (x \<up> 2 + (1::real))",
|
walther@59997
|
427 |
"integrateBy x", "antiDerivativeName F"];
|
neuper@37906
|
428 |
val (dI',pI',mI') =
|
walther@59997
|
429 |
("Integrate",["named", "integrate", "function"],
|
walther@59997
|
430 |
["diff", "integration", "named"]);
|
neuper@37906
|
431 |
val p = e_pos'; val c = [];
|
neuper@37906
|
432 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
433 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
434 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
435 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *);
|
neuper@37906
|
436 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
437 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
438 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
439 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
|
neuper@37906
|
440 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
441 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
442 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
walther@60242
|
443 |
if f2str f = "F x = c + x + 1 / 3 * x \<up> 3" then()
|
neuper@38031
|
444 |
else error "integrate.sml: method [diff,integration,named]";
|
neuper@37906
|
445 |
|
neuper@37906
|
446 |
|
neuper@38013
|
447 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@38013
|
448 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@38013
|
449 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@37906
|
450 |
(*exp_CalcInt_No-3.xml*)
|
neuper@37906
|
451 |
val fmz = ["functionTerm (- q_0)",
|
walther@59997
|
452 |
"integrateBy x", "antiDerivativeName Q"];
|
neuper@37906
|
453 |
val (dI',pI',mI') =
|
walther@59997
|
454 |
("Biegelinie",["named", "integrate", "function"],
|
walther@59997
|
455 |
["diff", "integration", "named"]);
|
neuper@37906
|
456 |
val p = e_pos'; val c = [];
|
neuper@37906
|
457 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
458 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
459 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
460 |
(*Error Tac Q not in ...*)
|
neuper@37906
|
461 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *);
|
neuper@37906
|
462 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
463 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
464 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
465 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
|
neuper@37906
|
466 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
467 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
468 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
walther@60350
|
469 |
if f2str f = "Q x = c + - 1 * q_0 * x" then()
|
neuper@38031
|
470 |
else error "integrate.sml: method [diff,integration,named] .Q";
|
neuper@37906
|
471 |
|
neuper@37906
|
472 |
|