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@59879
|
27 |
val ctxt = ThyC.to_ctxt 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@59871
|
41 |
Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
|
walther@59871
|
42 |
Thm ("not_false",ThmC.numerals_to_Free @{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 =
|
neuper@42067
|
46 |
fst (the (rewrite_inst_ thy 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 ------------------------------------";
|
neuper@42067
|
54 |
val t = str2t "Integral x D x";
|
walther@60242
|
55 |
val t = str2t "Integral x \<up> 2 D x";
|
neuper@38048
|
56 |
case t of
|
neuper@38048
|
57 |
Const ("Integrate.Integral", _) $
|
wenzelm@60309
|
58 |
(Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ Free _) $ Free ("x", _) => ()
|
walther@60242
|
59 |
| _ => error "integrate.sml: parsing: Integral x \<up> 2 D x";
|
neuper@37906
|
60 |
|
wenzelm@60237
|
61 |
val t = str2t "ff x is_f_x";
|
walther@60278
|
62 |
case t of Const ("Integrate.is_f_x", _) $ _ => ()
|
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 ---------------------";
|
neuper@42067
|
69 |
val str = rewrit @{thm "integral_const"} (str2t "Integral 1 D x");
|
neuper@38048
|
70 |
if term2s str = "1 * x" then () else error "integrate.sml Integral 1 D x";
|
neuper@38048
|
71 |
|
neuper@42067
|
72 |
val str = rewrit @{thm "integral_const"} (str2t "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 |
|
neuper@42067
|
76 |
val str = rewrit @{thm "integral_var"} (str2t "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 |
|
neuper@42067
|
80 |
val str = rewrit @{thm "integral_add"} (str2t "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@60242
|
84 |
val str = rewrit @{thm "integral_mult"} (str2t "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@60242
|
88 |
val str = rewrit @{thm "integral_pow"} (str2t "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@60242
|
96 |
val term = str2t "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@60278
|
100 |
val SOME (id,t') = eval_add_new_c "" "Integrate.add_new_c" term thy;
|
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_");
|
wneuper@59255
|
105 |
val SOME (thmstr, thm) = adhoc_thm1_ thy cc term;
|
neuper@37906
|
106 |
|
neuper@37926
|
107 |
val SOME (t',_) = rewrite_set_ thy 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@60242
|
111 |
val term = str2t "ff x = x \<up> 2*c + c_2";
|
neuper@37926
|
112 |
val SOME (t',_) = rewrite_set_ thy 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"};
|
neuper@38030
|
175 |
"===== test 1";
|
walther@60329
|
176 |
val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
|
neuper@37906
|
177 |
|
neuper@37906
|
178 |
"----- stepwise from the rulesets in simplify_Integral and below-----";
|
neuper@38030
|
179 |
val rls = norm_Rational_noadd_fractions;
|
neuper@37906
|
180 |
case rewrite_set_inst_ thy true subs rls t of
|
neuper@38031
|
181 |
SOME _ => error "integrate.sml simplify by ruleset norm_Rational_.#2"
|
neuper@37926
|
182 |
| NONE => ();
|
neuper@37906
|
183 |
|
neuper@38030
|
184 |
"===== test 2";
|
neuper@38030
|
185 |
val rls = order_add_mult_in;
|
walther@60262
|
186 |
(*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\
|
walther@60262
|
187 |
assume flawed test setup hidden by "handle _ => ..."
|
walther@60262
|
188 |
ERROR ord_make_polynomial_in called with subst = []
|
neuper@37926
|
189 |
val SOME (t,[]) = rewrite_set_ thy true rls t;
|
walther@60329
|
190 |
if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + - 1 * (q_0 * x \<up> 2) / 2)" then()
|
neuper@38031
|
191 |
else error "integrate.sml simplify by ruleset order_add_mult_in #2";
|
walther@60262
|
192 |
\\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
|
neuper@37906
|
193 |
|
neuper@38030
|
194 |
"===== test 3";
|
neuper@38030
|
195 |
val rls = discard_parentheses;
|
walther@60262
|
196 |
(*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\
|
walther@60262
|
197 |
assume flawed test setup hidden by "handle _ => ..."
|
walther@60262
|
198 |
ERROR ord_make_polynomial_in called with subst = []
|
neuper@37926
|
199 |
val SOME (t,[]) = rewrite_set_ thy true rls t;
|
walther@60329
|
200 |
if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" then ()
|
neuper@38031
|
201 |
else error "integrate.sml simplify by ruleset discard_parenth.. #3";
|
walther@60262
|
202 |
\\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
|
neuper@37906
|
203 |
|
neuper@38030
|
204 |
"===== test 4";
|
wneuper@59399
|
205 |
val subs = [(str2t "bdv::real", str2t "x::real")];
|
neuper@37970
|
206 |
val rls =
|
walther@59852
|
207 |
(Rule_Set.append_rules "separate_bdv" collect_bdv
|
walther@59871
|
208 |
[Thm ("separate_bdv", ThmC.numerals_to_Free @{thm separate_bdv}),
|
neuper@42321
|
209 |
(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
|
walther@59871
|
210 |
Thm ("separate_bdv_n", ThmC.numerals_to_Free @{thm separate_bdv_n}),
|
walther@60242
|
211 |
(*"?a * ?bdv \<up> ?n / ?b = ?a / ?b * ?bdv \<up> ?n"*)
|
walther@59871
|
212 |
Thm ("separate_1_bdv", ThmC.numerals_to_Free @{thm separate_1_bdv}),
|
neuper@42321
|
213 |
(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
|
walther@59871
|
214 |
Thm ("separate_1_bdv_n", ThmC.numerals_to_Free @{thm separate_1_bdv_n})
|
walther@60242
|
215 |
(*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
|
neuper@42321
|
216 |
]);
|
neuper@38030
|
217 |
(*show_types := true; --- do we need type-constraint in thms? *)
|
neuper@38030
|
218 |
@{thm separate_bdv}; (*::?'a does NOT rewrite here WITHOUT type constraint*)
|
walther@60242
|
219 |
@{thm separate_bdv_n}; (*::real ..because of \<up> , rewrites*)
|
neuper@38030
|
220 |
@{thm separate_1_bdv}; (*::?'a*)
|
walther@59871
|
221 |
val xxx = ThmC.numerals_to_Free @{thm separate_1_bdv}; (*::?'a*)
|
walther@60242
|
222 |
@{thm separate_1_bdv_n}; (*::real ..because of \<up> *)
|
neuper@38030
|
223 |
(*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
|
neuper@38030
|
224 |
|
neuper@38030
|
225 |
val SOME (t, []) = rewrite_set_inst_ thy true subs rls t;
|
walther@60329
|
226 |
if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
|
neuper@38031
|
227 |
else error "integrate.sml simplify by ruleset separate_bdv.. #4";
|
neuper@37906
|
228 |
|
neuper@38030
|
229 |
"===== test 5";
|
walther@60329
|
230 |
val t = str2t "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
|
neuper@37906
|
231 |
val rls = simplify_Integral;
|
neuper@37926
|
232 |
val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
|
walther@60329
|
233 |
(* given was: "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" *)
|
walther@60329
|
234 |
if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
|
neuper@38031
|
235 |
else error "integrate.sml, simplify_Integral #99";
|
neuper@37906
|
236 |
|
neuper@37906
|
237 |
"........... 2nd integral ........................................";
|
neuper@37906
|
238 |
"........... 2nd integral ........................................";
|
neuper@37906
|
239 |
"........... 2nd integral ........................................";
|
neuper@42067
|
240 |
val t = str2t
|
walther@60329
|
241 |
"Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
|
neuper@37906
|
242 |
val rls = simplify_Integral;
|
neuper@37926
|
243 |
val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
|
walther@59868
|
244 |
if UnparseC.term t =
|
walther@60329
|
245 |
"Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x"
|
neuper@38048
|
246 |
then () else raise error "integrate.sml, simplify_Integral #198";
|
neuper@38030
|
247 |
|
neuper@37906
|
248 |
val rls = integration_rules;
|
neuper@37926
|
249 |
val SOME (t,[]) = rewrite_set_ thy true rls t;
|
walther@59868
|
250 |
UnparseC.term t;
|
walther@59868
|
251 |
if UnparseC.term t =
|
walther@60329
|
252 |
"1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + - 1 * q_0 / 6 * (x \<up> 4 / 4))"
|
neuper@38031
|
253 |
then () else error "integrate.sml, simplify_Integral #199";
|
neuper@37906
|
254 |
|
neuper@37906
|
255 |
|
neuper@38013
|
256 |
"----------- integrate by ruleset -----------------------";
|
neuper@38013
|
257 |
"----------- integrate by ruleset -----------------------";
|
neuper@38013
|
258 |
"----------- integrate by ruleset -----------------------";
|
wneuper@59384
|
259 |
val thy = @{theory "Integrate"};
|
wneuper@59384
|
260 |
val rls = integration_rules;
|
wneuper@59384
|
261 |
val subs = [(@{term "bdv::real"}, @{term "x::real"})];
|
neuper@37906
|
262 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
neuper@37906
|
263 |
|
walther@60230
|
264 |
val t = (Thm.term_of o the o (TermC.parse thy)) "Integral x D x";
|
wneuper@59384
|
265 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
266 |
if UnparseC.term res = "x \<up> 2 / 2" then () else error "Integral x D x changed";
|
wneuper@59384
|
267 |
|
walther@60242
|
268 |
val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x";
|
wneuper@59384
|
269 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
270 |
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
|
271 |
|
wneuper@59384
|
272 |
val rls = add_new_c;
|
walther@60242
|
273 |
val t = (Thm.term_of o the o (TermC.parse thy)) "c * (x \<up> 3 / 3) + c_2 * x";
|
wneuper@59384
|
274 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
275 |
if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x + c_3" then ()
|
neuper@38031
|
276 |
else error "integrate.sml: diff.behav. in add_new_c simpl.";
|
neuper@37906
|
277 |
|
walther@60242
|
278 |
val t = (Thm.term_of o the o (TermC.parse thy)) "F x = x \<up> 3 / 3 + x";
|
wneuper@59384
|
279 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
280 |
if UnparseC.term res = "F x = x \<up> 3 / 3 + x + c"(*not "F x + c =..."*) then ()
|
neuper@38031
|
281 |
else error "integrate.sml: diff.behav. in add_new_c equation";
|
neuper@37906
|
282 |
|
wneuper@59384
|
283 |
val rls = simplify_Integral;
|
neuper@37906
|
284 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
walther@60329
|
285 |
val t = (Thm.term_of o the o (TermC.parse thy)) "ff x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
|
wneuper@59384
|
286 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60329
|
287 |
if UnparseC.term res = "ff x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2"
|
neuper@38031
|
288 |
then () else error "integrate.sml: diff.behav. in simplify_I #1";
|
neuper@37906
|
289 |
|
wneuper@59384
|
290 |
val rls = integration;
|
neuper@37906
|
291 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
walther@60242
|
292 |
val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x";
|
wneuper@59384
|
293 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
294 |
if UnparseC.term res = "c_3 + c_2 * x + c / 3 * x \<up> 3"
|
neuper@38031
|
295 |
then () else error "integrate.sml: diff.behav. in integration #1";
|
neuper@37906
|
296 |
|
walther@60242
|
297 |
val t = (Thm.term_of o the o (TermC.parse thy)) "Integral 3*x \<up> 2 + 2*x + 1 D x";
|
wneuper@59384
|
298 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60242
|
299 |
if UnparseC.term res = "c + x + x \<up> 2 + x \<up> 3" then ()
|
neuper@38031
|
300 |
else error "integrate.sml: diff.behav. in integration #2";
|
neuper@37906
|
301 |
|
walther@60230
|
302 |
val t = (Thm.term_of o the o (TermC.parse thy))
|
walther@60329
|
303 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
|
wneuper@59384
|
304 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60329
|
305 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
|
walther@60329
|
306 |
if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
|
neuper@38031
|
307 |
then () else error "integrate.sml: diff.behav. in integration #3";
|
neuper@37906
|
308 |
|
walther@60230
|
309 |
val t = (Thm.term_of o the o (TermC.parse thy)) ("Integral " ^ UnparseC.term res ^ " D x");
|
wneuper@59384
|
310 |
val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
|
walther@60329
|
311 |
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
|
312 |
then () else error "integrate.sml: diff.behav. in integration #4";
|
neuper@37906
|
313 |
|
neuper@38013
|
314 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
neuper@38013
|
315 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
neuper@38013
|
316 |
"----------- rewrite 3rd integration in 7.27 ------------";
|
wneuper@59592
|
317 |
val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*);
|
walther@60329
|
318 |
val t = str2t "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \<up> 2) / 2) D x";
|
neuper@42347
|
319 |
val SOME(t,_)= rewrite_set_inst_ thy true subs simplify_Integral t;
|
walther@59868
|
320 |
if UnparseC.term t =
|
walther@60329
|
321 |
"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"
|
neuper@41931
|
322 |
then () else error "integrate.sml 3rd integration in 7.27, simplify_Integral";
|
neuper@37906
|
323 |
|
neuper@42347
|
324 |
val SOME(t,_)= rewrite_set_inst_ thy true subs integration t;
|
walther@59868
|
325 |
UnparseC.term t;
|
walther@59868
|
326 |
if UnparseC.term t =
|
walther@60329
|
327 |
"c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
|
neuper@38031
|
328 |
then () else error "integrate.sml 3rd integration in 7.27, integration";
|
neuper@37906
|
329 |
|
neuper@37906
|
330 |
|
neuper@38013
|
331 |
"----------- check probem type --------------------------";
|
neuper@38013
|
332 |
"----------- check probem type --------------------------";
|
neuper@38013
|
333 |
"----------- check probem type --------------------------";
|
neuper@37994
|
334 |
val model = {Given =["functionTerm f_f", "integrateBy v_v"],
|
neuper@37906
|
335 |
Where =[],
|
neuper@38048
|
336 |
Find =["antiDerivative F_F"],
|
neuper@37906
|
337 |
With =[],
|
neuper@37906
|
338 |
Relate=[]}:string ppc;
|
walther@60230
|
339 |
val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model;
|
wneuper@59188
|
340 |
val t1 = (Thm.term_of o hd) chkmodel;
|
wneuper@59188
|
341 |
val t2 = (Thm.term_of o hd o tl) chkmodel;
|
wneuper@59188
|
342 |
val t3 = (Thm.term_of o hd o tl o tl) chkmodel;
|
neuper@37906
|
343 |
case t3 of Const ("Integrate.antiDerivative", _) $ _ => ()
|
neuper@38031
|
344 |
| _ => error "integrate.sml: Integrate.antiDerivative ???";
|
neuper@37906
|
345 |
|
neuper@37994
|
346 |
val model = {Given =["functionTerm f_f", "integrateBy v_v"],
|
neuper@37906
|
347 |
Where =[],
|
neuper@38049
|
348 |
Find =["antiDerivativeName F_F"],
|
neuper@37906
|
349 |
With =[],
|
neuper@37906
|
350 |
Relate=[]}:string ppc;
|
walther@60230
|
351 |
val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model;
|
wneuper@59188
|
352 |
val t1 = (Thm.term_of o hd) chkmodel;
|
wneuper@59188
|
353 |
val t2 = (Thm.term_of o hd o tl) chkmodel;
|
wneuper@59188
|
354 |
val t3 = (Thm.term_of o hd o tl o tl) chkmodel;
|
neuper@37906
|
355 |
case t3 of Const ("Integrate.antiDerivativeName", _) $ _ => ()
|
neuper@38031
|
356 |
| _ => error "integrate.sml: Integrate.antiDerivativeName";
|
neuper@37906
|
357 |
|
neuper@37906
|
358 |
"----- compare 'Find's from problem, script, formalization -------";
|
walther@59997
|
359 |
val {ppc,...} = Problem.from_store ["named", "integrate", "function"];
|
neuper@37906
|
360 |
val ("#Find", (Const ("Integrate.antiDerivativeName", _),
|
neuper@38049
|
361 |
F1_ as Free ("F_F", F1_type))) = last_elem ppc;
|
walther@60154
|
362 |
val {scr = Prog sc,... } = MethodC.from_store ["diff", "integration", "named"];
|
neuper@37906
|
363 |
val [_,_, F2_] = formal_args sc;
|
neuper@38031
|
364 |
if F1_ = F2_ then () else error "integrate.sml: unequal find's";
|
neuper@37906
|
365 |
|
neuper@37906
|
366 |
val ((dsc as Const ("Integrate.antiDerivativeName", _))
|
neuper@42067
|
367 |
$ Free ("ff", F3_type)) = str2t "antiDerivativeName ff";
|
walther@59953
|
368 |
if Input_Descript.is_a dsc then () else error "integrate.sml: no description";
|
neuper@37906
|
369 |
if F1_type = F3_type then ()
|
neuper@38031
|
370 |
else error "integrate.sml: unequal types in find's";
|
neuper@37906
|
371 |
|
walther@59971
|
372 |
Test_Tool.show_ptyps();
|
walther@59997
|
373 |
val pbl = Problem.from_store ["integrate", "function"];
|
neuper@37926
|
374 |
case #cas pbl of SOME (Const ("Integrate.Integrate",_) $ _) => ()
|
neuper@38031
|
375 |
| _ => error "integrate.sml: Integrate.Integrate ???";
|
neuper@37906
|
376 |
|
neuper@37906
|
377 |
|
neuper@38013
|
378 |
"----------- me method [diff,integration] ---------------";
|
neuper@38013
|
379 |
"----------- me method [diff,integration] ---------------";
|
neuper@38013
|
380 |
"----------- me method [diff,integration] ---------------";
|
walther@60329
|
381 |
(*exp_CalcInt_No- 1.xml*)
|
neuper@37906
|
382 |
val p = e_pos'; val c = [];
|
neuper@38065
|
383 |
"----- step 0: returns nxt = Model_Problem ---";
|
neuper@38065
|
384 |
val (p,_,f,nxt,_,pt) =
|
neuper@38065
|
385 |
CalcTreeTEST
|
walther@60242
|
386 |
[(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
|
walther@59997
|
387 |
("Integrate", ["integrate", "function"], ["diff", "integration"]))];
|
walther@60242
|
388 |
"----- step 1: returns nxt = Add_Given \"functionTerm (x \<up> 2 + 1)\" ---";
|
neuper@38051
|
389 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
|
neuper@38065
|
390 |
"----- step 2: returns nxt = Add_Given \"integrateBy x\" ---";
|
neuper@37906
|
391 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
392 |
"----- step 3: returns nxt = Add_Find \"Integrate.antiDerivative FF\" ---";
|
neuper@37906
|
393 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
394 |
"----- step 4: returns nxt = Specify_Theory \"Integrate\" ---";
|
neuper@37906
|
395 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
396 |
"----- step 5: returns nxt = Specify_Problem [\"integrate\", \"function\"] ---";
|
neuper@37906
|
397 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
398 |
"----- step 6: returns nxt = Specify_Method [\"diff\", \"integration\"] ---";
|
neuper@37906
|
399 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@38065
|
400 |
"----- step 7: returns nxt = Apply_Method [\"diff\", \"integration\"] ---";
|
neuper@38065
|
401 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59749
|
402 |
case nxt of (Apply_Method ["diff", "integration"]) => ()
|
neuper@38065
|
403 |
| _ => error "integrate.sml -- me method [diff,integration] -- spec";
|
wneuper@59497
|
404 |
"----- step 8: returns nxt = Rewrite_Set_Inst ([\"(''bdv'', x)\"],\"integration\")";
|
neuper@37906
|
405 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
406 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
407 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
walther@60242
|
408 |
if f2str f = "c + x + 1 / 3 * x \<up> 3" then ()
|
neuper@38065
|
409 |
else error "integrate.sml -- me method [diff,integration] -- end";
|
neuper@37906
|
410 |
|
neuper@37906
|
411 |
|
wneuper@59248
|
412 |
"----------- autoCalculate [diff,integration] -----------";
|
wneuper@59248
|
413 |
"----------- autoCalculate [diff,integration] -----------";
|
wneuper@59248
|
414 |
"----------- autoCalculate [diff,integration] -----------";
|
s1210629013@55445
|
415 |
reset_states ();
|
neuper@38064
|
416 |
CalcTree
|
walther@60242
|
417 |
[(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
|
walther@59997
|
418 |
("Integrate", ["integrate", "function"], ["diff", "integration"]))];
|
neuper@38064
|
419 |
Iterator 1;
|
neuper@38064
|
420 |
moveActiveRoot 1;
|
wneuper@59248
|
421 |
autoCalculate 1 CompleteCalc;
|
walther@59983
|
422 |
val ((pt,p),_) = get_calc 1; @{make_string} p; Test_Tool.show_pt pt;
|
walther@59983
|
423 |
val (Form t,_,_) = ME_Misc.pt_extract (pt, p);
|
walther@60242
|
424 |
if UnparseC.term t = "c + x + 1 / 3 * x \<up> 3" then ()
|
neuper@38065
|
425 |
else error "integrate.sml -- interSteps [diff,integration] -- result";
|
neuper@38064
|
426 |
|
neuper@38064
|
427 |
|
neuper@38013
|
428 |
"----------- me method [diff,integration,named] ---------";
|
neuper@38013
|
429 |
"----------- me method [diff,integration,named] ---------";
|
neuper@38013
|
430 |
"----------- me method [diff,integration,named] ---------";
|
walther@60329
|
431 |
(*exp_CalcInt_No- 2.xml*)
|
walther@60242
|
432 |
val fmz = ["functionTerm (x \<up> 2 + (1::real))",
|
walther@59997
|
433 |
"integrateBy x", "antiDerivativeName F"];
|
neuper@37906
|
434 |
val (dI',pI',mI') =
|
walther@59997
|
435 |
("Integrate",["named", "integrate", "function"],
|
walther@59997
|
436 |
["diff", "integration", "named"]);
|
neuper@37906
|
437 |
val p = e_pos'; val c = [];
|
neuper@37906
|
438 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
439 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
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(*nxt <- Add_Find *);
|
neuper@37906
|
442 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
443 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
444 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
445 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
|
neuper@37906
|
446 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
447 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
448 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
walther@60242
|
449 |
if f2str f = "F x = c + x + 1 / 3 * x \<up> 3" then()
|
neuper@38031
|
450 |
else error "integrate.sml: method [diff,integration,named]";
|
neuper@37906
|
451 |
|
neuper@37906
|
452 |
|
neuper@38013
|
453 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@38013
|
454 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@38013
|
455 |
"----------- me met [diff,integration,named] Biegelinie.Q";
|
neuper@37906
|
456 |
(*exp_CalcInt_No-3.xml*)
|
neuper@37906
|
457 |
val fmz = ["functionTerm (- q_0)",
|
walther@59997
|
458 |
"integrateBy x", "antiDerivativeName Q"];
|
neuper@37906
|
459 |
val (dI',pI',mI') =
|
walther@59997
|
460 |
("Biegelinie",["named", "integrate", "function"],
|
walther@59997
|
461 |
["diff", "integration", "named"]);
|
neuper@37906
|
462 |
val p = e_pos'; val c = [];
|
neuper@37906
|
463 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
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;
|
neuper@37906
|
466 |
(*Error Tac Q not in ...*)
|
neuper@37906
|
467 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *);
|
neuper@37906
|
468 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
469 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
470 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
471 |
val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
|
neuper@37906
|
472 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
473 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
474 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
475 |
|
walther@60329
|
476 |
if f2str f = "Q x = c + - 1 * q_0 * x" then()
|
neuper@38031
|
477 |
else error "integrate.sml: method [diff,integration,named] .Q";
|
neuper@37906
|
478 |
|
neuper@37906
|
479 |
|